Skip to main content

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.BivariatePlotGAM(
    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)

Example from BivariatePlotRawGAM

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, split this data into wind vector components, and then fit the GAM to this binned-then-split data. In bivapp there is currently only one method that fits a GAM, BivariatePlotGAM. This method differs from openair's in a few ways:

  1. The GAM can be fit to either raw measurements or binned data;
  2. If fitting to binned data, the binning is applied after splitting the wind data into vector components rather than before. In other words, where openair bins then splits, we split then bin.
  3. Due to differences in GAM libraries (and their documentation), this package does not exactly replicate the thin-plate spline approach. Instead, bivapp uses the pygam package to fit 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.

Even with these differences, both packages can produce similar-looking plots that should permit comparable qualitative analyses. In both this package and openair, fitting a GAM serves to smooth the data, allowing for identification of potential emissions sources from noisy data.

Metadata

Release files for bivapp 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bivapp 0.2.0
File Size Uploaded
bivapp-0.2.0.tar.gz 2.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for bivapp 0.2.0
File Interpreter ABI Platform
bivapp-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.2 MB

Release files / bivapp-0.2.0.tar.gz

Download URL bivapp-0.2.0.tar.gz
Size 2.6 MB
Tags Source
SHA-256 checksum
How to use checksums
34f0cc1fe7bba48ac75c33c775f5efb36522dcd0d02623e5ce4398eb7e2320f8
BLAKE2b-256 checksum
How to use checksums
ad301246e5813b9be2ca96ce12479e4aeeca37c6d9cbf31be6db5cde66916589
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2025.

Transparency log

Release files / bivapp-0.2.0-py3-none-any.whl

Download URL bivapp-0.2.0-py3-none-any.whl
Size 2.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
34100561471e147b0606ed2098a61810e43af17f561e4403afaed09e2abb63e3
BLAKE2b-256 checksum
How to use checksums
91b4f6d80ef9589e65861e43f763c4cd4d829bf0cc5f1426bcc9a4570f508d82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 21, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page