Wind Climate Formats#

.tab - Binned Wind Climate#

Text format storing wind speed frequency distributions per sector.

Functions: read_tab(), write_tab(), format_tab()

Normalization: read_tab returns frequencies normalized to 0-1. write_tab and format_tab accept 0-1 values and convert to per-mille (wsfreq) and percent (wdfreq) for the file format.

Return structure:

{
    "wsfreq": np.ndarray,    # (n_wsbins, n_sectors) - wind speed frequencies (0-1)
    "wdfreq": np.ndarray,    # (n_sectors,) - direction frequencies (0-1)
    "wsbins": np.ndarray,    # (n_wsbins + 1,) - bin edges
    "coords": {
        "south_north": float,
        "west_east": float,
        "height": float,
    },
    "metadata": {"description": str},
}

Example:

from windkit.io.wasp import read_tab, write_tab, format_tab

# Read
data = read_tab("measurements.tab")
print(data["wsfreq"].shape)  # (30, 12) for 30 bins, 12 sectors
print(data["wdfreq"].sum())  # Close to 1.0

# Write
write_tab("output.tab",
          data["wsfreq"], data["wdfreq"], data["wsbins"],
          data["coords"], data["metadata"])

# Format as string (without writing to file)
tab_string = format_tab(
    data["wsfreq"], data["wdfreq"], data["wsbins"],
    data["coords"], data["metadata"])

.owc / .omwc - Observed Wind Climate#

XML format for observed wind climate data from measurements. Stores wind speed frequency distributions per sector, similar to .tab but in XML.

Functions: read_owc(), parse_owc_element()

Normalization: read_owc returns frequencies as stored in the XML (0-1).

Return structure:

{
    "wsfreq": np.ndarray,    # (n_wsbins, n_sectors) - wind speed frequencies (0-1)
    "wdfreq": np.ndarray,    # (n_sectors,) - direction frequencies (0-1)
    "wsbins": np.ndarray,    # (n_wsbins + 1,) - bin edges
    "coords": {
        "south_north": float,
        "west_east": float,
        "height": float,
    },
    "metadata": {"description": str},
}

Example:

from windkit.io.wasp import read_owc

# Read
data = read_owc("observed.omwc")
print(data["wsfreq"].shape)  # (30, 12) for 30 bins, 12 sectors
print(data["wdfreq"].sum())  # Close to 1.0

Note

The .owc and .omwc formats are read-only. There is no write_owc function; use write_tab() to export binned wind climate data.

.lib - Generalized Wind Climate Library#

Text format for generalized wind climate with Weibull parameters across multiple roughness classes and heights.

Functions: read_lib(), write_lib(), format_lib()

Normalization: read_lib returns wdfreq normalized to 0-1. write_lib and format_lib accept 0-1 values and convert to percent for the file format. A and k are raw Weibull parameters.

Return structure:

{
    "A": np.ndarray,              # (n_sectors, n_heights, n_roughnesses) - Weibull scale
    "k": np.ndarray,              # (n_sectors, n_heights, n_roughnesses) - Weibull shape
    "wdfreq": np.ndarray,         # (n_sectors, n_roughnesses) - direction freq (0-1)
    "gen_roughness": np.ndarray,  # (n_roughnesses,) - roughness classes
    "gen_height": np.ndarray,     # (n_heights,) - generalized heights
    "coords": {
        "south_north": float or None,
        "west_east": float or None,
        "height": float or None,
    },
    "metadata": {"description": str},
}

Example:

from windkit.io.wasp import read_lib, write_lib, format_lib

# Read
data = read_lib("climate.lib")
print(data["A"].shape)       # (12, 5, 5) for 12 sectors, 5 heights, 5 roughnesses
print(data["wdfreq"].sum(axis=0))  # Close to 1.0 per roughness class

# Write
write_lib("output.lib",
          data["A"], data["k"], data["wdfreq"],
          data["gen_roughness"], data["gen_height"],
          data["coords"], data["metadata"])

# Format as string (without writing to file)
lib_string = format_lib(
    data["A"], data["k"], data["wdfreq"],
    data["gen_roughness"], data["gen_height"],
    data["coords"], data["metadata"])