Skip to content
Snippets Groups Projects
Commit 71edacf3 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent dde06dd6
No related branches found
No related tags found
No related merge requests found
...@@ -196,7 +196,71 @@ def pirep_icing(filename, lon_range=[-180, 180], lat_range=[-63, 63]): ...@@ -196,7 +196,71 @@ def pirep_icing(filename, lon_range=[-180, 180], lat_range=[-63, 63]):
return ice_dict, no_ice_dict, neg_ice_dict return ice_dict, no_ice_dict, neg_ice_dict
def pirep_icing_from_boeing(dirname='/ships19/cloud/scratch/ICING/BOEING/icing/2020/', lon_range=[-180, 180], lat_range=[-63, 63]): # Returns icing, no_icing (no icing observed)
def pirep_icing_boeing_txt(filename, lon_range=[-180, 180], lat_range=[-63, 63]):
# year, month, day, hour, minute, sec, lat, lon, alt, degC, airspeed, icing
ice_dict = {}
no_ice_dict = {}
cnt_ice = 0
cnt_no_ice = 0
with open(filename) as file:
for idx, line in enumerate(file):
toks = line.split(' ')
if len(toks) != 12: # Check for line format error
continue
year = 2000 + toks[0]
month = toks[1]
day = toks[2]
hour = toks[3]
minute = toks[4]
second = toks[5]
try:
lat = float(toks[6])
lon = float(toks[7])
except Exception:
continue
if lon < lon_range[0] or lon > lon_range[1]:
continue
if lat < lat_range[0] or lat > lat_range[1]:
continue
flt_alt = float(toks[8]) * 0.3048 # convert feet to meters
degK = float(toks[9]) + 273.0
spd = float(toks[10])
ice_bool = int(toks[11])
dto = datetime.datetime(year=year, month=month, day=day, hour=hour, minute=minute, second=second)
dto = dto.replace(tzinfo=timezone.utc)
ts = dto.timestamp()
if ice_bool[k] == 1:
tup = (lat, lon, flt_alt, 1, 0, 'None', degK, spd)
rpts = ice_dict.get(ts)
if rpts is None:
rpts = []
rpts.append(tup)
ice_dict[ts] = rpts
else:
rpts.append(tup)
cnt_ice += 1
else:
tup = (lat, lon, flt_alt, -1, 0, 'None', degK, spd)
rpts = no_ice_dict.get(ts)
if rpts is None:
rpts = []
rpts.append(tup)
no_ice_dict[ts] = rpts
else:
rpts.append(tup)
cnt_no_ice += 1
def pirep_icing_from_boeing_nc(dirname='/ships19/cloud/scratch/ICING/BOEING/icing/2020/', lon_range=[-180, 180], lat_range=[-63, 63]):
flist = [] flist = []
for path in Path(dirname).rglob('*.nc'): for path in Path(dirname).rglob('*.nc'):
flist.append(path) flist.append(path)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment