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
5a314861
Commit
5a314861
authored
3 years ago
by
lkugler
Browse files
Options
Downloads
Patches
Plain Diff
minor update
parent
2796f7b7
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/create_obsseq.py
+100
-99
100 additions, 99 deletions
dartwrf/create_obsseq.py
with
100 additions
and
99 deletions
dartwrf/create_obsseq.py
+
100
−
99
View file @
5a314861
...
@@ -281,100 +281,100 @@ kind
...
@@ -281,100 +281,100 @@ kind
"""
+
str
(
obs
[
'
obserr_var
'
])
"""
+
str
(
obs
[
'
obserr_var
'
])
def
create_obsseq_in_separate_obs
(
time_dt
,
obscfg
,
obs_errors
=
False
,
# def create_obsseq_in_separate_obs(time_dt, obscfg, obs_errors=False,
archive_obs_coords
=
False
):
# archive_obs_coords=False):
"""
Create obs_seq.in of one obstype
# """Create obs_seq.in of one obstype
Args:
# Args:
time_dt (dt.datetime): time of observation
# time_dt (dt.datetime): time of observation
obscfg (dict)
# obscfg (dict)
obs_errors (int, np.array) : values of observation errors (standard deviations)
# obs_errors (int, np.array) : values of observation errors (standard deviations)
e.g. 0 = use zero error
# e.g. 0 = use zero error
archive_obs_coords (str, False): path to folder
# archive_obs_coords (str, False): path to folder
channel_id (int): SEVIRI channel number
# channel_id (int): SEVIRI channel number
see https://nwp-saf.eumetsat.int/downloads/rtcoef_rttov12/ir_srf/rtcoef_msg_4_seviri_srf.html
# see https://nwp-saf.eumetsat.int/downloads/rtcoef_rttov12/ir_srf/rtcoef_msg_4_seviri_srf.html
coords (list of 2-tuples with (lat,lon))
# coords (list of 2-tuples with (lat,lon))
obserr_std (np.array): shape (n_obs,), one value for each observation,
# obserr_std (np.array): shape (n_obs,), one value for each observation,
gaussian error with this std-dev is added to the truth at observation time
# gaussian error with this std-dev is added to the truth at observation time
archive_obs_coords (bool, str): False or str (filepath where `obs_seq.in` will be saved)
# archive_obs_coords (bool, str): False or str (filepath where `obs_seq.in` will be saved)
"""
# """
n_obs
=
obscfg
[
'
n_obs
'
]
# n_obs = obscfg['n_obs']
coords
=
calc_obs_locations
(
n_obs
,
# coords = calc_obs_locations(n_obs,
coords_from_domaincenter
=
False
,
# coords_from_domaincenter=False,
distance_between_obs_km
=
obscfg
.
get
(
'
distance_between_obs_km
'
,
False
),
# distance_between_obs_km=obscfg.get('distance_between_obs_km', False),
fpath_coords
=
archive_obs_coords
)
# fpath_coords=archive_obs_coords)
kind
=
obscfg
[
'
kind
'
]
# kind = obscfg['kind']
sat_channel
=
obscfg
.
get
(
'
sat_channel
'
,
False
)
# sat_channel = obscfg.get('sat_channel', False)
# determine vertical coordinates
# # determine vertical coordinates
if
not
sat_channel
:
# if not sat_channel:
if
'
SYNOP
'
in
kind
:
# if 'SYNOP' in kind:
vert_coord_sys
=
"
-1
"
# meters AGL
# vert_coord_sys = "-1" # meters AGL
vert_coords
=
[
2
,
]
# vert_coords = [2, ]
else
:
# else:
vert_coord_sys
=
"
3
"
# meters AMSL
# vert_coord_sys = "3" # meters AMSL
vert_coords
=
obscfg
[
'
heights
'
]
# vert_coords = obscfg['heights']
else
:
# else:
vert_coord_sys
=
"
-2
"
# undefined height
# vert_coord_sys = "-2" # undefined height
vert_coords
=
[
"
-888888.0000000000
"
,
]
# vert_coords = ["-888888.0000000000", ]
coords
=
append_hgt_to_coords
(
coords
,
vert_coords
)
# coords = append_hgt_to_coords(coords, vert_coords)
n_obs_3d
=
len
(
coords
)
# n_obs_3d = len(coords)
# define obs error
# # define obs error
obserr_std
=
np
.
zeros
(
n_obs_3d
)
# obserr_std = np.zeros(n_obs_3d)
if
obs_errors
:
# if obs_errors:
obserr_std
+=
obs_errors
# obserr_std += obs_errors
# other stuff for obsseq.in
# # other stuff for obsseq.in
obs_kind_nr
=
obs_kind_nrs
[
kind
]
# obs_kind_nr = obs_kind_nrs[kind]
line_obstypedef
=
'
'
+
obs_kind_nr
+
'
'
+
kind
# line_obstypedef = ' '+obs_kind_nr+' '+kind
time_dt
=
add_timezone_UTC
(
time_dt
)
# time_dt = add_timezone_UTC(time_dt)
dart_date_day
,
secs_thatday
=
get_dart_date
(
time_dt
)
# dart_date_day, secs_thatday = get_dart_date(time_dt)
print
(
'
secs, days:
'
,
secs_thatday
,
dart_date_day
)
# print('secs, days:', secs_thatday, dart_date_day)
if
sat_channel
:
sun_az
=
str
(
get_azimuth
(
lat0
,
lon0
,
time_dt
))
sun_zen
=
str
(
90.
-
get_altitude
(
lat0
,
lon0
,
time_dt
))
print
(
'
sunzen
'
,
sun_zen
,
'
sunazi
'
,
sun_az
)
appendix
=
"""
visir
"""
+
sat_az
+
"""
"""
+
sat_zen
+
"""
"""
+
sun_az
+
"""
"""
+
sun_zen
+
"""
12 4 21
"""
+
str
(
sat_channel
)
+
"""
-888888.000000000
1
"""
else
:
appendix
=
''
txt
=
preamble
(
n_obs_3d
,
line_obstypedef
)
for
i_obs
in
range
(
n_obs_3d
):
last
=
False
if
i_obs
==
int
(
n_obs_3d
)
-
1
:
last
=
True
# last_observation
txt
+=
write_section
(
dict
(
i
=
i_obs
+
1
,
kind_nr
=
obs_kind_nr
,
dart_date_day
=
dart_date_day
,
secs_thatday
=
secs_thatday
,
lon
=
coords
[
i_obs
][
1
],
lat
=
coords
[
i_obs
][
0
],
vert_coord
=
coords
[
i_obs
][
2
],
vert_coord_sys
=
vert_coord_sys
,
obserr_var
=
obserr_std
[
i_obs
]
**
2
,
appendix
=
appendix
),
last
=
last
)
write_file
(
txt
,
output_path
=
cluster
.
dartrundir
+
'
/obs_seq.in
'
)
def
create_obsseqin_alltypes
(
time_dt
,
list_obscfg
,
obs_errors
,
archive_obs_coords
=
False
):
# if sat_channel:
# sun_az = str(get_azimuth(lat0, lon0, time_dt))
# sun_zen = str(90. - get_altitude(lat0, lon0, time_dt))
# print('sunzen', sun_zen, 'sunazi', sun_az)
# appendix = """visir
# """+sat_az+""" """+sat_zen+""" """+sun_az+"""
# """+sun_zen+"""
# 12 4 21 """+str(sat_channel)+"""
# -888888.000000000
# 1"""
# else:
# appendix = ''
# txt = preamble(n_obs_3d, line_obstypedef)
# for i_obs in range(n_obs_3d):
# last = False
# if i_obs == int(n_obs_3d)-1:
# last = True # last_observation
# txt += write_section(dict(i=i_obs+1,
# kind_nr=obs_kind_nr,
# dart_date_day=dart_date_day,
# secs_thatday=secs_thatday,
# lon=coords[i_obs][1],
# lat=coords[i_obs][0],
# vert_coord=coords[i_obs][2],
# vert_coord_sys=vert_coord_sys,
# obserr_var=obserr_std[i_obs]**2,
# appendix=appendix),
# last=last)
# write_file(txt, output_path=cluster.dartrundir+'/obs_seq.in')
def
create_obsseqin_alltypes
(
time_dt
,
list_obscfg
,
archive_obs_coords
=
False
):
"""
Create obs_seq.in with multiple obs types in one file
"""
Create obs_seq.in with multiple obs types in one file
Args:
Args:
...
@@ -391,7 +391,7 @@ def create_obsseqin_alltypes(time_dt, list_obscfg, obs_errors, archive_obs_coord
...
@@ -391,7 +391,7 @@ def create_obsseqin_alltypes(time_dt, list_obscfg, obs_errors, archive_obs_coord
txt
=
''
txt
=
''
i_obs_total
=
0
i_obs_total
=
0
for
i
stage
,
obscfg
in
enumerate
(
list_obscfg
):
for
i
_cfg
,
obscfg
in
enumerate
(
list_obscfg
):
n_obs
=
obscfg
[
'
n_obs
'
]
n_obs
=
obscfg
[
'
n_obs
'
]
coords
=
calc_obs_locations
(
n_obs
,
coords
=
calc_obs_locations
(
n_obs
,
...
@@ -408,7 +408,8 @@ def create_obsseqin_alltypes(time_dt, list_obscfg, obs_errors, archive_obs_coord
...
@@ -408,7 +408,8 @@ def create_obsseqin_alltypes(time_dt, list_obscfg, obs_errors, archive_obs_coord
coords
=
append_hgt_to_coords
(
coords
,
vert_coords
)
coords
=
append_hgt_to_coords
(
coords
,
vert_coords
)
n_obs_3d_thistype
=
len
(
coords
)
n_obs_3d_thistype
=
len
(
coords
)
obserr_std
=
np
.
zeros
(
n_obs_3d_thistype
)
+
obs_errors
# user defined generation error
obserr_std
=
np
.
zeros
(
n_obs_3d_thistype
)
+
obscfg
[
"
error_generate
"
]
sat_info
=
write_sat_angle_appendix
(
sat_channel
,
lat0
,
lon0
,
time_dt
)
sat_info
=
write_sat_angle_appendix
(
sat_channel
,
lat0
,
lon0
,
time_dt
)
...
@@ -417,7 +418,7 @@ def create_obsseqin_alltypes(time_dt, list_obscfg, obs_errors, archive_obs_coord
...
@@ -417,7 +418,7 @@ def create_obsseqin_alltypes(time_dt, list_obscfg, obs_errors, archive_obs_coord
last
=
False
last
=
False
is_last_obs_in_type
=
(
i_obs
==
int
(
n_obs_3d_thistype
)
-
1
)
is_last_obs_in_type
=
(
i_obs
==
int
(
n_obs_3d_thistype
)
-
1
)
is_last_obstype
=
(
i
stage
==
len
(
list_obscfg
)
-
1
)
is_last_obstype
=
(
i
_cfg
==
len
(
list_obscfg
)
-
1
)
if
is_last_obs_in_type
and
is_last_obstype
:
if
is_last_obs_in_type
and
is_last_obstype
:
last
=
True
last
=
True
...
@@ -445,8 +446,8 @@ def create_obsseqin_alltypes(time_dt, list_obscfg, obs_errors, archive_obs_coord
...
@@ -445,8 +446,8 @@ def create_obsseqin_alltypes(time_dt, list_obscfg, obs_errors, archive_obs_coord
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
# for testing
# for testing
time_dt
=
dt
.
datetime
(
2008
,
7
,
30
,
9
,
0
)
time_dt
=
dt
.
datetime
(
2008
,
7
,
30
,
7
,
0
)
n_obs
=
22
801
# radar: n_obs for each observation height level
n_obs
=
22
500
# radar: n_obs for each observation height level
vis
=
dict
(
plotname
=
'
VIS 0.6µm
'
,
plotunits
=
'
[1]
'
,
vis
=
dict
(
plotname
=
'
VIS 0.6µm
'
,
plotunits
=
'
[1]
'
,
kind
=
'
MSG_4_SEVIRI_BDRF
'
,
sat_channel
=
1
,
n_obs
=
n_obs
,
kind
=
'
MSG_4_SEVIRI_BDRF
'
,
sat_channel
=
1
,
n_obs
=
n_obs
,
...
@@ -481,7 +482,7 @@ if __name__ == '__main__':
...
@@ -481,7 +482,7 @@ if __name__ == '__main__':
#create_obsseq_in(time_dt, radar, archive_obs_coords=False) #'./coords_stage1.pkl')
#create_obsseq_in(time_dt, radar, archive_obs_coords=False) #'./coords_stage1.pkl')
create_obsseqin_alltypes
(
time_dt
,
[
wv73
],
obs_errors
=
False
,
archive_obs_coords
=
False
)
#'./obs_coords.pkl')
create_obsseqin_alltypes
(
time_dt
,
[
vis
]
,
archive_obs_coords
=
False
)
#'./obs_coords.pkl')
if
False
:
if
False
:
error_assimilate
=
5.
*
np
.
ones
(
n_obs
*
len
(
radar
[
'
heights
'
]))
error_assimilate
=
5.
*
np
.
ones
(
n_obs
*
len
(
radar
[
'
heights
'
]))
...
...
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