Skip to main content

Heatwave Diagnostics Package (HDP) for computing heatwave metrics over gridded timeseries data.

Project description

HDP: Heatwave Diagnostics Package

Available on pypi Docs GitHub License status

The Heatwave Diagnostics Package (HDP) is an open-source Python project that equips researchers with computationally-efficient tools to quantify heatwave metrics across multiple parameters for daily, gridded data produced by climate model large ensembles.

The HDP offers functions that leverage Xarray, Dask, and Numba to take full advantage of the available hardware capabilites. These functions have been optimized to both run quickly in serial execution and scale effectively in parallel and distributed computing systems. In addition to computing heatwave datasets, the HDP also contains several plotting functions that generate summary figures for quickly evaluating changes in heatwave patterns spatially, temporally, and across the heatwave parameter space. The user can choose to use the resulting matplotlib figures as base templates for creating their own custom figures or opt to create a standardized deck of figures that broadly summarize the different metric trends. All graphical plots can then be stored in a Jupyter notebook for easy viewing and consolidated storage.

Why create the HDP?

Existing tools used to quantify heatwave metrics (such as ehfheatwaves, heatwave3, nctoolkit) were not designed to sample large sections of the heatwave parameter space. Many of these tools struggle to handle the computational burden of analyzing terabyte-scale datasets and do not offer a complete workflow for generating heatwave diagnostics from daily, gridded climate model output. The HDP expands upon this work to empower the user to conduct parameter-sampling analysis and reduce the computational burden of calculating heatwave metrics from increasingly large model output.

Documentation

To learn more about the HDP and how to use it, check out the full ReadTheDocs documentation at https://hdp.readthedocs.io/en/latest/user.html#.

Quick-Start

The code block below showcases an example HDP workflow using generated sample data:

import hdp
import numpy as np

output_dir = "."

sample_control_temp = hdp.utils.generate_test_control_dataarray(add_noise=True)
sample_warming_temp = hdp.utils.generate_test_warming_dataarray(add_noise=True)

baseline_measures = hdp.measure.format_standard_measures(
    temp_datasets=[sample_control_temp]
)
test_measures = hdp.measure.format_standard_measures(
    temp_datasets=[sample_warming_temp]
)

percentiles = np.arange(0.9, 1.0, 0.01)

thresholds_dataset = hdp.threshold.compute_thresholds(
    baseline_measures,
    percentiles
)

definitions = [[3,0,0], [3,1,1], [4,0,0], [4,1,1], [5,0,0], [5,1,1]]

metrics_dataset = hdp.metric.compute_group_metrics(test_measures, thresholds_dataset, definitions, include_threshold=True)
metrics_dataset.to_netcdf(f"{output_dir}/sample_hw_metrics.nc", mode='w')

figure_notebook = create_notebook(metrics_dataset)
figure_notebook.save_notebook(f"{output_dir}/sample_hw_summary_figures.ipynb")

sample_control_temp = sample_control_temp.to_dataset()
sample_control_temp.attrs["description"] = "Mock control temperature dataset generated by HDP for unit testing."
sample_control_temp.to_netcdf(f"{output_dir}/sample_control_temp.nc", mode='w')

sample_warming_temp = sample_warming_temp.to_dataset()
sample_warming_temp.attrs["description"] = "Mock temperature dataset with warming trend generated by HDP for unit testing."
sample_warming_temp.to_netcdf(f"{output_dir}/sample_warming_temp.nc", mode='w')

Contributing

Please report any bugs, ask questions, and make suggestions through the GitHub Issues form of this repository.

Acknowledgements

I would like to acknowledge the following people for their contributions to this project:

  1. Dr. Geeta Persad for her guidance, mentorship, and encouragement throughout the development of this package.
  2. Dr. Jane Baldwin for sharing her initial heatwave analysis code that inspired the HDP and providing her expertise on the science of extreme heat.
  3. Dr. Tammas Loughran for developing ehfheatwaves which served as a comparable project and informed the software design of the HDP.
  4. Dr. Ifeanyi Nduka for his design input and expertise in quantifying extreme heat.
  5. (Soon to be Dr.) Sebastian Utama for helping me debug my code and brainstorm ideas.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hdp_python-1.0.2.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hdp_python-1.0.2-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file hdp_python-1.0.2.tar.gz.

File metadata

  • Download URL: hdp_python-1.0.2.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for hdp_python-1.0.2.tar.gz
Algorithm Hash digest
SHA256 f6320dac627d0c053ed4bfd24ff53e84438d554e6ce53da6558292954df96691
MD5 c7864da77d89b8b44bb5329142d81e35
BLAKE2b-256 29e73fb35a32c3593f68e4bbe231f7a5e2a692a2648b29254d42c08f6253a99d

See more details on using hashes here.

File details

Details for the file hdp_python-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: hdp_python-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for hdp_python-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bc59c4e92b56aa809187f529ea3c00d48d6337fcf604e2ba2964d174609daee8
MD5 590266d5af1b1392cd5fb96ebc6f2154
BLAKE2b-256 24bd04b82dc5f333840d127d794db32a1afd1b3677aecdbf2abb8e201418e857

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page