Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pymistral
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Aaron Spring
pymistral
Commits
032e1c41
Unverified
Commit
032e1c41
authored
5 years ago
by
Aaron Spring
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update cdo_post.py
parent
0ca6c835
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pymistral/cdo_post.py
+36
-33
36 additions, 33 deletions
pymistral/cdo_post.py
with
36 additions
and
33 deletions
pymistral/cdo_post.py
+
36
−
33
View file @
032e1c41
...
...
@@ -64,40 +64,43 @@ def read_all_outdatatype_files_to_ds(
given `year` and return xr.Dataset.
"""
ds_list
=
[]
for
outdatatype_id
in
outdatatypes
:
print
(
f
'
Read
{
outdatatype_id
}
to xr.Dataset.
'
)
parts
=
outdatatype_id
.
split
(
'
_
'
)
model
=
parts
[
0
]
outdatatype
=
'
_
'
.
join
(
parts
[
1
:])
path
=
(
f
'
{
exppath
}
/
{
expid
}
/outdata/
{
model
}
/
'
+
f
'
{
expid
}
_
{
model
}
_
{
outdatatype
}
_
{
year
}
*
'
)
if
model
in
[
'
jsbach
'
,
'
echam6
'
]:
options
=
'
'
if
(
'
BOT
'
in
outdatatype
or
'
ATM
'
in
outdatatype
or
'
LOG
'
in
outdatatype
):
options
+=
'
-t echam6
'
try
:
print
(
f
'
Read
{
outdatatype_id
}
to xr.Dataset.
'
)
parts
=
outdatatype_id
.
split
(
'
_
'
)
model
=
parts
[
0
]
outdatatype
=
'
_
'
.
join
(
parts
[
1
:])
path
=
(
f
'
{
exppath
}
/
{
expid
}
/outdata/
{
model
}
/
'
+
f
'
{
expid
}
_
{
model
}
_
{
outdatatype
}
_
{
year
}
*
'
)
if
model
in
[
'
jsbach
'
,
'
echam6
'
]:
options
=
'
'
if
(
'
BOT
'
in
outdatatype
or
'
ATM
'
in
outdatatype
or
'
LOG
'
in
outdatatype
):
options
+=
'
-t echam6
'
else
:
table
=
(
f
'
{
exppath
}
/
{
expid
}
/log/
'
+
f
'
{
expid
}
_
{
model
}
_
{
outdatatype
[
:
2
]
}
*.codes
'
)
options
+=
'
-t
'
+
table
else
:
table
=
(
f
'
{
exppath
}
/
{
expid
}
/log/
'
+
f
'
{
expid
}
_
{
model
}
_
{
outdatatype
[
:
2
]
}
*.codes
'
)
options
+=
'
-t
'
+
table
else
:
options
=
''
ds
=
cdo
.
copy
(
input
=
path
,
options
=
options
,
returnXDataset
=
True
)
if
'
time
'
not
in
ds
.
dims
:
ds
=
ds
.
expand_dims
(
'
time
'
)
ds
.
to_netcdf
(
f
'
{
outpath
}
/sample_files/
{
model
}
_
{
outdatatype
}
.nc
'
)
# add outdatatype
for
v
in
ds
.
data_vars
:
ds
[
v
].
attrs
[
'
outdatatype
'
]
=
outdatatype
ds
[
v
].
attrs
[
'
model
'
]
=
model
ds
[
v
].
attrs
[
'
dims
'
]
=
list
(
ds
[
v
].
dims
)
ds_list
.
append
(
ds
.
isel
(
time
=
0
).
mean
())
options
=
''
ds
=
cdo
.
copy
(
input
=
path
,
options
=
options
,
returnXDataset
=
True
)
if
'
time
'
not
in
ds
.
dims
:
ds
=
ds
.
expand_dims
(
'
time
'
)
ds
.
to_netcdf
(
f
'
{
outpath
}
/sample_files/
{
model
}
_
{
outdatatype
}
.nc
'
)
# add outdatatype
for
v
in
ds
.
data_vars
:
ds
[
v
].
attrs
[
'
outdatatype
'
]
=
outdatatype
ds
[
v
].
attrs
[
'
model
'
]
=
model
ds
[
v
].
attrs
[
'
dims
'
]
=
list
(
ds
[
v
].
dims
)
ds_list
.
append
(
ds
.
isel
(
time
=
0
).
mean
())
except
:
print
(
f
'
{
outdatatype_id
}
failed
'
return
xr
.
merge
(
ds_list
,
compat
=
'
override
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment