Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DART-WRF-delete_byApril
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DataAssimilation
DART-WRF-delete_byApril
Commits
d4fa821c
Commit
d4fa821c
authored
3 years ago
by
lkugler
Browse files
Options
Downloads
Patches
Plain Diff
improved documentation
parent
9cf25538
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/prepare_wrf_initials.py
+31
-27
31 additions, 27 deletions
scripts/prepare_wrf_initials.py
with
31 additions
and
27 deletions
scripts/prepare_wrf_initials.py
+
31
−
27
View file @
d4fa821c
...
@@ -8,12 +8,16 @@ from utils import symlink, copy, mkdir, clean_wrfdir, try_remove
...
@@ -8,12 +8,16 @@ from utils import symlink, copy, mkdir, clean_wrfdir, try_remove
"""
"""
Sets initial condition data (wrfinput/wrrst file) in the run_WRF directory for each ensemble member
Sets initial condition data (wrfinput/wrrst file) in the run_WRF directory for each ensemble member
1) copies wrfrst to run_WRF directory
2) overwrites DA-updated variables with DART output fields
(for verification later on, since a restart run does not write the first wrfout)
You have 2 options to restart:
3) copy wrfout from prior to archivedir
1) using wrfout files (function create_updated_wrfinput_from_wrfout)
4) overwrite DA-updated variables with DART output
2) using wrfrst files (function create_wrfrst_in_WRF_rundir)
Ad 1: copy wrfout from prior to archivedir
overwrite DA-updated variables with DART output
Ad 2: copies wrfrst to run_WRF directory
overwrites DA-updated variables with DART output fields
# assumes T = THM (dry potential temperature as prognostic variable)
# assumes T = THM (dry potential temperature as prognostic variable)
"""
"""
...
@@ -50,8 +54,30 @@ def create_wrfrst_in_WRF_rundir(time, prior_init_time, exppath_firstguess):
...
@@ -50,8 +54,30 @@ def create_wrfrst_in_WRF_rundir(time, prior_init_time, exppath_firstguess):
for
f
in
files_rst
:
for
f
in
files_rst
:
try_remove
(
f
)
try_remove
(
f
)
def
create_updated_wrfinput_from_wrfout
(
time
,
prior_init_time
,
exppath_firstguess
):
"""
Same as create_wrfout_in_archivedir, but output is `wrfinput` in WRF run directory
"""
print
(
'
writing updated wrfout to WRF run directory as wrfinput
'
)
for
iens
in
range
(
1
,
exp
.
n_ens
+
1
):
prior_wrfout
=
exppath_firstguess
+
prior_init_time
.
strftime
(
'
/%Y-%m-%d_%H:%M/
'
)
\
+
str
(
iens
)
+
time
.
strftime
(
'
/wrfout_d01_%Y-%m-%d_%H:%M:%S
'
)
post_wrfout
=
cluster
.
wrf_rundir
(
iens
)
+
'
/wrfinput_d01
'
copy
(
prior_wrfout
,
post_wrfout
)
if
True
:
# overwrite DA updated variables
filter_out
=
cluster
.
dartrundir
+
'
/filter_restart_d01.
'
+
str
(
iens
).
zfill
(
4
)
os
.
system
(
cluster
.
ncks
+
'
-A -v
'
+
updates
+
'
'
+
filter_out
+
'
'
+
post_wrfout
)
# need to overwrite THM manually
with
nc
.
Dataset
(
filter_out
,
'
r
'
)
as
ds_filter
:
with
nc
.
Dataset
(
post_wrfout
,
'
r+
'
)
as
ds_wrfout
:
ds_wrfout
.
variables
[
'
THM
'
][:]
=
ds_filter
.
variables
[
'
T
'
][:]
print
(
post_wrfout
,
'
created.
'
)
def
create_wrfout_in_archivedir
(
time
,
prior_init_time
,
exppath_firstguess
):
def
create_wrfout_in_archivedir
(
time
,
prior_init_time
,
exppath_firstguess
):
"""
Put updated wrfout in archive dir (because wrf restart writes no 0 minute wrfout)
"""
Put updated wrfout in archive dir (because wrf restart writes no 0 minute wrfout)
probably not necessary, if using the wrf namelist option `write_hist_at_0h_rst`
"""
"""
print
(
'
writing updated wrfout to archive (for verification)
'
)
print
(
'
writing updated wrfout to archive (for verification)
'
)
for
iens
in
range
(
1
,
exp
.
n_ens
+
1
):
for
iens
in
range
(
1
,
exp
.
n_ens
+
1
):
...
@@ -74,28 +100,6 @@ def create_wrfout_in_archivedir(time, prior_init_time, exppath_firstguess):
...
@@ -74,28 +100,6 @@ def create_wrfout_in_archivedir(time, prior_init_time, exppath_firstguess):
ds_wrfout
.
variables
[
'
THM
'
][:]
=
ds_filter
.
variables
[
'
T
'
][:]
ds_wrfout
.
variables
[
'
THM
'
][:]
=
ds_filter
.
variables
[
'
T
'
][:]
print
(
post_wrfout_archive
,
'
created.
'
)
print
(
post_wrfout_archive
,
'
created.
'
)
def
create_updated_wrfinput_from_wrfout
(
time
,
prior_init_time
,
exppath_firstguess
):
"""
Same as create_wrfout_in_archivedir, but output is `wrfinput` in WRF run directory
"""
print
(
'
writing updated wrfout to WRF run directory as wrfinput
'
)
for
iens
in
range
(
1
,
exp
.
n_ens
+
1
):
prior_wrfout
=
exppath_firstguess
+
prior_init_time
.
strftime
(
'
/%Y-%m-%d_%H:%M/
'
)
\
+
str
(
iens
)
+
time
.
strftime
(
'
/wrfout_d01_%Y-%m-%d_%H:%M:%S
'
)
post_wrfout
=
cluster
.
wrf_rundir
(
iens
)
+
'
/wrfinput_d01
'
copy
(
prior_wrfout
,
post_wrfout
)
if
True
:
# overwrite DA updated variables
filter_out
=
cluster
.
dartrundir
+
'
/filter_restart_d01.
'
+
str
(
iens
).
zfill
(
4
)
os
.
system
(
cluster
.
ncks
+
'
-A -v
'
+
updates
+
'
'
+
filter_out
+
'
'
+
post_wrfout
)
# need to overwrite THM manually
with
nc
.
Dataset
(
filter_out
,
'
r
'
)
as
ds_filter
:
with
nc
.
Dataset
(
post_wrfout
,
'
r+
'
)
as
ds_wrfout
:
ds_wrfout
.
variables
[
'
THM
'
][:]
=
ds_filter
.
variables
[
'
T
'
][:]
print
(
post_wrfout
,
'
created.
'
)
if
__name__
==
'
__main__
'
:
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
'
)
prior_init_time
=
dt
.
datetime
.
strptime
(
sys
.
argv
[
2
],
'
%Y-%m-%d_%H:%M
'
)
prior_init_time
=
dt
.
datetime
.
strptime
(
sys
.
argv
[
2
],
'
%Y-%m-%d_%H:%M
'
)
...
...
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