from amv.intercompare import pirep_icing from deeplearning.amv_raob import get_images import numpy as np import pickle import os from util.util import get_time_tuple_utc from aeolus.datasource import CLAVRx clavrx_dir = '/apollo/cloud/scratch/ICING/' dir_fmt = '%Y_%m_%d_%j' # dir_list = [f.path for f in os.scandir('.') if f.is_dir()] ds_dct = {} pirep_file = '/home/rink/data/pirep/pireps_2018040100_2018123023.csv' ice_dict, no_ice_dict = pirep_icing(pirep_file) print('num obs: ice, no ice', len(ice_dict), len(no_ice_dict)) time_keys = list(ice_dict.keys()) hist = np.zeros(20) for idx, time in enumerate(time_keys): if (idx % 4) != 0: continue print(100.0*(idx/len(time_keys))) reports = ice_dict[time] lat_s = [] lon_s = [] for tup in reports: lat, lon, fl, rpt_str = tup lat_s.append(lat) lon_s.append(lon) images, _, _, idxs = get_images(lon_s, lat_s, time, ['14'], [10], [1]) if images is not None: counts, edges = np.histogram(images[0,], range=[150, 350], bins=20) hist += counts def get_clavrx_datasource(timestamp): dt_obj, time_tup = get_time_tuple_utc(timestamp) date_dir_str = dt_obj.strftime(dir_fmt) ds = ds_dct.get(date_dir_str) if ds is None: ds = CLAVRx(clavrx_dir + date_dir_str + '/') ds_dct[date_dir_str] = ds return ds f = open('/home/rink/ice_hist.pkl', 'wb') pickle.dump(hist, f) f.close() print('bin edges: ', edges)