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
0d948184
Commit
0d948184
authored
2 years ago
by
lkugler
Browse files
Options
Downloads
Patches
Plain Diff
new
parent
526d315f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dartwrf/evaluate_posterior.py
+27
-0
27 additions, 0 deletions
dartwrf/evaluate_posterior.py
dartwrf/evaluate_prior.py
+31
-0
31 additions, 0 deletions
dartwrf/evaluate_prior.py
dartwrf/obsseq_2dim.py
+56
-0
56 additions, 0 deletions
dartwrf/obsseq_2dim.py
with
114 additions
and
0 deletions
dartwrf/evaluate_posterior.py
0 → 100755
+
27
−
0
View file @
0d948184
import
os
,
sys
,
shutil
,
warnings
import
time
as
time_module
import
datetime
as
dt
import
numpy
as
np
from
config.cfg
import
exp
,
cluster
from
dartwrf
import
assim_synth_obs
as
aso
if
__name__
==
"
__main__
"
:
assim_time
=
dt
.
datetime
.
strptime
(
sys
.
argv
[
1
],
"
%Y-%m-%d_%H:%M
"
)
print
(
"
computing posterior observations
"
)
aso
.
write_list_of_inputfiles_posterior
(
assim_time
)
# prepare an obsseq without rejected observations
if
exp
.
use_existing_obsseq
:
# from another exp
oso_input
=
assim_time
.
strftime
(
exp
.
use_existing_obsseq
)
else
:
# from same exp
oso_input
=
cluster
.
archivedir
+
'
/obs_seq_out
'
+
assim_time
.
strftime
(
"
/%Y-%m-%d_%H:%M_obs_seq.out-beforeQC
"
)
if
not
os
.
path
.
isfile
(
oso_input
):
oso_input
=
cluster
.
archivedir
+
'
/obs_seq_out
'
+
assim_time
.
strftime
(
"
/%Y-%m-%d_%H:%M_obs_seq.out
"
)
shutil
.
copy
(
oso_input
,
cluster
.
dartrundir
+
'
/obs_seq.out
'
)
aso
.
evaluate
(
assim_time
,
output_format
=
"
%Y-%m-%d_%H:%M_obs_seq.final-eval_posterior_allobs
"
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
dartwrf/evaluate_prior.py
0 → 100755
+
31
−
0
View file @
0d948184
import
os
,
sys
,
shutil
,
warnings
import
time
as
time_module
import
datetime
as
dt
import
numpy
as
np
from
config.cfg
import
exp
,
cluster
from
dartwrf.utils
import
symlink
,
copy
,
sed_inplace
,
append_file
,
mkdir
,
try_remove
,
print
,
shell
from
dartwrf
import
assim_synth_obs
as
aso
from
osselyze.utils
import
get_prior_config
if
__name__
==
"
__main__
"
:
assim_time
=
dt
.
datetime
.
strptime
(
sys
.
argv
[
1
],
"
%Y-%m-%d_%H:%M
"
)
print
(
"
> computing posterior observations ...
"
)
print
(
"
>> prepare prior ensemble
"
)
prior_exp
,
prior_init
=
get_prior_config
(
cluster
.
archive_base
,
exp
.
expname
,
init
=
assim_time
)
prior_valid_time
=
assim_time
aso
.
prepare_prior_ensemble
(
assim_time
,
prior_init
,
prior_valid_time
,
cluster
.
archive_base
+
'
/
'
+
prior_exp
)
# prepare an obsseq without rejected observations
if
exp
.
use_existing_obsseq
:
# from another exp
oso_input
=
assim_time
.
strftime
(
exp
.
use_existing_obsseq
)
else
:
# from same exp
oso_input
=
cluster
.
archivedir
+
'
/obs_seq_out
'
+
assim_time
.
strftime
(
"
/%Y-%m-%d_%H:%M_obs_seq.out-beforeQC
"
)
if
not
os
.
path
.
isfile
(
oso_input
):
oso_input
=
cluster
.
archivedir
+
'
/obs_seq_out
'
+
assim_time
.
strftime
(
"
/%Y-%m-%d_%H:%M_obs_seq.out
"
)
shutil
.
copy
(
oso_input
,
cluster
.
dartrundir
+
'
/obs_seq.out
'
)
aso
.
evaluate
(
assim_time
,
output_format
=
"
%Y-%m-%d_%H:%M_obs_seq.final-eval_prior_allobs
"
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
dartwrf/obsseq_2dim.py
0 → 100755
+
56
−
0
View file @
0d948184
"""
Create obs_seq.out files with collapsed vertical dimension
Specifically, one observation per column which is the maximum of the column
"""
from
copy
import
copy
import
os
,
sys
,
shutil
,
warnings
import
time
as
time_module
import
datetime
as
dt
import
numpy
as
np
from
config.cfg
import
exp
,
cluster
from
dartwrf
import
assim_synth_obs
as
aso
from
dartwrf
import
obsseq
if
__name__
==
"
__main__
"
:
assim_time
=
dt
.
datetime
.
strptime
(
sys
.
argv
[
1
],
"
%Y-%m-%d_%H:%M
"
)
# prepare an obsseq without rejected observations
if
exp
.
use_existing_obsseq
:
# from another exp
oso_input
=
assim_time
.
strftime
(
exp
.
use_existing_obsseq
)
# only assured to work with single obstype
if
len
(
exp
.
observations
)
>
1
:
raise
NotImplementedError
()
n_obs
=
exp
.
observations
[
0
][
'
n_obs
'
]
# existing obsseq with multi levels
oso
=
obsseq
.
ObsSeq
(
oso_input
)
nlev
=
len
(
oso
.
df
)
/
n_obs
if
nlev
-
int
(
nlev
)
!=
0
:
raise
RuntimeError
()
nlev
=
int
(
nlev
)
# levels per obs
# copy will be modified
output
=
copy
(
oso
)
output
.
df
=
output
.
df
.
iloc
[
0
::
nlev
]
# every nth level = first level
#print(output.df, oso.df)
# iterate through, set value to max
for
i_obs
in
range
(
0
,
n_obs
):
# go through n_obs (all columns)
i_obs_subset
=
i_obs
*
nlev
# jumps by nlev (from one to next column)
column
=
oso
.
df
.
loc
[
0
+
i_obs_subset
:
nlev
+
i_obs_subset
,
:]
# select column
output
.
df
.
loc
[
i_obs_subset
,
(
'
observations
'
)]
=
float
(
column
[
'
observations
'
].
max
())
output
.
df
.
loc
[
i_obs_subset
,
(
'
truth
'
)]
=
float
(
column
[
'
truth
'
].
max
())
print
(
output
.
df
)
#, 'observations'], output.df.loc[i_obs, 'observations'])
fout
=
cluster
.
archivedir
+
assim_time
.
strftime
(
"
/obs_seq_out/%Y-%m-%d_%H:%M_obs_seq.out
"
)
os
.
makedirs
(
cluster
.
archivedir
+
'
/obs_seq_out
'
,
exist_ok
=
True
)
output
.
to_dart
(
fout
)
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