コード例 #1
0
def absolutehumidityfromRH(Ta, RH):
    # convert to masked arrays
    RH, WasND = SeriestoMA(RH)
    Ta, dummy = SeriestoMA(Ta)
    # do the job
    VPsat = es(Ta)
    vp = RH * VPsat / float(100)
    ah = float(1000000) * vp / ((Ta + 273.15) * c.Rv)
    # convert back to ndarray if input is not a masked array
    if WasND: ah, _ = MAtoSeries(ah)
    return ah
コード例 #2
0
def RHfromdewpoint(Td, Ta):
    # Relative humidity from dew point temperature
    #  Ta is the air temperature, C
    #  Td is the dew point temperature, C
    #  RH is the relative humidity, %
    # convert to masked arrays
    Td, WasND = SeriestoMA(Td)
    Ta, dummy = SeriestoMA(Ta)
    # do the job
    RH = 100 * 10**(7.591386 * (Td / (Td + 240.7263) - Ta / (Ta + 240.7263)))
    # convert back to ndarray if input is not a masked array
    if WasND: RH, _ = MAtoSeries(RH)
    return RH
コード例 #3
0
def RHfromspecifichumidity(q, Ta, ps):
    # Relative humidity from specific humidity
    #  q is the specific humidity, kg/kg
    #  Ta is the air temperature, C
    #  ps is the pressure, kPa
    #  RH is the relative humidity, %
    # convert to masked arrays
    q, WasND = SeriestoMA(q)
    Ta, dummy = SeriestoMA(Ta)
    # do the job
    VPsat = es(Ta)
    RH = float(100) * q * (c.Md / c.Mv) * ps / VPsat
    # convert back to ndarray if input is not a masked array
    if WasND: RH, _ = MAtoSeries(RH)
    return RH
コード例 #4
0
def RHfromabsolutehumidity(Ah, Ta):
    # Relative humidity from absolute humidity
    #  Ta is the air temperature, C
    #  Ah is the absolute humidity, g/m3
    #  RH is the relative humidity, %
    # convert to masked arrays
    Ah, WasND = SeriestoMA(Ah)
    Ta, dummy = SeriestoMA(Ta)
    # do the job
    VPsat = es(Ta)
    #vp = Ah * ((Ta+273.15)*c.Rv)/float(1000000)
    vp = vapourpressure(Ah, Ta)
    RH = float(100) * vp / VPsat
    # convert back to ndarray if input is not a masked array
    if WasND: RH, _ = MAtoSeries(RH)
    return RH
コード例 #5
0
def Fc_umolpm2psfrommgCO2pm2ps(Fc_mgpm2ps):
    """
    Convert Fc in units of mg/m2/s to units of umol/m2/s
    Usage:
     Fc_umolpm2ps = Fc_umolpm2psfrommgCO2pm2ps(Fc_mgpm2ps)
     where:
      Fc_mgpm2ps (input) - CO2 flux in units of mg/m2/s
    Returns the CO2 flux in units of umol/m2/s
    """
    # convert to masked array
    Fc_mgpm2ps, WasND = SeriestoMA(Fc_mgpm2ps)
    # do the job
    Fc_umolpm2ps = Fc_mgpm2ps / c.Mco2
    # convert back to ndarray if input is not a masked array
    if WasND: Fc_umolpm2ps, _ = MAtoSeries(Fc_umolpm2ps)
    return Fc_umolpm2ps
コード例 #6
0
def h2o_gpm3frommmolpmol(h_mmpm, T, p):
    """
     Convert H2O concentration units of mmol/mol to g/m3.
        Usage:
         H2O_gpm3 = h2o_gpm3frommmolpmol(H2O_mmolpmol, T, p)
         where
         H2O_mmolpmol (input) - H2O concentration, mmol/mol
         T (input) - air temperature, C
         p (input) - air pressure, kPa
        Returns the H2O concentration in g/m3.
    """
    # convert to masked arrays
    h_mmpm, WasND = SeriestoMA(h_mmpm)
    T, dummy = SeriestoMA(T)
    p, dummy = SeriestoMA(p)
    # do the job
    h_gpm3 = (c.Mv * h_mmpm * p * 1000) / (c.R * (T + 273.15))
    # convert to ndarray if input is not a masked array
    if WasND: h_gpm3, _ = MAtoSeries(h_gpm3)
    return h_gpm3
コード例 #7
0
def h2o_mmolpmolfromgpm3(h_gpm3, T, p):
    """
     Convert H2O concentration units of g/m3 to mmol/mol.
        Usage:
         H2O_mmolpmol = h2o_mmolpmolfromgpm3(H2O_gpm3, T, p)
         where
         H2O_gpm3 (input) - H2O concentration, g/m3
         T (input) - air temperature, C
         p (input) - air pressure, kPa
        Returns the H2O concentration in mmol/mol.
    """
    # convert to masked arrays
    h_gpm3, WasND = SeriestoMA(h_gpm3)
    T, dummy = SeriestoMA(T)
    p, dummy = SeriestoMA(p)
    # do the job
    h_mmpm = (h_gpm3 / c.Mv) * c.R * (T + 273.15) / (p * 1000)
    # convert to ndarray if input is not a masked array
    if WasND: h_mmpm, _ = MAtoSeries(h_mmpm)
    return h_mmpm
コード例 #8
0
def co2_umolpm3fromppm(c_ppm, T, p):
    """
     Convert CO2 concentration units of umol/mol (ppm) to umol/m3
        Usage:
         CO2_umolpm3 = co2_umolpm3fromppm(CO2_ppm, T, p)
         where
         CO2_ppm (input) - CO2 concentration, umol/mol
         T (input) - air temperature, C
         p (input) - air pressure, kPa
        Returns the CO2 concentration in umol/m3.
    """
    # convert to masked array if required
    c_ppm, WasND = SeriestoMA(c_ppm)
    T, dummy = SeriestoMA(T)
    T = T + 273.15  # temperature in K
    p, dummy = SeriestoMA(p)
    p = p * float(1000)  # pressure in Pa
    # do the job
    c_umolpm3 = c_ppm * p / (c.R * T)
    # convert back to ndarray if input is not a masked array
    if WasND: c_umolpm3, _ = MAtoSeries(c_umolpm3)
    return c_umolpm3
コード例 #9
0
def co2_ppmfrommgCO2pm3(c_mgpm3, T, p):
    """
     Convert CO2 concentration units of mgCO2/m3 to umol/mol (ppm)
        Usage:
         CO2_ppm = co2_ppmfrommgCO2pm3(CO2_mgpm3, T, p)
         where
         CO2_mgpm3 (input) - CO2 concentration, mgCO2/m3
         T (input) - air temperature, C
         p (input) - air pressure, kPa
        Returns the CO2 concentration in ppm.
    """
    # convert to masked array if required
    c_mgpm3, WasND = SeriestoMA(c_mgpm3)
    T, dummy = SeriestoMA(T)
    T = T + 273.15  # temperature in K
    p, dummy = SeriestoMA(p)
    p = p * float(1000)  # pressure in Pa
    # do the job
    c_ppm = (c_mgpm3 / c.Mco2) * c.R * T / p
    # convert back to ndarray if input is not a masked array
    if WasND: c_ppm, _ = MAtoSeries(c_ppm)
    return c_ppm