Skip to main content

Tools for processing cubed-sphere data.

Project description

m21ctools

m21ctools is a Python library designed to handle cubed-sphere data efficiently. It provides tools for reading, processing, interpolating, and visualizing data from NetCDF-4 files, making it easier to work with cubed-sphere grids in climate, meteorological, and geospatial applications.

Key Features

Data Loading and Cleaning

  • Reading NetCDF Files:
    Easily read cubed-sphere data from NetCDF-4 files using the xarray library with the h5netcdf engine.
  • Handling Duplicate Dimensions:
    Automatically resolves issues with duplicate 'ncontact' dimension names by replacing them with unique names, ensuring the dataset is ready for analysis.

Longitude Adjustment

  • Standardizing Coordinates:
    Automatically adjusts longitudes to fall within the standard range of -180° to 180°.

Data Aggregation

  • Combining Data Faces:
    Aggregates data from the six faces of the cubed-sphere into flat lists, which simplifies further analysis and processing.

Interpolation to Regular Grid

  • Grid Interpolation:
    Interpolates irregular cubed-sphere data onto a regular latitude-longitude grid using efficient methods from SciPy.

Visualization

  • Plotting Tools:
    Visualizes the interpolated data with contour plots using Matplotlib and Cartopy, complete with coastlines and axis labels.

Usage Example

Below is a simple example to get you started:

from m21ctools.data_handler import CubedSphereData

# Initialize the CubedSphereData object with your NetCDF file and desired settings.
data_handler = CubedSphereData(
    file_path="path/to/your/datafile.nc4",
    time=0,
    lev=0,
    variable="QV",
    resolution=1.0
)

# Access raw and cleaned data.
raw_data = data_handler.raw_data
clean_data = data_handler.raw_data_cleaned

# Retrieve aggregated latitudes, longitudes, and data as flat 1D arrays.
all_lats, all_lons, all_data = data_handler.all_lats, data_handler.all_lons, data_handler.all_data

# Interpolate data to a uniform latitude-longitude grid.
lat_grid, lon_grid, data_grid = data_handler.interpolate_to_latlon_grid(method='linear')  # Default interpolation method is 'linear'

# Visualize the data.
data_handler.plot_data(lat_grid, lon_grid, data_grid)

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

m21ctools-0.1.31.tar.gz (184.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

m21ctools-0.1.31-py2.py3-none-any.whl (182.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file m21ctools-0.1.31.tar.gz.

File metadata

  • Download URL: m21ctools-0.1.31.tar.gz
  • Upload date:
  • Size: 184.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for m21ctools-0.1.31.tar.gz
Algorithm Hash digest
SHA256 e3ec75adf4bcb4364d0d965a7ab67b15a69f827321dce66cf65d870329d505c1
MD5 ff7a1eccb0746f74bd83962aabde52f5
BLAKE2b-256 594c176fd57688083267b54e4160898217b5c4fb8ab988d15b193473104ec7ae

See more details on using hashes here.

File details

Details for the file m21ctools-0.1.31-py2.py3-none-any.whl.

File metadata

  • Download URL: m21ctools-0.1.31-py2.py3-none-any.whl
  • Upload date:
  • Size: 182.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for m21ctools-0.1.31-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 53a743080eab5d5bff4090ebd2125210e390d6b4758e2d91f09ad5b8e768b89e
MD5 f4d275977bab2a0320f31342d068efb3
BLAKE2b-256 201641e256222cb989081735e5df7971bb71dd806a1199f2f95e8f3aaad57ec7

See more details on using hashes here.

Supported by

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