Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self,ncfile,**kwargs):
"""
Initialise the suntides class
See sunpy.Spatial class for list of kwargs
"""
self.__dict__.update(kwargs)
Spatial.__init__(self,ncfile,**kwargs)
if self.hasVar('eta_amp'):
print 'Loading existing harmonic data...'
self._loadVars()
else:
# Get the tidal fruequencies
if self.frqnames == None:
# This returns the default frequencies from the uspectra class
self.frq,self.frqnames = uspectra.getTideFreq(Fin=None)
else:
self.frq,self.frqnames = uspectra.getTideFreq(Fin=self.frqnames)
self.Ntide = len(self.frqnames)
self.reftime = datetime(self.baseyear,1,1)
def __init__(self,ncfile,xpt=None,ypt=None,Npt=100,klayer=[-99],**kwargs):
self.Npt=Npt
Spatial.__init__(self,ncfile,klayer=klayer,**kwargs)
# Load the grid as a hybridgrid
self.grd = GridSearch(self.xp,self.yp,self.cells,nfaces=self.nfaces,\
edges=self.edges,mark=self.mark,grad=self.grad,neigh=self.neigh,\
xv=self.xv,yv=self.yv)
# Find the edge indices along the line
self.update_xy(xpt,ypt)
def __init__(self,ncfile,**kwargs):
"""
Initialize the 3-D grid, etc
"""
self.__dict__.update(kwargs)
if self.is3D:
Spatial.__init__(self,ncfile,klayer=[-99],**kwargs)
# Initialise the 3-D grid
self.init3Dgrid()
else: # surface layer only
print '%s\nRunning in 2D mode...\n%s'%(24*'#',24*'#')
Spatial.__init__(self,ncfile,klayer=['surface'],**kwargs)
self.nActive = self.Nc
#self.klayer=np.arange(0,self.Nkmax)
# Step 2) Initialise the interpolation function
if self.is3D:
if self.interp_method in ('idw','nearest'):
self.UVWinterp = interp3D(self.xv3d,self.yv3d,self.zv3d,method=self.interp_method)
# Interpolation function to find free surface and seabed
self.Hinterp = interp3D(self.xv,self.yv,0*self.xv,method='nearest')
elif self.interp_method == 'mesh':
if self.interp_meshmethod == 'nearest':
self.UVWinterp = \
interp3Dmesh(self.xp,self.yp,-self.z_w,self.cells,\
self.nfaces,self.mask3D,method='nearest')
def __init__(self,ncfile,xpt=None,ypt=None,Npt=100):
Spatial.__init__(self,ncfile,klayer=[-99])
# Calculate the horizontal coordinates of the slice
self.Npt = Npt
if xpt == None or ypt == None:
self._getXYgraphically()
else:
self.xpt=xpt
self.ypt=ypt
self._getSliceCoords()
# Initialise the slice interpolation object
self._initInterp()
def __init__(self,ncfile,**kwargs):
Spatial.__init__(self,ncfile,gridvars=untrim_gridvars,griddims=untrim_griddims,**kwargs)
# Make sure the number of faces array is correct
self.nfaces = np.sum(self.cells.mask==False,axis=1)
self.xy = self.cellxy()
def __init__(self,ncfile,xpt=None,ypt=None,Npt=100,klayer=[-99],**kwargs):
self.Npt=Npt
Spatial.__init__(self,ncfile,klayer=klayer,**kwargs)
# Load the grid as a hybridgrid
self.grd = GridSearch(self.xp,self.yp,self.cells,nfaces=self.nfaces,\
edges=self.edges,mark=self.mark,grad=self.grad,neigh=self.neigh,\
xv=self.xv,yv=self.yv)
# Find the edge indices along the line
self.update_xy(xpt,ypt)
self,
message="Open SUNTANS file...",
defaultDir=os.getcwd(),
defaultFile="",
wildcard=file_choices,
style= wx.FD_MULTIPLE)
if dlg.ShowModal() == wx.ID_OK:
self.plot_type='hydro'
path = dlg.GetPaths()
# Initialise the class
if dlg.GetFilterIndex() == 0 or dlg.GetFilterIndex() > 1: #SUNTANS
self.flash_status_message("Opening SUNTANS file: %s" % path)
Spatial.__init__(self,path)
startvar='dv'
if dlg.GetFilterIndex()==1: #UnTRIM
self.flash_status_message("Opening UnTRIMS file: %s" % path)
#Spatial.__init__(self,path,gridvars=untrim_gridvars,griddims=untrim_griddims)
UNTRIMSpatial.__init__(self,path)
startvar='Mesh2_face_depth'
# Populate the drop down menus
vnames = self.listCoordVars()
self.variable_list.SetItems(vnames)
# Update the time drop down list
if self.__dict__.has_key('time'):
self.timestr = [datetime.strftime(tt,'%d-%b-%Y %H:%M:%S') for tt in self.time]
else:
# Assume that it is a harmonic-type file