### Rscript Deployment Options Source: https://github.com/psychrometrics/psychrolib/blob/master/DEVELOP.md Example of running the R deployment script with options for preparing, documenting, or installing the package. ```bash Rscript tools/deploy.R [OPTION] ``` -------------------------------- ### Install psychrolib with Numba Source: https://context7.com/psychrometrics/psychrolib/llms.txt Install the psychrolib package. For enhanced performance with NumPy arrays and JIT acceleration, install the 'numba' package as well. ```bash pip install psychrolib # Optional: enable NumPy array support and JIT acceleration pip install psychrolib numba ``` -------------------------------- ### Install psychrolib for C# Source: https://context7.com/psychrometrics/psychrolib/llms.txt Install the PsychroLib NuGet package for C# projects. ```bash Install-Package PsychroLib ``` -------------------------------- ### Get Dew-Point Temperature from Relative Humidity (R) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Example of calculating dew-point temperature from dry-bulb temperature and relative humidity using the R API. Load the psychrolib library and set the unit system. ```r library(psychrolib) SetUnitSystem("SI") TDewPoint <- GetTDewPointFromRelHum(25.0, 0.80) cat(sprintf("TDewPoint: %.6f °C\n", TDewPoint)) # 21.309397 °C ``` -------------------------------- ### Get Dew-Point Temperature from Relative Humidity (Fortran) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Example of calculating dew-point temperature from dry-bulb temperature and relative humidity using the Fortran API. Ensure the psychrolib module is used and the unit system is set. ```fortran use psychrolib, only: GetTDewPointFromRelHum, SetUnitSystem, SI call SetUnitSystem(SI) print *, GetTDewPointFromRelHum(25.0, 0.80) ! 21.30935 °C ``` -------------------------------- ### Get Dew-Point Temperature from Relative Humidity (C#) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Example of calculating dew-point temperature from dry-bulb temperature and relative humidity using the C# (.NET) API. Instantiate the Psychrometrics class with the desired unit system. ```csharp var psy = new Psychrometrics(UnitSystem.SI); double tDewPoint = psy.GetTDewPointFromRelHum(25.0, 0.80); Console.WriteLine($"TDewPoint: {tDewPoint} °C"); // 21.309397 °C ``` -------------------------------- ### Install psychrolib for R Source: https://context7.com/psychrometrics/psychrolib/llms.txt Install the psychrolib package from CRAN for R. ```r install.packages("psychrolib") ``` -------------------------------- ### Numba Vectorization for Batch Array Processing (Python) Source: https://context7.com/psychrometrics/psychrolib/llms.txt When Numba is installed, psychrolib's Get* functions are automatically vectorized, allowing direct NumPy array input for high-throughput computation. This example demonstrates vectorized calls for calculating dew-point, wet-bulb temperature, humidity ratio, and enthalpy from arrays. ```python import numpy as np import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) # Simulate 1 hour of weather data at 1-minute resolution T_array = np.linspace(20.0, 30.0, 60) # °C RH_array = np.linspace(0.50, 0.80, 60) # dimensionless P_array = np.full(60, 101325.0) # Pa # Vectorized calls — no Python loop required TDewPoint_array = psychrolib.GetTDewPointFromRelHum(T_array, RH_array) TWetBulb_array = psychrolib.GetTWetBulbFromRelHum(T_array, RH_array, P_array) HumRatio_array = psychrolib.GetHumRatioFromRelHum(T_array, RH_array, P_array) Enthalpy_array = psychrolib.GetMoistAirEnthalpy(T_array, HumRatio_array) print(f"Dew-point range: {TDewPoint_array.min():.2f} – {TDewPoint_array.max():.2f} °C") print(f"Enthalpy range: {Enthalpy_array.min():.0f} – {Enthalpy_array.max():.0f} J/kg") ``` -------------------------------- ### Install Python Dependencies for Testing Source: https://github.com/psychrometrics/psychrolib/blob/master/DEVELOP.md Commands to install Python testing dependencies including numpy, m2r, cffi, and pytest. ```bash pip install numpy m2r cffi pytest cd tests/js && npm install cd ../.. ``` -------------------------------- ### Get Dew-Point Temperature from Relative Humidity (JavaScript) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Example of calculating dew-point temperature from dry-bulb temperature and relative humidity using the JavaScript API (Node.js). Ensure psychrolib.js is required and the unit system is set. ```javascript const psychrolib = require('./psychrolib.js'); psychrolib.SetUnitSystem(psychrolib.SI); const TDewPoint = psychrolib.GetTDewPointFromRelHum(25.0, 0.80); console.log(`TDewPoint: ${TDewPoint} °C`); // 21.309397 °C ``` -------------------------------- ### Get Dew-Point Temperature from Relative Humidity (C) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Example of calculating dew-point temperature from dry-bulb temperature and relative humidity using the C API. Ensure the psychrolib header is included and the unit system is set. ```c #include "psychrolib.h" SetUnitSystem(SI); double TDewPoint = GetTDewPointFromRelHum(25.0, 0.80); printf("TDewPoint: %f °C\n", TDewPoint); /* 21.309397 °C */ ``` -------------------------------- ### Multi-language Usage Examples Source: https://context7.com/psychrometrics/psychrolib/llms.txt The psychrolib API is available across multiple languages, with equivalent examples provided for common functions. ```APIDOC ## Multi-language usage (C, Fortran, JavaScript, C#, R, VBA) ### Description The same API is available across all supported languages. Below are equivalent examples of `GetTDewPointFromRelHum`. ### C Example ```c /* C */ #include "psychrolib.h" SetUnitSystem(SI); double TDewPoint = GetTDewPointFromRelHum(25.0, 0.80); printf("TDewPoint: %f °C\n", TDewPoint); /* 21.309397 °C */ ``` ### Fortran Example ```fortran ! Fortran use psychrolib, only: GetTDewPointFromRelHum, SetUnitSystem, SI call SetUnitSystem(SI) print *, GetTDewPointFromRelHum(25.0, 0.80) ! 21.30935 °C ``` ### JavaScript Example ```js // JavaScript (Node.js) const psychrolib = require('./psychrolib.js'); psychrolib.SetUnitSystem(psychrolib.SI); const TDewPoint = psychrolib.GetTDewPointFromRelHum(25.0, 0.80); console.log(`TDewPoint: ${TDewPoint} °C`); // 21.309397 °C ``` ### C# Example ```csharp // C# (.NET) var psy = new Psychrometrics(UnitSystem.SI); double tDewPoint = psy.GetTDewPointFromRelHum(25.0, 0.80); Console.WriteLine($"TDewPoint: {tDewPoint} °C"); // 21.309397 °C ``` ### R Example ```r # R library(psychrolib) SetUnitSystem("SI") TDewPoint <- GetTDewPointFromRelHum(25.0, 0.80) cat(sprintf("TDewPoint: %.6f °C\n", TDewPoint)) # 21.309397 °C ``` ### VBA Example ```vba ' Excel VBA — after importing psychrolib.bas ' Set Const PSYCHROLIB_UNITS = UnitSystem.SI (in psychrolib.bas) ' In worksheet cell: =GetTDewPointFromRelHum(A2, B2) ' Returns 21.30939716 ``` ``` -------------------------------- ### Get Saturation Humidity Ratio (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates the humidity ratio of saturated air in kg_H2O/kg_Air using SI units. Requires dry-bulb temperature and pressure. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) SatHumRatio = psychrolib.GetSatHumRatio(TDryBulb=30.0, Pressure=101325) print(f"Saturation humidity ratio: {SatHumRatio:.6f} kg_H2O/kg_Air") ``` -------------------------------- ### Numba Vectorization Source: https://context7.com/psychrometrics/psychrolib/llms.txt When numba is installed, all `Get*` functions are automatically vectorized with `@vectorize`, enabling direct NumPy array input for high-throughput computation. ```APIDOC ## Numba Vectorization (Python — batch arrays) ### Description When `numba` is installed, all `Get*` functions are automatically vectorized with `@vectorize`, enabling direct NumPy array input for high-throughput computation. ### Usage Provide NumPy arrays as input to `Get*` functions for vectorized calculations. ### Example ```python import numpy as np import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) # Simulate 1 hour of weather data at 1-minute resolution T_array = np.linspace(20.0, 30.0, 60) # °C RH_array = np.linspace(0.50, 0.80, 60) # dimensionless P_array = np.full(60, 101325.0) # Pa # Vectorized calls — no Python loop required TDewPoint_array = psychrolib.GetTDewPointFromRelHum(T_array, RH_array) TWetBulb_array = psychrolib.GetTWetBulbFromRelHum(T_array, RH_array, P_array) HumRatio_array = psychrolib.GetHumRatioFromRelHum(T_array, RH_array, P_array) Enthalpy_array = psychrolib.GetMoistAirEnthalpy(T_array, HumRatio_array) print(f"Dew-point range: {TDewPoint_array.min():.2f} – {TDewPoint_array.max():.2f} °C") print(f"Enthalpy range: {Enthalpy_array.min():.0f} – {Enthalpy_array.max():.0f} J/kg") ``` ### Output Example ``` Dew-point range: 10.00 – 24.99 °C Enthalpy range: 43345 – 75707 J/kg ``` ``` -------------------------------- ### Get Humidity Ratio from Relative Humidity (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates humidity ratio from dry-bulb temperature, relative humidity, and pressure using SI units. Ensure psychrolib is set to SI units before calling. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) HumRatio = psychrolib.GetHumRatioFromRelHum( TDryBulb=25.0, RelHum=0.80, Pressure=101325 ) print(f"Humidity ratio: {HumRatio:.6f} kg_H2O/kg_Air") # Humidity ratio: 0.016011 kg_H2O/kg_Air ``` -------------------------------- ### Get Dew-Point Temperature from Humidity Ratio (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates dew-point temperature from dry-bulb temperature, humidity ratio, and pressure using SI units. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) TDewPoint = psychrolib.GetTDewPointFromHumRatio( TDryBulb=25.0, HumRatio=0.016, Pressure=101325 ) print(f"Dew-point temperature: {TDewPoint:.4f} °C") # Dew-point temperature: 21.2764 °C ``` -------------------------------- ### Get Vapor Pressure Deficit (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates the vapor pressure deficit in Pascals using SI units. Requires dry-bulb temperature, humidity ratio, and pressure. Useful for plant science and evapotranspiration modeling. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) VPD = psychrolib.GetVaporPressureDeficit( TDryBulb=30.0, HumRatio=0.014, Pressure=101325 ) print(f"Vapor pressure deficit: {VPD:.2f} Pa") ``` -------------------------------- ### Get Saturation Vapor Pressure (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates saturation vapor pressure in Pascals using SI units. Valid for temperatures between -100 to 200 °C. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) for T in [-10, 0, 10, 25, 40]: pws = psychrolib.GetSatVapPres(T) print(f" T={T:4d} °C → Pws = {pws:9.2f} Pa") ``` -------------------------------- ### Get Standard Atmosphere Pressure and Temperature Source: https://context7.com/psychrometrics/psychrolib/llms.txt Retrieves standard atmospheric pressure and temperature for a given altitude using ASHRAE equations. The unit system should be set to SI for calculations in Pascals and Celsius. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) for alt in [0, 500, 1000, 2000]: P = psychrolib.GetStandardAtmPressure(alt) T = psychrolib.GetStandardAtmTemperature(alt) print(f" Altitude={alt:4d} m → P={P:.1f} Pa, T={T:.2f} °C") # Altitude= 0 m → P=101325.0 Pa, T=15.00 °C # Altitude= 500 m → P= 95461.0 Pa, T=11.75 °C # Altitude=1000 m → P= 89874.6 Pa, T= 8.50 °C # Altitude=2000 m → P= 79495.2 Pa, T= 2.00 °C ``` -------------------------------- ### Unit System Configuration Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/sphinx/api_docs.md Functions to set and get the current unit system for psychrometric calculations. SetUnitSystem must be called before using other library functions. ```APIDOC ## psychrolib.SetUnitSystem(Units: [UnitSystem](#psychrolib.UnitSystem)) -> None Set the system of units to use (SI or IP). * **Parameters:** **Units** – string indicating the system of units chosen (SI or IP) ### Notes This function *HAS TO BE CALLED* before the library can be used ## psychrolib.GetUnitSystem() -> [UnitSystem](#psychrolib.UnitSystem) | None Return system of units in use. ``` -------------------------------- ### Calculate Psychrometrics from Dew-Point Temperature (Python) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Computes all seven psychrometric properties from dry-bulb temperature, dew-point temperature, and pressure. Ensure psychrolib is installed and the unit system is set. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) HumRatio, TWetBulb, RelHum, VapPres, Enthalpy, Volume, DegSat = \ psychrolib.CalcPsychrometricsFromTDewPoint( TDryBulb=30.0, TDewPoint=20.0, Pressure=101325 ) print(f"Humidity ratio: {HumRatio:.6f} kg_H2O/kg_Air") print(f"Wet-bulb temp: {TWetBulb:.4f} °C") print(f"Relative humidity: {RelHum * 100:.2f} %") print(f"Vapor pressure: {VapPres:.2f} Pa") print(f"Enthalpy: {Enthalpy:.2f} J/kg") ``` -------------------------------- ### Get Dry Air Density and Volume (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates density (kg/m³) and specific volume (m³/kg) of dry air using SI units. Requires dry-bulb temperature and pressure. Uses the ideal gas law. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) Density = psychrolib.GetDryAirDensity(TDryBulb=25.0, Pressure=101325) Volume = psychrolib.GetDryAirVolume(TDryBulb=25.0, Pressure=101325) print(f"Dry air density: {Density:.5f} kg/m³") # 1.18394 kg/m³ print(f"Dry air volume: {Volume:.5f} m³/kg") # 0.84464 m³/kg ``` -------------------------------- ### Get Vapor Pressure from Relative Humidity (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates the partial pressure of water vapor from relative humidity and dry-bulb temperature using SI units. Uses ASHRAE equations 12 & 22. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) VapPres = psychrolib.GetVapPresFromRelHum(TDryBulb=25.0, RelHum=0.80) print(f"Vapor pressure: {VapPres:.2f} Pa") # Vapor pressure: 2533.56 Pa ``` -------------------------------- ### Get Relative Humidity from Humidity Ratio (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates relative humidity from dry-bulb temperature, humidity ratio, and pressure using SI units. The output is a value between 0 and 1. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) RelHum = psychrolib.GetRelHumFromHumRatio( TDryBulb=25.0, HumRatio=0.016, Pressure=101325 ) print(f"Relative humidity: {RelHum * 100:.2f} %") # Relative humidity: 79.87 % ``` -------------------------------- ### Calculate Psychrometrics from Relative Humidity (Python) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Computes all seven psychrometric properties from dry-bulb temperature, relative humidity, and pressure. This is a common entry point for weather station data. Ensure psychrolib is installed and the unit system is set. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) HumRatio, TWetBulb, TDewPoint, VapPres, Enthalpy, Volume, DegSat = \ psychrolib.CalcPsychrometricsFromRelHum( TDryBulb=25.0, RelHum=0.60, Pressure=101325 ) print(f"Humidity ratio: {HumRatio:.6f} kg_H2O/kg_Air") print(f"Wet-bulb temp: {TWetBulb:.4f} °C") print(f"Dew-point temp: {TDewPoint:.4f} °C") print(f"Vapor pressure: {VapPres:.2f} Pa") print(f"Moist air enthalpy: {Enthalpy:.2f} J/kg") print(f"Moist air volume: {Volume:.5f} m³/kg_DryAir") print(f"Degree of saturation: {DegSat:.5f}") ``` -------------------------------- ### Get Moist Air Volume (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates the specific volume of moist air in m³/kg_DryAir using SI units. Requires dry-bulb temperature, humidity ratio, and pressure. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) Volume = psychrolib.GetMoistAirVolume(TDryBulb=25.0, HumRatio=0.016, Pressure=101325) print(f"Moist air volume: {Volume:.5f} m³/kg_DryAir") ``` -------------------------------- ### Get Relative Humidity from Vapor Pressure (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates relative humidity from dry-bulb temperature and partial vapor pressure using SI units. The output is a value between 0 and 1. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) RelHum = psychrolib.GetRelHumFromVapPres(TDryBulb=25.0, VapPres=2533.56) print(f"Relative humidity: {RelHum * 100:.2f} %") # Relative humidity: 80.00 % ``` -------------------------------- ### Get Moist Air Enthalpy (SI and IP) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates moist air enthalpy using ASHRAE eqn 30. Supports both SI (J/kg) and IP (Btu/lb) unit systems. Requires dry-bulb temperature and humidity ratio. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) Enthalpy = psychrolib.GetMoistAirEnthalpy(TDryBulb=25.0, HumRatio=0.016) print(f"Moist air enthalpy: {Enthalpy:.2f} J/kg") ``` ```python # IP example psychrolib.SetUnitSystem(psychrolib.IP) Enthalpy_ip = psychrolib.GetMoistAirEnthalpy(TDryBulb=77.0, HumRatio=0.01) print(f"Moist air enthalpy: {Enthalpy_ip:.4f} Btu/lb") ``` -------------------------------- ### Build and Check R Package Source: https://github.com/psychrometrics/psychrolib/blob/master/DEVELOP.md Commands to build and check the R package from the src/r directory. ```bash R CMD build . R CMD check psychrolib*tar.gz ``` -------------------------------- ### Deploy Python Package Source: https://github.com/psychrometrics/psychrolib/blob/master/DEVELOP.md Commands to build and upload a Python package release from the src/python directory. ```bash python3 setup.py sdist --formats=zip python3 -m pip install --user --upgrade twine python3 -m twine upload dist/* ``` -------------------------------- ### Run JavaScript Tests Source: https://github.com/psychrometrics/psychrolib/blob/master/DEVELOP.md Commands to navigate to the JavaScript test directory and run tests using npm. ```bash cd tests/js && npm test ``` -------------------------------- ### Run .NET Tests Source: https://github.com/psychrometrics/psychrolib/blob/master/DEVELOP.md Command to execute tests for Microsoft .NET projects (C#, Visual Basic, F#) from the src/c_sharp directory. ```bash cd src/c_sharp && dotnet test # `dotnet-sdk.dotnet test` if installed with Snapcraft. ``` -------------------------------- ### Set Unit System and Calculate Dew Point Temperature (SI) Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/sphinx/api_docs.md Demonstrates how to set the unit system to SI and calculate the dew point temperature using dry bulb temperature and relative humidity. This function must be called before using other library functions. ```python >>> import psychrolib >>> # Set the unit system, for example to SI (can be either psychrolib.SI or psychrolib.IP) >>> psychrolib.SetUnitSystem(psychrolib.SI) >>> # Calculate the dew point temperature for a dry bulb temperature of 25 C and a relative humidity of 80% >>> TDewPoint = psychrolib.GetTDewPointFromRelHum(25.0, 0.80) >>> print(TDewPoint) 21.309397163661785 ``` -------------------------------- ### Get Dew-Point Temperature from Relative Humidity (Excel VBA) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Example of calculating dew-point temperature from dry-bulb temperature and relative humidity using Excel VBA. This requires importing the psychrolib.bas module and setting the unit system constant within the module. ```vba ' Excel VBA — after importing psychrolib.bas ' Set Const PSYCHROLIB_UNITS = UnitSystem.SI (in psychrolib.bas) ' In worksheet cell: =GetTDewPointFromRelHum(A2, B2) ' Returns 21.30939716 ``` -------------------------------- ### Deploy R Package Source: https://github.com/psychrometrics/psychrolib/blob/master/DEVELOP.md Command to source the deployment script for the R package. ```r source("tools/deploy.R") ``` -------------------------------- ### Set Unit System in Python Source: https://context7.com/psychrometrics/psychrolib/llms.txt Initialize the unit system for psychrolib calculations. This must be called once before other functions. Supports SI and IP units. ```python import psychrolib # SI units: temperatures in °C, pressures in Pa psychrolib.SetUnitSystem(psychrolib.SI) print(psychrolib.GetUnitSystem()) # UnitSystem.SI # IP units: temperatures in °F, pressures in Psi psychrolib.SetUnitSystem(psychrolib.IP) print(psychrolib.GetUnitSystem()) # UnitSystem.IP ``` -------------------------------- ### Get Dry Air Enthalpy (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates the enthalpy of dry air in J/kg using SI units. Requires dry-bulb temperature. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) DryEnthalpy = psychrolib.GetDryAirEnthalpy(TDryBulb=25.0) print(f"Dry air enthalpy: {DryEnthalpy:.2f} J/kg") ``` -------------------------------- ### SetUnitSystem Source: https://context7.com/psychrometrics/psychrolib/llms.txt Initializes the unit system for all subsequent calculations. Must be called once before any other function. Supports SI and IP unit systems. ```APIDOC ## SetUnitSystem — Initialize the unit system Must be called once before any other function. Raises `ValueError` if called with an invalid argument. In C#, the unit system is passed to the `Psychrometrics` constructor instead. ```python import psychrolib # SI units: temperatures in °C, pressures in Pa psychrolib.SetUnitSystem(psychrolib.SI) print(psychrolib.GetUnitSystem()) # UnitSystem.SI # IP units: temperatures in °F, pressures in Psi psychrolib.SetUnitSystem(psychrolib.IP) print(psychrolib.GetUnitSystem()) # UnitSystem.IP ``` ``` -------------------------------- ### Get Saturated Air Enthalpy (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates the enthalpy of saturated air in J/kg using SI units. Requires dry-bulb temperature and pressure. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) SatEnthalpy = psychrolib.GetSatAirEnthalpy(TDryBulb=30.0, Pressure=101325) print(f"Saturated air enthalpy: {SatEnthalpy:.2f} J/kg") ``` -------------------------------- ### Run Python, C, Fortran Tests Source: https://github.com/psychrometrics/psychrolib/blob/master/DEVELOP.md Command to execute Python tests with pytest, including verbose and capture-less output. ```bash python -m pytest -v -s ``` -------------------------------- ### Get Dew-Point Temperature from Wet-Bulb Temperature (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates dew-point temperature from dry-bulb temperature, wet-bulb temperature, and pressure using SI units. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) TDewPoint = psychrolib.GetTDewPointFromTWetBulb( TDryBulb=28.0, TWetBulb=20.0, Pressure=101325 ) print(f"Dew-point temperature: {TDewPoint:.4f} °C") # Dew-point temperature: 14.6100 °C ``` -------------------------------- ### Vapor Pressure Calculations Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/overview.md Functions to calculate vapor pressure. ```APIDOC ## GetVapPresFromRelHum ### Description Return partial pressure of water vapor as a function of relative humidity and temperature. ### Function Signature `GetVapPresFromRelHum(tDryBulb, relHum)` ### Parameters - **tDryBulb** (float) - Dry-bulb temperature. - **relHum** (float) - Relative humidity (0 to 1). ### Returns - float - Partial pressure of water vapor. ``` ```APIDOC ## GetVapPresFromHumRatio ### Description Return vapor pressure given humidity ratio and pressure. ### Function Signature `GetVapPresFromHumRatio(humRatio, pressure)` ### Parameters - **humRatio** (float) - Humidity ratio (kg water/kg dry air). - **pressure** (float) - Atmospheric pressure. ### Returns - float - Vapor pressure. ``` -------------------------------- ### Get Moist Air Density (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates moist air density in kg/m³ using SI units. Requires dry-bulb temperature, humidity ratio, and pressure. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) Density = psychrolib.GetMoistAirDensity(TDryBulb=25.0, HumRatio=0.016, Pressure=101325) print(f"Moist air density: {Density:.5f} kg/m³") ``` -------------------------------- ### Get Humidity Ratio from Dew-Point Temperature (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates humidity ratio from dew-point temperature and pressure using SI units. This is done via the saturation vapor pressure. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) HumRatio = psychrolib.GetHumRatioFromTDewPoint(TDewPoint=15.0, Pressure=101325) print(f"Humidity ratio: {HumRatio:.6f} kg_H2O/kg_Air") # Humidity ratio: 0.010667 kg_H2O/kg_Air ``` -------------------------------- ### psychrolib.GetVapPresFromTDewPoint Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/sphinx/api_docs.md Calculates the vapor pressure given the dew-point temperature. ```APIDOC ## psychrolib.GetVapPresFromTDewPoint(TDewPoint: float) -> float ### Description Return vapor pressure given dew point temperature. ### Parameters #### Path Parameters - **TDewPoint** (float) - Dew-point temperature in °F [IP] or °C [SI] ### Returns Partial pressure of water vapor in moist air in Psi [IP] or Pa [SI] ``` -------------------------------- ### Calculate Dew Point in C# (.NET Standard) Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/examples.md Use this C# snippet for calculating dew point temperature. Instantiate the Psychrometrics class with the desired unit system (e.g., new Psychrometrics(UnitSystem.SI)). ```csharp // Create instance of Psychrometrics class and specify the unit system. var psyIP = new Psychrometrics(UnitSystem.IP); var psySI = new Psychrometrics(UnitSystem.SI); // Calculate the dew point temperature for a dry bulb temperature of 25 C and a relative humidity of 80% var tDewPoint = psySI.GetTDewPointFromRelHum(25.0, 0.80); Console.WriteLine($"TDewPoint: {tDewPoint} degree C"); >>> TDewPoint: 21.309397163329322 degree C ``` -------------------------------- ### Get Dry-Bulb Temperature from Moist Air Volume and Humidity Ratio (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Inverse of GetMoistAirVolume. Recovers dry-bulb temperature in °C from specific volume, humidity ratio, and pressure using SI units. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) TDryBulb = psychrolib.GetTDryBulbFromMoistAirVolumeAndHumRatio( MoistAirVolume=0.86011, HumRatio=0.016, Pressure=101325 ) print(f"Dry-bulb temperature: {TDryBulb:.4f} °C") ``` -------------------------------- ### GetVaporPressureDeficit Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/sphinx/api_docs.md Calculates the vapor pressure deficit given dry-bulb temperature, humidity ratio, and atmospheric pressure. ```APIDOC ## psychrolib.GetVaporPressureDeficit(TDryBulb: float, HumRatio: float, Pressure: float) -> float ### Description Return Vapor pressure deficit given dry-bulb temperature, humidity ratio, and pressure. ### Parameters #### Path Parameters - **TDryBulb** (float) - Dry-bulb temperature in °F [IP] or °C [SI] - **HumRatio** (float) - Humidity ratio in lb_H₂O lb_Air⁻¹ [IP] or kg_H₂O kg_Air⁻¹ [SI] - **Pressure** (float) - Atmospheric pressure in Psi [IP] or Pa [SI] ### Returns - **float** - Vapor pressure deficit in Psi [IP] or Pa [SI] ``` -------------------------------- ### Enthalpy to Temperature/Humidity Ratio Conversions Source: https://context7.com/psychrometrics/psychrolib/llms.txt Performs inverse calculations based on the moist air enthalpy formula. Use `GetTDryBulbFromEnthalpyAndHumRatio` to find temperature given enthalpy and humidity ratio, or `GetHumRatioFromEnthalpyAndTDryBulb` to find humidity ratio given enthalpy and temperature. Ensure the unit system is set. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) # Given enthalpy and humidity ratio → dry-bulb temperature TDryBulb = psychrolib.GetTDryBulbFromEnthalpyAndHumRatio( MoistAirEnthalpy=66000.0, HumRatio=0.016 ) print(f"Dry-bulb temperature: {TDryBulb:.4f} °C") # Dry-bulb temperature: 24.6855 °C # Given enthalpy and dry-bulb temperature → humidity ratio HumRatio = psychrolib.GetHumRatioFromEnthalpyAndTDryBulb( MoistAirEnthalpy=66000.0, TDryBulb=25.0 ) print(f"Humidity ratio: {HumRatio:.6f} kg_H2O/kg_Air") # Humidity ratio: 0.015782 kg_H2O/kg_Air ``` -------------------------------- ### Get Humidity Ratio from Wet-Bulb Temperature (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates humidity ratio from dry-bulb temperature, wet-bulb temperature, and pressure using SI units. This function handles both above- and below-freezing wet-bulb temperatures. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) HumRatio = psychrolib.GetHumRatioFromTWetBulb( TDryBulb=30.0, TWetBulb=22.0, Pressure=101325 ) print(f"Humidity ratio: {HumRatio:.6f} kg_H2O/kg_Air") # Humidity ratio: 0.014973 kg_H2O/kg_Air ``` -------------------------------- ### Specific Humidity ↔ Humidity Ratio Conversion (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Converts between specific humidity (kg_H₂O/kg_MoistAir) and humidity ratio (kg_H₂O/kg_DryAir) using SI units. Uses ASHRAE equation 9b. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) # Humidity ratio → Specific humidity SpecHum = psychrolib.GetSpecificHumFromHumRatio(HumRatio=0.016) print(f"Specific humidity: {SpecHum:.6f} kg_H2O/kg_Air") # Specific humidity: 0.015748 kg_H2O/kg_Air # Specific humidity → Humidity ratio HumRatio = psychrolib.GetHumRatioFromSpecificHum(SpecificHum=0.015748) print(f"Humidity ratio: {HumRatio:.6f} kg_H2O/kg_DryAir") # Humidity ratio: 0.016000 kg_H2O/kg_DryAir ``` -------------------------------- ### GetStationPressure Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/sphinx/api_docs.md Calculates the station pressure from sea level pressure, altitude, and dry-bulb temperature. ```APIDOC ## psychrolib.GetStationPressure(SeaLevelPressure: float, Altitude: float, TDryBulb: float) -> float ### Description Return station pressure from sea level pressure. ### Parameters #### Path Parameters - **SeaLevelPressure** (float) - Required - Sea level barometric pressure in Psi [IP] or Pa [SI] - **Altitude** (float) - Required - Altitude in ft [IP] or m [SI] - **TDryBulb** (float) - Required - Dry-bulb temperature in °F [IP] or °C [SI] ### Returns - **float** - Station pressure in Psi [IP] or Pa [SI] ### Reference : See ‘GetSeaLevelPressure’ ### Notes This function is just the inverse of ‘GetSeaLevelPressure’. ``` -------------------------------- ### Temperature Conversion Utilities Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/sphinx/api_docs.md Utility functions for converting temperatures between different scales (Fahrenheit to Rankine, Rankine to Fahrenheit, Celsius to Kelvin). ```APIDOC ## psychrolib.GetTRankineFromTFahrenheit(TFahrenheit: float) -> float Utility function to convert temperature to degree Rankine (°R) given temperature in degree Fahrenheit (°F). * **Parameters:** **TRankine** – Temperature in degree Fahrenheit (°F) * **Returns:** Temperature in degree Rankine (°R) Reference: : Reference: ASHRAE Handbook - Fundamentals (2017) ch. 1 section 3 ### Notes Exact conversion. ## psychrolib.GetTFahrenheitFromTRankine(TRankine: float) -> float Utility function to convert temperature to degree Fahrenheit (°F) given temperature in degree Rankine (°R). * **Parameters:** **TRankine** – Temperature in degree Rankine (°R) * **Returns:** Temperature in degree Fahrenheit (°F) Reference: : Reference: ASHRAE Handbook - Fundamentals (2017) ch. 1 section 3 ## psychrolib.GetTKelvinFromTCelsius(TCelsius: float) -> float Utility function to convert temperature to Kelvin (K) given temperature in degree Celsius (°C). * **Parameters:** **TCelsius** – Temperature in degree Celsius (°C) * **Returns:** Temperature in Kelvin (K) Reference: : Reference: ASHRAE Handbook - Fundamentals (2017) ch. 1 section 3 ``` -------------------------------- ### psychrolib.GetTWetBulbFromHumRatio Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/sphinx/api_docs.md Calculates the wet-bulb temperature given dry-bulb temperature, humidity ratio, and atmospheric pressure. ```APIDOC ## psychrolib.GetTWetBulbFromHumRatio(TDryBulb: float, HumRatio: float, Pressure: float) -> float ### Description Return wet-bulb temperature given dry-bulb temperature, humidity ratio, and pressure. ### Parameters #### Path Parameters - **TDryBulb** (float) - Dry-bulb temperature in °F [IP] or °C [SI] - **HumRatio** (float) - Humidity ratio in lb_H₂O lb_Air⁻¹ [IP] or kg_H₂O kg_Air⁻¹ [SI] - **Pressure** (float) - Atmospheric pressure in Psi [IP] or Pa [SI] ### Returns Wet-bulb temperature in °F [IP] or °C [SI] ``` -------------------------------- ### Humidity Ratio ↔ Vapor Pressure Conversion (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Interconverts between humidity ratio and partial vapor pressure using SI units. Uses ASHRAE equation 20. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) # Vapor pressure → Humidity ratio HumRatio = psychrolib.GetHumRatioFromVapPres(VapPres=2000.0, Pressure=101325) print(f"Humidity ratio: {HumRatio:.6f} kg_H2O/kg_Air") # Humidity ratio: 0.012491 kg_H2O/kg_Air # Humidity ratio → Vapor pressure VapPres = psychrolib.GetVapPresFromHumRatio(HumRatio=0.012491, Pressure=101325) print(f"Vapor pressure: {VapPres:.2f} Pa") # Vapor pressure: 1999.98 Pa ``` -------------------------------- ### Calculate Wet-Bulb Temperature from Relative Humidity (SI) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculate the wet-bulb temperature given dry-bulb temperature, relative humidity, and atmospheric pressure in SI units. Uses a bisection algorithm. ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) TWetBulb = psychrolib.GetTWetBulbFromRelHum( TDryBulb=30.0, # °C RelHum=0.65, # 65 % Pressure=101325 # Pa (standard atmosphere) ) print(f"Wet-bulb temperature: {TWetBulb:.4f} °C") # Wet-bulb temperature: 23.4670 °C ``` -------------------------------- ### psychrolib.GetTDewPointFromVapPres Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/sphinx/api_docs.md Calculates the dew-point temperature given the dry-bulb temperature and vapor pressure. ```APIDOC ## psychrolib.GetTDewPointFromVapPres(TDryBulb: float, VapPres: float) -> float ### Description Return dew-point temperature given dry-bulb temperature and vapor pressure. ### Parameters #### Path Parameters - **TDryBulb** (float) - Dry-bulb temperature in °F [IP] or °C [SI] - **VapPres** (float) - Partial pressure of water vapor in moist air in Psi [IP] or Pa [SI] ### Returns Dew-point temperature in °F [IP] or °C [SI] ``` -------------------------------- ### Calculate Dew-Point Temperature from Relative Humidity (IP) Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculate the dew-point temperature given dry-bulb temperature and relative humidity in IP units. ```python # IP equivalent psychrolib.SetUnitSystem(psychrolib.IP) TDewPoint_ip = psychrolib.GetTDewPointFromRelHum(77.0, 0.80) print(f"Dew-point temperature: {TDewPoint_ip:.4f} °F") # Dew-point temperature: 70.3569 °F ``` -------------------------------- ### psychrolib.GetHumRatioFromTWetBulb Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/sphinx/api_docs.md Calculates the humidity ratio given dry-bulb temperature, wet-bulb temperature, and atmospheric pressure. ```APIDOC ## psychrolib.GetHumRatioFromTWetBulb(TDryBulb: float, TWetBulb: float, Pressure: float) -> float ### Description Return humidity ratio given dry-bulb temperature, wet-bulb temperature, and pressure. ### Parameters #### Path Parameters - **TDryBulb** (float) - Dry-bulb temperature in °F [IP] or °C [SI] - **TWetBulb** (float) - Wet-bulb temperature in °F [IP] or °C [SI] - **Pressure** (float) - Atmospheric pressure in Psi [IP] or Pa [SI] ### Returns Humidity ratio in lb_H₂O lb_Air⁻¹ [IP] or kg_H₂O kg_Air⁻¹ [SI] ``` -------------------------------- ### Temperature Unit Conversions Source: https://context7.com/psychrometrics/psychrolib/llms.txt Provides utility functions for converting temperatures between Fahrenheit/Rankine and Celsius/Kelvin. No specific unit system needs to be set for these conversions. ```python import psychrolib # Celsius ↔ Kelvin print(psychrolib.GetTKelvinFromTCelsius(0.0)) # 273.15 print(psychrolib.GetTCelsiusFromTKelvin(373.15)) # 100.0 # Fahrenheit ↔ Rankine print(psychrolib.GetTRankineFromTFahrenheit(32.0)) # 491.67 print(psychrolib.GetTFahrenheitFromTRankine(491.67))# 32.0 ``` -------------------------------- ### GetTWetBulbFromRelHum Source: https://context7.com/psychrometrics/psychrolib/llms.txt Calculates the wet-bulb temperature given dry-bulb temperature, relative humidity, and atmospheric pressure. Uses a bisection algorithm for convergence. ```APIDOC ## GetTWetBulbFromRelHum — Wet-bulb temperature from relative humidity Returns the wet-bulb temperature given dry-bulb temperature, relative humidity, and atmospheric pressure. Uses a bisection algorithm that converges within `PSYCHROLIB_TOLERANCE` (0.001 °C or equivalent in IP). ```python import psychrolib psychrolib.SetUnitSystem(psychrolib.SI) TWetBulb = psychrolib.GetTWetBulbFromRelHum( TDryBulb=30.0, # °C RelHum=0.65, # 65 % Pressure=101325 # Pa (standard atmosphere) ) print(f"Wet-bulb temperature: {TWetBulb:.4f} °C") # Wet-bulb temperature: 23.4670 °C ``` ``` -------------------------------- ### Wet-Bulb Temperature Calculations Source: https://github.com/psychrometrics/psychrolib/blob/master/docs/overview.md Functions to calculate wet-bulb temperature based on different input parameters. ```APIDOC ## GetTWetBulbFromTDewPoint ### Description Return wet-bulb temperature given dry-bulb temperature, dew-point temperature, and pressure. ### Function Signature `GetTWetBulbFromTDewPoint(tDryBulb, tDewPoint, pressure)` ### Parameters - **tDryBulb** (float) - Dry-bulb temperature. - **tDewPoint** (float) - Dew-point temperature. - **pressure** (float) - Atmospheric pressure. ### Returns - float - Wet-bulb temperature. ``` ```APIDOC ## GetTWetBulbFromRelHum ### Description Return wet-bulb temperature given dry-bulb temperature, relative humidity, and pressure. ### Function Signature `GetTWetBulbFromRelHum(tDryBulb, relHum, pressure)` ### Parameters - **tDryBulb** (float) - Dry-bulb temperature. - **relHum** (float) - Relative humidity (0 to 1). - **pressure** (float) - Atmospheric pressure. ### Returns - float - Wet-bulb temperature. ``` ```APIDOC ## GetTWetBulbFromHumRatio ### Description Return wet-bulb temperature given dry-bulb temperature, humidity ratio, and pressure. ### Function Signature `GetTWetBulbFromHumRatio(tDryBulb, humRatio, pressure)` ### Parameters - **tDryBulb** (float) - Dry-bulb temperature. - **humRatio** (float) - Humidity ratio (kg water/kg dry air). - **pressure** (float) - Atmospheric pressure. ### Returns - float - Wet-bulb temperature. ```