Skip to content

carbonplan/ndpyramid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Joe Hamman
May 31, 2022
41f2bed · May 31, 2022

History

89 Commits
Apr 11, 2022
May 31, 2022
May 31, 2022
Mar 25, 2022
Apr 11, 2022
Aug 19, 2021
Apr 4, 2022
Mar 25, 2022
Aug 19, 2021
Apr 29, 2022
Mar 31, 2022
Mar 25, 2022
May 31, 2022
Apr 6, 2022
Apr 4, 2022

Repository files navigation

ndpyramid

A small utility for generating ND array pyramids using Xarray and Zarr.

CI MIT License

installation

Ndpyramid can be installed in three ways:

Using the conda package manager that comes with the Anaconda/Miniconda distribution:

conda install ndpyramid --channel conda-forge

Using the pip package manager:

python -m pip install ndpyramid

To install a development version from source:

git clone https://github.com/carbonplan/ndpyramid
cd ndpyramid
python -m pip install -e .

usage

Ndpyramid provides a set of utilites for creating pyramids with standardized metadata. The example below demonstrates the usage of the pyramid_coarsen and pyramid_reproject utilities. Check out this Jupyter Notebook for a complete demonstration.

import xarray as xr
import rioxarray
from ndpyramid import pyramid_coarsen, pyramid_reproject

# load a sampel xarray.Dataset
ds = xr.tutorial.load_dataset('air_temperature')

# make a coarsened pyramid
pyramid = pyramid_coarsen(ds, factors=[16, 8, 4, 3, 2, 1], dims=['lat', 'lon'], boundary='trim')

# make a reprojected (EPSG:3857) pyramid
ds = ds.rio.write_crs('EPSG:4326')
pyramid = pyramid_reproject(ds, levels=2)

# write the pyramid to zarr
pyramid.to_zarr('./path/to/write')

See the docstrings for more details about input parameters and options.

license

All the code in this repository is MIT licensed, but we request that you please provide attribution if reusing any of our digital content (graphics, logo, articles, etc.).

about us

CarbonPlan is a non-profit organization working on the science and data of carbon removal. We aim to improve the transparency and scientific integrity of carbon removal and climate solutions through open data and tools. Find out more at carbonplan.org or get in touch by opening an issue or sending us an email.