|
| 1 | +# What is a climate cube? |
| 2 | + |
| 3 | +A **climate cube** is an `xarray.DataArray` or `xarray.Dataset` whose data are |
| 4 | +organized along shared space-time axes. The most common arrangement in this |
| 5 | +project is `(time, y, x)` for single-band cubes or `(time, y, x, band)` for |
| 6 | +multi-band collections. Each pixel stores the value of an environmental |
| 7 | +variable (e.g., reflectance, temperature, precipitation) measured at a given |
| 8 | +location `(y, x)` and instant `time`. |
| 9 | + |
| 10 | +## Why cubes? |
| 11 | + |
| 12 | +Satellite constellations (Sentinel-2, Landsat), gridded climate products |
| 13 | +(GRIDMET, PRISM), and model reanalyses are all naturally expressed as climate |
| 14 | +cubes because their data are already gridded over regular spatio-temporal |
| 15 | +coordinates. By sticking with `xarray`, we get labeled dimensions, lazy loading |
| 16 | +(with `dask`), and robust metadata handling. |
| 17 | + |
| 18 | +This package focuses on *streaming* cubes rather than requiring local |
| 19 | +downloads. Utilities such as `climate_cube_math.data.sentinel2.load_s2_cube` |
| 20 | +wrap remote APIs (e.g., Cubo) so that users can request an area/time window and |
| 21 | +immediately operate on the returned `xarray` cube inside notebooks or scripts. |
| 22 | + |
| 23 | +## Cube processing layers |
| 24 | + |
| 25 | +The rest of the documentation walks through the primary layers of the |
| 26 | +`climate_cube_math` workflow: |
| 27 | + |
| 28 | +1. **Data layer** – load space-time cubes (`load_s2_cube`). |
| 29 | +2. **Indices & anomalies layer** – derive vegetation indices and z-scores |
| 30 | + (`compute_ndvi_from_s2`, `zscore_over_time`). |
| 31 | +3. **Synchrony layer** – measure rolling correlation and tail dependence versus |
| 32 | + a reference pixel (`rolling_corr_vs_center`, `rolling_tail_dep_vs_center`). |
| 33 | +4. **Visualization layer** – explore cubes interactively with the Lexcube |
| 34 | + widget (`show_cube_lexcube`) and QA plots (`plot_median_over_space`). |
| 35 | + |
| 36 | +## Conceptual cube example |
| 37 | + |
| 38 | +```python |
| 39 | +import xarray as xr |
| 40 | + |
| 41 | +# Generic climate cube shape |
| 42 | +# time: T time steps, y: rows, x: columns |
| 43 | +cube = xr.DataArray( |
| 44 | + data, # shape (T, Y, X) |
| 45 | + coords={"time": time_coords, "y": y_coords, "x": x_coords}, |
| 46 | + dims=("time", "y", "x"), |
| 47 | + name="my_variable", |
| 48 | +) |
| 49 | +``` |
| 50 | + |
| 51 | +Once data are in this form, every operation in `climate_cube_math` simply |
| 52 | +composes transformations on the cube without ever breaking the labeled axes. |
0 commit comments