ladybug_pandas.accessors.psychrometrics module

class ladybug_pandas.accessors.psychrometrics.PsychrometricsAccessor(pandas_obj)[source]

Bases: object

A pandas Dataframe accessor to perform psychrometric calculation operations

Use this “psychro” accessor and pass in the name of a column in your dataframe, a Series or an int/float value to perform as psychormetric operation and return a Series.

Warning

If using a Dataframe column or a Series you must ensure that it is an instance of a LadybugArrayType. This is because the Psychrometric accessor runs type checks to convert a data type to the right unit if necessary.

Example


import ladybug_pandas as lbp from ladybug.epw import EPW

epw_path = ‘tests/assets/epw/tokyo.epw’

epw = EPW(epw_path)

df = lbp.dataframe_from_epw(epw)

df[‘Humidity Ratio’] = df.psychro.humid_ratio_from_db_rh(

db_temp=’Dry Bulb Temperature’, rel_humid=’Relative Humidity’

)

db_temp_from_enth_hr(enthalpy, humid_ratio, reference_temp=0)[source]

Dry bulb temperature (C) from enthalpy (kJ/kg) and humidity ratio (water/air).

Parameters:
  • enthalpy – Enthalpy (kJ/kg).

  • humid_ratio – Humidity ratio (kg water/kg air).

  • reference_temp – Reference dry air temperature (C). Default is 0C, which is standard practice for SI enthalpy values. However, for IP enthalpy, this is typically at 0F (-17.78C). Alternatively, for aboslute thermodynamic enthalpy, one can input 0K (-273.15).

Returns:

Dry bulb temperature (C).

Note

[1] ASHRAE Handbook - Fundamentals (2017) ch. 1 eqn 30

dew_point_from_db_enth(db_temp, enthalpy, b_press=101325, reference_temp=0)[source]

Dew point temperature (C) from air temperature (C) and enthalpy (kJ/kg).

Parameters:
  • db_temp – Dry bulb temperature (C).

  • enthalpy – Enthalpy (kJ/kg).

  • b_press – Air pressure (Pa). Default is pressure at sea level (101325 Pa).

  • reference_temp – Reference dry air temperature (C). Default is 0C, which is standard practice for SI enthalpy values. However, for IP enthalpy, this is typically at 0F (-17.78C). Alternatively, for aboslute thermodynamic enthalpy, one can input 0K (-273.15).

Returns:

Dew point temperature (C).

dew_point_from_db_hr(db_temp, humid_ratio, b_press=101325)[source]

Dew Point Temperature (C) from air temperature (C) and humidity ratio (water/air).

Parameters:
  • db_temp – Dry bulb temperature (C).

  • humid_ratio – Humidity ratio (kg water/kg air).

  • b_press – Air pressure (Pa). Default is pressure at sea level (101325 Pa).

Returns:

Dew point temperature (C).

dew_point_from_db_rh(db_temp, rel_humid)[source]

Dew point temperature (C) from air temperature (C) and relative humidity (%).

The dew point temperature is solved by inverting the equation giving water vapor pressure at saturation from temperature, which is relatively slow but ensures high accuracy down to 0.1 C at a wide range of dry bulb temperatures. The Newton-Raphson (NR) method is used on the logarithm of water vapour pressure as a function of temperature, which is a very smooth function Convergence is usually achieved in 3 to 5 iterations.

Parameters:
  • db_temp – Dry bulb temperature (C).

  • rel_humid – Relative humidity (%).

Returns:

Dew point temperature (C).

Note

[1] ASHRAE Handbook - Fundamentals (2017) ch. 1 eqn. 5 and 6

[2] Meyer et al., (2019). PsychroLib: a library of psychrometric functions to calculate thermodynamic properties of air. Journal of Open Source Software, 4(33), 1137, https://doi.org/10.21105/joss.01137 https://github.com/psychrometrics/psychrolib/blob/master/src/python/psychrolib.py

dew_point_from_db_rh_fast(db_temp, rel_humid)[source]

Dew point temperature (C) from air temperature (C) and relative humidity (%).

Note that the formula here is fast but is only accurate up to 90C. For accurate values at extreme temperatures, the dew_point_from_db_rh function should be used.

Parameters:
  • db_temp – Dry bulb temperature (C).

  • rel_humid – Relative humidity (%).

Returns:

Dew point temperature (C).

Note

[1] J. Sullivan and L. D. Sanders. “Method for obtaining wet-bulb temperatures by modifying the psychrometric formula.” Center for Experiment Design and Data Analysis. NOAA - National Oceanic and Atmospheric Administration. https://www.weather.gov/epz/wxcalc_rh

dew_point_from_db_wb(db_temp, wet_bulb, b_press=101325)[source]

Dew point temperature (C) from dry bulb (C) and wet bulb temperature (C).

Parameters:
  • db_temp – Dry bulb temperature (C).

  • wet_bulb – Wet bulb temperature (C).

  • b_press – Air pressure (Pa). Default is pressure at sea level (101325 Pa).

Returns:

Dew point temperature (C).

enthalpy_from_db_hr(db_temp, humid_ratio, reference_temp=0)[source]

Enthalpy (kJ/kg) at a given humidity ratio (water/air) and dry bulb temperature (C).

Parameters:
  • db_temp – Dry bulb temperature (C).

  • humid_ratio – Humidity ratio (kg water/kg air).

  • reference_temp – Reference dry air temperature (C). Default is 0C, which is standard practice for SI enthalpy values. However, for IP enthalpy, this is typically at 0F (-17.78C). Alternatively, for aboslute thermodynamic enthalpy, one can input 0K (-273.15).

