From 4a544737521495ed9d6b7ba73fafd5838bdaed50 Mon Sep 17 00:00:00 2001 From: Angel Farguell Caus Date: Tue, 2 Jul 2019 17:38:23 -0600 Subject: [PATCH] new experiments in forecast.py, solve infrared_perimeters.py problem, and reading GOES16 data --- forecast.py | 7 +++++-- infrared_perimeters.py | 11 +++++++---- read_goes.py | 10 ++++++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/forecast.py b/forecast.py index 1a5ad44..1856dc1 100644 --- a/forecast.py +++ b/forecast.py @@ -6,7 +6,7 @@ from utils import Dict import re, glob, sys, os -def process_tign_g(lon,lat,tign_g,bounds,ctime,dx,dy,wrfout_file='',dt_for=900.,plot=False): +def process_tign_g(lon,lat,tign_g,bounds,ctime,dx,dy,wrfout_file='',dt_for=3600.,plot=False): """ Process forecast from lon, lat, and tign_g @@ -157,7 +157,7 @@ def process_forecast_wrfout(wrfout_file,bounds,plot=False): if __name__ == "__main__": import saveload as sl - real = True + real = False if real: plot = True @@ -176,6 +176,9 @@ if __name__ == "__main__": if 'point' in ideal.keys(): p = [[ideal['point'][0]],[ideal['point'][1]],[ideal['point'][2]]] data.update(process_ignitions(p,ideal['bounds'])) + elif 'points' in ideal.keys(): + p = [[point[0] for point in ideal['points']],[point[1] for point in ideal['points']],[point[2] for point in ideal['points']]] + data.update(process_ignitions(p,ideal['bounds'])) etime = time_iso2num(ideal['ctime'].replace('_','T')) time_num_int = (etime-ideal['tign_g'].max(),etime) sl.save((data,ideal['lon'],ideal['lat'],time_num_int),'data') diff --git a/infrared_perimeters.py b/infrared_perimeters.py index 02f2365..9e0e433 100644 --- a/infrared_perimeters.py +++ b/infrared_perimeters.py @@ -122,9 +122,10 @@ def process_infrared_perimeters(dst,bounds,maxp=1000,ngrid=50,plot=False): # read name of the file name = re.findall(r'(.*?)',f_str,re.DOTALL)[0] # read date of the perimeter - date = re.match(r'.*([0-9]{2}-[0-9]{2}-[0-9]{4} [0-9]{4})',name).groups()[0] + date = re.match(r'.*([0-9]+)-([0-9]+)-([0-9]+) ([0-9]{2})([0-9]{2})',name).groups() + date = (date[2],date[0],date[1],date[3],date[4]) # create ISO time of the date - time_iso = date[6:10]+'-'+date[0:2]+'-'+date[3:5]+'T'+date[11:13]+':'+date[13:15]+':00' + time_iso = '%04d-%02d-%02dT%02d:%02d:00' % tuple([ int(d) for d in date ]) # create numerical time from the ISO time time_num = time_iso2num(time_iso) # create datetime element from the ISO time @@ -217,8 +218,10 @@ def process_infrared_perimeters(dst,bounds,maxp=1000,ngrid=50,plot=False): if __name__ == "__main__": plot = True - bounds = (-115.97282409667969, -115.28449249267578, 43.808258056640625, 44.302913665771484) - dst = './pioneer/perim' + #bounds = (-115.97282409667969, -115.28449249267578, 43.808258056640625, 44.302913665771484) + #dst = './pioneer/perim' + bounds = (-113.85068, -111.89413, 39.677563, 41.156837) + dst = './patch/perim' p = process_infrared_perimeters(dst,bounds,plot=plot) sl.save(p,'perimeters') diff --git a/read_goes.py b/read_goes.py index 477dbe9..1c8956a 100644 --- a/read_goes.py +++ b/read_goes.py @@ -17,7 +17,7 @@ ncf=Dataset(file,'r') add_seconds=ncf.variables['t'][0] # Datetime of image scan dt=datetime(2000, 1, 1, 12)+timedelta(seconds=float(add_seconds.data)) -print 'dt = ' +print 'dt = ' print dt # Detections in RGB array @@ -61,7 +61,7 @@ print sat_lon sat_sweep=ncf.variables['goes_imager_projection'].sweep_angle_axis print 'sat_sweep = ' print sat_sweep -# The projection x and y coordinates equals +# The projection x and y coordinates equals # the scanning angle (in radians) multiplied by the satellite height (https://proj4.org/operations/projections/geos.html) X=ncf.variables['x'][:] * sat_h Y=ncf.variables['y'][:] * sat_h @@ -79,6 +79,7 @@ lats[np.isnan(R)]=np.nan lons[np.isnan(R)]=np.nan # create new netCDF file with lat/lon info +''' newfile = "appended" + file w_ncf = Dataset(newfile, 'w') with Dataset(file) as src, w_ncf as dst: @@ -93,7 +94,7 @@ with Dataset(file) as src, w_ncf as dst: for name, variable in src.variables.iteritems(): x = dst.createVariable(name, variable.datatype, variable.dimensions) dst.variables[name][:] = src.variables[name][:] - + # add new lat/lon info dst.createDimension('longitude', None) dst.createDimension('lattitude', None) @@ -104,6 +105,7 @@ with Dataset(file) as src, w_ncf as dst: dst.variables['lattitude'][:] = lats # close the new file dst.close() +''' # Make a new map object for the HRRR model domain map projection mH = Basemap(resolution='l', projection='lcc', area_thresh=5000, \ @@ -137,7 +139,7 @@ l = {'latitude': 41.812, # 'longitude': -108.538} mZ = Basemap(projection='lcc', resolution='i', - width=3E5, height=3E5, + width=3E5, height=3E5, lat_0=l['latitude'], lon_0=l['longitude'],) # Now we can plot the GOES data on a zoomed in map centered on the Sugarloaf wildfire -- 2.11.4.GIT