Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DataAssimilation
DART-WRF
Commits
66def4b4
Commit
66def4b4
authored
3 months ago
by
Lukas Kugler
Browse files
Options
Downloads
Patches
Plain Diff
revert link/copy
parent
8e122c11
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
dartwrf/prep_IC_prior.py
+15
-11
15 additions, 11 deletions
dartwrf/prep_IC_prior.py
with
15 additions
and
11 deletions
dartwrf/prep_IC_prior.py
+
15
−
11
View file @
66def4b4
...
...
@@ -15,7 +15,7 @@ Ad 2: copies wrfrst to run_WRF directory
"""
def
create_wrfrst_in_WRF_rundir
(
time
:
dt
.
datetime
,
prior_init_time
:
dt
.
datetime
,
prior_path_exp
:
str
)
->
None
:
def
create_wrfrst_in_WRF_rundir
(
cfg
,
time
:
dt
.
datetime
,
prior_init_time
:
dt
.
datetime
,
prior_path_exp
:
str
)
->
None
:
"""
Copy WRF restart files to run_WRF directory
These files will be used as initial conditions for the next WRF run
"""
...
...
@@ -25,11 +25,14 @@ def create_wrfrst_in_WRF_rundir(time: dt.datetime, prior_init_time: dt.datetime,
prior_wrfrst
=
prior_path_exp
+
prior_init_time
.
strftime
(
'
/%Y-%m-%d_%H:%M/
'
)
\
+
str
(
iens
)
+
time
.
strftime
(
'
/wrfrst_d01_%Y-%m-%d_%H:%M:%S
'
)
wrfrst
=
dir_wrf_run
+
time
.
strftime
(
'
/wrfrst_d01_%Y-%m-%d_%H:%M:%S
'
)
print
(
'
linking prior (wrfrst)
'
,
prior_wrfrst
,
'
to
'
,
wrfrst
)
symlink
(
prior_wrfrst
,
wrfrst
,
check_if_source_exists
=
True
)
# we need a temporary copy of the wrfrst file, because there could be multiple experiments
# accessing the same file at the same time
print
(
'
copying prior (wrfrst)
'
,
prior_wrfrst
,
'
to
'
,
wrfrst
)
copy
(
prior_wrfrst
,
wrfrst
)
def
create_updated_wrfinput_from_wrfout
(
time
:
dt
.
datetime
,
prior_init_time
:
dt
.
datetime
,
prior_path_exp
:
str
,
new_start_time
:
dt
.
datetime
)
->
None
:
def
create_updated_wrfinput_from_wrfout
(
cfg
,
time
:
dt
.
datetime
,
prior_init_time
:
dt
.
datetime
,
prior_path_exp
:
str
,
new_start_time
:
dt
.
datetime
)
->
None
:
"""
Create a new wrfinput file from wrfout file
Output is created inside the WRF run directory
...
...
@@ -58,10 +61,7 @@ def create_updated_wrfinput_from_wrfout(time: dt.datetime, prior_init_time: dt.d
os
.
system
(
'
ncks -A -v XTIME,Times
'
+
template_time
+
'
'
+
new_start_wrfinput
)
print
(
'
overwritten times from
'
,
template_time
)
if
__name__
==
'
__main__
'
:
cfg
=
Config
.
from_file
(
sys
.
argv
[
1
])
def
main
(
cfg
):
prior_valid_time
=
cfg
.
prior_valid_time
prior_init_time
=
cfg
.
prior_init_time
prior_path_exp
=
cfg
.
prior_path_exp
...
...
@@ -71,8 +71,12 @@ if __name__ == '__main__':
# use_wrfout_as_wrfinput
# Caution: Even without assimilation increments, this will change the model forecast
new_start_time
=
cfg
.
new_start_time
create_updated_wrfinput_from_wrfout
(
prior_valid_time
,
prior_init_time
,
prior_path_exp
,
new_start_time
)
create_updated_wrfinput_from_wrfout
(
cfg
,
prior_valid_time
,
prior_init_time
,
prior_path_exp
,
new_start_time
)
sys
.
exit
(
0
)
# other case:
create_wrfrst_in_WRF_rundir
(
prior_valid_time
,
prior_init_time
,
prior_path_exp
)
create_wrfrst_in_WRF_rundir
(
cfg
,
prior_valid_time
,
prior_init_time
,
prior_path_exp
)
if
__name__
==
'
__main__
'
:
cfg
=
Config
.
from_file
(
sys
.
argv
[
1
])
main
(
cfg
)
\ No newline at end of file
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