Skip to main content

Tools to read in CryoGrid MATLAB data to Python, includes forcing, outputs, DEMs, etc.

Project description

CryoGrid-pyTools

Tools to read in CryoGrid MATLAB data to Python, includes forcing, outputs, DEMs, etc.

Feel free to use, modify, and distribute as you see fit.

Installation

pip install cryogrid_pytools

Usage

This package can read in

  • CryoGrid output (from OUT_regridded_FCI2)
  • simple MATLAB struct files (not run_info.mat)
  • ERA5 forcing
  • excel run configuration files (experimental)

Basic examples are shown below for the first two items, but see demo.ipynb for more comprehensive examples.

Reading single CryoGrid output files

Currently, only output files from the calss OUT_regridded_FCI2 are supported. However, the majority of files you'll use follow this format.

import cryogrid_pytools as cgt

# a single file that should look something like this
fname = "results_from_RUN_SIMPLE/<project_name>_<YYYYMMDD>.mat"

# currently the only output from OUT_regridded_FCI2 is supported
dataset = cgt.read_OUT_regridded_FCI2_file(fname)

Reading multiple CryoGrid output files

If you're working with RUN_SPATIAL_SPINUP_CLUSTERING, you can read in multiple files at once. The data are returned as an xarray.Dataset with the dimensions: [gridcell, depth, time]

# path contains wildcards where cluster ID and date are respectively
fname = "results_from_RUN_SPATIAL_SPINUP_CLUSTERING/project_name_*_*.mat"

# deepest_point is the deepest point in the saved files
dataset = cgt.read_OUT_regridded_FCI2_clusters(fname, deepest_point=-5)

Reading struct files from MATLAB

TIP: In MATLAB, You need to add the `CryoGrid/source` directory to the MATLAB path before the file can be loaded properly.

Note that run_info.mat cannot be read as it contains special classes that are not supported by scipy.io.loadmat. To save parts of run_info, use the following code in MATLAB:

run_info_spatial = run_info.SPATIAL.STATVAR
save "run_info_spatial.mat" run_info_spatial

Then, in Python:

fname = 'path_to_file/run_spatial_statvar.mat'
spatial = cgt.read_mat_struct_as_dataset(fname, index=['Y', 'X'])

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

cryogrid_pytools-0.1.4.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

cryogrid_pytools-0.1.4-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file cryogrid_pytools-0.1.4.tar.gz.

File metadata

  • Download URL: cryogrid_pytools-0.1.4.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for cryogrid_pytools-0.1.4.tar.gz
Algorithm Hash digest
SHA256 996623446b3a9827e2708e77fbd2d5d64b5badc452c4094abe0e57e5f6fde668
MD5 952b52c4787857f7b99ed3aacdb498a6
BLAKE2b-256 babc82f18fd56d3366fdbeeb2d9150fbb43fbb626c8a66b57a5268e32e0768cc

See more details on using hashes here.

File details

Details for the file cryogrid_pytools-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for cryogrid_pytools-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6fcd3ffadd05d0023e18d37bf2f99aab10d7ffd7eb83c7d79bdb5c97ae6b8433
MD5 777cdb8516a0438d2e2b90450da3f34d
BLAKE2b-256 b151b8511635e97a00be5319d6e08a5935d0a50439f88ec63358bf54e7ae7569

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page