dac_workflow_manager
¶
Classes:
DACWorkflowManager
¶
DACWorkflowManager(placements)
Bases: WorkflowManager
__init_(self, placements)
Initialization of an instance of the generic DACWorkflowManager class.
Parameters:
-
(placements¶pandas Dataframe) –The locations that the simulation should be run for. Columns must include "lon", "lat" (CRS: 4326) and "capacity" -The capacity is the nominal capacity of the DAC plant in tCO2/h
Returns:
Methods:
-
adjust_variable_to_long_run_average–Adjusts the average mean of the specified variable to a known long-run-average
-
apply_loss_factor–Applies a loss factor onto a specified variable
-
extract_raster_values_at_placements–Extracts pixel values at each of the configured placements from the specified raster file
-
get_scalar_values_from_raster–Auxiliary function to extract raster values with NaN fallback options.
-
load_lt_dac_model_data–Function to load the DAC model data of a given model. The model data maps temperature and relative humidity to energy demand, relative productivity and water desorption.
-
read–Reads the specified variables from the NetCDF4-style weather dataset, and then extracts
-
register_workflow_parameter–Add a parameter to the WorkflowManager which will be included in the output XArray dataset
-
set_time_index–Sets the time index of the WorkflowManager
-
simulate_ht_dac_model–Simulate the high-temperature (HT), liquid-solvent DAC (Direct Air Capture) model for a given model type.
-
simulate_lt_dac_model–Simulate the LT DAC (Direct Air Capture) model for the specified plant locations.
-
spatial_disaggregation–[summary]
-
to_netcdf–Saves an XArray dataset to netCDF4 format
-
to_xarray–Generates an XArray dataset from the data currently contained in the WorkflowManager
Source code in reskit/dac/workflows/dac_workflow_manager.py
adjust_variable_to_long_run_average
¶
adjust_variable_to_long_run_average(
variable: str,
source_long_run_average: Union[str, float, ndarray],
real_long_run_average: Union[str, float, ndarray],
real_lra_scaling: float = 1,
spatial_interpolation: str = "linear-spline",
nodata_fallback: str = "nan",
nodata_fallback_scaling: float = 1,
allow_nans: bool = True,
)
Adjusts the average mean of the specified variable to a known long-run-average
Note:
uses the equation: variable[t] = variable[t] * real_long_run_average / source_long_run_average
Parameters:
-
(variable¶str) –The variable to be adjusted
-
(source_long_run_average¶Union[str, float, ndarray]) –The variable's native long run average (the average in the weather file) - If a string is given, it is expected to be a path to a raster file which can be used to look up the average values from using the coordinates in
.placements- If a numpy ndarray (or derivative) is given, the shape must be one of (time, placements) or at least (placements) -
(real_long_run_average¶Union[str, float, ndarray]) –The variables 'true' long run average - If a string is given, it is expected to be a path to a raster file which can be used to look up the average values from using the coordinates in
.placements- If a numpy ndarray (or derivative) is given, the shape must be one of (time, placements) or at least (placements) -
(real_lra_scaling¶float, default:1) –An optional scaling factor to apply to the values derived from
real_long_run_average. - This is primarily useful whenreal_long_run_averageis a path to a raster file - By default 1 -
(spatial_interpolation¶str, default:'linear-spline') –When either
source_long_run_averageorreal_long_run_averageare a path to a raster file, this input specifies which interpolation algorithm should be used - Options are: "near", "linear-spline", "cubic-spline", "average" - By default "linear-spline" - See for more info: geokit.raster.interpolateValues -
(nodata_fallback¶str, default:'nan') –When real_long_run_average has no data, one can decide between different fallback options, by default np.nan: - np.nan or None : return np.nan for missing values in real_long_run_average - float : Apply this float value as a scaling factor for all no-data locations only: source_long_run_average * nodata_fallback. NOTE: A value of 1.0 will return the source lra value in case of missing real lra values (no additional nodata_fallback_scaling applied). - str : Will be interpreted as a filepath to a raster with alternative real_long_run_average values, scaled by nodata_fallback_scaling. - callable : any callable method taking the arguments (all iterables): 'locs' and 'source_long_run_average_value' (the locations as gk.geom.point objects and original value from source data). The output values will be considered as the new real_long_run_average for missing locations only (absolute data, no additional nodata_fallback_scaling applied).
NOTE: np.nan will also be returned in case that the nodata fallback does not yield values either.
-
(nodata_fallback_scaling¶float, default:1) –An optional scaling factor to apply to the values derived from
nodata_fallback. - This is primarily useful whennodata_fallbackis a path to a raster file - By default 1 -
(allow_nans¶boolean, default:True) –If True, NaN values may remain after scaling, else an error will raised. By default True.
Returns:
-
WorkflowManager–Returns the invoking WorkflowManager (for chaining)
Source code in reskit/workflow_manager.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | |
apply_loss_factor
¶
apply_loss_factor(
loss: Union[float, ndarray, FunctionType],
variables: Union[str, List[str]] = ["capacity_factor"],
)
Applies a loss factor onto a specified variable
Parameters:
-
(loss¶Union[float, ndarray, FunctionType]) –The loss factor(s) to be applied - If a float or a numpy ndarray is given, then the following operation is performed:
variable = variable * (1 - loss) - If a function is given, then the following operation is performed: variable = variable * (1 - loss(variable) ) - If a numpy ndarray is given, it must be broadcastable to the variable's shape in
.sim_data -
(variables¶Union[str, List[str]], default:['capacity_factor']) –The variable or variables to apply the loss factor to - By default ["capacity_factor"]
Returns:
-
WorkflowManager–Returns the invoking WorkflowManager (for chaining)
Source code in reskit/workflow_manager.py
extract_raster_values_at_placements
¶
Extracts pixel values at each of the configured placements from the specified raster file
get_scalar_values_from_raster
¶
Auxiliary function to extract raster values with NaN fallback options.
Source code in reskit/workflow_manager.py
load_lt_dac_model_data
¶
load_lt_dac_model_data(model: str)
Function to load the DAC model data of a given model. The model data maps temperature and relative humidity to energy demand, relative productivity and water desorption. Description: The DAC model data needs columns "T" and "RH" where the temperature (°C) and relative humidity are included. Its a csv file. Additionally, the data needs columns: -"totalElectricity" where the needed electricity input in MWh/tCO2 is stated at the specified ambient conditions -"totalThermal" where the needed heat input in MWh/tCO2 is stated at the specified ambient conditions -"relProd" where the relative productivity (i.e. the cpaacity factor) is stated at the specified ambient conditions -"waterDesorption" where the produced water is stated in tH2O/tCO2. It might also be possible that this is negative (if water is consumed rather than produced) The currently available models: -LT_jajjawi: Data from the developed low temperature (solid sorbent) DAC model by Jajjawi et al. [1]. Here, the heat is needed at 90 °C. -LT_sendi: Data from the developed low temperature (solid sorbent) DAC model by Sendi et al. [2]. Here, the heat is needed at 110 °C (for steam generation). The original Sendi data has been adapted as described in Wenzel 2025 [3].
Parameters:
-
(model¶str) –type of DAC model to use. Valid inputs are: "LT_sendi", "LT_jajjawi" or a path to a csv with DAC model data in the same format as in ./data/
References
[1] http://dx.doi.org/10.2139/ssrn.5230783 [2] 10.1016/j.oneear.2022.09.003 [3] 10.1016/j.adapen.2025.100229
Source code in reskit/dac/workflows/dac_workflow_manager.py
read
¶
read(
variables: Union[str, List[str]],
source_type: str,
source: str,
set_time_index: bool = False,
spatial_interpolation_mode: str = "bilinear",
temporal_reindex_method: str = "nearest",
time_index_from=None,
**kwargs,
)
Reads the specified variables from the NetCDF4-style weather dataset, and then extracts
those variables for each of the coordinates configured in .placements. The resulting
data is then available in .sim_data.
Parameters:
-
(variables¶str or list of strings) –The variables (or variables) to be read from the specified source - If a path to a weather source is given, then only the 'standard' variables configured for that source type are available (see the doc string for the weather source you are interested in) - If either 'elevated_wind_speed' or 'surface_wind_speed' is included in the variable list, then the members
.elevated_wind_speed_heightand.surface_wind_speed_height, respectfully, are also added. These are constants which specify what the 'native' wind speed height is, which depends on the source - A pre-loaded NCSource can also be given, thus allowing for any variable in the source to be specified in thevariableslist. But the user needs to take care of initializing the NCSource and loading the data they want -
(source_type¶str) –The type of weather datasource which is to be loaded. Can be one of: "ERA5", "SARAH", "MERRA", or 'user' - If a pre-loaded NCSource is given for the
sourceobject, then thesource_typeshould be "user" -
(source¶str or NCSource) –The source to read weather variables from
-
(set_time_index¶bool, default:False) –If True, instructs the workflow manager to set the time index to that which is read from the weather source - By default False
-
(spatial_interpolation_mode¶str, default:'bilinear') –The spatial interpolation mode to use while reading data from the weather source at each of the placement coordinates - By default "bilinear"
-
(temporal_reindex_method¶str, default:'nearest') –In the event of missing data, this algorithm is used to fill in the missing data. - Can be, for example, "nearest", "ffill", "bfill", "interpolate" - By default "nearest"
Returns:
-
WorkflowManager–Returns the invoking WorkflowManager (for chaining)
Raises:
-
RuntimeError–If set_time_index is False but no
.time_indexexists -
RuntimeError–If source_type is unknown
Source code in reskit/workflow_manager.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
register_workflow_parameter
¶
Add a parameter to the WorkflowManager which will be included in the output XArray dataset
Parameters:
-
(key¶str) –The workflow parameter's access key
-
(value¶Union[str, float]) –The workflow parameter's value. Only strings and floats are allowed
Source code in reskit/workflow_manager.py
set_time_index
¶
Sets the time index of the WorkflowManager
Source code in reskit/workflow_manager.py
simulate_ht_dac_model
¶
simulate_ht_dac_model(model: str = 'HT_okosun')
Simulate the high-temperature (HT), liquid-solvent DAC (Direct Air Capture) model for a given model type.
This function maps ambient temperature and relative humidity to energy demand, relative productivity, and water desorption for the specified DAC model. Currently, only the electrified HT DAC model "HT_okosun" is available.
Parameters:
-
(model¶str, default:'HT_okosun') –Type of DAC model to use. Currently, only "HT_okosun" is implemented. Default is "HT_okosun".
Raises:
-
NotImplementedError–If a DAC model type other than "HT_okosun" is requested.
Notes
The "HT_okosun" model is based on a natural gas-fired HT-DAC system [1], adapted to an electrified version as described in [2,3]. The electrified DAC model only consumes electricity.
References
[1] 10.1016/j.apenergy.2022.119895 [2] 10.3389/fclim.2020.618644 [3] 10.1016/j.adapen.2025.100229
Source code in reskit/dac/workflows/dac_workflow_manager.py
simulate_lt_dac_model
¶
simulate_lt_dac_model(fillMethod: str = 'nearest')
Simulate the LT DAC (Direct Air Capture) model for the specified plant locations.
This function interpolates DAC model data to the simulation grid and calculates electricity, heat, and water requirements as well as CO2 output for the plants. It also handles points outside the convex hull of the DAC data using a specified fill method.
Parameters:
-
(fillMethod¶str, default:'nearest') –Method to fill values for weather conditions outside the convex hull of the DAC model data. Options are: - "nearest" : use the nearest available datapoint (default) - "offTmin" : cut off for temperatures below the DAC data range, use nearest for relative humidity
Raises:
-
NotImplementedError–If a filling method other than "nearest" or "offTmin" is requested.
Source code in reskit/dac/workflows/dac_workflow_manager.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
spatial_disaggregation
¶
spatial_disaggregation(
variable: str,
source_high_resolution: Union[str, float, ndarray],
source_low_resolution: Union[str, float, ndarray],
real_lra_scaling: float = 1,
spatial_interpolation: str = "linear-spline",
)
[summary]
Parameters:
-
(variable¶str) –[description]
-
(source_long_run_average¶Union[str, float, ndarray]) –[description]
-
(real_long_run_average¶Union[str, float, ndarray]) –[description]
-
(real_lra_scaling¶float, default:1) –[description], by default 1
-
(spatial_interpolation¶str, default:'linear-spline') –[description], by default "linear-spline"
Source code in reskit/workflow_manager.py
to_netcdf
¶
to_netcdf(
xds: Dataset,
output_netcdf_path: str = None,
output_variables: List[str] = None,
custom_attributes: dict = None,
_intermediate_dict=False,
) -> str
Saves an XArray dataset to netCDF4 format
Note:
- The .placements data is automatically added to the XArray dataset along the 'locations' dimension
- The workflow_parameters data is automatically added as dimensionless variables
- The .sim_data is automatically added along the dimensions (time, locations)
- The .time_index is automatically added along the dimension 'time'
Parameters:
-
(xds¶Dataset) –The XArray dataset to save
-
(output_netcdf_path¶str, default:None) –If given, the XArray dataset will be written to disc at the specified path - By default None
-
(output_variables¶List[str], default:None) –If given, specifies the variables which should be included in the resulting dataset. Otherwise all suitable variables found in
.placements,.workflow_parameters,.sim_data, and.time_indexwill be included - Only variables of numeric or string type are suitable due to NetCDF4 limitations - By default None -
(custom_attributes¶dict, default:None) –If given, adds the key-value pairs as attributes to the XArray dataset before saving - These will be added in addition to existing attributes - By default None
Returns:
-
output_netcdf_path–The resulting output_netcdf_path
Source code in reskit/workflow_manager.py
to_xarray
¶
to_xarray(
output_netcdf_path: str = None,
output_variables: List[str] = None,
custom_attributes: dict = None,
_intermediate_dict=False,
) -> Dataset
Generates an XArray dataset from the data currently contained in the WorkflowManager
Note:
- The .placements data is automatically added to the XArray dataset along the 'locations' dimension
- The workflow_parameters data is automatically added as dimensionless variables
- The .sim_data is automatically added along the dimensions (time, locations)
- The .time_index is automatically added along the dimension 'time'
Parameters:
-
(output_netcdf_path¶str, default:None) –If given, the XArray dataset will be written to disc at the specified path - By default None
-
(output_variables¶List[str], default:None) –If given, specifies the variables which should be included in the resulting dataset. Otherwise all suitable variables found in
.placements,.workflow_parameters,.sim_data, and.time_indexwill be included - Only variables of numeric or string type are suitable due to NetCDF4 limitations - By default None -
(custom_attributes¶dict, default:None) –If given, adds the key-value pairs as attributes to the XArray dataset - These will be added in addition to the workflow_parameters - By default None
Returns:
-
Dataset–The resulting XArray dataset
Source code in reskit/workflow_manager.py
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | |