Beispiel #1
0
    def __init__(self,infile,**kwargs):
        
        self.__dict__.update(kwargs)

        Spatial.__init__(self,infile,**kwargs)
            
        #
        if self.is3D:
            self.klayer=np.arange(self.kstart,self.Nkmax)
            self.Nkmax-=self.kstart
            self.Nk -= self.kstart
            self.data = np.zeros((self.Nc,self.Nkmax))
            self.data = np.ravel(self.data)
            
            self.initTvtk3D()
        else:
            # Initialize the 2D object
            self.data = np.zeros((self.Nc,))

            self.returnPoints()
            if self.maxfaces==3:
                self.initTvtk2D()
            else:
                self.initMixedTvtk2D()

        if self.offscreen:
            print 'Using offscreen rendering.'
            mlab.options.offscreen=True
Beispiel #2
0
    def __init__(self,infile,**kwargs):
        
        self.__dict__.update(kwargs)

        Spatial.__init__(self,infile,**kwargs)
            
        #
        if self.is3D:
            self.klayer=np.arange(self.kstart,self.Nkmax)
            self.Nkmax-=self.kstart
            self.Nk -= self.kstart
            self.data = np.zeros((self.Nc,self.Nkmax))
            self.data = np.ravel(self.data)
            
            if self.maxfaces==3:
                self.initTvtk3D()
            else:
                self.initMixedTvtk3D()

        else:
            # Initialize the 2D object
            self.data = np.zeros((self.Nc,))

            self.returnPoints()
            if self.maxfaces==3:
                self.ug = self.initTvtk2D()
            else:
                self.ug = self.initMixedTvtk2D()

        if self.offscreen:
            print 'Using offscreen rendering.'
            mlab.options.offscreen=True
Beispiel #3
0
 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)
             
         self.Nt = len(self.time)
Beispiel #4
0
    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()
Beispiel #5
0
    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()
Beispiel #6
0
 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)
     
     self.Nt = len(self.time)
Beispiel #7
0
    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)
Beispiel #8
0
    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)
Beispiel #9
0
 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()
Beispiel #10
0
 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()
Beispiel #11
0
    def on_open_file(self, event):
        file_choices = "SUNTANS NetCDF (*.nc)|*.nc*|UnTRIM NetCDF (*.nc)|*.nc*|All Files (*.*)|*.*"
        
        dlg = wx.FileDialog(
            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
                self.timestr = self.nc.Constituent_Names.split()

            self.time_list.SetItems(self.timestr)

            # Draw the depth
            if startvar in vnames:
                self.variable=startvar
                self.loadData()
                self.create_figure()
    def on_open_file(self, event):
        file_choices = "SUNTANS NetCDF (*.nc)|*.nc*|UnTRIM NetCDF (*.nc)|*.nc*|All Files (*.*)|*.*"
        
        dlg = wx.FileDialog(
            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
                self.timestr = self.nc.Constituent_Names.split()

            self.time_list.SetItems(self.timestr)

            # Draw the depth
            if startvar in vnames:
                self.variable=startvar
                self.loadData()
                self.create_figure()
Beispiel #13
0
    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')
                elif self.interp_meshmethod == 'linear':
                        self.UVWinterp =\
                            interp3Dmesh(self.xp,self.yp,-self.z_w,self.cells,self.nfaces,\
                            self.mask3D,method='linear',grdfile=self.ncfile)
        else:
            # Surface layer use nearest point only for now
            self.UVWinterp = interp2Dmesh(self.xp,self.yp,self.cells,\
                    self.nfaces,method='nearest')
Beispiel #14
0
    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')
                elif self.interp_meshmethod == 'linear':
                        self.UVWinterp =\
                            interp3Dmesh(self.xp,self.yp,-self.z_w,self.cells,self.nfaces,\
                            self.mask3D,method='linear',grdfile=self.ncfile)
        else:
            # Surface layer use nearest point only for now
            self.UVWinterp = interp2Dmesh(self.xp,self.yp,self.cells,\
                    self.nfaces,method='nearest')
Beispiel #15
0
 def __init__(self,ncfile,**kwargs):
     """
     Calculates the energy variables from suntans output
     """
     # Initialize the spatial class
     Spatial.__init__(self,ncfile,klayer=[-99])