Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bw-bestperf
FuXi
Commits
6dd8498d
Commit
6dd8498d
authored
Aug 16, 2023
by
tpys
Browse files
add split param for save_like
parent
2fd65f0e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
data_util.py
data_util.py
+16
-16
No files found.
data_util.py
View file @
6dd8498d
...
...
@@ -25,13 +25,13 @@ def split_variable(ds, name):
return
v
def
save_like
(
output
,
input
,
step
,
save_dir
=
""
,
freq
=
6
):
def
save_like
(
output
,
input
,
step
,
save_dir
=
""
,
freq
=
6
,
split
=
False
):
if
save_dir
:
os
.
makedirs
(
save_dir
,
exist_ok
=
True
)
dtime
=
(
step
+
2
)
*
freq
#
init_time
=
pd
.
to_datetime
(
input
.
time
.
values
[
0
])
d
ata
=
xr
.
DataArray
(
d
s
=
xr
.
DataArray
(
output
[
None
,
None
],
dims
=
[
'member'
,
'time'
,
'dtime'
,
'level'
,
'lat'
,
'lon'
],
coords
=
dict
(
...
...
@@ -44,6 +44,7 @@ def save_like(output, input, step, save_dir="", freq=6):
)
).
astype
(
np
.
float32
)
if
split
:
def
rename
(
name
):
if
name
==
"tp"
:
return
"TP06"
...
...
@@ -51,13 +52,12 @@ def save_like(output, input, step, save_dir="", freq=6):
return
"RH"
return
name
.
upper
()
ds
=
[]
new_
ds
=
[]
for
k
in
pl_names
+
sfc_names
:
v
=
split_variable
(
d
ata
,
k
)
v
=
split_variable
(
d
s
,
k
)
v
.
name
=
rename
(
k
)
# print(f"{k}: {v.shape} {v.values.min()} ~ {v.values.max()}")
ds
.
append
(
v
)
ds
=
xr
.
merge
(
ds
,
compat
=
"no_conflicts"
)
new_ds
.
append
(
v
)
ds
=
xr
.
merge
(
new_ds
,
compat
=
"no_conflicts"
)
print
(
f
'Save to
{
save_name
}
...'
)
save_name
=
os
.
path
.
join
(
save_dir
,
f
'
{
dtime
:
03
d
}
.nc'
)
...
...
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