Skip to main content

A Python package for getting point and gridded climate data by AOI

Project description

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 (params())

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

# 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

MIT License

Copyright (c) 2023 Angus Watters, Mike J. Johnson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.



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.

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

climatePy-0.4.41.tar.gz (424.4 kB view details)

Uploaded Source

Built Distribution

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

climatePy-0.4.41-py3-none-any.whl (425.2 kB view details)

Uploaded Python 3

File details

Details for the file climatePy-0.4.41.tar.gz.

File metadata

  • Download URL: climatePy-0.4.41.tar.gz
  • Upload date:
  • Size: 424.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for climatePy-0.4.41.tar.gz
Algorithm Hash digest
SHA256 84f4377a995292562c11ff6a9f8d8a05967f5ad820fb8a58c47f516dce5bb445
MD5 5e346c44e9bc1a19617d96de46c0dd3a
BLAKE2b-256 def0b04ced9b1a529def3534ac32a2e9b1d76f343adf20c8815af766422a6de5

See more details on using hashes here.

File details

Details for the file climatePy-0.4.41-py3-none-any.whl.

File metadata

  • Download URL: climatePy-0.4.41-py3-none-any.whl
  • Upload date:
  • Size: 425.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for climatePy-0.4.41-py3-none-any.whl
Algorithm Hash digest
SHA256 23f6edd0092e17e5b9d2e51a8e451818b898e93a4829111f199eee0a52f770df
MD5 c2ae0e7f4893e506a35056ee080948c0
BLAKE2b-256 d33dba5631d4c53897fb150b02a6d9ce0fd8ae430c04c1bc98290c2c9ae8b742

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