Skip to main content

Library for post processing of MITgcm cubed sphere data

Project description

cubedsphere

Library for post processing of MITgcm cubed sphere data

Capabilities:

  • regrid cubed sphere datasets using xESMF and xgcm
  • open datasets created by the mnc package
  • open datasets using xmitgcm (needs current PR #98)
  • plot original cubed sphere data
  • some more small utilities
  • more to come...

Note:

Work in progress! This library is a collection of tools that I found useful to use for the interpretation of cubed sphere data.

Installation:

Create conda environment:

conda create -n mitgcm

Activate environment:

conda activate mitgcm

prepackaged installation:

Install cubedsphere:

conda install -c conda-forge xesmf esmpy xgcm matplotlib cubedsphere

Alternative: Installation of development version:

Clone this repo:

git clone https://github.com/AaronDavidSchneider/cubedsphere.git
cd cubedsphere

Install dependencies:

conda install -c conda-forge xesmf esmpy xgcm matplotlib

Install cubedsphere:

pip install -e .

You can now import the cubedsphere package from everywhere on your system

Example Usage

See examples/example.py. The following plots have been created using data from tutorial_held_suarez_cs.

import matplotlib.pyplot as plt
import cubedsphere as cs
import cubedsphere.const as c

# Specify directory where the output files can be found
outdir = "/Volumes/SCRATCH/sim_output/xmitgcm_test/nc_test"

# open Dataset
ds = cs.open_mnc_dataset(outdir, 276480)

# regrid dataset
regridder = cs.Regridder(ds, 5, 4, reuse_weights=False, filename="weights", concat_mode=False)
# Note: once weights were created, we can also reuse files by using reuse_weights=True (saves time).
ds_reg = regridder.regrid()

Only takes few seconds!

# do some basic plotting to demonstrate the dataset
# determine which timestep and Z to use:
isel_dict = {c.time:0, c.Z:0}

# do some basic plotting to demonstrate the dataset
fig = plt.figure(figsize=(8,6), constrained_layout=True)
ds_reg[c.T].isel(**isel_dict).plot(vmin=260,vmax=312, add_colorbar=False)
U, V = ds_reg["U"].isel(**isel_dict).values, ds_reg["V"].isel(**isel_dict).values
cs.overplot_wind(ds_reg, U, V)
plt.gca().set_aspect('equal')
plt.savefig("../docs/temp_reg.png")
plt.show()

# Now also plotting theta without regridding (on the original grid):
fig = plt.figure(figsize=(8,6), constrained_layout=True)
cs.plotCS(ds[c.T].isel(**isel_dict), ds, mask_size=5, vmin=260, vmax=312)
plt.gca().set_aspect('equal')
plt.savefig("../docs/temp_direct.png")
plt.show()

Tests with xmitgcm:

See examples/example_xmitgcm.py

Since we do not have the grid information, we need to fallback to the nearest_s2d interpolation with concat mode. Concat mode means that instead of regridding each face individually and summing up the results, we first concatenate the ds along the X dimension and regrid on the flattened dataset afterwards.

We can fix this and keep using conservative regridding by using the grid files from the mnc dataset:

In the future we will use xmitgcm.utils.get_grid_from_input function instead.

ToDo:

Postprocessing:

  • interface xmitgcm to enable the use of .meta and .data files -> added wrapper
  • how do we expand lon_b and lat_b from left to outer for xmitgcm wrapper? -> either nc file or soon with xmitgcm.utils.get_grid_from_input

Testing:

  • compare results with matlab scripts

Interface:

  • which values should be hardcoded? -> done in const.py
  • special tools needed for exorad?

future Ideas:

Regridding tools:

  • use ESMPy as an alternative to xESMF (requires 6 processors)

Credits

Many of the methods come from: https://github.com/JiaweiZhuang/cubedsphere

I would especially like to thank @rabernat for providing xgcm and @JiaweiZhuang for providing xESMF.

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

cubedsphere-0.1.1.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

cubedsphere-0.1.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file cubedsphere-0.1.1.tar.gz.

File metadata

  • Download URL: cubedsphere-0.1.1.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.0 requests/2.24.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0

File hashes

Hashes for cubedsphere-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5a576a829ed78ad582052db1fc774e1f3a760271dd3f0f97d8d41eb2d352d1a5
MD5 ac7f1119851681cff25713af6cee51a1
BLAKE2b-256 38c12f19352547a23ffb7598862e17aa6e6502e346424973b2ace72b75b2d5ba

See more details on using hashes here.

File details

Details for the file cubedsphere-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cubedsphere-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.0 requests/2.24.0 setuptools/49.6.0.post20201009 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.0

File hashes

Hashes for cubedsphere-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c18e9b43c376d50d183bcf4ea7c9dae783c7b6b47a9d5b579f3509354695c823
MD5 e6eda4a1a585adceb11664e06ecb868a
BLAKE2b-256 55338ceb3a6bbd82b72f0409da63149a6cd506df51bfa333ad73e9ea0133400b

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