forked from HaxyMoly/Pangu-Weather-ReadyToGo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforecast_decode.py
42 lines (38 loc) · 1.2 KB
/
forecast_decode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
from datetime import datetime
from forecast_decode_functions import surface, upper
# The date and time of the initial field
date_time = datetime(
year=2023,
month=7,
day=11,
hour=23,
minute=0)
date_time_final = datetime(
year=2023,
month=7,
day=17,
hour=11,
minute=0)
# The directory for results forecast
results_dir = os.path.join(
os.path.join(os.getcwd(), "results"),
date_time.strftime("%Y-%m-%d-%H-%M") + "to" + date_time_final.strftime("%Y-%m-%d-%H-%M")
)
# The results for output
outputs_dir = os.path.join(
os.path.join(os.getcwd(), "outputs"),
date_time.strftime("%Y-%m-%d-%H-%M" + "to" + date_time_final.strftime("%Y-%m-%d-%H-%M"))
)
# create dir if needed
os.makedirs(outputs_dir,exist_ok=True)
# get all files that need to be decoded
for file in os.listdir(results_dir):
print(file)
if file.endswith(".npy"):
if file.startswith("output_surface"):
# decode surface data
surface(os.path.join(results_dir, file),file[:-4]+".nc",outputs_dir)
elif file.startswith("output_upper"):
# decode upper data
upper(os.path.join(results_dir, file),file[:-4]+".nc",outputs_dir)