From 8d5c92675f9db5f745319ffea29d6ba2f671d24a Mon Sep 17 00:00:00 2001 From: tomrink <rink@ssec.wisc.edu> Date: Tue, 9 Mar 2021 14:41:38 -0600 Subject: [PATCH] snapshot --- modules/aeolus/datasource.py | 12 ++++++++++++ modules/icing/pirep_goes.py | 23 ++++++++++++++++++++++- modules/icing/pireps.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/modules/aeolus/datasource.py b/modules/aeolus/datasource.py index aec7b39d..e402d401 100644 --- a/modules/aeolus/datasource.py +++ b/modules/aeolus/datasource.py @@ -52,6 +52,18 @@ class Files: return None, None, None +class GOESL1B(Files): + def __init__(self, files_path, band='14'): + super().__init__(files_path, 10, 'OR_ABI-L1b-RadC-M3C'+band+'*.nc') + + def get_datetime(self, pathname): + filename = os.path.split(pathname)[1] + so = re.search('_s\\d{11}', filename) + dt_str = so.group() + dto = datetime.datetime.strptime(dt_str, '_s%Y%j%H%M').replace(tzinfo=timezone.utc) + return dto + + class CLAVRx(Files): def __init__(self, files_path): super().__init__(files_path, 10, 'clavrx_OR_ABI-L1b*.level2.nc') diff --git a/modules/icing/pirep_goes.py b/modules/icing/pirep_goes.py index f272cfc8..f5e3c21b 100644 --- a/modules/icing/pirep_goes.py +++ b/modules/icing/pirep_goes.py @@ -3,14 +3,19 @@ import numpy as np import pickle import os from util.util import get_time_tuple_utc -from aeolus.datasource import CLAVRx +from aeolus.datasource import CLAVRx, GOESL1B from util.geos_nav import GEOSNavigation import h5py +import datetime +from datetime import timezone +goes_date_format = '%Y%j%H' +goes16_directory = '/arcdata/goes/grb/goes16/' # /year/date/abi/L1b/RadC 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 = {} +goes_ds_dct = {} ice_dict = None no_ice_dict = None time_keys = None @@ -38,6 +43,22 @@ def get_clavrx_datasource(timestamp): return ds +def get_goes_datasource(timestamp): + dt_obj, time_tup = get_time_tuple_utc(timestamp) + + yr_dir = str(dt_obj.timetuple().tm_year) + date_dir = dt_obj.strftime(dir_fmt) + yr_date = yr_dir+date_dir + + files_path = goes16_directory + '/' + yr_dir + '/' + date_dir + '/abi' + '/L1b' + '/RadC/' + print(files_path) + ds = goes_ds_dct.get(yr_date) + if ds is None: + ds = GOESL1B(files_path) + goes_ds_dct[yr_date] = ds + return ds + + def get_grid_values(h5f, grid_name, j_c, i_c, half_width, scale_factor_name='scale_factor', add_offset_name='add_offset'): hfds = h5f[grid_name] attrs = hfds.attrs diff --git a/modules/icing/pireps.py b/modules/icing/pireps.py index 61053b00..3c1da4b4 100644 --- a/modules/icing/pireps.py +++ b/modules/icing/pireps.py @@ -1,6 +1,9 @@ import datetime from datetime import timezone import re +import numpy as np + +from icing.pirep_goes import get_goes_datasource NO_ICE = '\s*NEG\s*|\s*NONE\s*|\s*NEGATIVE\s*|\s*NO\s*' ICE_LVL = '\d+-\d+|FL\d+-FL\d+' @@ -105,3 +108,30 @@ def pirep_icing(filename, lon_range=[-180, 180], lat_range=[-55, 55]): rpts.append(tup) return ice_dict, no_ice_dict + + +def analyze(ice_dct, no_ice_dct): + ice_times = np.array(list(ice_dct.keys())) + no_ice_times = np.array(list(no_ice_dct.keys())) + + dt_str = '201601010000' + dto = datetime.datetime.strptime(dt_str, '%Y%m%d%H%M').replace(tzinfo=timezone.utc) + t0 = dto.timestamp() + + dt_str = '201906300000' + dto = datetime.datetime.strptime(dt_str, '%Y%m%d%H%M').replace(tzinfo=timezone.utc) + t1 = dto.timestamp() + + tline = np.arange(t0, t1, 600) + hist_a, edges = np.histogram(no_ice_times, bins=tline) + print(len(np.nonzero(hist_a)[0])) + + hist_b, edges = np.histogram(ice_times, bins=tline) + print(len(np.nonzero(hist_b)[0])) + + print(np.sum(np.logical_and(hist_a > 0, hist_b > 0))) + + for ts in list(no_ice_dct.keys()): + ds = get_goes_datasource(ts) + goes_file = ds.get_file(ts)[0] + print(goes_file) \ No newline at end of file -- GitLab