pywasp.bwc_from_tswc#
- pywasp.bwc_from_tswc(ds, hist=None, normalize=True, revert_to_original=True, wsbin_width=1, n_wsbins=30, n_sectors=12, wind_dir_crs=None)[source]#
Add timeseries to histogram
Converts a time series with wind speed & direction to derive summed histogram of the wind vector.
Warning
This function is experimental and its signature may change.
- Parameters:
ds (
Dataset) – PyWAsP Timeseries dataset. Can have any of the pywasp spatial data structureshist (
Dataset, optional) – Histogram with dimensions point, wsbin, sector containing counts to add to this time series. The input is not modified. Default is None, creating a histogram using wsbin_width, n_wsbins, and n_sectors.normalize (
bool) – Normalize histogram for each sector, storing the frequency per sector in “wdfreq” variable, Default Truerevert_to_original (
bool) – If True (default), operate on and return ds’s own native spatial structure directly – there is no promotion/reversion round trip to pay for any more, unlike before. If False, promote to point structure and return that; still useful when composing with other point-structured accumulators, e.g. across chunked calls.wsbin_width (
float) – width of wind speed binsn_wsbins (
int) – Number of wind speed binsn_sectors (
int) – Number of sectors (wind direction bins)wind_dir_crs (
CRS-like, optional) – CRS that defines the output wind-direction frame. Ifdshas awind_dir_crsattribute, input directions are treated as already expressed in that CRS frame. Otherwise, input directions are assumed true-north-relative. Directions are rotated into a projected target CRS’s grid-north frame before binning; a geographic target CRS retains them in the true-north frame.
- Returns:
hist (
Dataset) – Histogram with dimensions point, wsbin, sector containing the values from the time series. The per-location count_bins_exceeded diagnostic is retained for both normalized and unnormalized output.
Notes
NumPy-backed inputs are evaluated eagerly. Dask-backed inputs remain lazy and histogram each time chunk independently before a tree reduction, preserving the input spatial chunks. Dask is therefore optional. For lazy output, inspect count_bins_exceeded after computation instead of relying on the eager bin-overflow warning.
The result’s
count,count_missingandrecovery_percentageattributes need the actual data values (a missing-sample count) and are therefore only set for eager input;start_time,end_timeandcount_expectedare always set. For lazy input, or once any chunk in an accumulation has been lazy, those three attributes are omitted rather than reported as a number that could be wrong.