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
0e02b26f
Commit
0e02b26f
authored
Feb 3, 2022
by
lkugler
Browse files
Options
Downloads
Patches
Plain Diff
bug removal assign OE_assim
parent
0ad88654
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dartwrf/assim_synth_obs.py
+33
-27
33 additions, 27 deletions
dartwrf/assim_synth_obs.py
with
33 additions
and
27 deletions
dartwrf/assim_synth_obs.py
+
33
−
27
View file @
0e02b26f
...
@@ -5,10 +5,10 @@ import numpy as np
...
@@ -5,10 +5,10 @@ import numpy as np
from
scipy.interpolate
import
interp1d
from
scipy.interpolate
import
interp1d
from
config.cfg
import
exp
,
cluster
from
config.cfg
import
exp
,
cluster
from
utils
import
symlink
,
copy
,
sed_inplace
,
append_file
,
mkdir
,
try_remove
,
print
from
dartwrf.
utils
import
symlink
,
copy
,
sed_inplace
,
append_file
,
mkdir
,
try_remove
,
print
import
create_obsseq
as
osq
import
dartwrf.
create_obsseq
as
osq
import
wrfout_add_geo
from
dartwrf
import
wrfout_add_geo
import
obsseq
from
dartwrf
import
obsseq
earth_radius_km
=
6370
earth_radius_km
=
6370
...
@@ -18,8 +18,8 @@ y_oe = [1, 4.5, 10, 12, 13] # adjusted observation error
...
@@ -18,8 +18,8 @@ y_oe = [1, 4.5, 10, 12, 13] # adjusted observation error
oe_73_linear
=
interp1d
(
x_ci
,
y_oe
,
assume_sorted
=
True
)
oe_73_linear
=
interp1d
(
x_ci
,
y_oe
,
assume_sorted
=
True
)
def
oe_
73
(
ci
):
def
OE_model_harnisch_WV
73
(
ci
):
if
ci
<
1
3
:
if
ci
>=
0
and
ci
<
1
6
:
return
oe_73_linear
(
ci
)
return
oe_73_linear
(
ci
)
else
:
else
:
return
13.0
return
13.0
...
@@ -291,21 +291,20 @@ def calc_obserr_WV73(Hx_nature, Hx_prior):
...
@@ -291,21 +291,20 @@ def calc_obserr_WV73(Hx_nature, Hx_prior):
Returns
Returns
np.array Observation error std-deviation with dim (observations)
np.array Observation error std-deviation with dim (observations)
"""
"""
debug
=
False
debug
=
False
n_obs
=
len
(
Hx_nature
)
n_obs
=
len
(
Hx_nature
)
OEs
=
np
.
ones
(
n_obs
)
OEs
=
np
.
ones
(
n_obs
)
for
iobs
in
range
(
n_obs
):
for
iobs
in
range
(
n_obs
):
bt_y
=
Hx_nature
[
iobs
]
bt_y
=
Hx_nature
[
iobs
]
bt_x_ens
=
Hx_prior
[:,
iobs
]
bt_x_ens
=
Hx_prior
[:,
iobs
]
# compute Cloud impact for every pair (ensemble, truth)
CIs
=
[
cloudimpact_73
(
bt_x
,
bt_y
)
for
bt_x
in
bt_x_ens
]
CIs
=
[
cloudimpact_73
(
bt_x
,
bt_y
)
for
bt_x
in
bt_x_ens
]
mean_CI
=
np
.
mean
(
CIs
)
mean_CI
=
np
.
mean
(
CIs
)
oe_model
=
OE_model_harnisch_WV73
(
mean_CI
)
oe_nature
=
oe_73
(
mean_CI
)
if
debug
:
if
debug
:
print
(
"
oe_nature:
"
,
oe_nature
,
"
, bt_y:
"
,
bt_y
,
"
,
mean_CI
:
"
,
mean_CI
)
print
(
"
BT_nature=
"
,
bt_y
,
"
=>
mean_CI
=
"
,
mean_CI
,
"
=> OE_assim=
"
,
oe_model
)
OEs
[
iobs
]
=
oe_
nature
OEs
[
iobs
]
=
oe_
model
return
OEs
return
OEs
...
@@ -464,6 +463,26 @@ def get_parametrized_error(obscfg):
...
@@ -464,6 +463,26 @@ def get_parametrized_error(obscfg):
# since the assimilation is done on the averaged grid
# since the assimilation is done on the averaged grid
return
calc_obserr_WV73
(
Hx_truth
,
Hx_prior
)
return
calc_obserr_WV73
(
Hx_truth
,
Hx_prior
)
def
set_obserr_assimilate_in_obsseqout
(
obsseqout
,
outfile
=
"
./obs_seq.out
"
):
for
obscfg
in
exp
.
observations
:
kind_str
=
obscfg
[
'
kind
'
]
kind
=
osq
.
obs_kind_nrs
[
kind_str
]
print
(
'
kind=
'
,
kind
)
# modify each kind separately, one after each other
mask_kind
=
obsseqout
.
df
.
kind
==
kind
if
is_assim_error_parametrized
(
obscfg
):
assim_err
=
get_parametrized_error
(
obscfg
)
obsseqout
.
df
.
loc
[
mask_kind
,
'
variance
'
]
=
assim_err
**
2
assert
np
.
allclose
(
assim_err
,
obsseqout
.
df
[
'
variance
'
]
**
2
)
else
:
# overwrite with user-defined values
obsseqout
.
df
.
loc
[
mask_kind
,
'
variance
'
]
=
obscfg
[
"
error_assimilate
"
]
**
2
obsseqout
.
to_dart
(
outfile
+
'
2
'
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
"""
Assimilate observations (different obs types)
"""
Assimilate observations (different obs types)
...
@@ -548,21 +567,8 @@ if __name__ == "__main__":
...
@@ -548,21 +567,8 @@ if __name__ == "__main__":
oso
.
to_dart
(
f
=
cluster
.
dartrundir
+
"
/obs_seq.out
"
)
oso
.
to_dart
(
f
=
cluster
.
dartrundir
+
"
/obs_seq.out
"
)
################################################
################################################
print
(
"
2) define observation-errors for assimilation
"
)
print
(
"
2) assign observation-errors for assimilation
"
)
set_obserr_assimilate_in_obsseqout
(
oso
,
outfile
=
cluster
.
dartrundir
+
"
/obs_seq.out
"
)
for
obscfg
in
exp
.
observations
:
kind
=
obscfg
[
'
kind
'
]
mask_kind
=
oso
.
df
.
kind
==
kind
if
is_assim_error_parametrized
(
obscfg
):
assim_err
=
get_parametrized_error
(
obscfg
)
oso
.
df
[
mask_kind
]
=
assim_err
**
2
else
:
# overwrite with user-defined values
oso
.
df
[
mask_kind
]
=
obscfg
[
"
error_assimilate
"
]
**
2
oso
.
to_dart
(
cluster
.
dartrundir
+
"
/obs_seq.out
"
)
print
(
"
3) assimilate
"
)
print
(
"
3) assimilate
"
)
archive_osq_out
(
time
)
archive_osq_out
(
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