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
57bd0d7d
Commit
57bd0d7d
authored
Feb 07, 2022
by
Guillaume
Browse files
Update .sh
parent
f6362188
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
19 deletions
+22
-19
constants.py
constants.py
+1
-1
esm_cat_generator.py
esm_cat_generator.py
+6
-3
utils.py
utils.py
+15
-15
No files found.
constants.py
View file @
57bd0d7d
...
...
@@ -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'
,
...
...
esm_cat_generator.py
View file @
57bd0d7d
...
...
@@ -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
)
...
...
utils.py
View file @
57bd0d7d
...
...
@@ -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
)):
...
...
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