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 for scientists and engineers 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 customizable 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.3.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.3-py2.py3-none-any.whl (182.7 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: m21ctools-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 b15180d9e77eb93c3fcbba743f2953ca23d1ae48b98c5d5609c210281619463b
MD5 ab582b1e0071b39a2763c108ebc48aa3
BLAKE2b-256 8ea37c2037022563369a945330583123ce4eddaec497bb59587122a4dd91fe91

See more details on using hashes here.

File details

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

File metadata

  • Download URL: m21ctools-0.1.3-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.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b6a8126e77c7499777a4b971465e71d37b327394854ad4702fdc78d42b436f37
MD5 eb6d41117a531f38a8b95f858930621c
BLAKE2b-256 595b9f91ca6e40c519111353f8712732d6ce4516f52524519b399be950f76281

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