From c5d0d49ed01488c51ef17e846b3b3f292f712ce8 Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Mon, 11 Oct 2021 15:10:47 -0500 Subject: [PATCH] start support for Boeing icing data... --- modules/icing/pireps.py | 49 +++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/modules/icing/pireps.py b/modules/icing/pireps.py index 54599f90..293b9233 100644 --- a/modules/icing/pireps.py +++ b/modules/icing/pireps.py @@ -164,12 +164,47 @@ def pirep_icing_from_boeing(dirname='/ships19/cloud/scratch/ICING/BOEING/icing/2 for path in Path(dirname).rglob('*.nc'): flist.append(path) - cnt = 0 + ice_dict = {} + no_ice_dict = {} + + cnt_ice = 0 + cnt_no_ice = 0 + for fname in flist: - print(fname) - h5f = h5py.File(fname, 'r') - ice_bool = h5f['ice_bool'][:] - cnt += ice_bool.shape[0] - print('num_icing: ', cnt) + try: + h5f = h5py.File(fname, 'r') + ice_bool = h5f['ice_bool'][:] + lons = h5f['longitude'][:] + lats = h5f['latitude'][:] + years = h5f['year'][:] + mons = h5f['month'][:] + days = h5f['day'][:] + hours = h5f['hour'][:] + mins = h5f['minute'][:] + secs = h5f['second'][:] + flt_levs = h5f + except Exception as e: + print(e) + h5f.close() + continue + nrpts = ice_bool.shape[0] + if nrpts > 0: + for k in range(nrpts): + dto = datetime.datetime(year=years[k], month=mons[k], day=days[k], hour=hours[k], minute=mins[k], second=secs[k]) + dto = dto.replace(tzinfo=timezone.utc) + ts = dto.timestamp() + + if ice_bool[k]: + tup = (lats[k], lons[k], flt_levs[k], 1, 0, 'None') + ice_dict[ts] = tup + cnt_ice += 1 + else: + tup = (lats[k], lons[k], flt_levs[k], 0, 0, 'None') + no_ice_dict[ts] = tup + cnt_no_ice += 1 + h5f.close() - print('num icing: ', cnt) \ No newline at end of file + + print('num icing/no icing: ', cnt_ice, cnt_no_ice) + + return ice_dict, no_ice_dict, None \ No newline at end of file -- GitLab