Skip to main content
Python Package Index Conda Version https://zenodo.org/badge/215552269.svg

xlayers: Python implementation of MITgcm’s layer package

xlayers allows you to transform your data from a regular vertical grid (like depth) to a vertical grid defined based on contours of some variable (like density). xlayers uses FORTRAN code from the layers package of the MITgcm, which was written by Ryan Abernathey.

We recommend using this package on xarrays, but it can also be applied to numpy arrays. This example may be helpful in getting started.

Why a new vertical regridding package?

xlayers has many advantages over other similar tools. It conserves the total quantity of the input variable in the water column: this is particularly important when performing volume or heat budgets in density space. xlayers outputs the thickness-weighted variable in density space, which makes thickness-weighted averaging easier. This output is mapped in a smooth and sensible way. xlayers is also very fast and parallelizable.

Installation

xlayers can be installed from PyPI with pip:

python -m pip install xlayers

It is also available from conda-forge for conda installations:

conda install -c conda-forge xlayers

To install xlayers from source repository, the fortran-compiler package is required. The easiest way to install the fortran-compiler is via conda :

conda install -c conda-forge fortran-compiler
unset LDFLAGS

Once the compiler is installed, now we can install xlayers from Github:

git clone https://github.com/cspencerjones/xlayers.git
cd xlayers
python setup.py install

Features

xlayers is property conserving, meaning that the total amount of your variable in the water column will not change when it is transformed into the new coordinate system.

xlayers acheives this using binning: it bins the variable onto a much finer vertical grid, estimates the depth of the new coordinate surfaces, and adds up these bins in the new space.

Inputs

This package expects your initial coordinate system to be on a structured grid. i.e. it will not take density as an initial vertical variable, but depth is ok.

Before running layers_xarray, you must run finegrid to define some of the binning parameters needed. finegrid takes 2 inputs (which should both be numpy arrays): the vertical depth of the gridcells, and the vertical distance between the centers of the grid cells. The second variable should be loneger by 1 than the first, because it includes the distance between the cell center of the top cell and the sea surface, and the distance between the cell center of the bottom cell and the domain bottom.

The first two inputs to layers_xarray should be on the same gridpoints. data_in is the variable to be remapped and theta_in is the variable that defines the location of the new coordinate system.

Outputs

The output of layers_xarray is thickness weighted, i.e. if the input variable is salinity, the output variable is the salinity in each layer multiplied by the depth of the layer. In order to get an output that has the same units as the input, divide by the thickness of the layer (which you can get by inputting an array of ones into layers_xarray instead of you input variable data_in).

Get in touch

  • Report bugs, suggest features or view the source code on GitHub.

Release files for xlayers 0.2.2

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

Source distribution (sdist)

Source distribution for xlayers 0.2.2
File Size Uploaded
xlayers-0.2.2.tar.gz 127.2 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for xlayers 0.2.2
File
xlayers-0.2.2-pp36-pypy36_pp73-manylinux2010_x86_64.whl PyPy 3.6 PyPy 3.6 7.3 Linux glibc 2.12+ x86-64 Details
xlayers-0.2.2-pp36-pypy36_pp73-macosx_10_9_x86_64.whl PyPy 3.6 PyPy 3.6 7.3 macOS 10.9+ x86-64 Details
xlayers-0.2.2-pp27-pypy_73-manylinux2010_x86_64.whl PyPy 2.7 PyPy 7.3 Linux glibc 2.12+ x86-64 Details
xlayers-0.2.2-pp27-pypy_73-macosx_10_9_x86_64.whl PyPy 2.7 PyPy 7.3 macOS 10.9+ x86-64 Details
xlayers-0.2.2-cp38-cp38-manylinux2010_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-64 Details
xlayers-0.2.2-cp38-cp38-manylinux2010_i686.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-32 Details
xlayers-0.2.2-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
xlayers-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 Details
xlayers-0.2.2-cp37-cp37m-manylinux2010_i686.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-32 Details
xlayers-0.2.2-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details
xlayers-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 Details
xlayers-0.2.2-cp36-cp36m-manylinux2010_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-32 Details
xlayers-0.2.2-cp36-cp36m-macosx_10_9_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 Details

Total release size: 13.4 MB

Release files / xlayers-0.2.2.tar.gz

Download URL xlayers-0.2.2.tar.gz
Size 127.2 kB
Tags Source
SHA-256 checksum
How to use checksums
93f6954ba589685bc39fcee490ca86810471b072ce06082fe53bd35b2b2478ca
BLAKE2b-256 checksum
How to use checksums
6c24d65026c67e8f3162f92fbafd83c4ffcf2c8a3abf0bc9f630cc22cbe4d278
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-pp36-pypy36_pp73-manylinux2010_x86_64.whl

Download URL xlayers-0.2.2-pp36-pypy36_pp73-manylinux2010_x86_64.whl
Size 940.0 kB
Tags Linux glibc 2.12+ x86-64 PyPy 3.6 PyPy 3.6 7.3
SHA-256 checksum
How to use checksums
37155243b095d337b6a68b072d209efc4188e617b95dffa47a2a1810bff831f6
BLAKE2b-256 checksum
How to use checksums
f48604d6f7c4b5567e62e2c9138381ff300b5d9863ccb31248b19897c138c4a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-pp36-pypy36_pp73-macosx_10_9_x86_64.whl

Download URL xlayers-0.2.2-pp36-pypy36_pp73-macosx_10_9_x86_64.whl
Size 1.2 MB
Tags PyPy 3.6 PyPy 3.6 7.3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
fed7e9fec25a12320f5745fa9da98c8cde6f9ef3c4a58539fe6ef881a45ff809
BLAKE2b-256 checksum
How to use checksums
ad520b793895e419e77a9706c0aaa39a3d7c315798ac65dc614bbc7bdaec05a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-pp27-pypy_73-manylinux2010_x86_64.whl

Download URL xlayers-0.2.2-pp27-pypy_73-manylinux2010_x86_64.whl
Size 939.4 kB
Tags Linux glibc 2.12+ x86-64 PyPy 2.7 PyPy 7.3
SHA-256 checksum
How to use checksums
cb8d3f90336f8c7c8fe2e4970a0773bffc33f68cffe826ff7b86369ea9bca854
BLAKE2b-256 checksum
How to use checksums
932188f521d34291ce9a759ba9ae3553015701f69e148653c5528c3d563489af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-pp27-pypy_73-macosx_10_9_x86_64.whl

Download URL xlayers-0.2.2-pp27-pypy_73-macosx_10_9_x86_64.whl
Size 1.2 MB
Tags PyPy 2.7 PyPy 7.3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
787d8c8178939ce5f2580667a6cbd07c85e08569b9791042a1d93f3aac13321c
BLAKE2b-256 checksum
How to use checksums
79921579142ad4a9d657ac1d3fb9e71ec76f56e2e488ffbaba1070337f016227
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-cp38-cp38-manylinux2010_x86_64.whl

Download URL xlayers-0.2.2-cp38-cp38-manylinux2010_x86_64.whl
Size 1.0 MB
Tags CPython 3.8 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
30dd347a2b5c57c3e00192e2e2bb70aca143cb1a6fae76e99daf6bc196bc4723
BLAKE2b-256 checksum
How to use checksums
f9f3f0c7d7cb0a533b1f165c8da8d7b872b724c20b4d298eb7e9aa710b08a097
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-cp38-cp38-manylinux2010_i686.whl

Download URL xlayers-0.2.2-cp38-cp38-manylinux2010_i686.whl
Size 841.9 kB
Tags CPython 3.8 Linux glibc 2.12+ x86-32
SHA-256 checksum
How to use checksums
33f90df71f08aed2035e40d46d4c347f852c982dd132a14236187bd146c67944
BLAKE2b-256 checksum
How to use checksums
b73173ee601c8636a52a1d3a602bc3661a172864879a8615604dd3e2bb8af727
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-cp38-cp38-macosx_10_9_x86_64.whl

Download URL xlayers-0.2.2-cp38-cp38-macosx_10_9_x86_64.whl
Size 1.2 MB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
799b68942d6eef5cc8865a77e8a14fb8818863a95cf8c301e0aa11c39d2faada
BLAKE2b-256 checksum
How to use checksums
bd049ae72461865e002d23c62df4a6c2538c40e3919fd4e9c3018b66505e6236
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl

Download URL xlayers-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl
Size 1.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
8f445ac1cc03195366ea4e6cebbb3ad95babfff0db6e2f01fcb52a9f405da7a8
BLAKE2b-256 checksum
How to use checksums
d7c9d6d43318acb94a8564a8522c2a47d5c1706fe031aa087e1a033087a8d482
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-cp37-cp37m-manylinux2010_i686.whl

Download URL xlayers-0.2.2-cp37-cp37m-manylinux2010_i686.whl
Size 841.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-32
SHA-256 checksum
How to use checksums
87d50d4ce51691ece7f847590323bb14122b895019bc3cdf9762781a33641782
BLAKE2b-256 checksum
How to use checksums
f3d050f567bbdbc50babf0bc0f863a9b357a6184782c8e00273a9ce8a5da3ec5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL xlayers-0.2.2-cp37-cp37m-macosx_10_9_x86_64.whl
Size 1.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
d8adccd112f4467f493edefa3e91e88f94daf40d226e8ad1a3411b5b453044a9
BLAKE2b-256 checksum
How to use checksums
0cc8b45b526073e8b33573a777d61089e746e15f7f8a9cad0d0b439392de5a92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl

Download URL xlayers-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl
Size 1.0 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
7fbda8deee8dd313091da7e819609831bf64bcd6a93035b739327d5763b9d2e7
BLAKE2b-256 checksum
How to use checksums
463b679464ca89d6ece8275cf3d3ecc786f32859b8490e50405658e7d3e3edc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-cp36-cp36m-manylinux2010_i686.whl

Download URL xlayers-0.2.2-cp36-cp36m-manylinux2010_i686.whl
Size 838.3 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-32
SHA-256 checksum
How to use checksums
9aa87d6e4fd5f37ae8dc5b0a7665742580e4dfb2f008dfa76b8309923e0156d9
BLAKE2b-256 checksum
How to use checksums
118919d9bfcd74943d6609469bc5a6aeeee83de95f76c7e7201a4c71f87617e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release files / xlayers-0.2.2-cp36-cp36m-macosx_10_9_x86_64.whl

Download URL xlayers-0.2.2-cp36-cp36m-macosx_10_9_x86_64.whl
Size 1.2 MB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
ee45cdabb330586c3a5f34f8679a763c921bdc1bde4480dcc3ab10681005fbb7
BLAKE2b-256 checksum
How to use checksums
57ec4487dcf55b93aa407db89f139e1b6eba55d471ea0be0e422c3b21f2dae62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.2.2 This release

14 release files

0.2

10 release files

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