def hasz(self, v): ''' True if variable has depth dimension (s_rho or s_w) ''' dnames = netcdf.vdim(self.name, v) return 's_rho' in dnames or 's_w' in dnames
def hasz(self,v): ''' True if variable has depth dimension (s_rho or s_w) ''' dnames=netcdf.vdim(self.name,v) return 's_rho' in dnames or 's_w' in dnames
def hasz(self, v): """ True if variable has depth dimension (s_rho or s_w) """ dnames = netcdf.vdim(self.name, v) return "s_rho" in dnames or "s_w" in dnames
def hast(self,v): ''' True if variable has *time* dimension ''' dnames=netcdf.vdim(self.name,v) for d in dnames: if d.find('time')>=0: return True return False
def hast(self, v): ''' True if variable has *time* dimension ''' dnames = netcdf.vdim(self.name, v) for d in dnames: if d.find('time') >= 0: return True return False
def hast(self, v): """ True if variable has *time* dimension """ dnames = netcdf.vdim(self.name, v) for d in dnames: if d.find("time") >= 0: return True return False
def var_at(self,v,_3d=True): ''' returns location of the variable in the 2d/3d grid Possible values are u,v,r(rho), p(psi) If _3d, also checks if at w points ''' dims=netcdf.vdim(self.name,v).keys() if _3d and 's_w' in dims: return 'w' elif 'xi_u' in dims or 'eta_u' in dims: return 'u' elif 'xi_v' in dims or 'eta_v' in dims: return 'v' elif 'xi_psi' in dims and 'eta_psi' in dims: return 'p' elif 'xi_rho' in dims and 'eta_rho' in dims: return 'r' return False
def var_at(self, v, _3d=True): ''' returns location of the variable in the 2d/3d grid Possible values are u,v,r(rho), p(psi) If _3d, also checks if at w points ''' dims = netcdf.vdim(self.name, v).keys() if _3d and 's_w' in dims: return 'w' elif 'xi_u' in dims or 'eta_u' in dims: return 'u' elif 'xi_v' in dims or 'eta_v' in dims: return 'v' elif 'xi_psi' in dims and 'eta_psi' in dims: return 'p' elif 'xi_rho' in dims and 'eta_rho' in dims: return 'r' return False
def vaxes(self,v): ''' returns variables axes as string: ex: 'vaxes('temp') is 'tzyx' indicating time (t), vertical (z) and horizontal (y,x) dimensions ''' dnames=netcdf.vdim(self.nc,v) out='' for d in dnames: if d.find('time')>=0: out+='t' elif d in ('s_rho','s_w'): out+='z' if d.startswith('eta_'): out+='y' if d.startswith('xi_'): out+='x' return out
def var_at(self,v):##,_3d=True): ''' returns location of the variable in the 2d/3d grid Possible values are u,v,r(rho), p(psi) If _3d, also checks if at w points ''' dims=netcdf.vdim(self.nc,v).keys() hLoc='r' # r,u,v vLoc='r' # r,w if 's_w' in dims: vLoc='w' if 'xi_u' in dims or 'eta_u' in dims: hLoc='u' # or instead of and cos of agrif ... elif 'xi_v' in dims or 'eta_v' in dims: hLoc='v' elif 'xi_psi' in dims and 'eta_psi' in dims: hLoc='p' return hLoc,vLoc
def var_at(self, v, _3d=True): """ returns location of the variable in the 2d/3d grid Possible values are u,v,r(rho), p(psi) If _3d, also checks if at w points """ dims = netcdf.vdim(self.name, v).keys() if _3d and "s_w" in dims: return "w" elif "xi_u" in dims or "eta_u" in dims: return "u" elif "xi_v" in dims or "eta_v" in dims: return "v" elif "xi_psi" in dims and "eta_psi" in dims: return "p" elif "xi_rho" in dims and "eta_rho" in dims: return "r" return False