def __init__(self,suntanspath,**kwargs): self.__dict__.update(kwargs) Grid.__init__(self,suntanspath) # Initialise the trisearch object self.tsearch = GridSearch(self.xp,self.yp,self.cells)
def __init__(self,suntanspath,timestep): self.suntanspath = suntanspath Grid.__init__(self,suntanspath) # Get the time timestep self.time = datetime.strptime(timestep,'%Y%m%d.%H%M%S') # Initialise the output array self.initArrays()
def __init__(self,suntanspath,basename,numprocs,outvars=None): tic=time.clock() print '########################################################' print ' Initializing python SUNTANS NetCDF joining script...' print '########################################################' # Step 1) Read the main grid #print 'Loading suntans grid points...' Grid.__init__(self,suntanspath) self.numprocs = numprocs self.suntanspath=suntanspath self.basename=basename # Step 2) Build a dictionary of the variable names, attributes and dimensions in the first ncfile proc=0 self.ncfile='%s/%s.%d'%(suntanspath,basename,proc) self.variables, self.dims, self.globalatts = nc_info(self.ncfile) # If outvars have been set only write those variables and the grid variables if not outvars==None: self.outvars=gridvars+outvars self.outvars=outvars newvariables = [vv for vv in self.variables if vv['Name'] in self.outvars] self.variables = newvariables # Step 3) Set the dimension sizes based on the original grid self.dims['Nc']=self.Nc self.dims['Np']=self.xp.shape[0] self.dims['Ne']=self.edges.shape[0] self.dims['time']=None # Sets to unlimited # Open each input file and load the cell and edge pointers that go from # the "localgrid" to the "maingrid" self.ncin=[] self.cptr=[] # cell pointer self.eptr=[] # edge pointer for n in range(numprocs): ncfile='%s/%s.%d'%(suntanspath,basename,n) # Open all of the input files and get some info self.ncin.append(Dataset(ncfile,'r')) ncvars= self.ncin[n].variables self.nt = len(ncvars['time'][:]) self.cptr.append(ncvars['mnptr'][:]) self.eptr.append(ncvars['eptr'][:])
def on_load_grid(self, event): dlg = wx.DirDialog( self, message="Open SUNTANS grid from folder...", defaultPath=os.getcwd(), style= wx.DD_DEFAULT_STYLE) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath() # Initialise the class self.flash_status_message("Opening SUNTANS grid from folder: %s" % path) Grid.__init__(self,path) # Plot the Grid self.axes,self.collection = self.plotmesh(ax=self.axes,edgecolors='y') # redraw the figure self.canvas.draw()
def __init__(self,x,y,z,cells,nfaces,mask,method='nearest',grdfile=None): self.method=method # Initialise the trisearch array GridSearch.__init__(self,x,y,cells,nfaces=nfaces,force_inside=True) if self.method == 'linear': Grid.__init__(self,grdfile) self.datatmp = np.zeros(mask.shape,dtype=np.double) self.z = np.sort(z) self.z[-1]=10.0 # Set the surface layer to large self.Nkmax = z.size-1 self.mask3d = mask self.maskindex = -1*np.ones(self.mask3d.shape,dtype=np.int32) rr=0 for ii in range(self.mask3d.shape[0]): for jj in range(self.mask3d.shape[1]): if self.mask3d[ii,jj]: self.maskindex[ii,jj]=rr rr+=1
def __init__(self, ncfile): self.ncfile = ncfile Grid.__init__(self, ncfile, gridvars=untrim_gridvars, griddims=untrim_griddims)
def __init__(self,ncfile): self.ncfile=ncfile Grid.__init__(self,ncfile,gridvars=untrim_gridvars,griddims=untrim_griddims)