Skip to main content

climatePy

stage Dependencies License: MIT

Description

A Python 📦 for getting point and gridded climate data by AOI. climatePy is the Python version of the climateR R package, providing all of the same functionality but in Python.

As its stated in the climateR README: climatePy simplifies the steps needed to get climate data into Python. At its core it provides three main things:

  1. A climate catalog of over 100,000k datasets from over 2,000 data providers/archives. See (data_catalog())

  2. A general toolkit for accessing remote and local gridded data files bounded by space, time, and variable constraints (dap(), dap_crop(), read_dap_file())

  3. A set of shortcuts that implement these methods for a core set of selected catalog elements


Links


Table of Contents


Installation

climatePy can be downloaded from PyPI via pip like so:

pip install climatePy

Note: climatePy is still in development


Usage

Loading climate catalog

import climatePy
import geopandas as gpd
import matplotlib.pyplot as plt

# load climate catalog
catalog = climatePy.data_catalog()

# load example AOI data
AOI = gpd.read_file('src/data/san_luis_obispo_county.gpkg')

Using climatepy_filter():

The climatepy_filter() is one of the core functions of climatePy and is used to do the first round of filtering on the base climate catalog.

Here we filter down our climate catalog to TerraClim precipitation data for San Luis Obispo County, CA.

# collect raw meta data
raw = climatePy.climatepy_filter(
        id        = "terraclim",
        AOI       = AOI,
        varname   = "ppt"
        )
id asset varname
gridmet agg_terraclimate_ppt_1958_CurrentYear_GLOBE ppt

AOI

San Luis Obispo County county


Getting climate data in AOI

Now lets use the getTerraClim() function from climatePy to get precipitation data for January 1st, 2018 in San Luis Obispo County, CA.

# collect raw meta data
prcp = climatePy.getTerraClim(
    AOI       = AOI,
    varname   = "ppt",
    startDate = "2018-01-01",
    endDate   = "2018-01-01"
    )

Precipitation San Luis Obispo County



Get data within a date range

We can also get data within a date range. we'll use getTerraClim() to get monthly precipitation data for all of 2018 in San Luis Obispo County, CA.

# collect raw meta data
prcp = climatePy.getTerraClim(
    AOI       = AOI,
    varname   = "ppt",
    startDate = "2018-01-01",
    endDate   = "2018-12-01"
    )

2018 precipitation in San Luis Obispo County, CA


Data from known bounding coordinates

climatePy offers support for shapely bounding boxes. Here we are requesting wind velocity data for the four corners region of the USA by bounding coordinates.

from shapely.geometry import box

bbox = box(-112, 34, -105, 39)

bbox = gpd.GeoDataFrame(geometry=[bbox], crs ='EPSG:4326')

vs = climatePy.getGridMET(
       AOI       = bbox,
       varname   = "vs",
       startDate = "2018-09-01"
       )

Daily Wind Velocity Four Corners, USA



Credits

Credit to Mike J Johnson and the other contributors to the original climateR package listed below:


License

GNU General Public License v3.0

climatePy: Find, subset and retrieve climate and geospatial data by AOI in Python. Copyright (C) 2023 Angus Watters, Mike J. Johnson

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.



How to Contribute

If you would like to contribute, submit a PR and we will get to as soon as we can! If you have any issues please open an issue on GitHub. For any questions, feel free to ask @anguswg-ucsb or @mikejohnson51, or simply create an issue on GitHub.

Metadata

Release files for climatePy 0.5.1

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

Source distribution (sdist)

Source distribution for climatePy 0.5.1
File Size Uploaded
climatePy-0.5.1.tar.gz 531.3 kB Details

Built distribution (wheel)

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

Total release size: 1.1 MB

Release files / climatePy-0.5.1.tar.gz

Download URL climatePy-0.5.1.tar.gz
Size 531.3 kB
Tags Source
SHA-256 checksum
How to use checksums
857f52efc2e81cc7a6524bf126673bb90fd607267e81fce5025321918216edf4
BLAKE2b-256 checksum
How to use checksums
2644c2470a2826ed130cd14251a99cbb5dd816c98f543731ff3c9dfcfddd2461
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19

Release files / climatePy-0.5.1-py3-none-any.whl

Download URL climatePy-0.5.1-py3-none-any.whl
Size 535.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ade25c69c886606ca974954947d4b8cbca4bb20b1c26aa8b01189b40995b906
BLAKE2b-256 checksum
How to use checksums
6f87c10bb853349afb4e4230e773e1ce71ad6ff7ca3a0b8321f49023b72b54bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19
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