Returns:

Enthalpy (kJ/kg).

Note

[1] ASHRAE Handbook - Fundamentals (2017) ch. 1 eqn 30

[2] Meyer et al., (2019). PsychroLib: a library of psychrometric functions to calculate thermodynamic properties of air. Journal of Open Source Software, 4(33), 1137, https://doi.org/10.21105/joss.01137 https://github.com/psychrometrics/psychrolib/blob/master/src/python/psychrolib.py

humid_ratio_from_db_rh(db_temp, rel_humid, b_press=101325)[source]

Humidity ratio (kg water/kg air) from air temperature (C) and relative humidity (%).

Parameters:
  • db_temp – Dry bulb temperature (C).

  • rel_humid – Relative humidity (%).

  • b_press – Air pressure (Pa). Default is pressure at sea level (101325 Pa).

Returns:

Humidity ratio (kg water/kg air).

Note

[1] ASHRAE Handbook - Fundamentals (2017) ch. 1 eqn 20

[2] Meyer et al., (2019). PsychroLib: a library of psychrometric functions to calculate thermodynamic properties of air. Journal of Open Source Software, 4(33), 1137, https://doi.org/10.21105/joss.01137 https://github.com/psychrometrics/psychrolib/blob/master/src/python/psychrolib.py

humid_ratio_from_db_wb(db_temp, wb_temp, b_press=101325)[source]

Humidity ratio from air temperature (C) and wet bulb temperature (C).

Parameters:
  • db_temp – Dry bulb temperature (C).

  • wb_temp – Wet bulb temperature (C).

  • b_press – Air pressure (Pa). Default is pressure at sea level (101325 Pa).

Returns:

Humidity ratio (kg water / kg air).

Note

[1] ASHRAE Handbook - Fundamentals (2017) ch. 1 eqn 36, solved for W

rel_humid_from_db_dpt(db_temp, dew_pt)[source]

Relative humidity (%) from dry bulb temperature (C), and dew point temperature (C).

Parameters:
  • db_temp – Dry bulb temperature (C).

  • dew_pt – Dew point temperature (C).

Returns:

Relative humidity (%).

rel_humid_from_db_enth(db_temp, enthalpy, b_press=101325, reference_temp=0)[source]

Relative Humidity (%) from air temperature (C) and enthalpy (kJ/kg).

Parameters:
  • db_temp – Dry bulb temperature (C).

  • enthalpy – Enthalpy (kJ/kg).

  • b_press – Air pressure (Pa). Default is pressure at sea level (101325 Pa).

  • reference_temp – Reference dry air temperature (C). Default is 0C, which is standard practice for SI enthalpy values. However, for IP enthalpy, this is typically at 0F (-17.78C). Alternatively, for aboslute thermodynamic enthalpy, one can input 0K (-273.15).

Returns:

Relative humidity (%).

rel_humid_from_db_hr(db_temp, humid_ratio, b_press=101325)[source]

Relative Humidity (%) from humidity ratio (water/air) and air temperature (C).

Parameters:
  • db_temp – Dry bulb temperature (C).

  • humid_ratio – Humidity ratio (kg water/kg air).

  • b_press – Air pressure (Pa). Default is pressure at sea level (101325 Pa).

Returns:

Relative humidity (%).

rel_humid_from_db_wb(db_temp, wet_bulb, b_press=101325)[source]

Relative humidity (%) from dry bulb temperature (C), and wet bulb temperature (C).

Parameters:
  • db_temp – Dry bulb temperature (C).

  • wet_bulb – Wet bulb temperature (C).

  • b_press – Air pressure (Pa). Default is pressure at sea level (101325 Pa).

Returns:

Relative humidity (%).

saturated_vapor_pressure(t_kelvin: Union[str, float, int, LadybugArrayType]) → Series[source]
wet_bulb_from_db_rh(db_temp, rel_humid, b_press=101325)[source]

Wet bulb temperature (C) from air temperature (C) and relative humidity (%).

Parameters:
  • db_temp – Dry bulb temperature (C).

  • rel_humid – Relative humidity (%).

  • b_press – Air pressure (Pa). Default is pressure at sea level (101325 Pa).

Returns:

Wet bulb temperature (C).

Note

[1] ASHRAE Handbook - Fundamentals (2017) ch. 1 eqn 33 and 35

[2] Meyer et al., (2019). PsychroLib: a library of psychrometric functions to calculate thermodynamic properties of air. Journal of Open Source Software, 4(33), 1137, https://doi.org/10.21105/joss.01137 https://github.com/psychrometrics/psychrolib/blob/master/src/python/psychrolib.py

wet_bulb_from_db_rh_fast(db_temp, rel_humid, b_press=101325)[source]

Wet bulb temperature (C) from air temperature (C) and relative humidity (%).

Note that the formula here is fast but is only accurate around temperatures of 20C and lower. For accurate values at extreme temperatures, the wet_bulb_from_db_rh function should be used.

Parameters:
  • db_temp – Dry bulb temperature (C).

  • rel_humid – Relative humidity (%).

  • b_press – Air pressure (Pa). Default is pressure at sea level (101325 Pa).

Returns:

Wet bulb temperature (C).

Note

[1] J. Sullivan and L. D. Sanders. “Method for obtaining wet-bulb temperatures by modifying the psychrometric formula.” Center for Experiment Design and Data Analysis. NOAA - National Oceanic and Atmospheric Administration. https://www.weather.gov/epz/wxcalc_rh