-
Notifications
You must be signed in to change notification settings - Fork 1
/
free_forecast.py
executable file
·195 lines (147 loc) · 6.98 KB
/
free_forecast.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/python3
"""
running the forecast model without assimilation
"""
import os, sys, shutil
import datetime as dt
import pandas as pd
from dartwrf.workflows import WorkFlows
w = WorkFlows(exp_config='exp_template.py', server_config='jet.py')
id = None
if False: # generate_nature
begin = dt.datetime(2008, 7, 30, 7)
id = w.prepare_WRFrundir(begin) # create initial conditions
id = w.run_ideal(depends_on=id)
#id = wrfinput_insert_wbubble(perturb=False, depends_on=id)
end = dt.datetime(2008, 7, 30, 12)
id = w.run_ENS(begin=begin, end=end,
input_is_restart=False,
output_restart_interval=(end-begin).total_seconds()/60,
depends_on=id)
# id = w.create_satimages(begin, depends_on=id)
if False: # to continue a nature
start = dt.datetime(2008, 7, 30, 12)
id = w.prepare_WRFrundir(start) # create initial conditions
# id = w.run_ideal(depends_on=id)
prior_path_exp = '/jetfs/scratch/lkugler/data/sim_archive//exp_v1.18_P1_nature+1/' # w.cluster.archivedir
time = start
prior_init_time = dt.datetime(2008, 7, 30, 6)
end = start + dt.timedelta(minutes=30)
restarts = pd.date_range(start=dt.datetime(2008, 7, 30, 12,30),
end=dt.datetime(2008, 7, 30, 14),
freq=dt.timedelta(minutes=30))
for i, next_restart in enumerate(restarts):
prior_valid_time = time
id = w.prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time,
depends_on=id)
# integration time
start = time
end = next_restart
id = w.run_ENS(begin=start, end=end,
input_is_restart=True,
first_minute=True, # to get a +1 minute forecast after each restart
output_restart_interval=(end-start).total_seconds()/60,
#output_restart_interval=9999,
depends_on=id)
w.create_satimages(start, depends_on=id)
prior_init_time = time # this iteration's start
time = end # this iteration's end = next iteration's start
# after last restart
prior_valid_time = time
id = w.prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time,
depends_on=id)
end = time + dt.timedelta(minutes=5)
id = w.run_ENS(begin=time, end=end,
input_is_restart=True,
first_minute=True, # to get a +1 minute forecast after each restart
output_restart_interval=9999,
depends_on=id)
w.create_satimages(start, depends_on=id)
if True: # do a free run (all inits)
begin = dt.datetime(2008, 7, 30, 12,30)
#id = w.prepare_WRFrundir(begin) # create initial conditions
# id = w.run_ideal(depends_on=id)
#id = wrfinput_insert_wbubble(perturb=True, depends_on=id)
restarts = pd.date_range(start=dt.datetime(2008, 7, 30, 13),
end=dt.datetime(2008, 7, 30, 14,30),
freq=dt.timedelta(minutes=30))
# restarts = [dt.datetime(2008, 7, 30, 12, 30)]
input_is_restart = True
time = begin
last_init = dt.datetime(2008, 7, 30, 12)
for i, next_restart in enumerate(restarts):
print('run_WRF from', time, 'to', next_restart)
prior_path_exp = '/jetfs/scratch/lkugler/data/sim_archive/exp_v1.19_P2_noDA+1/' #w.cluster.archivedir
prior_init_time = last_init
prior_valid_time = time
id = w.prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, depends_on=id)
id = w.run_ENS(begin=time, end=next_restart,
input_is_restart=input_is_restart,
output_restart_interval=(next_restart-time).total_seconds()/60,
first_minute=True,
#output_restart_interval=720,
depends_on=id)
last_init = time
time = next_restart
input_is_restart = True
id_sat = w.create_satimages(last_init, depends_on=id)
# free run, no restart files anymore
# end = dt.datetime(2008, 7, 30, 18)
# print('run WRF from', time, 'until', end)
# id = w.run_ENS(begin=time, end=end,
# input_is_restart=input_is_restart,
# #output_restart_interval=(next_restart-time).total_seconds()/60,
# output_restart_interval=9999,
# depends_on=id)
w.verify_wrf(depends_on=id)
#id = w.create_satimages(time, depends_on=id)
w.verify_sat(depends_on=id_sat)
if False: # to continue a free run
start = dt.datetime(2008, 7, 30, 7)
id = w.prepare_WRFrundir(start) # create initial conditions
prior_path_exp = '/jetfs/scratch/lkugler/data/sim_archive/exp_v1.19_P2_noDA' # w.cluster.archivedir
prior_init_time = dt.datetime(2008, 7, 30, 7)
prior_valid_time = start
id = w.prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, depends_on=id)
id = w.run_ENS(begin=start, end=end,
input_is_restart=True,
output_restart_interval=(end-start).total_seconds()/60,
#output_restart_interval=9999,
depends_on=id)
id = w.create_satimages(start, depends_on=id)
w.verify(depends_on=id)
if False: # to continue a free run after spinup
start = dt.datetime(2008, 7, 30, 13,30)
end = dt.datetime(2008, 7, 30, 14)
id = w.prepare_WRFrundir(start) # create initial conditions
# id = w.run_ideal(depends_on=id)
prior_path_exp = '/jetfs/home/lkugler/data/sim_archive/exp_v1.19_P2_noDA' # w.cluster.archivedir
prior_init_time = dt.datetime(2008, 7, 30, 13)
prior_valid_time = dt.datetime(2008, 7, 30, 13,30)
id = w.prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time,
# new_start_time=start, # <---------- to overwrite start time / leads to a call to `create_updated_wrfinput_from_wrfout()`
depends_on=id)
#frequency_restart = (end-start).total_seconds()/60
frequency_restart = dt.timedelta(minutes=30).total_seconds()/60
id = w.run_ENS(begin=start, end=end,
input_is_restart=True,
output_restart_interval=frequency_restart,
#output_restart_interval=9999,
depends_on=id)
# id = w.create_satimages(start, depends_on=id)
# # continue now with free run
# # no restart files anymore
# prior_path_exp = w.cluster.archivedir
# prior_init_time = start
# prior_valid_time = end
# id = w.prepare_IC_from_prior(prior_path_exp, prior_init_time, prior_valid_time, depends_on=id)
# start = end
# end = dt.datetime(2008, 7, 30, 18)
# print('run WRF from', start, 'until', end)
# id = w.run_ENS(begin=start, end=end,
# input_is_restart=True,
# #output_restart_interval=(next_restart-time).total_seconds()/60,
# output_restart_interval=9999,
# depends_on=id)
# id = w.create_satimages(start, depends_on=id)
# w.verify(depends_on=id)