diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py index 8ce2d6c93ba83abc18a3ae05b697f19d20e90526..95ddaddacf0075a6baa806e74d33856236ca74ba 100644 --- a/modules/icing/pirep_goes.py +++ b/modules/icing/pirep_goes.py @@ -46,10 +46,8 @@ def setup(): def get_clavrx_datasource(timestamp): dt_obj, time_tup = get_time_tuple_utc(timestamp) date_dir_str = dt_obj.strftime(dir_fmt) - print(dt_obj) ds = ds_dct.get(date_dir_str) if ds is None: - print(' new datasource: ', date_dir_str) ds = CLAVRx(clavrx_dir + date_dir_str + '/') ds_dct[date_dir_str] = ds return ds @@ -188,36 +186,63 @@ def run(pirep_dct, outfile=None, outfile_l1b=None, dt_str_start=None, dt_str_end continue if time > t_end: continue + dt_obj, time_tup = get_time_tuple_utc(time) + print(dt_obj) + try: + clvr_ds = get_clavrx_datasource(time) + except Exception: + continue - reports = pirep_dct[time] - for tup in reports: - lat, lon, fl, I, id, rpt_str = tup - lat_s[0] = lat - lon_s[0] = lon + clvr_file = clvr_ds.get_file(time)[0] + if clvr_file is None: + continue + print(clvr_file, last_clvr_file) + if clvr_file != last_clvr_file: try: - clvr_ds = get_clavrx_datasource(time) + h5f = h5py.File(clvr_file, 'r') except Exception: + if h5f is not None: + h5f.close() + print('Problem with file: ', clvr_file) continue + if last_h5f is not None: + last_h5f.close() + last_h5f = h5f + last_clvr_file = clvr_file + print('new file') + else: + h5f = last_h5f - clvr_file = clvr_ds.get_file(time)[0] - if clvr_file is None: - continue + reports = pirep_dct[time] + for tup in reports: + lat, lon, fl, I, id, rpt_str = tup + lat_s[0] = lat + lon_s[0] = lon - if clvr_file != last_clvr_file: - try: - h5f = h5py.File(clvr_file, 'r') - except Exception: - if h5f is not None: - h5f.close() - print('Problem with file: ', clvr_file) - continue - if last_h5f is not None: - last_h5f.close() - last_h5f = h5f - last_clvr_file = clvr_file - else: - h5f = last_h5f + # try: + # clvr_ds = get_clavrx_datasource(time) + # except Exception: + # continue + # + # clvr_file = clvr_ds.get_file(time)[0] + # if clvr_file is None: + # continue + # + # if clvr_file != last_clvr_file: + # try: + # h5f = h5py.File(clvr_file, 'r') + # except Exception: + # if h5f is not None: + # h5f.close() + # print('Problem with file: ', clvr_file) + # continue + # if last_h5f is not None: + # last_h5f.close() + # last_h5f = h5f + # last_clvr_file = clvr_file + # else: + # h5f = last_h5f cc, ll = nav.earth_to_lc_s(lon_s, lat_s) if cc[0] < 0: