Time Series Wind Climate (TSWC)#

The time series wind climate contains a time series of wind_speed and wind_direction. It is the most basic wind climate from which all others can be derived, retaining all original information.

Data Structure#

TSWC objects are xarray.Dataset with the following schema:

Dimensions:  (time, ...)
Variables:
    wind_speed      (time, ...)  - wind speed in m/s
    wind_direction  (time, ...)  - wind direction in degrees

In addition to the core spatial coordinates, TSWC objects contain the time dimension.

I/O#

Format

Read

write

Description

.csv

yes

no

Comma-separated values

.nc

yes

via .to_netcdf()

NetCDF format

Reading:

windkit.read_tswc() reads time series wind climates:

# Read from NetCDF
tswc = wk.read_tswc("wind_data.nc")

# Read from CSV
tswc = wk.read_tswc("wind_data.csv", crs="EPSG:4326")

Writing:

TSWC can be written to NetCDF using xarray’s built-in method:

tswc.to_netcdf("output.nc")

Creating from Arrays#

tswc = xr.Dataset(
    data_vars=dict(
        wind_speed = xr.DataArray(np.random.rand(100, 3)*10, dims=['time', 'height']),
        wind_direction = xr.DataArray(np.random.rand(100, 3)*360, dims=['time', 'height']),
    ),
    coords=dict(
        time = (("time",), pd.date_range('2020-01-01', periods=100, freq='h')),
        height = (("height"), [10, 50, 100]),
    )
)
print(tswc)
<xarray.Dataset> Size: 6kB
Dimensions:         (time: 100, height: 3)
Coordinates:
  * time            (time) datetime64[us] 800B 2020-01-01 ... 2020-01-05T03:0...
  * height          (height) int64 24B 10 50 100
Data variables:
    wind_speed      (time, height) float64 2kB 1.982 4.794 ... 5.668 0.3662
    wind_direction  (time, height) float64 2kB 48.88 210.4 153.7 ... 22.0 230.6

To add spatial information:

tswc = (
    tswc
    .expand_dims("stacked_point")
    .assign_coords(
        west_east = (("stacked_point",), [10.0]),
        south_north = (("stacked_point",), [56.0]),
    )
)

tswc = wk.spatial.set_crs(tswc, crs=4326)
tswc
<xarray.Dataset> Size: 6kB
Dimensions:         (time: 100, height: 3, stacked_point: 1)
Coordinates:
  * time            (time) datetime64[us] 800B 2020-01-01 ... 2020-01-05T03:0...
  * height          (height) int64 24B 10 50 100
    west_east       (stacked_point) float64 8B 10.0
    south_north     (stacked_point) float64 8B 56.0
    crs             int8 1B 0
Dimensions without coordinates: stacked_point
Data variables:
    wind_speed      (stacked_point, time, height) float64 2kB 1.982 ... 0.3662
    wind_direction  (stacked_point, time, height) float64 2kB 48.88 ... 230.6

Creating from DataFrame#

windkit.tswc_from_dataframe() creates TSWC from pandas DataFrames:

data = {
    "wind_speed_10m": np.random.rand(100)*10,
    "wind_speed_50m": np.random.rand(100)*10,
    "wind_direction_10m": np.random.rand(100)*360,
    "wind_direction_50m": np.random.rand(100)*360,
}

df = pd.DataFrame(
    data,
    index=pd.date_range('2020-01-01', periods=100, freq='h'),
)

height_to_columns = {
    10: ("wind_speed_10m", "wind_direction_10m"),
    50: ("wind_speed_50m", "wind_direction_50m"),
}

tswc = wk.tswc_from_dataframe(
    df,
    west_east=10.0,
    south_north=56.0,
    crs=4326,
    height_to_columns=height_to_columns,
)
tswc
<xarray.Dataset> Size: 4kB
Dimensions:         (time: 100, height: 2, stacked_point: 1)
Coordinates:
  * time            (time) datetime64[us] 800B 2020-01-01 ... 2020-01-05T03:0...
  * height          (height) int64 16B 10 50
    west_east       (stacked_point) float64 8B 10.0
    south_north     (stacked_point) float64 8B 56.0
    crs             int8 1B 0
Dimensions without coordinates: stacked_point
Data variables:
    wind_speed      (time, height, stacked_point) float64 2kB 5.129 ... 2.848
    wind_direction  (time, height, stacked_point) float64 2kB 104.4 ... 302.7
Attributes:
    history:          2026-04-23T06:10:33+00:00:\twindkit==2.1.0\twk.tswc_fro...
    Conventions:      CF-1.8
    Package name:     windkit
    Package version:  2.1.0
    Creation date:    2026-04-23T06:10:33+00:00
    Object type:      Time Series Wind Climate
    author:           Default User
    author_email:     default_email@example.com
    institution:      Default Institution

Creating Synthetic Data#

windkit.create_tswc() creates a synthetic TSWC with realistic temporal and spatial correlations, useful for testing and prototyping:

from windkit.spatial import create_point

out_locs = create_point(500000, 6200000, 100, 32632)
tswc = wk.create_tswc(out_locs, weibull_A=7.5, weibull_k=2.0)
tswc
<xarray.Dataset> Size: 1MB
Dimensions:         (point: 1, time: 52560)
Coordinates:
    height          (point) int64 8B 100
    south_north     (point) int64 8B 6200000
    west_east       (point) int64 8B 500000
  * time            (time) datetime64[us] 420kB 2001-01-01 ... 2001-12-31T23:...
    crs             int8 1B 0
Dimensions without coordinates: point
Data variables:
    wind_speed      (time, point) float64 420kB 4.231 4.196 ... 6.313 5.425
    wind_direction  (time, point) float64 420kB 214.1 211.5 ... 148.2 157.8
Attributes:
    Conventions:      CF-1.8
    history:          2026-04-23T06:10:34+00:00:\twindkit==2.1.0\t"point")\n2...
    Package name:     windkit
    Package version:  2.1.0
    Creation date:    2026-04-23T06:10:34+00:00
    Object type:      Time Series Wind Climate
    author:           Default User
    author_email:     default_email@example.com
    institution:      Default Institution

Pass not_empty=False to create a NaN-filled TSWC skeleton instead.

windkit.create_tswc_pair() generates a pair of correlated synthetic TSWCs, useful for testing long-term correction (MCP) methods. The two datasets share the same time axis but differ in Weibull parameters and directional bias:

ref_tswc, tgt_tswc = wk.create_tswc_pair(
    out_locs,
    weibull_A=(6.0, 8.0),
    weibull_k=(1.6, 2.2),
    target_r2=0.8,
)
ref_tswc
<xarray.Dataset> Size: 1MB
Dimensions:         (point: 1, time: 52560)
Coordinates:
    height          (point) int64 8B 100
    south_north     (point) int64 8B 6200000
    west_east       (point) int64 8B 500000
  * time            (time) datetime64[us] 420kB 2001-01-01 ... 2001-12-31T23:...
    crs             int8 1B 0
Dimensions without coordinates: point
Data variables:
    wind_speed      (time, point) float64 420kB 2.933 2.904 2.75 ... 4.838 4.002
    wind_direction  (time, point) float64 420kB 214.1 211.5 ... 148.2 157.8
Attributes:
    Conventions:      CF-1.8
    history:          2026-04-23T06:10:34+00:00:\twindkit==2.1.0\t"point")\n2...
    Package name:     windkit
    Package version:  2.1.0
    Creation date:    2026-04-23T06:10:35+00:00
    Object type:      Time Series Wind Climate
    author:           Default User
    author_email:     default_email@example.com
    institution:      Default Institution

Validation#