pywasp.align_direction_crs#

pywasp.align_direction_crs(wind_climate, target_wind_dir_crs, source_wind_dir_crs=None, conf=None)[source]#

Align a wind climate to a target wind-direction CRS.

Wind directions may be expressed relative to true north or relative to the grid north of a projected CRS. This helper rotates the directional part of a wind climate from source_wind_dir_crs into target_wind_dir_crs at the climate locations and stores the target frame in the wind_dir_crs attribute.

The simpler the wind climate, the harder this operation is to perform without information loss. TSWC direction values are rotated directly and therefore retain the original time-series information. BWC sector histograms are resampled, so information is limited by sector and wind-speed bin resolution. WWC and GWC contain only sectoral Weibull parameters and frequencies, so rotation is the most compressed approximation and relies on conserving moments during sector rotation.

Parameters:
  • wind_climate (xarray.Dataset) – TSWC, BWC, WWC, or GWC dataset. GeoWC is not supported because it contains additional directional variables that cannot be rotated by the WWC sector-rotation routine.

  • target_wind_dir_crs (CRS-like) – Coordinate reference system whose grid north should define the output wind-direction frame.

  • source_wind_dir_crs (CRS-like, optional) – Coordinate reference system whose grid north defines the input wind-direction frame. If omitted, the function reads wind_climate.attrs["wind_dir_crs"]. All supported wind climates require explicit source-frame metadata.

  • conf (pywasp.wasp.Config, optional) – Configuration object passed to wwc_rotate for WWC and GWC input.

Returns:

xarray.Dataset – Wind climate with directions aligned to target_wind_dir_crs and a wind_dir_crs attribute containing the target CRS WKT. The spatial CRS metadata is preserved from the input.

Raises:

ValueError – If wind_climate is unsupported, if source-frame metadata is missing, or if a GeoWC is passed.