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 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.2.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.2-py2.py3-none-any.whl (182.7 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: m21ctools-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 8f18b6c7b4302af616bb455acccd2cc10f41bb09113ff15dc34779b69fd1e4d6
MD5 17c48a916c4f8c0eed8164bcaeeb92a6
BLAKE2b-256 8bab809541acbc163e815b69d9bd0c536190b527c747e637363cf80f7068373d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: m21ctools-0.1.2-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.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ba985a67b09d20f5bc330a3a88111472a67c9ad16c4ed25c36897acd45ed8b7f
MD5 e0a8622ad7e3431fa0c95de1e4d04fa0
BLAKE2b-256 9319b8b9c992884930f4e872907c589e650d4b856012eb3fd4fd0fbdb2dace8f

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