Ejemplo n.º 1
0
def absolutehumidityfromrelativehumidity(Ta, RH):
    # convert to masked arrays
    RH, WasND = pfp_utils.SeriestoMA(RH)
    Ta, dummy = pfp_utils.SeriestoMA(Ta)
    # do the job
    vp = RH * VPsat(Ta) / 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, _ = pfp_utils.MAtoSeries(ah)
    return ah
Ejemplo n.º 2
0
def relativehumidityfromdewpoint(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 = pfp_utils.SeriestoMA(Td)
    Ta, dummy = pfp_utils.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, _ = pfp_utils.MAtoSeries(RH)
    return RH
Ejemplo n.º 3
0
def relativehumidityfromspecifichumidity(SH, Ta, ps):
    # Relative humidity from specific humidity
    #  SH is the specific humidity, kg/kg
    #  Ta is the air temperature, degC
    #  ps is the pressure, kPa
    #  RH is the relative humidity, percent
    # convert to masked arrays
    SH, WasND = pfp_utils.SeriestoMA(SH)
    Ta, dummy = pfp_utils.SeriestoMA(Ta)
    # do the job
    RH = float(100) * SH * (c.Md / c.Mv) * ps / VPsat(Ta)
    # convert back to ndarray if input is not a masked array
    if WasND: RH, _ = pfp_utils.MAtoSeries(RH)
    return RH
Ejemplo n.º 4
0
def relativehumidityfromabsolutehumidity(AH, Ta):
    # Relative humidity from absolute humidity
    #  Ta is the air temperature, degC
    #  AH is the absolute humidity, g/m^3
    #  RH is the relative humidity, percent
    # convert to masked arrays
    AH, WasND = pfp_utils.SeriestoMA(AH)
    Ta, dummy = pfp_utils.SeriestoMA(Ta)
    # do the job
    VP = vapourpressure(AH, Ta)
    RH = float(100) * VP / VPsat(Ta)
    # convert back to ndarray if input is not a masked array
    if WasND: RH, _ = pfp_utils.MAtoSeries(RH)
    return RH
Ejemplo n.º 5
0
def h2o_mmolpm3fromgpm3(h_gpm3):
    """
     Convert H2O concentration units of g/m^3 to mmol/m^3.
        Usage:
         H2O_mmolpm3 = h2o_mmolpm3fromgpm3(H2O_gpm3)
         where
         H2O_gpm3 (input) - H2O concentration, g/m^3
        Returns the H2O concentration in mmol/m^3.
    """
    # convert to masked arrays
    h_gpm3, WasND = pfp_utils.SeriestoMA(h_gpm3)
    # do the job
    h_mmolpm3 = h_gpm3 / float(c.Mv)
    # convert to ndarray if input is not a masked array
    if WasND: h_mmolpm3, _ = pfp_utils.MAtoSeries(h_mmolpm3)
    return h_mmolpm3
Ejemplo n.º 6
0
def Fco2_umolpm2psfrommgCO2pm2ps(Fc_mgpm2ps):
    """
    Convert Fc in units of mg/m^2/s to units of umol/m^2/s
    Usage:
     Fc_umolpm2ps = Fco2_umolpm2psfrommgCO2pm2ps(Fc_mgpm2ps)
     where:
      Fc_mgpm2ps (input) - CO2 flux in units of mg/m^2/s
    Returns the CO2 flux in units of umol/m^2/s
    """
    # convert to masked array
    Fc_mgpm2ps, WasND = pfp_utils.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, _ = pfp_utils.MAtoSeries(Fc_umolpm2ps)
    return Fc_umolpm2ps
Ejemplo n.º 7
0
def Fco2_gCpm2psfromumolpm2ps(Fc_umolpm2ps):
    """
    Convert Fco2 in units of umol/m^2/s to units of g/m^2/s (C, not CO2)
    Usage:
     Fco2_mgpm2ps = Fco2_gCpm2psfromumolpm2ps(Fc_umolpm2ps)
     where:
      Fco2_umolpm2ps (input) - CO2 flux in units of umol/m^2/s
    Returns the CO2 flux in units of g/m^2/s (C, not CO2)
    """
    # convert to masked array
    Fc_umolpm2ps, WasND = pfp_utils.SeriestoMA(Fc_umolpm2ps)
    # do the job
    Fc_gCpm2ps = Fc_umolpm2ps * c.Mc / 1E3
    # convert back to ndarray if input is not a masked array
    if WasND: Fc_gCpm2ps, _ = pfp_utils.MAtoSeries(Fc_gCpm2ps)
    return Fc_gCpm2ps
Ejemplo n.º 8
0
def h2o_mmolpmolfromgpm3(h_gpm3, T, p):
    """
     Convert H2O concentration units of g/m^3 to mmol/mol.
        Usage:
         H2O_mmolpmol = h2o_mmolpmolfromgpm3(H2O_gpm3, T, p)
         where
         H2O_gpm3 (input) - H2O concentration, g/m^3
         T (input) - air temperature, C
         p (input) - air pressure, kPa
        Returns the H2O concentration in mmol/mol.
    """
    # convert to masked arrays
    h_gpm3, WasND = pfp_utils.SeriestoMA(h_gpm3)
    T, dummy = pfp_utils.SeriestoMA(T)
    p, dummy = pfp_utils.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, _ = pfp_utils.MAtoSeries(h_mmpm)
    return h_mmpm
Ejemplo n.º 9
0
def h2o_gpm3frommmolpmol(h_mmpm, T, p):
    """
     Convert H2O concentration units of mmol/mol to g/m^3.
        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/m^3.
    """
    # convert to masked arrays
    h_mmpm, WasND = pfp_utils.SeriestoMA(h_mmpm)
    T, dummy = pfp_utils.SeriestoMA(T)
    p, dummy = pfp_utils.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, _ = pfp_utils.MAtoSeries(h_gpm3)
    return h_gpm3
Ejemplo n.º 10
0
def co2_umolpm3fromppm(c_ppm, T, p):
    """
     Convert CO2 concentration units of umol/mol (ppm) to umol/m^3
        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/m^3.
    """
    # convert to masked array if required
    c_ppm, WasND = pfp_utils.SeriestoMA(c_ppm)
    T, dummy = pfp_utils.SeriestoMA(T)
    T = T + 273.15  # temperature in K
    p, dummy = pfp_utils.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, _ = pfp_utils.MAtoSeries(c_umolpm3)
    return c_umolpm3
Ejemplo n.º 11
0
def co2_ppmfrommgCO2pm3(c_mgpm3, T, p):
    """
     Convert CO2 mass density (mgCO2/m^3) to mole fraction (umol/mol)
        Usage:
         CO2_ppm = co2_ppmfrommgCO2pm3(CO2_mgpm3, T, p)
         where
         CO2_mgpm3 (input) - CO2 concentration, mgCO2/m^3
         T (input) - air temperature, degC
         p (input) - air pressure, kPa
        Returns the CO2 mole fraction in umol/mol.
    """
    # convert to masked array if required
    c_mgpm3, WasND = pfp_utils.SeriestoMA(c_mgpm3)
    T, dummy = pfp_utils.SeriestoMA(T)
    T = T + 273.15  # temperature in K
    p, dummy = pfp_utils.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, _ = pfp_utils.MAtoSeries(c_ppm)
    return c_ppm