Synthetic data¶
tutorial ¶
Synthetic OPERA DISP granules with a known truth, for examples and tests.
make_disp_stack(directory) writes a small frame of granules that open like
real ones, and returns the displacement they were built from, so a result can
be checked against the truth. The gallery and the test suite use it.
The files copy the layout of real granules (see tests/data/disp_s1_layout.md):
one 2D (y, x) layer per variable, chunked and gzip-compressed with shuffle, a
length-1 time coordinate, a reference_time variable, a spatial_ref
grid mapping, and the /corrections, /identification and /metadata
groups. Each ministack's reference date is the last secondary date of the
previous ministack, as in real frames.
Request a stack by variant name through :func:make_disp_stack.
make_gnss_source(ds, pixels, cache_dir) serves synthetic GNSS stations
that follow the DISP displacement at given pixels, through the geepers source
interface, so :func:disp_xr.gnss.load and :func:disp_xr.residuals.compare
run without a network (gnss extra). vertical_los(ds) gives matching
static layers.
VARIANTS
module-attribute
¶
VARIANTS = ('two_ministacks', 'three_ministacks', 'with_gaps', 'duplicate', 'mixed_dtype', 'nisar', 'two_utm_zones')
DispStack
dataclass
¶
make_disp_stack ¶
make_disp_stack(root: Path, variant: str = 'two_ministacks', *, epochs_per_ministack: int = 5, shape: tuple[int, int] = (64, 64), seed: int = 0) -> DispStack
Write a synthetic DISP-S1 stack under root and return its truth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
Directory to write into (created if missing). |
required |
variant
|
str
|
One of :data:
|
'two_ministacks'
|
epochs_per_ministack
|
int
|
Secondaries per ministack. |
5
|
shape
|
tuple[int, int]
|
|
(64, 64)
|
seed
|
int
|
Seed for the noise. |
0
|
Returns:
| Type | Description |
|---|---|
DispStack
|
Paths and truth. |
Examples:
correlated_noise ¶
correlated_noise(shape: tuple[int, int], *, correlation_range: float, sill: float = 1.0, nugget: float = 0.0, spacing: float = SPACING, seed: int = 0) -> np.ndarray
Return a Gaussian random field with a known exponential covariance.
The covariance is sill * exp(-3 h / correlation_range) (practical
range correlation_range, the convention of
:class:disp_xr.residuals.VariogramModel) plus nugget of white
noise, so variogram and cell-sigma estimates can be checked against the
truth. Exact, by circulant embedding on a grid twice the size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
(int, int)
|
|
required |
correlation_range
|
float
|
Practical range, in the unit of |
required |
sill
|
float
|
Variance of the correlated part. |
1.0
|
nugget
|
float
|
Variance of the added white noise. |
0.0
|
spacing
|
float
|
Pixel spacing. |
SPACING
|
seed
|
int
|
Random seed. |
0
|
Examples:
make_gnss_source ¶
make_gnss_source(ds: Dataset, pixels: list[tuple[int, int]], cache_dir: str | Path, *, noise: float = 0.001, extra_rate: dict[int, float] | None = None, seed: int = 0)
Return a geepers GNSS source whose stations follow DISP at pixels.
Each station sits at a (row, col) pixel; its daily up motion is that
pixel's displacement (interpolated to days) plus white noise, with east
and north zero, so it matches DISP under a vertical line of sight
(:func:vertical_los). Needs the gnss extra (geepers).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Chained, re-referenced DISP with a CRS. |
required |
pixels
|
list of (int, int)
|
Station pixels; stations are named |
required |
cache_dir
|
str or Path
|
geepers cache directory (nothing is downloaded). |
required |
noise
|
float
|
Standard deviation of the daily noise and the station sigmas (m). |
0.001
|
extra_rate
|
dict
|
Station index to an added up rate (m/yr), to make an outlier. |
None
|
seed
|
int
|
Seed of the noise. |
0
|
Returns:
| Type | Description |
|---|---|
geepers source
|
Pass it as |
Examples: