Skip to content

dac

Modules:

Functions:

calculate_relative_humidity

calculate_relative_humidity(
    dewpoint_temperature, air_temperature
)

Function to calculate the relative humidity from dewpoint temperature and air temperature using the Sonntag formula.

Parameters:

  • dewpoint_temperature

    dewpoint temperature in °C

  • air_temperature

    air temperature in °C

References

[1] https://www.npl.co.uk/resources/q-a/dew-point-and-relative-humidity

Source code in reskit/util/relative_humidity.py
def calculate_relative_humidity(dewpoint_temperature, air_temperature):
    """
    Function to calculate the relative humidity from dewpoint temperature and air temperature using the Sonntag formula.

    Parameters
    ----------
    dewpoint_temperature: float | int
        dewpoint temperature in °C
    air_temperature: float | int
        air temperature in °C

    References
    ----------
    [1] https://www.npl.co.uk/resources/q-a/dew-point-and-relative-humidity
    """

    def calculate_vapor_pressure(temperature):
        """
        Function to calculate the vapor pressure from the temperature

        temperature: temperature in °C
        """
        temperature_Kelvin = temperature + 273.15
        vapor_pressure = np.exp(
            -6096.9385 / temperature_Kelvin
            + 21.2409642
            - 2.711193 * 10**-2 * temperature_Kelvin
            + 1.673952 * 10**-5 * temperature_Kelvin**2
            + 2.433502 * np.log(temperature_Kelvin)
        )  # vapor pressure [1]
        return vapor_pressure

    relative_humidity = (
        calculate_vapor_pressure(dewpoint_temperature) / calculate_vapor_pressure(air_temperature) * 100
    )  # [1]

    return relative_humidity

ht_dac_era5_wenzel2025

ht_dac_era5_wenzel2025(
    placements: DataFrame,
    era5_path: str,
    output_netcdf_path: str = None,
    output_variables: List[str] = None,
    model: str = "HT_okosun",
)

Simulate HT-DAC plants using ERA5 weather data.

This function runs a full simulation workflow for high-temperature direct air capture (HT-DAC) plants. It reads ERA5 weather data, calculates relative humidity, runs the specified HT-DAC model simulation, and optionally saves results to a NetCDF file.

Parameters:

  • placements

    (DataFrame) –

    DataFrame specifying the plant locations and capacities.

  • era5_path

    (str) –

    Path to the ERA5 weather data source.

  • output_netcdf_path

    (str, default: None ) –

    Path to save the output NetCDF file. If None, no file is saved. Default is None.

  • output_variables

    (list of str, default: None ) –

    List of variables from the simulation to include in the output NetCDF file. If None, all available variables are included. Default is None.

  • model

    (str, default: 'HT_okosun' ) –

    DAC model to use. Currently, only "HT_okosun" is implemented. Default is "HT_okosun".

Returns:

  • Dataset

    Simulation results, optionally limited to output_variables and including all plant locations.

Raises:

  • AssertionError

    If model is not "HT_okosun".

Notes

The simulation includes calculation of: - relative humidity - DAC capacity factor - electricity conversion factor - CO2 output per plant

The simulation relies on the DACWorkflowManager and the specified HT-DAC model.

Source code in reskit/dac/workflows/workflows.py
def ht_dac_era5_wenzel2025(
    placements: pd.DataFrame,
    era5_path: str,
    output_netcdf_path: str = None,
    output_variables: List[str] = None,
    model: str = "HT_okosun",
):
    """
    Simulate HT-DAC plants using ERA5 weather data.

    This function runs a full simulation workflow for high-temperature direct air capture (HT-DAC)
    plants. It reads ERA5 weather data, calculates relative humidity, runs the specified HT-DAC
    model simulation, and optionally saves results to a NetCDF file.

    Parameters
    ----------
    placements : pd.DataFrame
        DataFrame specifying the plant locations and capacities.
    era5_path : str
        Path to the ERA5 weather data source.
    output_netcdf_path : str, optional
        Path to save the output NetCDF file. If None, no file is saved. Default is None.
    output_variables : list of str, optional
        List of variables from the simulation to include in the output NetCDF file.
        If None, all available variables are included. Default is None.
    model : str, optional
        DAC model to use. Currently, only "HT_okosun" is implemented. Default is "HT_okosun".

    Returns
    -------
    xarray.Dataset
        Simulation results, optionally limited to `output_variables` and including all plant locations.

    Raises
    ------
    AssertionError
        If `model` is not "HT_okosun".

    Notes
    -----
    The simulation includes calculation of:
    - relative humidity
    - DAC capacity factor
    - electricity conversion factor
    - CO2 output per plant

    The simulation relies on the `DACWorkflowManager` and the specified HT-DAC model.
    """
    assert model in ["HT_okosun"], f"Invalid model: {model}. You can chose 'HT_okosun'"

    wf = DACWorkflowManager(placements)

    wf.read(
        variables=["surface_air_temperature", "surface_dew_temperature"],
        source_type="ERA5",
        source=era5_path,
        set_time_index=True,
        verbose=False,
    )
    wf.sim_data["relative_humidity"] = calculate_relative_humidity(
        dewpoint_temperature=wf.sim_data["surface_dew_temperature"],
        air_temperature=wf.sim_data["surface_air_temperature"],
    )
    wf.simulate_ht_dac_model(model=model)

    return wf.to_xarray(
        output_netcdf_path=output_netcdf_path,
        output_variables=output_variables,
        custom_attributes=wf.units,
    )

