{"id":16802753,"url":"https://github.com/mathause/dist_cov","last_synced_at":"2025-04-05T09:14:58.900Z","repository":{"id":163626149,"uuid":"639098248","full_name":"mathause/dist_cov","owner":"mathause","description":"conditional distributions with covariates","archived":false,"fork":false,"pushed_at":"2023-08-31T07:23:02.000Z","size":565,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-10T18:13:45.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathause.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-10T18:54:56.000Z","updated_at":"2024-11-22T11:42:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"df2d484b-f146-4b20-a586-951df40dacdc","html_url":"https://github.com/mathause/dist_cov","commit_stats":{"total_commits":34,"total_committers":1,"mean_commits":34.0,"dds":0.0,"last_synced_commit":"b11418453f01e9a091bc39cb95f4eb83b12dd71a"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathause%2Fdist_cov","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathause%2Fdist_cov/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathause%2Fdist_cov/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathause%2Fdist_cov/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathause","download_url":"https://codeload.github.com/mathause/dist_cov/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312092,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T09:40:34.673Z","updated_at":"2025-04-05T09:14:58.871Z","avatar_url":"https://github.com/mathause.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Distributions with covariates\n\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7922002.svg)](https://doi.org/10.5281/zenodo.7922002)\n\nAuthors: Mathias Hauser\u003csup\u003e1\u003c/sup\u003e, Dominik Schumacher\u003csup\u003e1\u003c/sup\u003e, Sonia I. Seneviratne\u003csup\u003e1\u003c/sup\u003e\n\n\u003csup\u003e1\u003c/sup\u003eInstitute for Atmospheric and Climate Science, Department of Environmental Systems Science, ETH Zurich, Zurich, Switzerland\n\nConditional distributions with covariates\n\n:warning: **Warning**: this package does currently not have any tests.\n\n## Approach\n\nWe use distributions where one (or more) parameter is dependent on a covariate - e.g. the global mean temperature ($T_{glob}$). for the normal distribution model the mean ($\\mu$) and standard deviation ($\\sigma$) as follows:\n\n$\\mu' = \\beta_0 + \\beta_1 * T_{glob}$\n\n$\\sigma' = \\sigma$\n\nAs no such distribution is available in python we adapt distributions in scipy (e.g. [scipy.stats.norm](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.norm.html)).\n\n### Markov chain Monte Carlo (MCMC) sampler\n\nThe parameter uncertainty is estimated with [emcee](https://emcee.readthedocs.io/en/stable/) - an MCMC sampler - see `dist_cov.sample.run_mcmc`. Also check it's website for a good overview. Of course any other MCMCM sampler can be used as well.\n\nI usually describe this as follows: \"We calculate uncertainties in a Bayesian setting and use a Markov Chain MonteCarlo (MCMC) sampler that is affine-transformation invariant (Goodman \u0026 Weare, [2010](https://doi.org/10.2140/camcos.2010.5.6); Foreman-Mackey et al., [2013](https://doi.org/10.1086/67006)) to estimate the parameters of the distributions. Starting from non-informative\u003csup\u003e*\u003c/sup\u003e priors, the converged posterior distributions (50,000\u003csup\u003e**\u003c/sup\u003e non-independent samples) give an estimate of the parameteruncertainty.\n\n\u003csup\u003e*\u003c/sup\u003e Not all priors are non-informative (i.e. when setting a `constrain` in `dist_cov.distributions.gev_cov`)!\n\n\u003csup\u003e**\u003c/sup\u003e This is `n_walker * production` in `dist_cov.sample.run_mcmc`\n\n\n## Installation\n\n### Dependencies\n\ndist_cov depends on the python packages emcee, numpy, and scipy. To run the examples corner.py, matplotlib, and xarray are required as well.\n\n\n### Install development version\n\ndist_cov is not available from pypi or conda-forge, therefore it needs to be installed using pip directly from github.\n\n```bash\npip install git+https://github.com/mathause/dist_cov\n```\n\nTo run the examples also install:\n\n```bash\npip install corner matplotlib xarray\n```\n\n### Install latest released version\n\nGo to the [newest release on github](https://github.com/mathause/dist_cov/releases/latest), copy the URL of the `*.tar.gz` source file at the botton and then use pip to install it (i.e., `pip install ...`).\n\n## Documentation\n\nDocumentation is sparse, but check the [examples](./examples).\n\n## Citing dist_cov\n\nPlease cite Hauser et al. ([2017](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1002/2017EF000612)) or [10.5281/zenodo.7922001](https://doi.org/10.5281/zenodo.7922001) if you are using dist_cov.\n\nIf you use [emcee](https://emcee.readthedocs.io/en/stable/) also consider citing Foreman-Mackey et al. ([2013](https://doi.org/10.1086/67006)) and/ or Goodman \u0026 Weare ([2010](https://doi.org/10.2140/camcos.2010.5.6)).\n\n\n## History\n\nThis code was originally developed for Hauser et al. ([2017](https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1002/2017EF000612)) based on the approach described in Coles ([2001](https://link.springer.com/book/10.1007/978-1-4471-3675-0); Chapter 3).\nIt has been employed in several rapid attribution studies under the auspices of the world weather attribution group, namely:\n- Siberian heatwave of 2020 (Ciavarella et al., [2020](https://www.worldweatherattribution.org/siberian-heatwave-of-2020-almost-impossible-without-climate-change/) and Ciavarella et al., [2021](https://link.springer.com/article/10.1007/s10584-021-03052-w))\n- Western North American heat wave of 2021 (Philip et al., [2021](https://www.worldweatherattribution.org/western-north-american-extreme-heat-virtually-impossible-without-human-caused-climate-change/) and Philip et al., [2022](https://esd.copernicus.org/articles/13/1689/2022/))\n- Indian heat wave of 2022 (Zachariah, et al., [2022](https://www.worldweatherattribution.org/climate-change-made-devastating-early-heat-in-india-and-pakistan-30-times-more-likely/) and Zachariah et al., in review)\n- UK heatwave of 2022 (Zachariah et al. [2022](https://www.worldweatherattribution.org/without-human-caused-climate-change-temperatures-of-40c-in-the-uk-would-have-been-extremely-unlikely/))\n- Northern Hemisphere droughts of 2022 (Schumacher et al., [2022](https://www.worldweatherattribution.org/high-temperatures-exacerbated-by-climate-change-made-2022-northern-hemisphere-droughts-more-likely/) and Schumacher et al., in review)\n\nIt further builds the starting point for modelling extremes in MESMER-X (Quilcaille et al., [2022](https://agupubs.onlinelibrary.wiley.com/doi/full/10.1029/2022GL099012)).\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md).\n\n## License\n\nThis project is published under a MIT license.\n\n\n## References\n\n- Ciavarella, A., Cotterill, D., Stott, P., ... Hauser, M., et al. Prolonged Siberian heat of 2020 almost impossible without human influence. Climatic Change 166, 9 (2021). https://doi.org/10.1007/s10584-021-03052-w\n- Coles, S. (2001), An Introduction to Statistical Modeling of Extreme Values, vol. 208, Springer, London.\n- Foreman-Mackey, D., Hogg, D. W., Lang, D., \u0026 Goodman, J. (2013). emcee: The MCMC hammer.Publications of the Astronomical Society ofthe Pacific,125, 306–312. https://doi.org/10.1086/67006\n- Goodman, J., \u0026 Weare, J. (2010). Ensemble samplers with affine invariance.Communications in Applied Mathematics and ComputationalScience,5(1), 65–80. https://doi.org/10.2140/camcos.2010.5.6\n- Hauser, M., Gudmundsson, L., Orth, R., Jézéquel, A., Haustein, K., Vautard, R., van Oldenborgh, G.J., Wilcox, L. and Seneviratne, S.I. (2017), Methods and Model Dependency of Extreme Event Attribution: The 2015 European Drought. Earth's Future, 5: 1034-1043. https://doi.org/10.1002/2017EF000612\n- Philip, S. Y., Kew, S. F., van Oldenborgh, G. J., Anslow, F. S., Seneviratne, S. I., Vautard, R., Coumou, D., Ebi, K. L., Arrighi, J., Singh, R., van Aalst, M., Pereira Marghidan, C., Wehner, M., Yang, W., Li, S., Schumacher, D. L., Hauser, M., Bonnet, R., Luu, L. N., Lehner, F., Gillett, N., Tradowsky, J. S., Vecchi, G. A., Rodell, C., Stull, R. B., Howard, R., and Otto, F. E. L.: Rapid attribution analysis of the extraordinary heat wave on the Pacific coast of the US and Canada in June 2021, Earth Syst. Dynam., 13, 1689–1713, https://doi.org/10.5194/esd-13-1689-2022, 2022.\n- Quilcaille, Y., Gudmundsson, L., Beusch, L., Hauser, M., \u0026 Seneviratne, S. I. (2022). Showcasing MESMER-X: Spatially resolved emulation of annual maximum temperatures of Earth System Models. Geophysical Research Letters, 49, e2022GL099012. https://doi.org/10.1029/2022GL099012\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathause%2Fdist_cov","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathause%2Fdist_cov","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathause%2Fdist_cov/lists"}