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
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)
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.
fixAccess 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.
fixUse 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).
fixEnsure 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)