Skip to main content

r2x-plexos

Translate power-system models between PLEXOS XML and the R2X ecosystem.

PyPI version Supported Python versions CI status Documentation build Coverage

r2x-plexos is an R2X Core plugin for reading PLEXOS XML databases into typed R2X/Infrasys systems and writing those systems back to PLEXOS XML. It supports both Python workflows and repeatable r2x CLI pipelines.

What it does

  • Parse PLEXOS models: Read model objects, properties, memberships, scenarios, horizons, and referenced time series.
  • Export R2X systems: Create PLEXOS XML databases from R2X systems, including memberships and time-series CSV files.
  • Round-trip models: Parse, inspect or transform a system, then export a new PLEXOS model.
  • Configure simulations: Build models, horizons, and simulation settings for the exported database.
  • Compose pipelines: Connect the PLEXOS parser and exporter with other R2X plugins through YAML pipelines.

Installation

Using uv:

uv add r2x-plexos

Or using pip:

python -m pip install r2x-plexos

The package supports Python 3.11, 3.12, and 3.13. To verify installation and plugin discovery:

python -c "import r2x_plexos; print(r2x_plexos.__version__)"
r2x list

The CLI executable is r2x. Its discovered plugin names include plexos-parser and plexos-exporter.

Python quick start

Parse a PLEXOS XML model

The parser is initialized with an R2X Core PluginContext. fpath can point to an XML file or to a directory containing one.

from pathlib import Path
from typing import cast

from r2x_core import DataFile, DataStore, PluginContext
from r2x_plexos import PLEXOSConfig, PLEXOSParser

xml_path = Path("input/model.xml")
store = DataStore(path=xml_path.parent)
store.add_data(DataFile(name="xml_file", fpath=xml_path))

config = PLEXOSConfig(
        fpath=str(xml_path),
        model_name="Base",
        horizon_year=2024,
        timeseries_dir=xml_path.parent,
)
context = PluginContext(config=config, store=store)
parser = cast(PLEXOSParser, PLEXOSParser.from_context(context))

result = parser.run()
if result.is_err() or result.system is None:
        raise RuntimeError(result.error if result.is_err() else "No system returned")

system = result.system
print(system.name)

Parsed components can be queried through the R2X system:

from r2x_plexos.models import PLEXOSGenerator

for generator in system.get_components(PLEXOSGenerator):
        print(generator.name, generator.max_capacity)

Export a system to PLEXOS

Pass the parsed or transformed system to the exporter through a context. The exporter creates the simulation configuration and writes XML output using a bundled PLEXOS template.

from typing import cast

from r2x_core import PluginContext
from r2x_plexos import PLEXOSConfig, PLEXOSExporter

export_config = PLEXOSConfig(
        model_name="Base_2024",
        horizon_year=2024,
        template="PLEXOS10.0",
        output_path="output",
)
export_context = PluginContext(config=export_config, system=system)
exporter = cast(PLEXOSExporter, PLEXOSExporter.from_context(export_context))

result = exporter.run()
if result.is_err():
        raise RuntimeError(result.error)

Supported templates include PLEXOS9.0, PLEXOS10.0, PLEXOS11.0, and PLEXOS12.0. A custom XML template path can also be supplied through PLEXOSConfig.template.

R2X CLI pipelines

Use a pipeline when several plugins should run as one reproducible workflow. Create a starter file with:

r2x init plexos-pipeline.yaml

The following example parses a PLEXOS model and exports it again:

variables:
    input_xml: /data/input/model.xml
    output_dir: /data/output
    model_name: Base
    horizon_year: 2024
    template: PLEXOS10.0

pipelines:
    round_trip:
        - r2x-plexos.plexos-parser
        - r2x-plexos.plexos-exporter

config:
    r2x-plexos.plexos-parser:
        fpath: ${input_xml}
        model_name: ${model_name}
        horizon_year: ${horizon_year}

    r2x-plexos.plexos-exporter:
        model_name: ${model_name}
        horizon_year: ${horizon_year}
        template: ${template}
        output_path: ${output_dir}

output_folder: ${output_dir}

Inspect and run the pipeline with:

r2x list
r2x run plexos-pipeline.yaml round_trip --print
r2x run plexos-pipeline.yaml round_trip --dry-run
r2x run plexos-pipeline.yaml round_trip

Transformations from other R2X plugins can be inserted between the parser and exporter. For example:

pipelines:
    p2s:
        - r2x-plexos.plexos-parser
        - r2x-plexos-to-sienna.plexos-to-sienna
        - r2x-sienna.sienna-exporter

Use ${variable} references for shared paths and years, and use r2x list to find installed plugin references.

Documentation

The complete documentation includes tutorials, task-focused recipes, architecture explanations, API details, and pipeline examples:

Contributing

License

This project is distributed under the BSD 3-Clause License.

Metadata

Release files for r2x-plexos 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for r2x-plexos 0.3.3
File Size Uploaded
r2x_plexos-0.3.3.tar.gz 115.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for r2x-plexos 0.3.3
File Interpreter ABI Platform
r2x_plexos-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 248.4 kB

Release files / r2x_plexos-0.3.3.tar.gz

Download URL r2x_plexos-0.3.3.tar.gz
Size 115.3 kB
Tags Source
SHA-256 checksum
How to use checksums
12ab9c17ff5af13a5f9e3add270ea7000a7311c3a66ff4b46d274890cfa186a0
BLAKE2b-256 checksum
How to use checksums
6682364d88cc27528868de254cbc3c06f748cf67da4feea9a4015467df84b212
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release files / r2x_plexos-0.3.3-py3-none-any.whl

Download URL r2x_plexos-0.3.3-py3-none-any.whl
Size 133.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d133929ed3436c9137efa924f6d20a0c3af044b42c33a3c6fe83bc099dfe4342
BLAKE2b-256 checksum
How to use checksums
6b8a9041bcf7f2ab293b4d613add32eff76584e8953976ca399738b027ef1784
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page