Units, validation and files#

Unit helpers. Gas conditions are explicit rather than inferred from a unit label.

x2power.utilities.units.mj_to_kwh(energy_mj)[source]#
Parameters:

energy_mj (float)

Return type:

float

x2power.utilities.units.normalize_gas_volume(actual_m3, temperature_c, pressure_pa, *, water_vapour_pressure_pa=0.0)[source]#

Ideal-gas conversion to dry Nm³ at 0 °C and 101325 Pa.

Supply ABSOLUTE pressure and the actual water-vapour partial pressure for wet gas. Compressibility differences are not modelled.

Parameters:
  • actual_m3 (float)

  • temperature_c (float)

  • pressure_pa (float)

  • water_vapour_pressure_pa (float)

Return type:

float

Shared strict numeric validation; booleans and non-finite values are rejected.

x2power.utilities.validation.number(name, value, *, minimum=0.0, strict=False)[source]#
Parameters:
  • name (str)

  • value (float)

  • minimum (float)

  • strict (bool)

Return type:

None

x2power.utilities.validation.fraction(name, value, *, positive=False)[source]#
Parameters:
  • name (str)

  • value (float)

  • positive (bool)

Return type:

None

Portable JSON/CSV I/O without third-party runtime dependencies.

x2power.utilities.io.load_scenario(path)[source]#
Parameters:

path (str | Path)

Return type:

dict[str, Any]

x2power.utilities.io.write_json(data, path)[source]#
Parameters:
  • data (object)

  • path (str | Path)

Return type:

None

x2power.utilities.io.write_csv(rows, path)[source]#
Parameters:
  • rows (Sequence[Mapping[str, Any]])

  • path (str | Path)

Return type:

None