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
4beb45f0
Commit
4beb45f0
authored
2 years ago
by
lkugler
Browse files
Options
Downloads
Patches
Plain Diff
evaluate only if necessary
parent
25e0d822
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/assim_synth_obs.py
+30
-21
30 additions, 21 deletions
dartwrf/assim_synth_obs.py
with
30 additions
and
21 deletions
dartwrf/assim_synth_obs.py
+
30
−
21
View file @
4beb45f0
...
@@ -259,26 +259,32 @@ def get_parametrized_error(obscfg, osf_prior):
...
@@ -259,26 +259,32 @@ def get_parametrized_error(obscfg, osf_prior):
NotImplementedError
(
'
sat_channel not implemented
'
,
obscfg
.
get
(
"
sat_channel
"
))
NotImplementedError
(
'
sat_channel not implemented
'
,
obscfg
.
get
(
"
sat_channel
"
))
def
set_obserr_assimilate_in_obsseqout
(
oso
,
osf_prior
,
outfile
=
"
./obs_seq.out
"
):
def
set_obserr_assimilate_in_obsseqout
(
oso
,
outfile
=
"
./obs_seq.out
"
):
""""
Overwrite existing variance values in obs_seq.out files
""""
Overwrite existing variance values in obs_seq.out files
Args:
Args:
oso (ObsSeq): python representation of obs_seq.out file, will be modified and written to file
oso (ObsSeq): python representation of obs_seq.out file, will be modified and written to file
osf_prior (ObsSeq): python representation of obs_seq.final (output of filter in evaluate-mode without posterior)
contains prior values; used for parameterized errors
Returns:
Returns:
None (writes to file)
None (writes to file)
Variables:
osf_prior (ObsSeq): python representation of obs_seq.final (output of filter in evaluate-mode without posterior)
contains prior values; used for parameterized errors
"""
"""
for
obscfg
in
exp
.
observations
:
for
obscfg
in
exp
.
observations
:
kind_str
=
obscfg
[
'
kind
'
]
kind_str
=
obscfg
[
'
kind
'
]
# e.g. 'RADIOSONDE_TEMPERATURE'
kind
=
osq
.
obs_kind_nrs
[
kind_str
]
kind
=
osq
.
obs_kind_nrs
[
kind_str
]
# e.g. 263
# modify
each kind separately, one after each other
# modify
observation error of each kind sequentially
where_oso_iskind
=
oso
.
df
.
kind
==
kind
where_oso_iskind
=
oso
.
df
.
kind
==
kind
where_osf_iskind
=
osf_prior
.
df
.
kind
==
kind
if
obscfg
[
"
error_assimilate
"
]
==
False
:
if
obscfg
[
"
error_assimilate
"
]
==
False
:
osf_prior
=
obsseq
.
ObsSeq
(
cluster
.
dartrundir
+
"
/obs_seq.final
"
)
# this file will be generated by `evaluate()`
where_osf_iskind
=
osf_prior
.
df
.
kind
==
kind
assim_err
=
get_parametrized_error
(
obscfg
,
osf_prior
.
df
[
where_osf_iskind
])
assim_err
=
get_parametrized_error
(
obscfg
,
osf_prior
.
df
[
where_osf_iskind
])
oso
.
df
.
loc
[
where_oso_iskind
,
'
variance
'
]
=
assim_err
**
2
oso
.
df
.
loc
[
where_oso_iskind
,
'
variance
'
]
=
assim_err
**
2
#assert np.allclose(assim_err, oso.df['variance']**2) # check
#assert np.allclose(assim_err, oso.df['variance']**2) # check
...
@@ -288,7 +294,9 @@ def set_obserr_assimilate_in_obsseqout(oso, osf_prior, outfile="./obs_seq.out"):
...
@@ -288,7 +294,9 @@ def set_obserr_assimilate_in_obsseqout(oso, osf_prior, outfile="./obs_seq.out"):
oso
.
to_dart
(
outfile
)
oso
.
to_dart
(
outfile
)
def
qc_obs
(
time
,
oso
,
osf_prior
):
def
qc_obs
(
time
,
oso
):
osf_prior
=
obsseq
.
ObsSeq
(
cluster
.
dartrundir
+
"
/obs_seq.final
"
)
# obs should be superobbed already!
# obs should be superobbed already!
for
i
,
obscfg
in
enumerate
(
exp
.
observations
):
for
i
,
obscfg
in
enumerate
(
exp
.
observations
):
if
i
>
0
:
if
i
>
0
:
...
@@ -373,9 +381,6 @@ def evaluate(assim_time,
...
@@ -373,9 +381,6 @@ def evaluate(assim_time,
copy
(
cluster
.
dartrundir
+
"
/obs_seq.final
"
,
fout
)
copy
(
cluster
.
dartrundir
+
"
/obs_seq.final
"
,
fout
)
print
(
fout
,
"
saved.
"
)
print
(
fout
,
"
saved.
"
)
osf
=
obsseq
.
ObsSeq
(
cluster
.
dartrundir
+
"
/obs_seq.final
"
)
return
osf
def
generate_obsseq_out
(
time
):
def
generate_obsseq_out
(
time
):
...
@@ -522,9 +527,14 @@ def main(time, prior_init_time, prior_valid_time, prior_path_exp):
...
@@ -522,9 +527,14 @@ def main(time, prior_init_time, prior_valid_time, prior_path_exp):
None
None
"""
"""
nproc
=
cluster
.
max_nproc
nproc
=
cluster
.
max_nproc
do_QC
=
getattr
(
exp
,
"
reject_smallFGD
"
,
False
)
# True: triggers additional evaluations of prior & posterior
# for which observation type do we have a parametrized observation error?
error_is_parametrized
=
[
obscfg
[
"
error_assimilate
"
]
==
False
for
obscfg
in
exp
.
observations
]
# create directory to run DART in
archive_time
=
cluster
.
archivedir
+
time
.
strftime
(
"
/%Y-%m-%d_%H:%M/
"
)
archive_time
=
cluster
.
archivedir
+
time
.
strftime
(
"
/%Y-%m-%d_%H:%M/
"
)
os
.
makedirs
(
cluster
.
dartrundir
,
exist_ok
=
True
)
# create directory to run DART in
os
.
makedirs
(
cluster
.
dartrundir
,
exist_ok
=
True
)
os
.
chdir
(
cluster
.
dartrundir
)
os
.
chdir
(
cluster
.
dartrundir
)
# link DART binaries to run_DART
# link DART binaries to run_DART
...
@@ -534,8 +544,6 @@ def main(time, prior_init_time, prior_valid_time, prior_path_exp):
...
@@ -534,8 +544,6 @@ def main(time, prior_init_time, prior_valid_time, prior_path_exp):
os
.
system
(
"
rm -f input.nml obs_seq.in obs_seq.out obs_seq.out-orig obs_seq.final
"
)
os
.
system
(
"
rm -f input.nml obs_seq.in obs_seq.out obs_seq.out-orig obs_seq.final
"
)
set_DART_nml
()
set_DART_nml
()
do_QC_here
=
getattr
(
exp
,
"
reject_smallFGD
"
,
False
)
# True: triggers additional evaluations of prior & posterior
print
(
"
prepare nature
"
)
print
(
"
prepare nature
"
)
prepare_nature_dart
(
time
)
# link WRF files to DART directory
prepare_nature_dart
(
time
)
# link WRF files to DART directory
...
@@ -545,16 +553,17 @@ def main(time, prior_init_time, prior_valid_time, prior_path_exp):
...
@@ -545,16 +553,17 @@ def main(time, prior_init_time, prior_valid_time, prior_path_exp):
print
(
"
get observations with specified obs-error
"
)
print
(
"
get observations with specified obs-error
"
)
oso
=
get_obsseq_out
(
time
)
oso
=
get_obsseq_out
(
time
)
if
do_QC_here
:
# is any observation error parametrized?
if
any
(
error_is_parametrized
)
or
do_QC
:
print
(
"
(optional) evaluate prior for all observations (incl rejected)
"
)
print
(
"
(optional) evaluate prior for all observations (incl rejected)
"
)
osf_prior
=
evaluate
(
time
,
output_format
=
"
%Y-%m-%d_%H:%M_obs_seq.final-eval_prior_allobs
"
)
evaluate
(
time
,
output_format
=
"
%Y-%m-%d_%H:%M_obs_seq.final-eval_prior_allobs
"
)
print
(
"
assign observation-errors for assimilation
"
)
print
(
"
assign observation-errors for assimilation
"
)
set_obserr_assimilate_in_obsseqout
(
oso
,
osf_prior
,
outfile
=
cluster
.
dartrundir
+
"
/obs_seq.out
"
)
set_obserr_assimilate_in_obsseqout
(
oso
,
outfile
=
cluster
.
dartrundir
+
"
/obs_seq.out
"
)
if
do_QC
_here
:
if
do_QC
:
print
(
"
2.3) reject observations?
"
)
print
(
"
2.3) reject observations?
"
)
qc_obs
(
time
,
oso
,
osf_prior
)
qc_obs
(
time
,
oso
)
if
exp
.
prior_inflation
==
2
:
if
exp
.
prior_inflation
==
2
:
prepare_inflation_2
(
time
,
prior_init_time
)
prepare_inflation_2
(
time
,
prior_init_time
)
...
@@ -567,7 +576,7 @@ def main(time, prior_init_time, prior_valid_time, prior_path_exp):
...
@@ -567,7 +576,7 @@ def main(time, prior_init_time, prior_valid_time, prior_path_exp):
if
exp
.
prior_inflation
==
2
:
if
exp
.
prior_inflation
==
2
:
archive_inflation_2
(
time
)
archive_inflation_2
(
time
)
if
do_QC
_here
:
if
do_QC
:
print
(
"
4) evaluate posterior observations for all observations (incl rejected)
"
)
print
(
"
4) evaluate posterior observations for all observations (incl rejected)
"
)
write_list_of_inputfiles_posterior
(
time
)
write_list_of_inputfiles_posterior
(
time
)
...
...
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