pywasp.stability_histogram#

pywasp.stability_histogram(ds, hist=None, finalize=True, revert_to_original=True, wsbin_width=1, n_wsbins=40, n_sectors=12, percentile=0.5, wv_count=None, landmask=None)[source]#

Add timeseries to existing histogram

Uses the stability parameters “temp_scale” and “ustar_over_pblh”. See the paper “Using observed and modelled heat fluxes for improved extrapolation of wind distributions” for the definitions of these variables. The temp_scale variable is defined as $T_*$ in that paper, whereas the “ustar_over_pblh” should be defined as $u_*/pblh$ as input for this function. This is done to give priority to the smallest pblh that are most important for the wind profile. The output is reversed ($**-1$) to give the input format as required by WAsP ($pblh/u_*$). The time dimension is copied so that one can see what was the period that was used to generate the histogram. This method is optimized for large datasets, where storing all values in memory is not possible. It uses a binning so that the stability parameters are calculated as a conditional mean (on the wind speed and direction) in a single pass through the data. The histogram is created if not provided, but it can also be provided to add more data to an existing histogram. The idea is than that you sum to the existing histogram and then finalize at the end using finalize=True. When using finalize=True, the histogram is converted into a mean and standard deviation of the stability parameters per wind speed and direction bin. To calculate both sea and land stability, you will have to provide a landmask so that the finalize step can separate between sea and land points.

Warning

This function is experimental and its signature may change.

Parameters:
  • ds (xarray.Dataset) – Dataset containing variables [‘wind_speed’, ‘wind_direction’, ‘temp_scale’, ‘ustar_over_pblh’] Can have any pywasp spatial structure

  • hist (xarray.Dataset) – Histogram with dimensions point, wsbin, sector

  • finalize (bool) – Convert the stabilility histogram into a mean and standard deviation?

  • revert_to_original (bool) – Return the histogram input in original format from the input ds? If false, keeps the data in stacked point format which is more efficient when doing large calculations for numerical wind atlases.

  • wsbin_width (float) – width of wind speed bins

  • n_wsbins (int) – Number of wind speed bins

  • n_sectors (int) – Number of sectors (wind direction bins)

  • percentile (float) – Percentile of the wind speed distribution to use for calculating the stability parameters. Default is 0.5, which is the median.

  • wv_count (xarray.Dataset, optional) – Histogram with dimensions point, wsbin, sector containg a count. If provided, this histogram is used for the finalization step. If None, a new histogram is created from the input ds. Default is None.

  • landmask (DataArray) – Landmask with values 0 (sea) and 1 (land)

Returns:

hist (xarray.Dataset) – Histogram with dimensions point, wsbin, sector with the values from ds-timeseries added.

Raises:
  • ValueError – If landmask is provided, but does not have the same spatial structure as ds.

  • ValueError – If hist is provided, but does not have the same spatial structure as ds.

  • ValueError – If landmask is provided, finalize=True and there are only land or sea points in ds.