Skip to content
Snippets Groups Projects
Commit 8d5c9267 authored by tomrink's avatar tomrink
Browse files

snapshot

parent e83ba619
No related branches found
No related tags found
No related merge requests found
......@@ -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')
......
......@@ -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
......
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
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