Skip to main content

Compare meterological station data to gridded data

Project description

Build Coverage Documentation Status Downloads per month PyPI version


A package for comparing weather station data to gridded weather data including gridMET and other gridded datasets that are hosted on Google Earth Engine. Major functionality includes:

  • pairing of station locations with overlapping grid cells

  • downloading point data from gridded datasets on Google Earth Engine or gridMET data from OpenDap server

  • calculation of mean bias ratios between station and gridded data and other statistics

  • performing spatial interpolation of bias ratios with multiple options

  • building geo-referenced vector and raster data of spatially interpolated bias ratios and statistics

  • extraction of zonal means from spatially interpolated bias ratios using the gridded dataset resolution

  • production of interactive time series and scatter plot comparisons between station and gridded data

  • calculation and plotting of the residuals between spatially interpolated bias ratios and those computed at station locations

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.

gridwxcomp was used to create monthly bias ratios of gridMET reference evapotranspiration (ETo) data relative to ETo calculated at irrigated weather stations. The bias ratios were subsequently interpolated and used to correct gridMET ETo which is a key scaling flux for most of the remote sensing models that are part of the OpenET platform.

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

If you are experiencing errors on installing the gridwxcomp conda environment above with dependencies. For example, if the Shapely package is not installing from the enironment.yml file, remove it or modify it from the “setup.py” file in the install requirements section before you install gridwxcomp from source with:

$ pip install -e .

More help with installation issues related to dependency conflicts can be found in the gridwxcomp issues on GitHub, be sure to check the closed issues as well.

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

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

gridwxcomp-0.1.4.post4.tar.gz (11.8 MB view details)

Uploaded Source

Built Distribution

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

gridwxcomp-0.1.4.post4-py2.py3-none-any.whl (12.2 MB view details)

Uploaded Python 2Python 3

File details

Details for the file gridwxcomp-0.1.4.post4.tar.gz.

File metadata

  • Download URL: gridwxcomp-0.1.4.post4.tar.gz
  • Upload date:
  • Size: 11.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for gridwxcomp-0.1.4.post4.tar.gz
Algorithm Hash digest
SHA256 b720bdcef6af94b6ac166273320b15d9ce9e5ae701fecb38ae97af8cbb363deb
MD5 ef1fa4c86d411b0e51e2bf4a1fbf58d6
BLAKE2b-256 19d961cb24f981e605dda7c0c706ac8a6bfeed7ae579133160f9feaf9e946cf1

See more details on using hashes here.

File details

Details for the file gridwxcomp-0.1.4.post4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for gridwxcomp-0.1.4.post4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d63410ac2481ce1deb1223c826139f5edc07c926f6bba5c3c1510fa8490c88db
MD5 47488b39762054f11df5c863adb3bf97
BLAKE2b-256 50f1097869eaad699e9cf306f8e97fe14424ba85345f8d17d8e27b796da81511

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