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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DataAssimilation
DART-WRF
Commits
a4cbd178
Commit
a4cbd178
authored
Mar 13, 2023
by
lkugler
Browse files
Options
Downloads
Patches
Plain Diff
interface
parent
a783896e
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/obsseq_2dim.py
+23
-12
23 additions, 12 deletions
dartwrf/obsseq_2dim.py
with
23 additions
and
12 deletions
dartwrf/obsseq_2dim.py
+
23
−
12
View file @
a4cbd178
"""
Create obs_seq.out files with collapsed vertical dimension
"""
Create obs_seq.out files with collapsed vertical dimension
Specifically, one observation per column which is the maximum of the column
Specifically, one observation per column which is the maximum of the column
Use this script before running the OSSE workflow, to prepare obs_seq.out files.
path_3d_obsseq =
'
/path/exp_obs10_loc20/obs_seq_out/2008-07-30_%H:%M_obs_seq.out
'
"""
"""
from
copy
import
copy
from
copy
import
copy
...
@@ -8,35 +12,41 @@ import time as time_module
...
@@ -8,35 +12,41 @@ import time as time_module
import
datetime
as
dt
import
datetime
as
dt
import
numpy
as
np
import
numpy
as
np
from
config.cfg
import
exp
from
config.cluster
import
cluster
from
config.cluster
import
cluster
from
dartwrf
import
utils
from
dartwrf
import
assim_synth_obs
as
aso
from
dartwrf
import
assim_synth_obs
as
aso
from
dartwrf
import
obsseq
from
dartwrf
import
obsseq
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
assim_time
=
dt
.
datetime
.
strptime
(
sys
.
argv
[
1
],
"
%Y-%m-%d_%H:%M
"
)
exp
=
sys
.
argv
[
1
]
assim_time
=
dt
.
datetime
.
strptime
(
sys
.
argv
[
2
],
"
%Y-%m-%d_%H:%M
"
)
path_3d_obsseq
=
cluster
.
archive_base
+
exp
+
'
/obs_seq_out/%Y-%m-%d_%H:%M_obs_seq.out
'
oso_input
=
assim_time
.
strftime
(
path_3d_obsseq
)
#
prepare an obsseq without rejected observations
#
load experiment config
if
exp
.
use_existing_obsseq
:
# from another exp
sys
.
path
.
insert
(
0
,
cluster
.
archivedir
+
'
/
'
+
exp
+
'
/DART-WRF
'
)
oso_input
=
assim_time
.
strftime
(
exp
.
use_existing_obsseq
)
from
config
import
cfg
# only assured to work with single obstype
# only assured to work with single obstype
if
len
(
exp
.
observations
)
>
1
:
if
len
(
cfg
.
exp
.
observations
)
>
1
:
raise
NotImplementedError
()
raise
NotImplementedError
()
n_obs
=
exp
.
observations
[
0
][
'
n_obs
'
]
# existing obsseq with multi levels
# existing obsseq with multi levels
oso
=
obsseq
.
ObsSeq
(
oso_input
)
oso
=
obsseq
.
ObsSeq
(
oso_input
)
n_obs
=
cfg
.
exp
.
observations
[
0
][
'
n_obs
'
]
nlev
=
len
(
oso
.
df
)
/
n_obs
nlev
=
len
(
oso
.
df
)
/
n_obs
if
nlev
-
int
(
nlev
)
!=
0
:
if
nlev
-
int
(
nlev
)
!=
0
:
raise
RuntimeError
()
raise
RuntimeError
()
nlev
=
int
(
nlev
)
# levels per obs
nlev
=
int
(
nlev
)
# levels per obs
print
(
'
nlev
'
,
nlev
)
print
(
'
n_obs
'
,
n_obs
)
# copy will be modified
output
=
copy
(
oso
)
# copy will be modified
output
=
copy
(
oso
)
#
output
.df = output.df.copy() # without this, we get a SettingWithCopyWarning
output
.
df
=
output
.
df
.
iloc
[
0
::
nlev
]
# every nth level = first level
output
.
df
=
output
.
df
.
iloc
[
0
::
nlev
]
# every nth level = first level
#print(output.df, oso.df)
#print(output.df, oso.df)
...
@@ -50,8 +60,9 @@ if __name__ == "__main__":
...
@@ -50,8 +60,9 @@ if __name__ == "__main__":
output
.
df
.
loc
[
i_obs_subset
,
(
'
observations
'
)]
=
float
(
column
[
'
observations
'
].
max
())
output
.
df
.
loc
[
i_obs_subset
,
(
'
observations
'
)]
=
float
(
column
[
'
observations
'
].
max
())
output
.
df
.
loc
[
i_obs_subset
,
(
'
truth
'
)]
=
float
(
column
[
'
truth
'
].
max
())
output
.
df
.
loc
[
i_obs_subset
,
(
'
truth
'
)]
=
float
(
column
[
'
truth
'
].
max
())
print
(
output
.
df
)
#, 'observations'], output.df.loc[i_obs, 'observations'])
print
(
output
.
df
)
fout
=
cluster
.
archivedir
+
assim_time
.
strftime
(
"
/obs_seq_out/%Y-%m-%d_%H:%M_obs_seq.out
"
)
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
)
os
.
makedirs
(
cluster
.
archivedir
+
'
/obs_seq_out
'
,
exist_ok
=
True
)
output
.
to_dart
(
fout
)
output
.
to_dart
(
fout
)
utils
.
write_txt
([
"
created from
"
,
oso_input
,],
fout
[:
-
3
]
+
'
.txt
'
)
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