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
2f128e8c
Commit
2f128e8c
authored
Aug 01, 2023
by
tpys
Browse files
use data latitiude in save_like
parent
24c3da0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
inference_fuxi.py
inference_fuxi.py
+8
-7
No files found.
inference_fuxi.py
View file @
2f128e8c
...
...
@@ -55,25 +55,22 @@ def load_data(data_file):
return
input
def
save_like
(
output
,
data
,
step
,
save_dir
=
""
,
freq
=
6
,
grid
=
0.25
):
def
save_like
(
output
,
data
,
step
,
save_dir
=
""
,
freq
=
6
):
if
save_dir
:
os
.
makedirs
(
save_dir
,
exist_ok
=
True
)
lead_time
=
(
step
+
1
)
*
freq
init_time
=
pd
.
to_datetime
(
data
.
time
.
values
[
-
1
])
lat
=
np
.
linspace
(
-
90
,
90
,
int
(
180
/
grid
)
+
1
,
dtype
=
np
.
float32
)
lon
=
np
.
arange
(
0
,
360
,
grid
,
dtype
=
np
.
float32
)
fcst_time
=
init_time
+
pd
.
Timedelta
(
hours
=
lead_time
)
output
=
xr
.
DataArray
(
output
,
# 1 x 70 x 721 x 1440
dims
=
[
'time'
,
'level'
,
'lat'
,
'lon'
],
coords
=
dict
(
time
=
[
fcst_time
],
level
=
data
.
level
,
lat
=
lat
,
lon
=
lon
,
lat
=
data
.
lat
,
lon
=
data
.
lon
,
)
)
output
.
name
=
'data'
...
...
@@ -90,6 +87,10 @@ def run_inference(model_dir, data, num_steps, save_dir=""):
print
(
f
'init_time:
{
init_time
.
strftime
((
"%Y%m%d-%H"
))
}
'
)
print
(
f
'latitude:
{
data
.
lat
.
values
[
0
]
}
~
{
data
.
lat
.
values
[
-
1
]
}
'
)
assert
data
.
lat
.
values
[
0
]
==
90
assert
data
.
lat
.
values
[
-
1
]
==
-
90
input
=
data
.
values
[
None
]
print
(
f
'input:
{
input
.
shape
}
,
{
input
.
min
():.
2
f
}
~
{
input
.
max
():.
2
f
}
'
)
print
(
f
'tembs:
{
tembs
.
shape
}
,
{
tembs
.
mean
():.
4
f
}
'
)
...
...
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