Skip to content

ergminer.write

ergminer.write_ergml(erg, file_path, sim_time=5000.0)

Serialise erg to an ERGML XML file.

Parameters:

Name Type Description Default
erg 'ERG'

The ERG object to export.

required
file_path str

Destination file path (conventionally ending in .ergml).

required
sim_time float

Simulation horizon to embed in the ERGML (seconds).

5000.0
Source code in src\ergminer\write.py
def write_ergml(
    erg: 'ERG',
    file_path: str,
    sim_time: float = 5000.0,
) -> None:
    """Serialise *erg* to an ERGML XML file.

    Args:
        erg:       The ``ERG`` object to export.
        file_path: Destination file path (conventionally ending in ``.ergml``).
        sim_time:  Simulation horizon to embed in the ERGML (seconds).
    """
    from .ERGML_converter import save_ergml

    Path(file_path).parent.mkdir(parents=True, exist_ok=True)
    save_ergml(erg, file_path, sim_time=sim_time)

ergminer.write_erg_json(erg, file_path)

Serialise erg to a JSON file.

Parameters:

Name Type Description Default
erg 'ERG'

The ERG object to export.

required
file_path str

Destination file path (conventionally ending in .json).

required
Source code in src\ergminer\write.py
def write_erg_json(
    erg: 'ERG',
    file_path: str,
) -> None:
    """Serialise *erg* to a JSON file.

    Args:
        erg:       The ``ERG`` object to export.
        file_path: Destination file path (conventionally ending in ``.json``).
    """
    Path(file_path).parent.mkdir(parents=True, exist_ok=True)
    erg.to_json(filepath=file_path)

ergminer.write_dot(erg, file_path)

Serialise erg to a GraphViz DOT file.

Parameters:

Name Type Description Default
erg 'ERG'

The ERG object to export.

required
file_path str

Destination file path (conventionally ending in .dot).

required
Source code in src\ergminer\write.py
def write_dot(
    erg: 'ERG',
    file_path: str,
) -> None:
    """Serialise *erg* to a GraphViz DOT file.

    Args:
        erg:       The ``ERG`` object to export.
        file_path: Destination file path (conventionally ending in ``.dot``).
    """
    Path(file_path).parent.mkdir(parents=True, exist_ok=True)
    erg.generate_graphviz_dot(filepath=file_path)