lt_dac_era5_wenzel2025

lt_dac_era5_wenzel2025(
    placements: DataFrame,
    era5_path: str,
    output_netcdf_path: str = None,
    output_variables: List[str] = None,
    model: str = "LT_jajjawi",
    fillMethod: str = "nearest",
)

Simulate LT-DAC plants using ERA5 weather data.

This function runs a full simulation workflow for low-temperature direct air capture (LT-DAC) plants. It reads ERA5 weather data, calculates relative humidity, loads the specified LT-DAC model data, performs the simulation, and optionally saves results to a NetCDF file.

Parameters:

  • placements

    (DataFrame) –

    DataFrame specifying the plant locations and capacities.

  • era5_path

    (str) –

    Path to the ERA5 weather data source.

  • output_netcdf_path

    (str, default: None ) –

    Path to save the output NetCDF file. If None, no file is saved. Default is None.

  • output_variables

    (list of str, default: None ) –

    List of variables from the simulation to include in the output NetCDF file. If None, all available variables are included. Default is None.

  • model

    (str, default: 'LT_jajjawi' ) –

    DAC model data to utilize. Default is "LT_jajjawi".

  • fillMethod

    (str, default: 'nearest' ) –

    Method for filling weather conditions outside the DAC model data hull: - "nearest" : use the nearest available datapoint (default) - "offTmin" : cut off for temperatures outside the model range, nearest for relative humidity

Returns:

  • Dataset

    Simulation results, optionally limited to output_variables and including all plant locations.

Notes

The simulation includes calculation of: - relative humidity - DAC capacity factor - electricity, heat, and water conversion factors - CO2, water, electricity, and heat outputs per plant

Source code in reskit/dac/workflows/workflows.py
def lt_dac_era5_wenzel2025(
    placements: pd.DataFrame,
    era5_path: str,
    output_netcdf_path: str = None,
    output_variables: List[str] = None,
    model: str = "LT_jajjawi",
    fillMethod: str = "nearest",
):
    """
    Simulate LT-DAC plants using ERA5 weather data.

    This function runs a full simulation workflow for low-temperature direct air capture (LT-DAC)
    plants. It reads ERA5 weather data, calculates relative humidity, loads the specified LT-DAC
    model data, performs the simulation, and optionally saves results to a NetCDF file.

    Parameters
    ----------
    placements : pd.DataFrame
        DataFrame specifying the plant locations and capacities.
    era5_path : str
        Path to the ERA5 weather data source.
    output_netcdf_path : str, optional
        Path to save the output NetCDF file. If None, no file is saved. Default is None.
    output_variables : list of str, optional
        List of variables from the simulation to include in the output NetCDF file.
        If None, all available variables are included. Default is None.
    model : str, optional
        DAC model data to utilize. Default is "LT_jajjawi".
    fillMethod : str, optional
        Method for filling weather conditions outside the DAC model data hull:
        - "nearest" : use the nearest available datapoint (default)
        - "offTmin" : cut off for temperatures outside the model range, nearest for relative humidity

    Returns
    -------
    xarray.Dataset
        Simulation results, optionally limited to `output_variables` and including all plant locations.

    Notes
    -----
    The simulation includes calculation of:
    - relative humidity
    - DAC capacity factor
    - electricity, heat, and water conversion factors
    - CO2, water, electricity, and heat outputs per plant
    """
    wf = DACWorkflowManager(placements)

    wf.read(
        variables=["surface_air_temperature", "surface_dew_temperature"],
        source_type="ERA5",
        source=era5_path,
        set_time_index=True,
        verbose=False,
    )

    wf.sim_data["relative_humidity"] = calculate_relative_humidity(
        dewpoint_temperature=wf.sim_data["surface_dew_temperature"],
        air_temperature=wf.sim_data["surface_air_temperature"],
    )
    wf.load_lt_dac_model_data(model=model)
    wf.simulate_lt_dac_model(fillMethod=fillMethod)

    return wf.to_xarray(
        output_netcdf_path=output_netcdf_path,
        output_variables=output_variables,
        custom_attributes=wf.units,
    )