Bivariate polar plots in Python
Project description
Bivariate polar plots in Python
What it says on the tin. This repo provides functions for producing bivariate polar plots, a useful graphical analysis tool in air pollution research. This implementation is largely based on the R package openair and Carslaw and Beevers (2013) - these sources also provide some excellent example cases of bivariate polar plots in practice.
What bivapp does and does not provide
bivapp is intended to provide bivariate polar plots similar to the implementation in openair and as described by Carslaw and Beevers (2013). It is not intended to be a full-featured alternative to openair, as that package provides enough features that it is effectively a complete data analysis suite for air pollution studies. Many of openair's features are already available in other popular Python libraries. For example, openair provides a function for calculating Theil-Sen slopes, but scikit-learn and scipy already feature such tools.
bivapp currently also does not support producing windroses. See windrose instead. This may change in the future.
Documentation
At this early stage functions are only self-documented. Proper documentation is planned.
Getting started
Install from PyPI: pip install bivapp.
Note that because the dependency pyGAM has fallen behind on maintenance bivapp depends on specific versions of some common dependencies, so you might want to use it in a dedicated virtual environment for the time being.
Here's an example of a basic plotting setup.
from bivapp.sampledata import ImportOpenairDataExample
import bivapp.plots as bp
import cmcrameri.cm as cm
df = ImportOpenairDataExample()
fig, axs = bp.BivariatePlotRawGAM(
df["so2"],
df["ws"],
df["wd"],
pred_res=200,
positive=True,
vmin=None,
vmax=df["so2"].quantile(0.9),
cmap=cm.batlowK,
colourbar_label="SO$_2$ [ppbv]",
masking_method="near",
near_dist=1,
)
fig.set_figwidth(6)
fig.set_figheight(4.5)
Existing solutions
The openair package for R provides all these features, but is obviously in R and not Python. The topic of bivariate polar plots in Python also pops up occasionally, like here, here, here, and here. Lastly, there is the existing windrose library, but it lacks bivariate polar plots.
Differences from openair
Users should be aware that the implementation of smoothed bivariate polar plots in this library differs from openair. openair uses the mgcv R package to fit a thin-plate spline GAM to smooth their bivariate polar plots. In their implementation, they bin input data by wind direction and speed, and then fit the GAM to this binned data. In bivapp there is currently only one method that fits a GAM, BivariatePlotRawGAM. This method differs from openair's in a couple ways: first, the GAM is fit to the raw measurements rather than binned measurements; second, due to differences in GAM libraries (and their documentation), we are not exactly replicating the thin-plate spline approach. Instead, bivapp fits a GAM to a tensor product of the $u$ and $v$ components of the input wind data. Thus, the GAM-smoothed bivariate polar plot in bivapp is not a perfect replication of openair's smoothed plots, but does appear to achieve the same goal of producing a reasonably smoothed plot.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bivapp-0.1.1.tar.gz.
File metadata
- Download URL: bivapp-0.1.1.tar.gz
- Upload date:
- Size: 2.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ffe8042a13a87ec902fd6d55fd4907ba85e21f06a0717099ee78a81e95e07ba
|
|
| MD5 |
3452078bdacd4750647fa241bc11491e
|
|
| BLAKE2b-256 |
018ab2b1d2209fbfba6b7ac3e13bac08137bacb10798cc68f55e7ef6b2c7cd1d
|
Provenance
The following attestation bundles were made for bivapp-0.1.1.tar.gz:
Publisher:
publish-to-pypi.yml on Zelpuz/bivapp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bivapp-0.1.1.tar.gz -
Subject digest:
0ffe8042a13a87ec902fd6d55fd4907ba85e21f06a0717099ee78a81e95e07ba - Sigstore transparency entry: 215741638
- Sigstore integration time:
-
Permalink:
Zelpuz/bivapp@f92ad32d8173ddad352b5ae562c1a5d10deb6c0e -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Zelpuz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@f92ad32d8173ddad352b5ae562c1a5d10deb6c0e -
Trigger Event:
push
-
Statement type:
File details
Details for the file bivapp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: bivapp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 2.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8860359bf92493bf6dcdc58f679faba606c41b7912fc4455fbf4944773ea0674
|
|
| MD5 |
33064834027a8e25ca13bd11a483b98d
|
|
| BLAKE2b-256 |
8d251b2bcfd5894081b895590254eafe3967d760db2a82839d550077fc0e44d4
|
Provenance
The following attestation bundles were made for bivapp-0.1.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on Zelpuz/bivapp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bivapp-0.1.1-py3-none-any.whl -
Subject digest:
8860359bf92493bf6dcdc58f679faba606c41b7912fc4455fbf4944773ea0674 - Sigstore transparency entry: 215741639
- Sigstore integration time:
-
Permalink:
Zelpuz/bivapp@f92ad32d8173ddad352b5ae562c1a5d10deb6c0e -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Zelpuz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@f92ad32d8173ddad352b5ae562c1a5d10deb6c0e -
Trigger Event:
push
-
Statement type: