Registry / data / ndcube

ndcube

JSON →
library2.4.1pypypi✓ verified 85d ago

A Python package for multi-dimensional contiguous and non-contiguous coordinate aware arrays, built on sunpy and astropy. Current version 2.4.0, release cadence irregular. Works with NumPy arrays and supports powerful slicing and dicing with World Coordinate System (WCS) awareness.

pip install ndcube
INSTALL
IMPORT
SIG · NDCUBE
N
ndcube
datapythonv2.4.1
Install
46.8s avg
Import
6258ms
Disk
470MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.3.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
1/2 runs
✓ 34.45s
py 3.11
1/2 runs
✓ 56.2s
py 3.12
1/2 runs
✓ 53.5s
py 3.13
1/2 runs
✓ 52.55s
py 3.9
1/2 runs
✓ 37.45s
470MB installed
● package 470MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NDCube
from ndcube import NDCube
from ndcube.ndcube import NDCube
ndcube.ndcube is the internal module, but the public API is directly under ndcube
NDCollection
from ndcube import NDCollection
from ndcube.collection import NDCollection
NDCollection is also available directly under ndcube since v2.0

Minimal demo of NDCube creation and slicing.

import numpy as np from ndcube import NDCube, NDCollection # Create a simple 2D array data = np.random.rand(10, 10) wcs = None # For simplicity; in practice, provide astropy WCS cube = NDCube(data, wcs) print(cube) print(cube.shape) # Slice along first axis slice1 = cube[0] print(slice1.shape) # Create collection of cubes cubes = [NDCube(np.random.rand(5,5), None) for _ in range(3)] collection = NDCollection(cubes, meta={'source': 'test'}) print(collection)
Debug
Known issues
breakingAPI change in v2.0: NDCube.crop returns a new NDCube, not a tuple of slices.
fix
If upgrading from v1.x, update code that assigns crop result to multiple variables.
affects: >=2.0.0
deprecatedNDCubeSequence is deprecated since v2.1; use NDCollection instead.
fix
Replace ndcube.NDCubeSequence with ndcube.NDCollection.
affects: >=2.1.0
gotchaWhen slicing an NDCube, the result may drop WCS information if the slice is not a view (e.g., fancy indexing). Always check cube.wcs after slicing.
fix
Use boolean or integer array indexing with caution; prefer basic slicing.
affects: all
gotchaInstalling from source may require Cython and numpy headers if not using wheels. Wheels are provided for common platforms, but on rare architectures you may need to build.
fix
Install via conda (conda install -c conda-forge ndcube) to avoid compilation.
affects: all
Errors
Common errors & fixes
AttributeError: 'NDCube' object has no attribute 'unit'
ndcube v2.0 removed the 'unit' attribute in favor of astropy unit in the WCS.
fix
Access units via cube.wcs.world_axis_units or similar astropy properties.
ImportError: cannot import name 'NDCubeSequence' from 'ndcube'
NDCubeSequence was removed in ndcube v2.1.
fix
Use ndcube.NDCollection instead of ndcube.NDCubeSequence.
ValueError: The dimension of the WCS does not match the data.
Data array has fewer dimensions than WCS expects (common when slicing).
fix
Ensure the data shape matches the number of WCS axes, or use cube.drop_axis() after slicing.
Upgrade
Version history
2.4.1latest on PyPI · released Jun 10, 2026
Audit
Dependencies
sunpyrequiredNDCube is built on sunpy's WCS and coordinate framework
astropyrequiredFor unit handling and WCS support
matplotliboptionalFor plotting functionality (ndcube provides visualization wrappers)
Agent activity
4 hits · last 30 days
node
4
Resources
ndcube — pip install ndcube · libregistry