def surface_parcel(self,mixdepth=125): """Returns parameters for a parcel initialised by: 1. Surface pressure (i.e. pressure of lowest level) 2. Surface temperature determined from max(theta) of lowest <mixdepth> mbar 3. Dew point temperature representative of lowest <mixdepth> mbar Inputs: mixdepth (mbar): depth to average mixing ratio over """ pres=self.data["pres"] temp=self.data["temp"] dwpt=self.data["dwpt"] # identify the layers for averaging layers=pres>pres[0]-mixdepth # parcel pressure is surface pressure pres_s=pres[0] # average theta over mixheight to give # parcel temperature thta_mix=Theta(temp[layers]+273.15,pres[layers]*100.).max() temp_s=TempK(thta_mix,pres_s*100)-273.15 # average mixing ratio over mixheight vpres=SatVap(dwpt) mixr=MixRatio(vpres,pres*100) mixr_mix=mixr[layers].mean() vpres_s=MixR2VaporPress(mixr_mix,pres_s*100) # surface dew point temp dwpt_s=DewPoint(vpres_s) return pres_s,temp_s,dwpt_s
def mixed_layer_parcel(self, depth=100): """Returns parameters for a parcel initialised by: 1. Surface pressure (i.e. pressure of lowest level) 2. Surface temperature determined from mean(theta) of lowest <depth> mb 3. Dew point temperature representative of lowest <depth> mbar Inputs: depth (mbar): depth to average mixing ratio over """ pres = self.soundingdata["pres"] temp = self.soundingdata["temp"] dwpt = self.soundingdata["dwpt"] pres0, temp0, dwpt0, null = self.surface_parcel() # identify the layers for averaging layers = pres > (pres0-depth) # average theta over mixheight to give # parcel temperature thta_mix = Theta(temp[layers]+degCtoK, pres[layers]*100.).mean() temp_s = TempK(thta_mix, pres0*100) - degCtoK # average mixing ratio over mixheight vpres = VaporPressure(dwpt) mixr = MixRatio(vpres, pres*100) mixr_mix = mixr[layers].mean() vpres_s = MixR2VaporPress(mixr_mix, pres0*100) # surface dew point temp dwpt_s = DewPoint(vpres_s) # print "----- Mixed Layer Parcel Characteristics -----" # print "Mixed layer depth : %5d mb "%depth # print "Mean mixed layer potential temperature: %5.1f K"%thta_mix # print "Mean mixed layer mixing ratio : %5.2f g/kg"% # (mixr_mix*1e3) return pres0, temp_s, dwpt_s, 'ml' raise NotImplementedError
rgrData3Dstag[v3,:,:,:]=np.squeeze(ncid.variables[rgr3DERAStag[v3]][:]) ncid.close() # clean up os.system("rm "+iFileGRIB); os.system("rm "+iFileNC) #################################################################################################### #################################################################################################### ############# Derive the target variables ############ #################################################################################################### #################################################################################################### print ' Wet bulb zero high' from thermodynamics import VaporPressure, MixRatio, WetBulb, esat, MixR2VaporPress ESAT=esat(rgrData3DAct[rgr3Dvariables.index('00_00_t'),:,:,:]) VapPres=MixR2VaporPress(rgrData3DAct[rgr3Dvariables.index('01_00_q'),:,:,:],rgrData3DAct[rgr3Dvariables.index('03_25_lnsp'),:,:,:]) rgrRH=(VapPres/ESAT)*100. rgrWBT=WetBulb(rgrData3DAct[rgr3Dvariables.index('00_00_t'),:,:,:]-273.15,rgrRH) rgrWBZheight=np.zeros((iTimeSteps,rgrData3DAct.shape[3],rgrData3DAct.shape[4])); rgrWBZheight[:]=np.nan for tt in range(iTimeSteps): print ' '+str(tt)+' of '+str(iTimeSteps) for lo in range(rgrData3DAct.shape[3]): for la in range(rgrData3DAct.shape[4]): if rgrWBT[tt,-1,lo,la] <= 0: rgrWBZheight[tt,lo,la]=0 else: ff = interpolate.interp1d(rgrWBT[tt,-40:,lo,la], rgrData3DAct[rgr3Dvariables.index('Z'),tt,-40:,lo,la]) rgrWBZheight[tt,lo,la]=ff(0) rgrWBZheight[rgrWBZheight < 0]=0 print ' 3 Degree Temp. height'
if rgrData_act[rgsSondVars.index('T'), 0] <= 3: rgr3CLevel[st, iTT] = 0 else: f = interp1d(rgrData_act[rgsSondVars.index('T'), :], rgrData_act[rgsSondVars.index('Z'), :]) rgr3CLevel[st, iTT] = f(3) # calculate melting level height ESAT = esat(rgrData_act[rgsSondVars.index('T'), :] + 273.15) ee = VaporPressure( rgrData_act[rgsSondVars.index('T'), :] - rgrData_act[rgsSondVars.index('DPD'), :], phase="liquid") rgrMixRatio = MixRatio( ee, rgrData_act[rgsSondVars.index('P'), :]) VapPres = MixR2VaporPress( rgrMixRatio, rgrData_act[rgsSondVars.index('P'), :]) rgrRH = (VapPres / ESAT) * 100. rgrWBT = WetBulb(rgrData_act[rgsSondVars.index('T'), :], rgrRH) if rgrWBT[0] <= 0: rgrWBZ[st, iTT] = 0 else: f = interp1d(rgrWBT, rgrData_act[rgsSondVars.index('Z'), :]) rgrWBZ[st, iTT] = f(0) # rSolPrecProb=fnSolidPrecip(1,-5,0) try: iZeroH = np.where( rgrData_act[rgsSondVars.index('Z'), :] == 0)[0][0] except: continue