Obtain the climatology and anomalies only for monthly data.
Project description
Climatology and Anomalies in Python
Overview
This code provides experimental and simples tools for differents operations on climate data, mainly obtaining climatologies and anomalies values, in addition to others operations such as data extraction from continent, ocean or a shapefile.
Pip install
pip install clima_anom
Manual installation
clone clima_anom and install in exists or new conda env.
- Clone repo and install
git clone https://github.com/mhacarthur/clima_anom.git
cd clima_anom
pip install .
Dependencies
- Python >= 3.5
- cartopy == 0.18.0
- netcdf4 == 1.5.7
- pyshp == 2.1.3
- Option: Linux
- How to install dependencies
# cartopy
conda install -c conda-forge cartopy
# netcdf4
conda install netcdf4
# pyshp
pip install pyshp
Data
The data use for examples is in directory data. For complete data see:
TRMM Precipitation L3 daily 0.25x0.25 V7
Example
Read data
import os
import clima_anom as ca
data_dir = '..'+os.sep+'data'+os.sep+'3B42_199901_201212.nc'
data = ca.read_netcdf(data_dir,2)
lat = data['lat']
lon = data['lon']
pre = data['prec']
pre_dictionary = ca.data_dictionary(pre)
Colorbar example
import clima_anom as ca
import matplotlib.pyplot as plt
cmap = plt.cm.Spectral_r
cmap_midle_white = ca.colorbar_middle_white(cmap,'middle')
Remove ocean or continent
import numpy as np
import clima_anom as ca
data_dir = '..'+os.sep+'data'+os.sep+'3B42_199901_201212_climatology.nc'
data = ca.read_netcdf(data_dir,2)
lat = data['lat']
lon = data['lon']
pre = data['pre']
pre_continent = ca.remove_continent_ocean(pre,lat,lon,'continent')
pre_ocen = ca.remove_continent_ocean(pre,lat,lon,'ocean')
Extract data using shapefile
import clima_anom as ca
import cartopy.io.shapereader as shpreader
file_shape = '..'+os.sep+'shapefile'+os.sep+''+os.sep+'Amazonas.shp'
amazonas = list(shpreader.Reader(file_shape).geometries())
data_dir = '..'+os.sep+'data'+os.sep+'3B42_199901_201212_climatology.nc'
data = ca.read_netcdf(data_dir,2)
lat = data['lat']
lon = data['lon']
pre = data['pre']
pre_amazonas = ca.extract_shapefile('..'+os.sep+'shapefile'+os.sep+'Amazonas.shp',pre,lat,lon,0)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clima_anom-0.7.8.tar.gz
(12.5 kB
view details)
File details
Details for the file clima_anom-0.7.8.tar.gz
.
File metadata
- Download URL: clima_anom-0.7.8.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73dfefe275f9deff4dac883793f36a829cc5f8b0f2e12c4f730c1a0f07feb856 |
|
MD5 | 6ccca10d2ed10dd3cf5da640b7cb0f0c |
|
BLAKE2b-256 | 7a25395464e7d8f9d3a525e6f0763c794f61ebbf7fd0bb8a1700b6a09f2ed9ee |