windkit.io.wasp.parse_gwc_element#

windkit.io.wasp.parse_gwc_element(gwc, context='GWC element')[source]#

Parse a RveaGeneralisedMeanWindClimate XML element.

Only the .tag / .attrib / .find / .findall subset of the ElementTree interface is used, so both lxml.etree and xml.etree.ElementTree elements are accepted.

Parameters:
  • gwc (lxml.etree._Element or xml.etree.ElementTree.Element) – The RveaGeneralisedMeanWindClimate element.

  • context (str, optional) – Identifier used in error messages, typically the source file path.

Returns:

Dictionary with keys:

  • "A" : ndarray, shape (n_sectors, n_heights, n_roughnesses)

  • "k" : ndarray, same shape as A

  • "wdfreq" : ndarray, same shape as A, normalized along the sector axis (0-1)

  • "sector" : ndarray, shape (n_sectors,), sector centre angles in degrees

  • "gen_roughness" : ndarray, shape (n_roughnesses,)

  • "gen_height" : ndarray, shape (n_heights,)

  • "coords" : dict with "west_east", "south_north", "height"; the first two come from an embedded RveaLatitudeLongitudeCoordinate and "height" is always None (the element does not carry one). Values are None when absent.

  • "metadata" : dict with "description" (the Description attribute, or None when absent)

  • "barometric_reference" : dict with the floats "source_elevation", "source_elevation_temperature", "surface_pressure" (Pa), "temperature_celcius", "relative_humidity" (%) and "lapse_rate" (K/m, None before WAsP 12.6), from BarometricReferenceData

  • "stability_inputs" : dict with arrays of shape (n_sectors,) "sector", "mean_temp_scale_land", "rms_temp_scale_land", "mean_temp_scale_sea", "rms_temp_scale_sea", "mean_pblh_scale_land" and "mean_pblh_scale_sea", from StabilityInputs

  • "geostrophic_shear" : dict with arrays of shape (n_sectors,) "sector", "mean_dgdz" (1/s) and "mean_dgdz_dir" (degrees), from GeostrophicShearRose

The last three are None when the element does not carry them.

Return type:

dict

Raises:
  • WindkitFileFormatError – If a required attribute is missing or an attribute does not parse, or the stability inputs or geostrophic shear lack a sector or repeat one.

  • ValueError – If the element has another tag, holds no WindAtlasWeibullWindRose, the grid size cannot be determined, a wind rose cannot be placed on the grid, a grid cell has no rose or more than one, or a rose lacks a sector or repeats one. WindkitFileFormatError subclasses it.