Commit f3fdaa5a authored by Carl Schreck's avatar Carl Schreck
Browse files

Automated Nightly Commit - Fri May 17 00:00:51 EDT 2019

parent ed8ba8c7
......@@ -11,7 +11,6 @@ import sys
sys.path.append('/home/carl/lib/python')
import cjs
#class Ibtracs(xr.Dataset):
class Ibtracs:
''' This class uses IBTrACS data. '''
def __init__(
......@@ -24,34 +23,33 @@ class Ibtracs:
else:
self.inpath = inpath
self.inpath = inpath
self.dataset = xr.open_dataset(self.inpath)
self.ds = xr.open_dataset(self.inpath)
def find_tropical(self, thresh=35, keep_subtropical=True):
if keep_subtropical:
bad_natures = [b'DS', b'ET']
else:
bad_natures = [b'SS', b'DS', b'ET']
is_tropical = ~self.dataset.nature.isin(bad_natures)
is_tropical = ~self.ds.nature.isin(bad_natures)
if thresh < 0:
retval = is_tropical
else:
is_strong_enough = self.dataset.usa_wind >= thresh
is_strong_enough = self.ds.usa_wind >= thresh
retval = is_tropical & is_strong_enough
return(retval)
def find_first_ind(self, thresh=35, keep_subtropical=True):
is_main = self.dataset.track_type != b'spur'
is_main = self.ds.track_type != b'spur'
is_tropical = self.find_tropical(thresh, keep_subtropical)
is_strong = self.data.usa_wind > thresh
firstind = np.empty( self.dataset.sizes['storm'], int )
for stormind in range(self.dataset.storm.size):
if ( (not is_main[stormind]) or
( not any(is_tropical[stormind,:]))):
firstind[stormind] = -1
else:
if thresh < 0:
firstind[stormind] = 0
print(firstind)
if thresh >= 0:
is_strong = self.ds.usa_wind > thresh
else:
lmi = np.amax(self.ds.usa_wind, axis=1)
is_strong = self.ds.usa_wind == lmi
nstrong = np.sum(is_strong, axis=1)
is_eligible = is_main & is_tropical & is_strong
neligible = np.sum(is_eligible, axis=1)
print(np.c_[self.ds.sid.values, nstrong, neligible])
......
""" Empty file to start python scripts """
__author__ = "Carl Schreck"
__email__ = "cjschrec@ncsu.edu"
__copyright__ = "Copyright 2019, North Carolina State University"
__license__ = "BSD-3.0"
import xarray as xr
import sys
sys.path.append('/home/carl/lib/python')
import cjs
import ibtracs
cjs.tstamp('Here we go!')
ibt = ibtracs.Ibtracs('last3years')
ibt.find_first_ind(-1)
cjs.tstamp('Thank you, come again.')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment