def Winds_hPa(U,V,P,pressurelevel): # Calculates and creates a file with pressurelevel hPa winds pressurelevel_pascal=pressurelevel*100. U_hPa=cdu.logLinearInterpolation(U,P,levels=pressurelevel_pascal) U_hPa.long_name=''.join(['U at ',str(pressurelevel),'hPa']) U_hPa.id='U' U_hPa.notes='U manipulated by cdutils.logLinearInterpolation' V_hPa=cdu.logLinearInterpolation(V,P,levels=pressurelevel_pascal) V_hPa.long_name=''.join(['V at ',str(pressurelevel),'hPa']) V_hPa.notes='V manipulated by cdutils.logLinearInterpolation' V_hPa.id='V' return U_hPa,V_hPa
def testVert(self): f = cdms2.open( os.path.join(cdat_info.get_sampledata_path(), 'vertical.nc')) Ps = f('PS') U = f('U') B = f('hybm') A = f('hyam') Po = f('variable_2') P = cdutil.reconstructPressureFromHybrid(Ps, A, B, Po) U2 = cdutil.logLinearInterpolation(U, P) U2b = cdutil.logLinearInterpolation(U, P, axis='0') self.assertTrue(numpy.ma.allclose(U2, U2b)) U2b = cdutil.logLinearInterpolation(U, P, axis='(lev)') self.assertTrue(numpy.ma.allclose(U2, U2b))
def EIS_LTS(T,P,RELHUM): #Calculates the Lower Tropospheric Stability (LTS) and Estimated Inversion Strenght (EIS) Theta_700=cdu.logLinearInterpolation(T,P,levels=70000)*(1000./700.)**(2./7.) Theta_700=cdu.averager(Theta_700,axis='z') Theta_1000=cdu.logLinearInterpolation(T,P,levels=100000) Theta_1000=cdu.averager(Theta_1000,axis='z') LTS=Theta_700-Theta_1000 LTS.id='LTS' LTS.long_name='Lower tropospheric stability' LTS.units='K' Theta_700.long_name='Potential temperature at 700hPa' Theta_700.units='K' Theta_1000.long_name='Potential temperature at 1000hPa' Theta_1000.units='K' # !!! Still need to develop EIS !!! EIS=LTS return LTS,EIS,Theta_700,Theta_1000
def Variable_hPa(var,P,pressurelevel): # Calculates and creates a file with pressurelevel hPa winds pressurelevel_pascal=pressurelevel*100. var_hPa=cdu.logLinearInterpolation(var,P,levels=pressurelevel_pascal) var_id=var.id var_hPa.long_name=''.join([var_id,' at ',str(pressurelevel),'hPa']) var_hPa.id=var_id var_hPa.notes=''.join([var_id,' manipulated by cdutils.logLinearInterpolation']) return var_hPa
#!/usr/bin/env python # Adapted for numpy/ma/cdms2 by convertcdms.py import cdutil import cdms2 as cdms,vcs,sys,os import vcs.test.support bg = vcs.test.support.bg f = cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','vertical.nc')) Ps=f('PS') U=f('U') B=f('hybm') A=f('hyam') Po=f('variable_2') P=cdutil.reconstructPressureFromHybrid(Ps,A,B,Po) U2=cdutil.logLinearInterpolation(U,P) x=vcs.init() x.plot(U2,bg=bg) vcs.test.support.check_plot(x)
#!/usr/bin/env python # Adapted for numpy/ma/cdms2 by convertcdms.py import cdutil, cdat_info import cdms2 import os bg = 0 f = cdms2.open(os.path.join(cdat_info.get_sampledata_path(), 'vertical.nc')) Ps = f('PS') U = f('U') B = f('hybm') A = f('hyam') Po = f('variable_2') P = cdutil.reconstructPressureFromHybrid(Ps, A, B, Po) U2 = cdutil.logLinearInterpolation(U, P) #x=vcs.init() #x.plot(U2,bg=bg) #raw_input()
#!/usr/bin/env python # Adapted for numpy/ma/cdms2 by convertcdms.py import cdutil import cdat_info import numpy import cdms2 import os bg = 0 f = cdms2.open(os.path.join(cdat_info.get_sampledata_path(), 'vertical.nc')) Ps = f('PS') U = f('U') B = f('hybm') A = f('hyam') Po = f('variable_2') P = cdutil.reconstructPressureFromHybrid(Ps, A, B, Po) U2 = cdutil.logLinearInterpolation(U, P) U2b = cdutil.logLinearInterpolation(U, P, axis='0') assert(numpy.ma.allclose(U2, U2b)) U2b = cdutil.logLinearInterpolation(U, P, axis='(lev)') assert(numpy.ma.allclose(U2, U2b))
axes = v.getAxisList() opened = False for itim, tm in enumerate(tim): # loop over time if ranks[itim] == myPe: T = v(time=slice(itim, itim + 1)) Ps = fps('ps', time=slice(itim, itim + 1)) # create the pressure field P = cdutil.reconstructPressureFromHybrid(Ps, A, B, Po) # interpolate print '[%d] Interpolating at time index %d' % (myPe, itim) out = cdutil.logLinearInterpolation(T, P, levels) out.info() ## print '[%d] Done!' % myPe ## sh=list(out.shape) ## sh.insert(0,1) ## out=MA.reshape(out,tuple(sh)) ## t=tim.subAxis(itim,itim+1) ## xx=reltime(tim[itim],tim.units) ## t_new=xx.torel('days since 1800').value ## t[0]=t_new ## t.units='days since 1800' ## meta[0][0]=t ## levelsax=cdms.createAxis(levels/100.) ## levelsax.id='plev' ## levelsax.units='hPa' ## levelsax.designateLevel()
axes=v.getAxisList() opened = False for itim,tm in enumerate(tim): # loop over time if ranks[itim] == myPe: T=v(time=slice(itim,itim+1)) Ps=fps('ps',time=slice(itim,itim+1)) # create the pressure field P=cdutil.reconstructPressureFromHybrid(Ps,A,B,Po) # interpolate print '[%d] Interpolating at time index %d' % (myPe, itim) out=cdutil.logLinearInterpolation(T,P,levels) out.info() ## print '[%d] Done!' % myPe ## sh=list(out.shape) ## sh.insert(0,1) ## out=MA.reshape(out,tuple(sh)) ## t=tim.subAxis(itim,itim+1) ## xx=reltime(tim[itim],tim.units) ## t_new=xx.torel('days since 1800').value ## t[0]=t_new ## t.units='days since 1800' ## meta[0][0]=t ## levelsax=cdms.createAxis(levels/100.) ## levelsax.id='plev' ## levelsax.units='hPa' ## levelsax.designateLevel()