windkit.create_tswc_pair#

windkit.create_tswc_pair(output_locs, date_range=None, seed=9876538, weibull_A=(8.0, 7.2), weibull_k=(2.1, 2.3), target_r2=0.8, smooth_sigma=1.5, speed_tau=14400.0, direction_mean=240.0, direction_kappa=1.5, direction_tau=21600.0, direction_bias=5.0, direction_noise_std=15.0, spatial_correlation_length=10000.0)[source]#

Create a pair of correlated synthetic TSWC datasets.

Generates a first TSWC with realistic temporal and spatial correlations, then derives a second TSWC that is correlated with the first but has different Weibull parameters (speed bias) and a directional bias.

Parameters:
  • output_locs (xarray.Dataset) – Output geospatial information.

  • date_range (pandas.DatetimeIndex or None) – Time range. If None, defaults to one year (2001) at 10 min resolution.

  • seed (int) – Random seed for reproducibility.

  • weibull_A (tuple of float) – Weibull scale parameters [m/s] for the first and second dataset.

  • weibull_k (tuple of float) – Weibull shape parameters for the first and second dataset.

  • target_r2 (float) – Target Pearson r-squared between the two datasets’ speeds.

  • smooth_sigma (float) – Gaussian filter width in time steps for latent smoothing.

  • speed_tau (float) – Autocorrelation e-folding timescale for speed [s].

  • direction_mean (float) – Prevailing wind direction [degrees].

  • direction_kappa (float) – Von Mises concentration around prevailing direction.

  • direction_tau (float) – Autocorrelation timescale for direction [s].

  • direction_bias (float) – Constant directional bias of the second dataset relative to the first [degrees].

  • direction_noise_std (float) – Std of Gaussian angular noise added to the second dataset’s direction [degrees].

  • spatial_correlation_length (float) – Spatial e-folding length scale for inter-point correlation within each dataset. Only relevant when output_locs contains multiple points.

Returns:

  • tswc_1 (xarray.Dataset) – First TSWC dataset.

  • tswc_2 (xarray.Dataset) – Second TSWC dataset.

Examples

Create a measurement/reference pair for MCP testing:

>>> import pandas as pd
>>> from windkit.spatial import create_dataset
>>> import windkit as wk
>>> locs = create_dataset(10.0, 55.0, 100.0, 4326).drop_vars("output")
>>> dates = pd.date_range("2020-01-01", periods=8760, freq="h")
>>> meas, ref = wk.create_tswc_pair(locs, date_range=dates)

Customize Weibull parameters and target correlation:

>>> meas, ref = wk.create_tswc_pair(
...     locs,
...     date_range=dates,
...     weibull_A=(9.0, 7.5),
...     weibull_k=(2.0, 2.4),
...     target_r2=0.85,
... )

Both outputs are valid TSWC datasets:

>>> wk.validate_tswc(meas)
>>> wk.validate_tswc(ref)