Units parser

units.parser.qau_to_string(qau)

Converts a QuantityAndUnit instance to a string, for example “POWER in MW”.

Parameters:

qau – an esdl.QuantityAndUnit instance

Result:

string representation of the QuanityAndUnit instance

units.parser.unit_to_string(qau)

Converts the unit of a QuantityAndUnit instance to a string, for example “MW”.

Parameters:

qau – an esdl.QuantityAndUnit instance

Result:

string representation of the unit only of the QuanityAndUnit instance

units.parser.build_qau_from_unit_string(unit_string: str, physical_quantity=None)

Build an esdl.QuantityAndUnit instance from a string representing only the unit (and not the physical quantity), for example from “kWh/yr”.

Parameters:
  • unit_string – string representation of the QuanityAndUnit unit (without the physical quantity)

  • physical_quantity – Optional sets the associated Physical quantity, e.g. esdl.PhysicalQuantityEnum.POWER or esdl.PhysicalQuantityEnum.ENERGY, esdl.PhysicalQuantityEnum.COST, also string version is supported, e.g. “POWER”, “ENERGY”, “COST” (case does not matter), but Python 3.10 does not like the esdl.PhysicalQuantityEnum | str definition in the method definition.

Result:

an esdl.QuantityAndUnit instance

units.parser.is_valid_uuid(uuid_to_test, version=4)

Check if uuid_to_test is a valid UUID.

Parameters:
  • uuid_to_test (str) –

  • version ({1, 2, 3, 4}) –

Return type:

True if uuid_to_test is a valid UUID, otherwise False.

Examples

>>> is_valid_uuid('c9bf9e57-1685-4c89-bafb-ff5af830be8a')
True
>>> is_valid_uuid('c9bf9e58')
False
units.parser.instantiate_qau(orig_qau: QuantityAndUnitType)

Creates a new instance of a QuantityAndUnit instance by copying the contents and creating a new ID.

Parameters:

orig_qau – an esdl.QuantityAndUnit instance used as template

units.parser.get_or_create_global_qau_reference(es: EnergySystem, orig_qau: QuantityAndUnitType)

Finds a QuantityAndUnit instance in the global list of QuantityAndUnit instances in the EnergySystemInformation. It the QuantityAndUnit exists, a QuantityAndUnitReference is returned. If the QuantityAndUnit does not exist, it will be created and a QuantityAndUnitReference is returned. Must be used with the default QuantityAndUnits, like defined in conversion.py, like ENERGY_IN_PJ, COST_IN_MEur

Parameters:
  • es – the EnergySystem instance

  • orig_qau – a QuantityAndUnit instance from the list of QuantityAndUnit templates