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 coordinates, TSWC objects contain the time dimension.
I/O#
Format |
Read |
write |
Description |
|---|---|---|---|
|
yes |
no |
Comma-separated values |
|
yes |
via |
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 8.118 7.161 9.722 ... 2.419 9.152
wind_direction (time, height) float64 2kB 229.9 312.5 149.4 ... 141.5 313.0
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 8.118 ... 9.152
wind_direction (stacked_point, time, height) float64 2kB 229.9 ... 313.0Creating 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 2.475 ... 1.269
wind_direction (time, height, stacked_point) float64 2kB 334.4 ... 287.0
Attributes:
history: 2026-01-29T09:30:18+00:00:\twindkit==2.0.1\twk.tswc_fro...
Conventions: CF-1.8
Package name: windkit
Package version: 2.0.1
Creation date: 2026-01-29T09:30:18+00:00
Object type: Time Series Wind Climate
author: Default User
author_email: default_email@example.com
institution: Default InstitutionValidation#
windkit.validate_tswc()- Validate TSWC dataset structurewindkit.is_tswc()- Check if dataset is valid TSWC