xarray¶
synthetic
¶
Synthetic climate datasets shaped like open-climate-service stores.
Every generator returns an xr.Dataset with dims (time, y, x) — the
normalized layout OCS writes to its zarr stores — daily time steps, lat/lon-like
coordinates on a regular grid, and CF-style attrs (units, long_name).
Deterministic for a given seed, so examples and tests are reproducible.
Functions:¶
temperature_dataset(days=30, ny=20, nx=30, seed=0)
¶
Return a daily 2 m temperature dataset with dims (time, y, x).
Values are degrees Celsius: a base field with a north-south gradient, a seasonal-ish sine over time, and gaussian noise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
days
|
int
|
Number of daily time steps; must be at least 1. |
30
|
ny
|
int
|
Grid height; must be at least 1. |
20
|
nx
|
int
|
Grid width; must be at least 1. |
30
|
seed
|
int
|
Seed for the random noise component. |
0
|
Returns:
| Type | Description |
|---|---|
Dataset
|
A dataset with one data variable |
Raises:
| Type | Description |
|---|---|
ValueError
|
If days, ny, or nx is less than 1. |
Source code in xarray/src/ocs_stack_xarray/synthetic.py
precipitation_dataset(days=30, ny=20, nx=30, seed=0)
¶
Return a daily precipitation dataset with dims (time, y, x).
Values are mm/day: zero on dry days (roughly 60 percent of the field), gamma-distributed amounts otherwise — the zero-inflated shape real rainfall data has, which matters for masking and skipna examples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
days
|
int
|
Number of daily time steps; must be at least 1. |
30
|
ny
|
int
|
Grid height; must be at least 1. |
20
|
nx
|
int
|
Grid width; must be at least 1. |
30
|
seed
|
int
|
Seed for the random components. |
0
|
Returns:
| Type | Description |
|---|---|
Dataset
|
A dataset with one data variable |
Raises:
| Type | Description |
|---|---|
ValueError
|
If days, ny, or nx is less than 1. |