Skip to main content

gridwxcomp

A package for comparing climate station time series data to gridMET (or other gridded) data. Major functionality includes tools to:

  • pair station locations with overlapping grid cells

  • download gridMET data from OpenDap server

  • calculate mean bias ratios between station and gridded data and other statistics

  • spatial interpolation of bias ratios with multiple interpolation options

  • build geo-referenced files of point data and interpolated rasters

  • extract zonal means for a subset of gridcells

  • graphics, e.g. time series comparisons and interpolated residuals at stations

Bias ratios calculated by gridwxcomp can be used to correct bias of grid to station data based on the properties of the stations. For example, monthly humidity ratios between station and grid for stations within agricultural settings can be used to estimate grid bias relative to agricultural locations. gridwxcomp includes an intuitive command line interface and a Python API.

Documentation

Online documentation

Installation

Currently we recommend using the provided conda environment file to install gridwxcomp and its dependencies in a virtual environment. Download the environment.yml file and then install and activate it. If you don’t have conda get it here. To install dependencies in a virtual environment run

$ conda env create -f environment.yml

To activate the environment before using gridwxcomp run

$ conda activate gridwxcomp

Optionally, install using pip,

$ pip install gridwxcomp

Due to dependency conflicts you may have issues directly installing with pip before activating the conda environment.

Alternatively, or if there are installation issues, you can manually install. First activate the gridwxcomp conda environment (above). Next, clone or download the package from GitHub or PyPI and then install locally with pip in “editable” mode. For example with cloning,

$ git clone https://github.com/WSWUP/gridwxcomp.git
$ cd gridwxcomp
$ pip install -e .

If you downloaded the source distribution then run pip install -e . in the root directory where the setup.py file is located. This installation method is ideal if you want to be able to modify the source code.

Quick start from command line

This example uses data provided with gridwxcomp including climate variable time series data for four climate stations, it uses the gridMET as the gridded dataset however any uniform gridded data product can be used with gridwxcomp if extra information including a vector grid file is provided.

After installation you can find the location of the data needed for the example by typing the following at the command line,

$ python -c "import pkg_resources; print(pkg_resources.resource_filename('gridwxcomp', 'example_data/Station_Data.txt'))"

Once complete, this example will calculate bias ratios between station and gridMET ETr (reference evapotranspiration), spatially interpolate GeoTIFF rasters of bias ratios at 400 meter resolution, and calculate zonal statistics of mean bias ratios for each gridMET cell in the region of the stations, similar to what is shown in the figure below.

https://raw.githubusercontent.com/WSWUP/gridwxcomp/master/docs/source/_static/test_case.png

The same procedure can be done for climate variables other than ETr, e.g. observed evapotranspiration, temperature, precipitation, wind speed, short wave radiation, etc.

After installing with pip the gridwxcomp command line interface can be used from any directory, the first step pairs climate station data with their nearest gridMET cell and produces a CSV file used in the following steps,

$ gridwxcomp prep-input <PATH_TO example_data/Station_Data.txt>

This will result in the file “merged_input.csv”. Next download matching gridMET climate time series with OpeNDAP by running

$ gridwxcomp download-gridmet-opendap merged_input.csv -y 2016-2017

The time series of gridMET data that correpond with the stations in “merged_input.csv” will be saved to a new folder called “gridmet_data” by default. In this case only the years 2016-2017 are used.

Next, to calculate mean monthly and annual bias ratios for each station/gridMET pair along with other statistics and metadata and save to CSV files,

$ gridwxcomp calc-bias-ratios merged_input.csv -o monthly_ratios

Last, to calculate interpolated surfaces of mean bias ratios and extract zonal means to gridMET cells using the default interpolation method (inverse distance weighting):

$ gridwxcomp spatial monthly_ratios/etr_mm_summary_comp_all_yrs.csv -b 5

The [-b 5] option indicates that we want to expand the rectangular bounding area for interpolation by five gridMET cells (extrapolation in the outer regions).

GeoTIFF rasters of interpolated ratios will be saved to “monthly_ratios/spatial/etr_mm_invdist_400m/”. Note, the gridMET variable name (etr_mm), the interpolation method (invdist), and the raster resolution (400m) are specified in the output directory. A fishnet grid with gridMET id values and a point shapefile of station ratios should all be created and saved in the “monthly_ratios/spatial/” directory.

The output file “monthly_ratios/spatial/etr_mm_invdist_400m/gridMET_stats.csv” contains monthly bias ratios for each gridMET cell in the interpolation region, similar to what is shown below.

GRIDMET_ID

Jan_mean

Feb_mean

Mar_mean

…

515902

0.66

0.76

0.96

…

514516

0.66

0.77

0.96

…

513130

0.67

0.77

0.97

…

511744

0.67

0.78

0.97

…

510358

0.68

0.79

0.97

…

…

…

…

…

…

Note GRIDMET_ID is the index of the master gridMET dataset 4 km fishnet grid starting at 0 in the upper left corner and moving across rows and down columns. This value can be joined with previously created data, e.g. the ID values can be joined to centroid coordinates of gridMET cells.

Bar plots that show the residual between station mean ratios and interpolated estimates are saved to “monthly_ratios/spatial/etr_mm_invdist_400m/residual_plots/”.

To get abbreviated descriptions for any of the above gridwxcomp commands use the [--help] option, e.g.

$ gridwxcomp spatial --help

Metadata

Release files for gridwxcomp 0.1.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 gridwxcomp 0.1.0
File Size Uploaded Provenance Actions
gridwxcomp-0.1.0.tar.gz 1.6 MB Without provenance Details for gridwxcomp-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gridwxcomp 0.1.0
File Interpreter ABI Platform Actions
gridwxcomp-0.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for gridwxcomp-0.1.0-py2.py3-none-any.whl

Total release size: 13.7 MB

Release files / gridwxcomp-0.1.0.tar.gz

Download URL gridwxcomp-0.1.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
64887f10f8b0717bb596fcb9ae2d212a830b5d512cd08b1767f84207e09e5453
BLAKE2b-256 checksum
How to use checksums
6fae7652a6011c4e54e53cf2e3be96bdea19c4746a0b570753b0b35693bce66f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.8

Release files / gridwxcomp-0.1.0-py2.py3-none-any.whl

Download URL gridwxcomp-0.1.0-py2.py3-none-any.whl
Size 12.2 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
cec8f411f7d599df808bcb19731137bfd997ba235d2140d52d6be16016d68af5
BLAKE2b-256 checksum
How to use checksums
d4f224ce80a23216bd4cec4b8d507c3e110ef94810199a0abc5f16e59dad9853
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.1.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.8

Security for gridwxcomp 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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