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
32a12674
Commit
32a12674
authored
1 year ago
by
lkugler
Browse files
Options
Downloads
Patches
Plain Diff
eval posterior
parent
eed51634
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dartwrf/evaluate_obs_space.py
+25
-25
25 additions, 25 deletions
dartwrf/evaluate_obs_space.py
evaluate_plus1.py
+11
-10
11 additions, 10 deletions
evaluate_plus1.py
with
36 additions
and
35 deletions
dartwrf/evaluate_obs_space.py
+
25
−
25
View file @
32a12674
import
os
,
sys
,
shutil
,
warnings
import
os
,
sys
,
shutil
,
warnings
,
glob
import
datetime
as
dt
import
datetime
as
dt
from
dartwrf.exp_config
import
exp
from
dartwrf.exp_config
import
exp
from
dartwrf.server_config
import
cluster
from
dartwrf.server_config
import
cluster
from
dartwrf
import
assim_synth_obs
as
aso
from
dartwrf
import
assim_synth_obs
as
aso
def
evaluate_one_time
(
init
,
valid
):
def
evaluate_one_time
(
assim_time
,
valid_time
,
use_other_obsseq
=
False
):
"""
Evaluate the ensemble forecast in observation space at a given time, apart from the analysis time.
"""
Evaluate the ensemble forecast in observation space at a given time, apart from the analysis time.
Args:
Args:
init
(datetime): initialization time of the forecast
assim_time
(datetime): initialization time of the forecast
valid (datetime): valid
time of the forecast
valid
_time
(datetime): valid
_
time of the forecast
Returns:
Returns:
None
None
"""
"""
aso
.
prepare_nature_dart
(
valid_time
)
aso
.
prepare_prior_ensemble
(
valid_time
,
prior_init_time
=
assim_time
,
prior_valid_time
=
valid_time
,
prior_path_exp
=
cluster
.
archivedir
)
# # prepare nature and prior ensemble
# does an observation exist at this time?
aso
.
prepare_nature_dart
(
valid
)
f_oso
=
cluster
.
archivedir
+
valid_time
.
strftime
(
"
/obs_seq_out/%Y-%m-%d_%H:%M:%S_obs_seq.out
"
)
aso
.
prepare_prior_ensemble
(
valid
,
prior_init_time
=
init
,
prior_valid_time
=
valid
,
prior_path_exp
=
cluster
.
archivedir
)
if
os
.
path
.
exists
(
f_oso
):
if
use_other_obsseq
:
# use a different obsseq file
# use the existing file
f_obs_seq_out
=
use_other_obsseq
shutil
.
copy
(
f_oso
,
cluster
.
dart_rundir
+
'
/obs_seq.out
'
)
shutil
.
copy
(
f_obs_seq_out
,
cluster
.
dart_rundir
+
'
/obs_seq.out
'
)
else
:
# use an old obsseq file and
else
:
# from same exp
f_oso
=
cluster
.
archivedir
+
assim_time
.
strftime
(
"
/obs_seq_out/%Y-%m-%d_%H:%M:%S_obs_seq.out
"
)
# use the last assimilation obsseq file for the observation locations (note: observed values are not valid)
f_obs_seq_out
=
cluster
.
archivedir
+
valid
.
strftime
(
"
/obs_seq_out/%Y-%m-%d_%H:%M_obs_seq.out
"
)
from
dartwrf.obs
import
obsseq
from
dartwrf.obs
import
obsseq
oso
=
obsseq
.
ObsSeq
(
f_obs_seq_out
)
oso
=
obsseq
.
ObsSeq
(
f_oso
)
oso
.
df
[
'
observations
'
]
=
-
9999
# overwrite obs/truth values with "missing value"
oso
.
df
[
'
observations
'
]
=
-
888888.0
oso
.
df
[
'
truth
'
]
=
-
888888.0
oso
.
to_dart
(
cluster
.
dart_rundir
+
'
/obs_seq.out
'
)
oso
.
to_dart
(
cluster
.
dart_rundir
+
'
/obs_seq.out
'
)
aso
.
evaluate
(
valid
,
output_format
=
"
%Y-%m-%d_%H:%M_obs_seq.final-evaluate
"
)
aso
.
evaluate
(
valid
_time
,
output_format
=
"
%Y-%m-%d_%H:%M
:%S
_obs_seq.final-evaluate
"
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
@@ -45,15 +47,13 @@ if __name__ == "__main__":
...
@@ -45,15 +47,13 @@ if __name__ == "__main__":
Usage: python3 evaluate_obs_space.py init1,valid1 init2,valid2 ...
Usage: python3 evaluate_obs_space.py init1,valid1 init2,valid2 ...
"""
"""
args
=
sys
.
argv
[
1
:]
args
=
sys
.
argv
[
1
:]
init_valid_tuples
=
[
a
.
split
(
'
,
'
)
for
a
in
args
]
arg_tuples
=
[
a
.
split
(
'
,
'
)
for
a
in
args
]
use_other_obsseq
=
False
# we need an existing run_DART folder
# we need an existing run_DART folder
aso
.
prepare_run_DART_folder
()
aso
.
prepare_run_DART_folder
()
for
(
init
,
valid
)
in
init_valid
_tuples
:
for
(
assim_time
,
valid_time
)
in
arg
_tuples
:
init
=
dt
.
datetime
.
strptime
(
init
,
"
%Y-%m-%d_%H:%M
"
)
assim_time
=
dt
.
datetime
.
strptime
(
assim_time
,
"
%Y-%m-%d_%H:%M
"
)
valid
=
dt
.
datetime
.
strptime
(
valid
,
"
%Y-%m-%d_%H:%M
"
)
valid_time
=
dt
.
datetime
.
strptime
(
valid_time
,
"
%Y-%m-%d_%H:%M:%S
"
)
evaluate_one_time
(
init
,
valid
)
evaluate_one_time
(
assim_time
,
valid_time
)
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
evaluate_plus1.py
+
11
−
10
View file @
32a12674
...
@@ -6,18 +6,19 @@ import datetime as dt
...
@@ -6,18 +6,19 @@ import datetime as dt
from
dartwrf.workflows
import
WorkFlows
from
dartwrf.workflows
import
WorkFlows
w
=
WorkFlows
(
exp_config
=
'
exp_nonlin.py
'
,
server_config
=
'
jet.py
'
)
w
=
WorkFlows
(
exp_config
=
'
exp_nonlin.py
'
,
server_config
=
'
jet.py
'
)
id
=
None
assim_times
=
[
dt
.
datetime
(
2008
,
7
,
30
,
12
),
]
assim_times
=
[
dt
.
datetime
(
2008
,
7
,
30
,
12
),
# dt.datetime(2008,7,30,12,30),
dt
.
datetime
(
2008
,
7
,
30
,
12
,
30
),
# dt.datetime(2008,7,30,13),
dt
.
datetime
(
2008
,
7
,
30
,
13
),
# dt.datetime(2008,7,30,13,30),
dt
.
datetime
(
2008
,
7
,
30
,
13
,
30
),
# dt.datetime(2008,7,30,14),]
dt
.
datetime
(
2008
,
7
,
30
,
14
),]
# generate observations at +1 minute after the assimilation time
# generate observations at +1 minute after the assimilation time
obs_times
=
[
each
+
dt
.
timedelta
(
minutes
=
1
)
for
each
in
assim_times
]
w
.
generate_obsseq_out
(
obs_times
)
tuples
=
[]
for
init
in
assim_times
:
for
s
in
range
(
30
,
3
*
60
+
1
,
30
):
tuples
.
append
((
init
,
init
+
dt
.
timedelta
(
seconds
=
s
)))
# evaluate the forecast at +1 minute after the assimilation time
w
.
evaluate_obs_posterior_after_analysis
(
tuples
,
depends_on
=
id
)
w
.
evaluate_plus1
(
assim_times
)
\ 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