Skip to content
Snippets Groups Projects
Commit 198d036e authored by lkugler's avatar lkugler
Browse files

docs

parent 087ff27b
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,7 @@ def round_to_day(dtobj): ...@@ -42,7 +42,7 @@ def round_to_day(dtobj):
return dtobj.replace(second=0, minute=0, hour=0) return dtobj.replace(second=0, minute=0, hour=0)
def add_timezone_UTC(t): def _add_timezone_UTC(t):
return dt.datetime(t.year, t.month, t.day, t.hour, t.minute, tzinfo=dt.timezone.utc) return dt.datetime(t.year, t.month, t.day, t.hour, t.minute, tzinfo=dt.timezone.utc)
...@@ -61,14 +61,7 @@ def get_dart_date(time_dt): ...@@ -61,14 +61,7 @@ def get_dart_date(time_dt):
return dart_date_day, secs_thatday return dart_date_day, secs_thatday
def write_tuple_to_pickle(fpath_out, tuple): def _write_file(msg, output_path='./'):
import pickle
os.makedirs(os.path.dirname(fpath_out), exist_ok=True)
with open(fpath_out, 'wb') as f:
pickle.dump(tuple, f)
print(fpath_out, 'saved.')
def write_file(msg, output_path='./'):
try: try:
os.remove(output_path) os.remove(output_path)
except OSError: except OSError:
...@@ -79,7 +72,7 @@ def write_file(msg, output_path='./'): ...@@ -79,7 +72,7 @@ def write_file(msg, output_path='./'):
print(output_path, 'saved.') print(output_path, 'saved.')
def append_hgt_to_coords(coords, heights): def _append_hgt_to_coords(coords, heights):
coords2 = [] coords2 = []
for i in range(len(coords)): for i in range(len(coords)):
for hgt_m in heights: for hgt_m in heights:
...@@ -108,7 +101,7 @@ obs_kind_definitions ...@@ -108,7 +101,7 @@ obs_kind_definitions
first: 1 last: """+n_obs_str first: 1 last: """+n_obs_str
def determine_vert_coords(sat_channel, kind, obscfg): def _determine_vert_coords(sat_channel, kind, obscfg):
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
...@@ -124,6 +117,15 @@ def determine_vert_coords(sat_channel, kind, obscfg): ...@@ -124,6 +117,15 @@ def determine_vert_coords(sat_channel, kind, obscfg):
def write_sat_angle_appendix(sat_channel, lat0, lon0, time_dt): def write_sat_angle_appendix(sat_channel, lat0, lon0, time_dt):
"""Writes metadata str for an observation inside obs_seq.out """Writes metadata str for an observation inside obs_seq.out
Args:
sat_channel (int or False): False if not a satellite observation
lat0 (float): latitude of point on earth
lon0 (float): longitude of point on earth
time_dt (dt.datetime): time of observation
Returns:
str
""" """
if sat_channel: if sat_channel:
sun_az = str(get_azimuth(lat0, lon0, time_dt)) sun_az = str(get_azimuth(lat0, lon0, time_dt))
...@@ -146,6 +148,9 @@ def write_section(obs, last=False): ...@@ -146,6 +148,9 @@ def write_section(obs, last=False):
Args: Args:
obs (object) obs (object)
last (bool): True if this is the last observation in the obs_seq file last (bool): True if this is the last observation in the obs_seq file
Returns:
str
""" """
lon_rad = str(degr_to_rad(obs['lon'])) lon_rad = str(degr_to_rad(obs['lon']))
lat_rad = str(degr_to_rad(obs['lat'])) lat_rad = str(degr_to_rad(obs['lat']))
...@@ -188,7 +193,7 @@ def create_obs_seq_in(time_dt, list_obscfg, ...@@ -188,7 +193,7 @@ def create_obs_seq_in(time_dt, list_obscfg,
os.makedirs(os.path.dirname(output_path), exist_ok=True) os.makedirs(os.path.dirname(output_path), exist_ok=True)
print('creating obs_seq.in:') print('creating obs_seq.in:')
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)
txt = '' txt = ''
...@@ -216,8 +221,8 @@ def create_obs_seq_in(time_dt, list_obscfg, ...@@ -216,8 +221,8 @@ def create_obs_seq_in(time_dt, list_obscfg,
sat_channel = obscfg.get('sat_channel', False) sat_channel = obscfg.get('sat_channel', False)
# add observation locations in the vertical at different levels # add observation locations in the vertical at different levels
vert_coord_sys, vert_coords = determine_vert_coords(sat_channel, kind, obscfg) vert_coord_sys, vert_coords = _determine_vert_coords(sat_channel, kind, obscfg)
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)
# user defined generation error # user defined generation error
...@@ -252,57 +257,19 @@ def create_obs_seq_in(time_dt, list_obscfg, ...@@ -252,57 +257,19 @@ def create_obs_seq_in(time_dt, list_obscfg,
pretxt = preamble(n_obs_total, list_kinds) pretxt = preamble(n_obs_total, list_kinds)
alltxt = pretxt + txt alltxt = pretxt + txt
write_file(alltxt, output_path=output_path) _write_file(alltxt, output_path=output_path)
if __name__ == '__main__': if __name__ == '__main__':
# for testing # for testing
time_dt = dt.datetime(2008, 7, 30, 13, 0) time_dt = dt.datetime(2008, 7, 30, 13, 0)
radar = dict(var_name='Radar reflectivity', unit='[dBz]',
vis = dict(plotname='VIS 0.6µm', plotunits='[1]', kind='RADAR_REFLECTIVITY',
kind='MSG_4_SEVIRI_BDRF', sat_channel=1, n_obs=5776, obs_locations='square_array_evenly_on_grid',
n_obs=961, obs_locations='square_array_evenly_on_grid', error_generate=2.5, error_assimilate=2.5,
error_generate=0.03, error_assimilate=0.06, heights=range(2000, 14001, 2000),
cov_loc_radius_km=32) loc_horiz_km=20, loc_vert_km=2.5)
# wv62 = dict(plotname='Brightness temperature WV 6.2µm', plotunits='[K]',
# kind='MSG_4_SEVIRI_TB', sat_channel=5,
# n_obs=n_obs, obs_locations='square_array_evenly_on_grid',
# error_generate=1., error_assimilate=False,
# cov_loc_radius_km=20)
# wv73 = dict(plotname='Brightness temperature WV 7.3µm', plotunits='[K]',
# kind='MSG_4_SEVIRI_TB', sat_channel=6,
# n_obs=n_obs, obs_locations='square_array_evenly_on_grid',
# error_generate=1., error_assimilate=False,
# cov_loc_radius_km=20)
# ir108 = dict(plotname='Brightness temperature IR 10.8µm', plotunits='[K]',
# kind='MSG_4_SEVIRI_TB', sat_channel=9,
# n_obs=n_obs, obs_locations='square_array_evenly_on_grid',
# error_generate=5., error_assimilate=10.,
# cov_loc_radius_km=32)
radar = dict(plotname='Radar reflectivity', plotunits='[dBz]',
kind='RADAR_REFLECTIVITY',
n_obs=1, obs_locations=[(45,0),],
error_generate=2.5, error_assimilate=5.,
heights=np.arange(1000, 15001, 1000),
cov_loc_radius_km=20, cov_loc_vert_km=4)
# t2m = dict(plotname='SYNOP Temperature', plotunits='[K]',
# kind='SYNOP_TEMPERATURE',
# n_obs=n_obs, obs_locations='square_array_evenly_on_grid',
# error_generate=0.1, error_assimilate=1.,
# cov_loc_radius_km=20, cov_loc_vert_km=3)
# psfc = dict(plotname='SYNOP Pressure', plotunits='[dBz]',
# kind='SYNOP_SURFACE_PRESSURE',
# n_obs=n_obs, obs_locations='square_array_evenly_on_grid',
# error_generate=50., error_assimilate=100.,
# cov_loc_radius_km=32, cov_loc_vert_km=5)
create_obs_seq_in(time_dt, [radar], create_obs_seq_in(time_dt, [radar],
output_path=utils.userhome+'/run_DART/obs_seq.in') output_path=utils.userhome+'/run_DART/obs_seq.in')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment