Commit 57bd0d7d authored by Guillaume's avatar Guillaume
Browse files

Update .sh

parent f6362188
......@@ -140,7 +140,7 @@ VOCAB_URLS = {
}
}
INIT_YEAR_REGEX = '(s(?P<init_year>[0-9]{4})-)?r[0-9]+i[0-9]+p[0-9]+f[0-9]+'
INIT_YEAR_REGEX = '(s(?P<init_year>[0-9]{{4}})-)?(?P<{}>r[0-9]+i[0-9]+p[0-9]+f[0-9]+)'
AGGREGATION_VARIABLE = {
'CMIP6': 'variable_id',
......
......@@ -67,8 +67,11 @@ class Process(object):
facets.update(drs.get_facets_from_filename(path.stem))
# Extract CMIP6 DCPP initial year.
regex = re.match(re.compile(INIT_YEAR_REGEX), AGGREGATION_MEMBER[self.project])
facets['init_year'] = regex.groupdict()['init_year'] if regex else ''
match = re.match(re.compile(INIT_YEAR_REGEX.format(AGGREGATION_MEMBER['CMIP6'])),
facets[AGGREGATION_MEMBER[self.project]])
facets.update({k: ('' if v is None else v) for k, v in match.groupdict().items()})
facets['init_year'] = match.groupdict()['init_year'] if match else ''
# If facet dict is empty, go to next line/path.
if not facets:
......@@ -82,7 +85,7 @@ class Process(object):
facets['period_start'],
facets['period_end'],
facets['climatology'],
latest])
latest.title()])
# Ensure header and entry have same length.
assert len(self.header) == len(entry)
......
......@@ -61,22 +61,22 @@ def make_json(catdir, project, header):
content['aggregation_control']['variable_column_name'] = AGGREGATION_VARIABLE[project]
content['aggregation_control']['groupby_attrs'] = AGGREGATION_GROUP[project]
content['aggregations'] = list()
content['aggregations'].append({'type': 'union',
'attribute_name': 'variable_id'})
content['aggregations'].append({'type': 'join_existing',
'attribute_name': 'period_start',
'options': {'dim': 'time',
'coords': 'minimal',
'compat': 'override'}})
content['aggregations'].append({'type': 'join_new',
'attribute_name': AGGREGATION_MEMBER[project],
'options': {'coords': 'minimal',
'compat': 'override'}})
content['aggregations'].append({"type": "union",
"attribute_name": "variable_id"})
content['aggregations'].append({"type": "join_existing",
"attribute_name": "period_start",
"options": {"dim": "time",
"coords": "minimal",
"compat": "override"}})
content['aggregations'].append({"type": "join_new",
"attribute_name": AGGREGATION_MEMBER[project],
"options": {"coords": "minimal",
"compat": "override"}})
if project == 'CMIP6':
content['aggregations'].append({'type': 'join_new',
'attribute_name': 'init_year',
'options': {'coords': 'minimal',
'compat': 'override'}})
content['aggregations'].append({"type": "join_new",
"attribute_name": "init_year",
"options": {"coords": "minimal",
"compat": "override"}})
# Create directory if not exists.
if not os.path.exists(os.path.dirname(catpath)):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment