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
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
Built Distribution
File details
Details for the file cryogrid_pytools-0.1.1.tar.gz
.
File metadata
- Download URL: cryogrid_pytools-0.1.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4f76c3bd29a14a463de4b6587646bba99df2014c68f97e0f1eb0ec994737da7 |
|
MD5 | a8633995cc7a5d3b9aafa1dd594f1ee0 |
|
BLAKE2b-256 | ad7791555ef627b5853585683e9d51114b56481fb3bd40af7599ec8cebe7f165 |
File details
Details for the file cryogrid_pytools-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: cryogrid_pytools-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb9de3bcbc13d062632f4b19e25faaf9af7556f6236c9001af42eef314c0e281 |
|
MD5 | 86c624e00f37af72ca01675c707db7e4 |
|
BLAKE2b-256 | c0d364ff677cec7cb538a0db2bfe9f56f90f14bfdd060ab54e24421443e893ce |