Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DART-WRF
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DataAssimilation
DART-WRF
Commits
83221903
Commit
83221903
authored
4 years ago
by
Lukas Kugler
Browse files
Options
Downloads
Patches
Plain Diff
various fixes
parent
d3123b44
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
config/cfg.py
+2
-2
2 additions, 2 deletions
config/cfg.py
scheduler.py
+20
-14
20 additions, 14 deletions
scheduler.py
scripts/apply_obs_op_dart.py
+9
-7
9 additions, 7 deletions
scripts/apply_obs_op_dart.py
scripts/gen_synth_obs.py
+9
-5
9 additions, 5 deletions
scripts/gen_synth_obs.py
with
40 additions
and
28 deletions
config/cfg.py
+
2
−
2
View file @
83221903
import
numpy
as
np
from
.
import
clusters
from
.
import
clusters
cluster
=
clusters
.
vsc
# change cluster configuration here
cluster
=
clusters
.
vsc
# change cluster configuration here
...
@@ -31,7 +31,7 @@ radar = dict(kind='RADAR', n_obs=n_obs, err_std=5.,
...
@@ -31,7 +31,7 @@ radar = dict(kind='RADAR', n_obs=n_obs, err_std=5.,
t2m
=
dict
(
kind
=
'
SYNOP_TEMPERATURE
'
,
n_obs
=
n_obs
,
err_std
=
1.0
,
t2m
=
dict
(
kind
=
'
SYNOP_TEMPERATURE
'
,
n_obs
=
n_obs
,
err_std
=
1.0
,
cov_loc_radius_km
=
32
,
cov_loc_vert_km
=
1
)
cov_loc_radius_km
=
32
,
cov_loc_vert_km
=
1
)
psfc
=
dict
(
kind
=
'
SYNOP_SURFACE_PRESSURE
'
,
n_obs
=
n_obs
,
err_std
=
50.
,
psfc
=
dict
(
kind
=
'
SYNOP_SURFACE_PRESSURE
'
,
n_obs
=
n_obs
,
err_std
=
50.
,
cov_loc_radius_km
=
32
)
cov_loc_radius_km
=
32
,
cov_loc_vert_km
=
5
)
exp
.
observations
=
[
t2m
,
psfc
,
]
exp
.
observations
=
[
t2m
,
psfc
,
]
...
...
This diff is collapsed.
Click to expand it.
scheduler.py
+
20
−
14
View file @
83221903
...
@@ -43,19 +43,25 @@ def backup_scripts():
...
@@ -43,19 +43,25 @@ def backup_scripts():
old_a
=
main_a
+
'
/old/
'
old_a
=
main_a
+
'
/old/
'
os
.
makedirs
(
cluster
.
archivedir
(),
exist_ok
=
True
)
os
.
makedirs
(
cluster
.
archivedir
(),
exist_ok
=
True
)
os
.
makedirs
main_a
,
exist_ok
=
True
)
os
.
makedirs
(
main_a
,
exist_ok
=
True
)
os
.
makedirs
,
exist_ok
=
True
)
os
.
makedirs
(
old_a
,
exist_ok
=
True
)
def
func
(
a
,
b
,
method
):
# call method if not link or directory
if
os
.
path
.
islink
(
a
)
or
os
.
path
.
isdir
(
a
):
pass
else
:
method
(
a
,
b
)
# archive existing files
# archive existing files
for
f
in
os
.
listdir
(
main_a
):
for
f
in
os
.
listdir
(
main_a
):
shutil
.
move
(
os
.
path
.
join
(
main_a
,
f
),
old_a
+
'
/
'
)
func
(
os
.
path
.
join
(
main_a
,
f
),
old_a
+
'
/
'
+
f
,
shutil
.
move
)
# reproducibility
# reproducibility
for
f
in
[
'
scheduler.py
'
,
'
config/clusters.py
'
,
'
config/cfg.py
'
]:
for
f
in
[
'
scheduler.py
'
,
'
config/clusters.py
'
,
'
config/cfg.py
'
]:
shutil
.
copy
(
current
+
'
/../
'
+
f
,
main_a
+
'
/scheduler.py
'
)
func
(
current
+
'
/../
'
+
f
,
main_a
+
'
/scheduler.py
'
,
shutil
.
copy
)
for
f
in
os
.
listdir
(
current
):
for
f
in
os
.
listdir
(
current
):
shutil
.
copy
(
os
.
path
.
join
(
current
,
f
),
main_a
+
'
/
'
)
func
(
os
.
path
.
join
(
current
,
f
),
main_a
+
'
/
'
,
shutil
.
copy
)
def
prepare_wrfinput
():
def
prepare_wrfinput
():
"""
Create WRF/run directories and wrfinput files
"""
Create WRF/run directories and wrfinput files
...
@@ -112,7 +118,7 @@ def run_ENS(begin, end, depends_on=None):
...
@@ -112,7 +118,7 @@ def run_ENS(begin, end, depends_on=None):
cluster
.
scriptsdir
+
'
/prepare_namelist.py
'
,
cluster
.
scriptsdir
+
'
/prepare_namelist.py
'
,
begin
.
strftime
(
'
%Y-%m-%d_%H:%M
'
),
begin
.
strftime
(
'
%Y-%m-%d_%H:%M
'
),
begin_plus1
.
strftime
(
'
%Y-%m-%d_%H:%M
'
),
begin_plus1
.
strftime
(
'
%Y-%m-%d_%H:%M
'
),
str
(
hist_interval
),
str
(
radt
),])
str
(
hist_interval
),
str
(
radt
),])
,
depends_on
=
[
id
])
depends_on
=
[
id
])
s
=
my_Slurm
(
"
runWRF1
"
,
cfg_update
=
{
"
nodes
"
:
"
1
"
,
"
array
"
:
"
1-
"
+
str
(
exp
.
n_nodes
),
s
=
my_Slurm
(
"
runWRF1
"
,
cfg_update
=
{
"
nodes
"
:
"
1
"
,
"
array
"
:
"
1-
"
+
str
(
exp
.
n_nodes
),
...
@@ -135,7 +141,7 @@ def run_ENS(begin, end, depends_on=None):
...
@@ -135,7 +141,7 @@ def run_ENS(begin, end, depends_on=None):
cluster
.
scriptsdir
+
'
/prepare_namelist.py
'
,
cluster
.
scriptsdir
+
'
/prepare_namelist.py
'
,
begin
.
strftime
(
'
%Y-%m-%d_%H:%M
'
),
begin
.
strftime
(
'
%Y-%m-%d_%H:%M
'
),
begin_plus1
.
strftime
(
'
%Y-%m-%d_%H:%M
'
),
begin_plus1
.
strftime
(
'
%Y-%m-%d_%H:%M
'
),
str
(
hist_interval
),
str
(
radt
),])
str
(
hist_interval
),
str
(
radt
),])
,
depends_on
=
[
id
])
depends_on
=
[
id
])
time_in_simulation_hours
=
(
end
-
begin
).
total_seconds
()
/
3600
time_in_simulation_hours
=
(
end
-
begin
).
total_seconds
()
/
3600
...
@@ -164,8 +170,8 @@ def assimilate(assim_time, prior_init_time,
...
@@ -164,8 +170,8 @@ def assimilate(assim_time, prior_init_time,
if False: use `archivedir` (defined in config) to get prior state
if False: use `archivedir` (defined in config) to get prior state
if str: use this directory to get prior state
if str: use this directory to get prior state
"""
"""
if
prior_path_exp
==
False
:
if
not
prior_path_exp
:
prior_exp
dir
=
cluster
.
archivedir
()
prior_
path_
exp
=
cluster
.
archivedir
()
elif
not
isinstance
(
prior_path_exp
,
str
):
elif
not
isinstance
(
prior_path_exp
,
str
):
raise
TypeError
(
'
prior_path_exp either str or False, is
'
+
str
(
type
(
prior_path_exp
)))
raise
TypeError
(
'
prior_path_exp either str or False, is
'
+
str
(
type
(
prior_path_exp
)))
...
@@ -243,13 +249,13 @@ elif start_from_existing_state:
...
@@ -243,13 +249,13 @@ elif start_from_existing_state:
# get initial conditions from archive
# get initial conditions from archive
init_time
=
dt
.
datetime
(
2008
,
7
,
30
,
6
)
init_time
=
dt
.
datetime
(
2008
,
7
,
30
,
6
)
valid_
time
=
dt
.
datetime
(
2008
,
7
,
30
,
10
)
time
=
dt
.
datetime
(
2008
,
7
,
30
,
10
)
exppath_arch
=
'
/gpfs/data/fs71386/lkugler/sim_archive/exp_v1.11_LMU_filter
'
exppath_arch
=
'
/gpfs/data/fs71386/lkugler/sim_archive/exp_v1.11_LMU_filter
'
id
=
update_wrfinput_from_archive
(
valid_
time
,
init_time
,
exppath_arch
,
depends_on
=
id
)
id
=
update_wrfinput_from_archive
(
time
,
init_time
,
exppath_arch
,
depends_on
=
id
)
# values for assimilation
# values for assimilation
assim_time
=
valid_
time
assim_time
=
time
prior_init_time
=
init_time
prior_init_time
=
init_time
prior_path_exp
=
exppath_arch
prior_path_exp
=
exppath_arch
...
...
This diff is collapsed.
Click to expand it.
scripts/apply_obs_op_dart.py
+
9
−
7
View file @
83221903
...
@@ -9,23 +9,22 @@ import create_obsseq as osq
...
@@ -9,23 +9,22 @@ import create_obsseq as osq
from
gen_synth_obs
import
read_prior_obs
,
set_input_nml
from
gen_synth_obs
import
read_prior_obs
,
set_input_nml
import
pre_assim
import
pre_assim
def
run_operator
(
time
):
def
run_operator
(
obscfg
,
time
):
"""
"""
time_for_dart (dt.datetime) : needs to be consistent with wrfout files!
time_for_dart (dt.datetime) : needs to be consistent with wrfout files!
"""
"""
# assume only 1 obstype for now
obscfg
=
exp
.
observations
[
0
]
# get observation file (obs not important, but their locations)
# get observation file (obs not important, but their locations)
# this should correspond to configuration to have same locations as in real assim
# this should correspond to configuration to have same locations as in real assim
obs_seq_all_out
=
cluster
.
dartrundir
+
'
/obs_seq_all.out
'
obs_seq_all_out
=
cluster
.
dartrundir
+
'
/obs_seq_all.out
'
os
.
chdir
(
cluster
.
dartrundir
)
os
.
chdir
(
cluster
.
dartrundir
)
n_obs
=
obscfg
[
'
n_obs
'
]
n_obs
=
obscfg
[
'
n_obs
'
]
error_var
=
(
obscfg
[
'
err_std
'
])
**
2
error_var
=
(
obscfg
[
'
err_std
'
])
**
2
sat_channel
=
obscfg
.
get
(
'
channel
'
,
False
)
sat_channel
=
obscfg
.
get
(
'
channel
'
,
False
)
cov_loc
=
obscfg
[
'
cov_loc_radius_km
'
]
cov_loc
=
obscfg
[
'
cov_loc_radius_km
'
]
dist_obs
=
obscfg
.
get
(
'
distance_between_obs_km
'
,
False
)
dist_obs
=
obscfg
.
get
(
'
distance_between_obs_km
'
,
False
)
obs_coords
=
osq
.
calc_obs_locations
(
n_obs
,
coords_from_domaincenter
=
False
,
obs_coords
=
osq
.
calc_obs_locations
(
n_obs
,
coords_from_domaincenter
=
False
,
distance_between_obs_km
=
dist_obs
,
distance_between_obs_km
=
dist_obs
,
fpath_obs_locations
=
None
)
fpath_obs_locations
=
None
)
...
@@ -55,8 +54,10 @@ def run_operator(time):
...
@@ -55,8 +54,10 @@ def run_operator(time):
# copy output to archive
# copy output to archive
savedir
=
cluster
.
archivedir
()
+
'
/obs_seq_final_1min/
'
savedir
=
cluster
.
archivedir
()
+
'
/obs_seq_final_1min/
'
mkdir
(
savedir
)
mkdir
(
savedir
)
copy
(
cluster
.
dartrundir
+
'
/obs_seq.final
'
,
obsname
=
obscfg
.
get
(
'
kind
'
,
'
satch
'
+
str
(
obscfg
[
'
sat_channel
'
]))
savedir
+
time
.
strftime
(
'
/%Y-%m-%d_%H:%M_obs_seq.final
'
))
fout
=
time
.
strftime
(
'
/%Y-%m-%d_%H:%M_
'
+
obsname
+
'
_obs_seq.final
'
)
copy
(
cluster
.
dartrundir
+
'
/obs_seq.final
'
,
savedir
+
fout
)
print
(
'
output of observation operator saved to
'
,
fout
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
@@ -69,4 +70,5 @@ if __name__ == '__main__':
...
@@ -69,4 +70,5 @@ if __name__ == '__main__':
pre_assim
.
run
(
time_to_run_fw_op
,
prev_forecast_init
,
exppath_firstguess
)
pre_assim
.
run
(
time_to_run_fw_op
,
prev_forecast_init
,
exppath_firstguess
)
# run fwd operator, save to archive
# run fwd operator, save to archive
run_operator
(
time_to_run_fw_op
)
for
i_obs
,
obscfg
in
enumerate
(
exp
.
observations
):
run_operator
(
obscfg
,
time_to_run_fw_op
)
This diff is collapsed.
Click to expand it.
scripts/gen_synth_obs.py
+
9
−
5
View file @
83221903
...
@@ -115,13 +115,16 @@ def set_input_nml(sat_channel=False, just_prior_values=False,
...
@@ -115,13 +115,16 @@ def set_input_nml(sat_channel=False, just_prior_values=False,
# input.nml for RTTOV
# input.nml for RTTOV
if
sat_channel
>
0
:
if
sat_channel
>
0
:
if
sat_channel
in
[
1
,
2
,
3
,
12
]:
if
sat_channel
in
[
1
,
2
,
3
,
12
]:
# VIS channels
rttov_nml
=
cluster
.
scriptsdir
+
'
/../templates/obs_def_rttov.VIS.nml
'
rttov_nml
=
cluster
.
scriptsdir
+
'
/../templates/obs_def_rttov.VIS.nml
'
else
:
# IR channels
rttov_nml
=
cluster
.
scriptsdir
+
'
/../templates/obs_def_rttov.IR.nml
'
append_file
(
cluster
.
dartrundir
+
'
/input.nml
'
,
rttov_nml
)
else
:
else
:
# append any rttov segment, needs to exist anyway
rttov_nml
=
cluster
.
scriptsdir
+
'
/../templates/obs_def_rttov.IR.nml
'
rttov_nml
=
cluster
.
scriptsdir
+
'
/../templates/obs_def_rttov.IR.nml
'
append_file
(
cluster
.
dartrundir
+
'
/input.nml
'
,
rttov_nml
)
append_file
(
cluster
.
dartrundir
+
'
/input.nml
'
,
rttov_nml
)
def
obs_operator_ensemble
():
def
obs_operator_ensemble
():
os
.
chdir
(
cluster
.
dartrundir
)
os
.
chdir
(
cluster
.
dartrundir
)
...
@@ -162,8 +165,9 @@ if __name__ == "__main__":
...
@@ -162,8 +165,9 @@ if __name__ == "__main__":
time
=
dt
.
datetime
.
strptime
(
sys
.
argv
[
1
],
'
%Y-%m-%d_%H:%M
'
)
time
=
dt
.
datetime
.
strptime
(
sys
.
argv
[
1
],
'
%Y-%m-%d_%H:%M
'
)
fpath_obs_coords
=
cluster
.
archivedir
()
+
time
.
strftime
(
'
/%Y-%m-%d_%H:%M/obs_coords.pkl
'
)
fpath_obs_coords
=
cluster
.
archivedir
()
+
time
.
strftime
(
'
/%Y-%m-%d_%H:%M/obs_coords.pkl
'
)
# remove any existing observation files
os
.
chdir
(
cluster
.
dartrundir
);
os
.
system
(
'
rm -f obs_seq_*.out obs_seq.in obs_seq.final
'
)
os
.
chdir
(
cluster
.
dartrundir
)
os
.
system
(
'
rm -f obs_seq_*.out obs_seq.in obs_seq.final
'
)
# remove any existing observation files
def
prepare_nature_dart
():
def
prepare_nature_dart
():
# get wrfout_d01 from nature run
# get wrfout_d01 from nature run
...
...
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