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

Automated Nightly Commit - Thu May 16 00:00:05 EDT 2019

parent 0742d208
...@@ -6,15 +6,17 @@ __copyright__ = "Copyright 2019, North Carolina State University" ...@@ -6,15 +6,17 @@ __copyright__ = "Copyright 2019, North Carolina State University"
__license__ = "BSD-3.0" __license__ = "BSD-3.0"
import xarray as xr import xarray as xr
import numpy as np
import sys import sys
sys.path.append('/home/carl/lib/python') sys.path.append('/home/carl/lib/python')
import cjs import cjs
#class Ibtracs(xr.Dataset):
class Ibtracs: class Ibtracs:
''' This class uses IBTrACS data. ''' ''' This class uses IBTrACS data. '''
def __init__( def __init__(
self, epoch='last3years', self, epoch='last3years',
inpath='~/data/ibtracs/v04r00/IBTrACS.ALL.v04r00.nc'): inpath='~/data/ibtracs/v04r00/IBTrACS.last3years.v04r00.nc'):
epochs = [ 'last3years', 'All', 'since1980' ] epochs = [ 'last3years', 'All', 'since1980' ]
if inpath in epochs: if inpath in epochs:
self.inpath = ( '~/data/ibtracs/v04r00/IBTrACS.' + epochs self.inpath = ( '~/data/ibtracs/v04r00/IBTrACS.' + epochs
...@@ -23,13 +25,35 @@ class Ibtracs: ...@@ -23,13 +25,35 @@ class Ibtracs:
self.inpath = inpath self.inpath = inpath
self.inpath = inpath self.inpath = inpath
self.dataset = xr.open_dataset(self.inpath) self.dataset = xr.open_dataset(self.inpath)
def find_tropical(self, thresh=35, keep_subtropical=True ):
def find_tropical(self, thresh=35, keep_subtropical=True):
if keep_subtropical: if keep_subtropical:
isTropical = self.dataset['nature'] == b'' bad_natures = [b'DS', b'ET']
def find_first_ind(self, thresh=35) else:
wind = self.dataset['usa_wind'] bad_natures = [b'SS', b'DS', b'ET']
is_main = self.dataset['nature'] != b'spur' is_tropical = ~self.dataset.nature.isin(bad_natures)
track_type = self.dataset['track_type'] if thresh < 0:
retval = is_tropical
else:
is_strong_enough = self.dataset.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_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)
......
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