def qflx_prec_2lhflx(QFLX, PRECC, PRECL, PRECSC, PRECSL): """computes LHFLX from QFLX and the precipitation variables PRECC, PRECL, PRECSC, PERCSL. Assumes that the input is in compatible units, such as kg/(m^2 s) for QFLX and m/s for PRECC, PRECL.""" QFLX = convert_units(QFLX, 'kg/(m^2 s)') PRECC = convert_units(PRECC, 'm/s') PRECL = convert_units(PRECL, 'm/s') PRECSC = convert_units(PRECSC, 'm/s') PRECSL = convert_units(PRECSL, 'm/s') Lv = 2.501e6 # units J/kg Lf = 3.337e5 # units J/kg LHFLX = (Lv + Lf) * QFLX - Lf * 1.e3 * (PRECC + PRECL - PRECSC - PRECSL) LHFLX.units = "W/m^2" LHFLX.long_name = "Surf latent heat flux" return LHFLX
def qflx_2lhflx(QFLX): """computes LHFLX from QFLX.""" # Based on get_LHFLX in the NCL code for AMWG. It may be that Susannah Burrow's qflx_lhflx_conversions.py # does the same thing in more generality, but I've not looked at it carefully. QFLX = convert_units(QFLX, 'kg/(m^2 s)') Lv = 2.501e6 # units J/kg LHFLX = Lv * QFLX LHFLX.units = "W/m^2" LHFLX.long_name = "Surf latent heat flux" return LHFLX
def prect2precip( PRECT, seasonid ): """converts a precipitation rate PRECT (averaged over a season; typical units mm/day) to a cumulative precipitation PRECIP (summed over the season). Thus PRECIP is PRECT multiplied by the length of the season. PRECIP is returned. We assume a 365-day (noleap) calendar.""" lenseason = { 'ANN':365, 'JFMAMJJASOND':365, 'DJF':90, 'MAM':92, 'JJA':92, 'SON':91, 'JAN':31, 'FEB':28, 'MAR':31, 'APR':30, 'MAY':31, 'JUN':30, 'JUL':31, 'AUG':31, 'SEP':30, 'OCT':31, 'NOV':30, 'DEC':31 } if seasonid not in lenseason: raise DiagError( "While converting precipitation rate to cumulative, cannot identify season %s" % seasonid ) PRECIP = lenseason[seasonid] * convert_units( PRECT, 'mm/day' ) PRECIP.units = 'mm' return PRECIP
derived_var( vid='CLDLOW_TAU1.3-9.4_MISR', inputs=['CLMISR'], outputs=['CLDLOW_TAU1.3-9.4_MISR'], func=(lambda clmisr, h0=0,h1=3, t0=1.3,t1=9.4: reduce_height_thickness( clmisr, h0,h1, t0,t1) ) ) #func=(lambda clmisr, h0=0,h1=6, t0=2,t1=4: reduce_height_thickness( clmisr, h0,h1, t0,t1) ) ) ], #6-MISR 'CLDLOW_TAU9.4_MISR':[ derived_var( vid='CLDLOW_TAU9.4_MISR', inputs=['CLMISR'], outputs=['CLDLOW_TAU9.4_MISR'], func=(lambda clmisr, h0=0,h1=3, t0=9.4,t1=379: reduce_height_thickness( clmisr, h0,h1, t0,t1) ) ) ], #TGCLDLWP_OCEAN 'TGCLDLWP_OCN':[derived_var( vid='TGCLDLWP', inputs=['TGCLDLWP_OCEAN'], outputs=['TGCLDLWP_OCN'], func=(lambda x: convert_units(x, 'g/m^2')) ), derived_var( vid='TGCLDLWP_OCN', inputs=['TGCLDLWP', 'OCNFRAC'], outputs=['TGCLDLWP_OCN'], func=(lambda x, y, units='g/m^2': simple_vars.ocean_only(x,y, units)) )], #...end of clouds, Yuying Zhang # To compare LHFLX and QFLX, need to unify these to a common variable # e.g. LHFLX (latent heat flux in W/m^2) vs. QFLX (evaporation in mm/day). # The conversion functions are defined in qflx_lhflx_conversions.py. # [SMB: 25 Feb 2015] #'LHFLX':[derived_var( # vid='LHFLX', inputs=['QFLX'], outputs=['LHFLX'], # func=(lambda x: x) ) ], #'QFLX':[derived_var( # vid='QFLX', inputs=['LHFLX'], outputs=['QFLX'], # func=(lambda x: x) ) ],
def ocean_only(var, OCNFRAC, units=None): if units != None: convert_units(var, units) return mask_by(var, OCNFRAC, lo=0.5, hi=None)