Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Creating DataArrays

Creating DataArrays in Coordax: A Pedagogical Introduction

This guide demonstrates how to create Field objects (coordax’s equivalent to xarray DataArrays) for different types of scientific data.

1. RGB Image (Height × Width × Channels)

An RGB image has spatial dimensions (height, width) and a channel dimension (R, G, B). Because LabeledAxis ticks must be numeric, we use SizedAxis for the channel dimension.

RGB Image: ('height', 'width', 'channel'), shape: (8, 8, 3)

2. Hyperspectral/Radiance Image (Height × Width × Wavelength)

Hyperspectral images have spatial dimensions plus a wavelength/spectral dimension.

HSI Image: ('y', 'x', 'wavelength'), shape: (8, 8, 16)
Wavelength range: 400.0 - 900.0 nm

3. Time Series (Time)

A simple 1D time series with temporal coordinates.

Time Series: ('time',), shape: (100,)

4. 2D Spatial + Time (e.g., Temperature field over time)

2D+Time Field: ('time', 'y', 'x'), shape: (10, 16, 16)

5. 3D Spatial + Time (e.g., Atmospheric/Ocean model)

3D+Time Field: ('time', 'z', 'y', 'x'), shape: (5, 4, 8, 8)

6. 2D Spatial + Wavelength + Time (Satellite Imagery)

2D+Wavelength+Time: ('time', 'latitude', 'longitude', 'wavelength'), shape: (4, 8, 8, 16)

7. Key Patterns Summary

  • cx.LabeledAxis('name', numeric_array) — axis with physical tick values (ticks must be numeric)
  • cx.SizedAxis('name', size) — axis with only a name and size (no tick values; use for categorical dims)
  • cx.field(data, axis1, axis2, ...) — create a coordinate-aware Field (preferred in coordax >= 0.2)
  • field.coord_fields['dim'] — access coordinate value Field for a dimension
  • field.axes['dim'].ticks — access raw tick values from a LabeledAxis
=== Key access patterns ===
field.dims: ('wavelength',)
field.shape: (8,)
field.axes['wavelength'].ticks[:3]: [400.         471.42857143 542.85714286]
field.coord_fields['wavelength'].data[:3]: [400.         471.42857143 542.85714286]

SizedAxis dims: ('channel',), shape: (3,)