Skip to main content

Unofficial PERSIANN Python API.

Project description

persiann_api

The persiann_api python package was built in order to make data more readily available for data scientist, analyst, etc, that wish to work with weather data through the PERSIANN database. It is not an official API for the PERSIANN project.

The PERSIANN database is made from the "system developed by the Center for Hydrometeorology and Remote Sensing (CHRS) at the University of California, Irvine (UCI) uses neural network function classification/approximation procedures to compute an estimate of rainfall rate at each 0.25° x 0.25° pixel of the infrared brightness temperature image provided by geostationary satellites."

As our API currently download the data in the GeoTIFF format, every "pixel" in the .tiff file would be the value of the rainfall rate at the 0.25° x 0.25° space.

PERSIANN data. Screenshot taken from https://chrsdata.eng.uci.edu/ .

The screenshot above was taken from https://chrsdata.eng.uci.edu/, which is the official site for the PERSIANN project. This was taken from Brazil in the 28th of December!

Installation

Install it throught pip or Poetry, if you already have the gdal package.

pip install persiann_api
poetry add persiann_api

The gdal package is not so easy to straightforward install. Click in this link for the official guide in PyPi, click here.

There is also this guide for Ubuntu users, click here. This is the summary for Ubuntu users:

sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt-get update
sudo apt-get update
sudo apt-get install gdal-bin

ogrinfo --version

Then, install the specific version of GDAL from the previous output.

sudo apt-get install libgdal-dev
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal

pip install GDAL==[SPECIFIC VERSION FROM THE 'ogrinfo' OUTPUT]

Usage

The API has one main function that downloads the data inside a folder given some parameters.

from persiann_api.main import download_data
from PIL import Image

# downloads daily data and store each data from date inside the folder.
download_data(
    from_date=datetime.date(2021, 12, 28),
    to_date=datetime.date(2021, 12, 28),
    folder='data/',
    # bounding box for Brazil
    lat_bb=(-35, 6),
    lon_bb=(-69, -36)
)
# read the GeoTIFF with your favorite package
geotiff_path = 'data/2021_12_28.tiff'
arr = np.asarray(Image.open(geotiff_path, mode='r'))[::-1] # we must mirror the array for the GeoTIFF.
plt.imshow(arr)
plt.clim(0, 78)

PERSIANN data for Brazil from 28st December of 2021.

See? This is the same data as the first original data!

This is a longer example to put here, but in the notebooks folder you can find the code to generate this picture:

PERSIANN data for Brazil from 28st December of 2021.

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

persiann_api-0.1.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

persiann_api-0.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file persiann_api-0.1.1.tar.gz.

File metadata

  • Download URL: persiann_api-0.1.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.10 Linux/5.4.0-96-generic

File hashes

Hashes for persiann_api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a044199d861b1e729bf78207b19e6f21f1f924198c11eda1c8ecab32d7fc9854
MD5 0f6831d7001c01a291bbc28d00c38a56
BLAKE2b-256 9d68fb0fc9f70a90ba1196cf4136703dc8cf5681809ff1a51131aa072419452f

See more details on using hashes here.

File details

Details for the file persiann_api-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: persiann_api-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.8.10 Linux/5.4.0-96-generic

File hashes

Hashes for persiann_api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0aab71e46359be4abafd8b99d476cf02ea0547e129edc370175eecce9127d10
MD5 de6c7658f08cc289f17143390fbd0df5
BLAKE2b-256 33894277085649ebaa127167507e0123c5494ad59bddd1fcbc85e9df5582bae2

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