Commit f2b8d9e5 authored by Guillaume's avatar Guillaume
Browse files

Fix JSON template

parent 8832a690
......@@ -15,20 +15,17 @@
},
"aggregation_control": {
"variable_column_name": "{{ aggregation_control.variable_column_name }}",
"groupby_attrs": [
"activity_id",
"institution_id",
"source_id",
"experiment_id",
"table_id",
"grid_label"
"groupby_attrs": [{% for attr in aggregation_control.groupby_attrs %}
"{{ attr }}"{% if not loop.last %},{% endif %}{% endfor %}
],
"aggregations": [{% for agg in aggregations %}
{
"type": "{{ agg.type }}",
"attribute_name": "{{ agg.attribute_name }}"{% if 'options' in agg %},
"options": "{{ agg.options | tojson }}"{% endif %}
}{% if not loop.last %},{% endif %}
{% endfor %}]
"options": { {% for opt, value in agg.options.items() %}
"{{ opt }}": "{{ value }}"{% if not loop.last %},{% endif %}{% endfor %}
}{% endif %}
}{% if not loop.last %},{% endif %}{% endfor %}
]
}
}
#!bin/python
# -*- coding: utf-8 -*-
import glob
import os
import re
import gzip
import re
from argparse import ArgumentParser
from datetime import date
from glob import glob
......
......@@ -61,22 +61,33 @@ 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"}})
agg = dict()
agg['type'] = 'union'
agg['attribute_name'] = AGGREGATION_VARIABLE[project]
content['aggregations'].append(agg)
agg = dict()
agg['type'] = 'join_existing'
agg['attribute_name'] = 'period_start'
agg['options'] = dict()
agg['options']['dim'] = 'time'
agg['options']['coords'] = 'minimal'
agg['options']['compat'] = 'override'
content['aggregations'].append(agg)
agg = dict()
agg['type'] = 'join_new'
agg['attribute_name'] = AGGREGATION_MEMBER[project]
agg['options'] = dict()
agg['options']['coords'] = 'minimal'
agg['options']['compat'] = 'override'
content['aggregations'].append(agg)
if project == 'CMIP6':
content['aggregations'].append({"type": "join_new",
"attribute_name": "init_year",
"options": {"coords": "minimal",
"compat": "override"}})
agg = dict()
agg['type'] = 'join_new'
agg['attribute_name'] = 'init_year'
agg['options'] = dict()
agg['options']['coords'] = 'minimal'
agg['options']['compat'] = 'override'
content['aggregations'].append(agg)
# 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