Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
IPSL
E
ESPRI
ESPRI-Mod
catalog
Commits
f2b8d9e5
Commit
f2b8d9e5
authored
Feb 08, 2022
by
Guillaume
Browse files
Fix JSON template
parent
8832a690
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
27 deletions
+34
-27
ESMCollectionTemplate.json
ESMCollectionTemplate.json
+7
-10
esm_cat_generator.py
esm_cat_generator.py
+1
-2
utils.py
utils.py
+26
-15
No files found.
ESMCollectionTemplate.json
View file @
f2b8d9e5
...
...
@@ -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
%
}
]
}
}
esm_cat_generator.py
View file @
f2b8d9e5
#!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
...
...
utils.py
View file @
f2b8d9e5
...
...
@@ -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
)):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment