Skip to main content

marutils - Utilities for working with MAR RCM outputs

This package contains utilities/tools that make it easier to open MAR RCM outputs.

  • Load outputs straight into an xarray Dataset with standard dimensions names (time, y, x).
  • Provide a path with a wildcard expression (*) to automatically load several years of MAR files at once, concatenating them along the time axis.
  • Plays nicely with Dask - chunking options default to 365-366 days (but can be changed at will).
  • Loaded Datasets are automatically "geo-aware" using the rioxarray .rio accessor - no more trying to work out MAR's geo-referencing manually!
  • Helper functions for turning X-hourly variables into continuous time series.
  • Helper functions for masking.

QuickStart

import marutils
# Open a time series for the 21st century.
mar_outputs = marutils.open_dataset('MARv3.11.2/MAR*20*.nc')

# Check out the coordinates.
print(mar_outputs.coords)
Coordinates:
  * x            (x) float32 -760000.0 -740000.0 -720000.0 ... 660000.0 680000.0
  * y            (y) float32 -1180000.0 -1160000.0 ... 1480000.0 1500000.0
  * SECTOR       (SECTOR) float32 1.0 2.0
  * SECTOR1_1    (SECTOR1_1) float32 1.0
  * time         (time) datetime64[ns] 2019-01-01T12:00:00 ... 2019-12-31T12:...
  * ATMLAY3_3    (ATMLAY3_3) float32 0.99974793
    spatial_ref  int64 0

# What is proj.4 string for the geo-referencing of this dataset?
print(mar_outputs.rio.crs.to_proj4())
+proj=stere +lat_0=70.5 +lon_0=-40 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs=True

Installation

At the moment, manually:

git clone <repository>
cd <repository>
pip install -e .

Soon to be available via pyPI.

Working with X-hourly outputs

To return an X-hourly variable with a single, continuous hourly time variable:

hourly_air_temperatures = marutils.xhourly.Xhourly_to_time(mar_outputs.TTH)

Useful notes

Pixel corners vs centres

It's useful to remember that netCDF file geo-referencing treats X,Y coordinates as pixel (cell) centres. In contrast, the rasterio/GDAL data model treats X,Y coordinates as pixel upper-left corners.

In the QuickStart section above we loaded a 20 km resolution dataset. The minimum and maximum X coordinates are -760000 and 680000 m respectively. These correspond to the centres of the min/max pixels.

Through the .rio accessor we can check on the bounds/complete spatial extent of the file:

# What is the centre of the top-left cell? (xmin, ymin, xmax, ymax)
mar_outputs.rio.bounds()
(-770000.0, 1510000.0, 690000.0, -1190000.0)

We can see that these bounds account for the 20 km pixel size of this dataset.

Caveats

The geo-referencing capabilities have so far been tested only for Greenland datasets. If you have problems trying to load other domains, please post an issue on this repository.

Metadata

Release files for marutils 1.0.0

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

Source distribution (sdist)

Source distribution for marutils 1.0.0
File Size Uploaded Provenance
marutils-1.0.0.tar.gz 7.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for marutils 1.0.0
File Interpreter ABI Platform
marutils-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.7 kB

Release files / marutils-1.0.0.tar.gz

Download URL marutils-1.0.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
614b531112c7974aaec543bfbcbd05a06a35b83c7e380b769829fc19edda38b8
BLAKE2b-256 checksum
How to use checksums
0621322bfc434ceeb49deaae154fba4141c82a279d2850169277f1b522b70e58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1

Release files / marutils-1.0.0-py3-none-any.whl

Download URL marutils-1.0.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
618d9290e53031b5742476a15527e9aae0d5fb51a5d2f1472b1b77b048724f44
BLAKE2b-256 checksum
How to use checksums
0878fb7671fc9076aa0910dc23916134aa94009797238d50e866b9f25996885a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1

Security for marutils 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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