API reference
The public API is intentionally small and is importable directly from the
top-level pyiecwind package. The stability guarantees for these names are
described in API contract.
Parameters
- class pyiecwind.IECParameters(si_unit, t1, wtc, catg, slope_deg, iec_edition, hh, dia, vin, vrated, vout, conditions=())[source]
Validated, immutable input parameters stored internally in SI units.
Construction is the single validation gate: every public path (the parser, the wizard, direct API use) goes through
__post_init__, which enforces the IEC turbine class/category/edition, finite and positive geometry, and a physically ordered cut-in < rated < cut-out speed range. A frozen dataclass with a tuple ofconditionsmakes an invalid object impossible to create and impossible to mutate into one afterwards.Length and speed fields are stored in SI (m, m/s);
si_unitonly controls how values are rendered in output files and how condition-code speeds are interpreted.- Parameters:
si_unit (bool) – Render output in SI (m, m/s) when
True, English (ft, ft/s) whenFalse.t1 (float) – Transient start time [s].
wtc (int) – IEC turbine class: 1, 2, or 3.
catg (str) – Turbulence category:
"A","B", or"C"(normalised to upper case).slope_deg (float) – Inflow inclination angle [deg].
iec_edition (int) – IEC 61400-1 edition for the power-law shear exponent: 1 or 3.
hh (float) – Hub height [m].
dia (float) – Rotor diameter [m]; must be positive and less than twice the hub height.
vin (float) – Cut-in, rated, and cut-out wind speeds [m/s]; must satisfy
0 < vin < vrated < vout.vrated (float) – Cut-in, rated, and cut-out wind speeds [m/s]; must satisfy
0 < vin < vrated < vout.vout (float) – Cut-in, rated, and cut-out wind speeds [m/s]; must satisfy
0 < vin < vrated < vout.conditions (tuple of str, optional) – Condition codes to generate (e.g.
("ECD+R", "EWM50")). Stored as a tuple.
- Raises:
ValueError – If any field is non-finite or out of its allowed range.
Generation
- pyiecwind.generate_all(params, output_dir=None, *, strict=True, atomic=False)[source]
Generate every condition listed in
params.Fails closed by default: the first invalid condition raises, so a caller never silently receives partial output. Repeated condition codes describe the same
<code>.wndfile and are generated once (first-seen order preserved).- Parameters:
params (IECParameters) – Validated turbine definition and the list of condition codes to generate.
output_dir (str or pathlib.Path or None, optional) – Directory to write the
<code>.wndfiles into; created if it does not exist. WhenNone(the default) files are written to the current working directory.strict (bool, default True) – If
True, raiseValueErroron the first condition that cannot be generated. IfFalse, collect failures into the result and continue.atomic (bool, default False) – If
True, stage all files in a temporary directory and only move them intooutput_dironce the whole batch has been generated. Combined withstrict=Truethis is all-or-nothing: an invalid condition raises and the output directory is left untouched, never partially populated.
- Returns:
The paths written and any per-condition errors (errors are only populated when
strict=False).- Return type:
- Raises:
ValueError – If
strictisTrueand a condition code is unknown or invalid.
Examples
>>> from pyiecwind import IECParameters, generate_all >>> params = IECParameters( ... si_unit=True, t1=40.0, wtc=2, catg="B", slope_deg=0.0, iec_edition=3, ... hh=80.0, dia=80.0, vin=4.0, vrated=10.0, vout=24.0, ... conditions=("EWM50", "NWP10.0"), ... ) >>> result = generate_all(params, output_dir="out", atomic=True) >>> result.count 2
- pyiecwind.generate_from_input_file(input_file, *, output_dir=None, strict=True, atomic=False)[source]
Parse
input_fileand generate all of its conditions.A convenience wrapper combining
parse_input_file()andgenerate_all().- Parameters:
input_file (str or pathlib.Path) – Path to an input file in any supported layout.
output_dir (str or pathlib.Path or None, optional) – Directory for the generated
.wndfiles (seegenerate_all()).strict (bool, default True) – Passed through to
generate_all(); fails closed by default.atomic (bool, default False) – Passed through to
generate_all(); when combined withstrict, a single invalid condition leaves no files behind.
- Returns:
The parsed parameters and the generation outcome.
- Return type:
- Raises:
FileNotFoundError – If
input_filedoes not exist.ValueError – For malformed input, or (when
strict=True) an invalid condition.
- class pyiecwind.GenerationResult(generated=(), errors=())[source]
Outcome of a batch generation run.
generatedholds the paths written successfully anderrorsholds the conditions that were skipped (only populated whenstrict=False).- Parameters:
errors (tuple[GenerationError, ...])
Condition generators
Each generator writes one .wnd file and returns its path. They are available
from the pyiecwind.core compatibility facade.
- pyiecwind.core.gen_ecd(code, params, output_dir=None)[source]
Generate an Extreme Coherent Gust with Direction Change (ECD)
.wndfile.- Parameters:
code (str) – Condition code of the form
ECD[+/-]R[+/-modifier](e.g."ECD+R","ECD-R+1.5"). The sign sets the direction-change sense; the optional modifier (magnitude <= 2 m/s in user units) offsets the rated hub speed.params (IECParameters) – Turbine definition supplying rated speed, slope, and shear exponent.
output_dir (str or pathlib.Path or None, optional) – Output directory; created if missing.
Nonewrites to the current working directory.
- Returns:
Path to the written
.wndfile.- Return type:
- Raises:
ValueError – If
codeis malformed, the modifier exceeds +/-2 m/s, or the resulting hub speed exceeds the reference wind speed.
Notes
Implements the IEC 61400-1 Extreme Coherent Gust with Direction Change: a coherent gust of 15 m/s with a direction change of 180 deg for Vhub <= 4 m/s (else 720/Vhub deg), each ramped over 10 s. See Theory for the equations.
- pyiecwind.core.gen_ews(code, params, output_dir=None)[source]
Generate an Extreme Wind Shear (EWS)
.wndfile.- Parameters:
code (str) – Condition code
EWS[V/H][+/-]<speed>(e.g."EWSV+12.0").V/Hselects vertical or horizontal shear, the sign selects the shear direction, and<speed>is the hub-height wind speed in user units.params (IECParameters) – Turbine definition supplying the operating range, turbulence, and geometry.
output_dir (str or pathlib.Path or None, optional) – Output directory; created if missing.
Nonewrites to the current working directory.
- Returns:
Path to the written
.wndfile.- Return type:
- Raises:
ValueError – If
codeis malformed, or the wind speed is outside[vin, vout].
Notes
Implements the IEC 61400-1 Extreme Wind Shear: a transient linear shear (vertical or horizontal) ramped over 12 s. See Theory for the equations.
- pyiecwind.core.gen_eog(code, params, output_dir=None)[source]
Generate an Extreme Operating Gust (EOG)
.wndfile.- Parameters:
code (str) – Condition code
EOGI,EOGO,EOGR, orEOGR[+/-modifier].I/O/Rselect the cut-in, cut-out, or rated reference speed; a modifier (magnitude <= 2 m/s in user units) is valid only withR.params (IECParameters) – Turbine definition supplying operating speeds, turbulence, and geometry.
output_dir (str or pathlib.Path or None, optional) – Output directory; created if missing.
Nonewrites to the current working directory.
- Returns:
Path to the written
.wndfile.- Return type:
- Raises:
ValueError – If
codeis malformed (including a modifier on anI/Oreference), or the modifier exceeds +/-2 m/s.
Notes
Implements the IEC 61400-1 Extreme Operating Gust over a 10.5 s transient. See Theory for the equations.
- pyiecwind.core.gen_edc(code, params, output_dir=None)[source]
Generate an Extreme Direction Change (EDC)
.wndfile.- Parameters:
code (str) – Condition code
EDC[+/-]I,EDC[+/-]O,EDC[+/-]R, orEDC[+/-]R[+/-modifier]. The leading sign sets the yaw-excursion sense;I/O/Rselect the reference speed; a modifier is valid only withR.params (IECParameters) – Turbine definition supplying operating speeds, turbulence, and geometry.
output_dir (str or pathlib.Path or None, optional) – Output directory; created if missing.
Nonewrites to the current working directory.
- Returns:
Path to the written
.wndfile.- Return type:
- Raises:
ValueError – If
codeis malformed (including a modifier on anI/Oreference), or the modifier exceeds +/-2 m/s.
Notes
Implements the IEC 61400-1 Extreme Direction Change ramped over 6 s. See Theory for the equations.
- pyiecwind.core.gen_nwp(code, params, output_dir=None)[source]
Generate a Normal Wind Profile (NWP)
.wndfile.- Parameters:
code (str) – Condition code
NWP<speed>(e.g."NWP10.0"). The embedded speed is always interpreted in m/s, matching the historical IECWind convention, regardless of thesi_unitsetting.params (IECParameters) – Turbine definition supplying slope and the shear exponent.
output_dir (str or pathlib.Path or None, optional) – Output directory; created if missing.
Nonewrites to the current working directory.
- Returns:
Path to the written
.wndfile.- Return type:
- Raises:
ValueError – If
codeis malformed.
Notes
Implements the IEC 61400-1 Normal Wind Profile (power law). See Theory.
- pyiecwind.core.gen_ewm(code, params, output_dir=None)[source]
Generate a steady Extreme Wind Model (EWM)
.wndfile.- Parameters:
code (str) – Condition code
EWM50(50-year recurrence) orEWM01(1-year).params (IECParameters) – Turbine definition supplying the reference wind speed and slope.
output_dir (str or pathlib.Path or None, optional) – Output directory; created if missing.
Nonewrites to the current working directory.
- Returns:
Path to the written
.wndfile.- Return type:
- Raises:
ValueError – If
codeis notEWM50orEWM01.
Notes
Implements the IEC 61400-1 steady Extreme Wind Model (Ve50 = 1.4*Vref, Ve1 = 0.8*Ve50). See Theory for the equations.
Input and templates
- pyiecwind.parse_input_file(filepath='pyiecwind.ipt', *, legacy=False)[source]
Read an input file and return validated
IECParameters.The OpenFAST-style table, keyed (
key = value), and legacy positional layouts are auto-detected. A file may instead pin its layout explicitly with a! format: <id>comment directive (openfast-table-v1,keyed-v1, orlegacy-v1); when present it overrides auto-detection. Seedocs/data_sources.rstfor the full Input Format v1 specification.- Parameters:
filepath (str or pathlib.Path, optional) – Path to the input file. Defaults to
pyiecwind.iptin the current working directory.legacy (bool, default False) – If
True, unsupported IEC editions are coerced to edition 3 (emitting anIECWindWarning) instead of raising. Provided for backward compatibility with older inputs.
- Returns:
The validated, immutable parameter object.
- Return type:
- Raises:
FileNotFoundError – If
filepathdoes not exist.ValueError – For malformed input, an unknown key, a duplicate scalar field, an unrecognised
si_unittoken orformatdirective, an out-of-range value, or (unlesslegacy=True) an unsupported edition.
Examples
>>> from pyiecwind import parse_input_file >>> params = parse_input_file("examples/sample_case.ipt") >>> params.wtc 2
- pyiecwind.write_template(dest='pyiecwind_template.ipt')[source]
Write a commented example input file to
dest.- Parameters:
dest (str or pathlib.Path, optional) – Destination path. Defaults to
pyiecwind_template.ipt.- Returns:
The path that was written.
- Return type:
- pyiecwind.format_openfast_input(params)[source]
Render parameters as an OpenFAST-style input file.
The output round-trips: feeding it back through
parse_input_file()reproduces the same conditions and scalars.- Parameters:
params (IECParameters) – The parameters to render. Length and speed fields are shown in the parameters’ own unit system (
si_unit).- Returns:
The formatted input-file text, including the grouped
Casessection.- Return type:
Diagnostics
- exception pyiecwind.IECWindWarning[source]
Advisory warning for non-fatal IEC validation concerns.
Emitted for inputs that are accepted but fall outside IEC guidance (for example an inclination angle beyond 8 deg). Callers who want strict behaviour can escalate these to errors:
import warnings warnings.simplefilter("error", IECWindWarning)