R2X-Sienna Documentation¶
r2x-sienna is an r2x-core plugin package for reading and writing Sienna/PowerSystems-style
system data.
It provides:
A parser plugin (
SiennaParser) that builds aninfrasys.Systemfrom PSY-style JSON (+ optional HDF5 time series metadata)An exporter plugin (
SiennaExporter) that serializes aninfrasys.Systemback to PSY-compatible JSON (+ optional HDF5 time series)A version upgrader pipeline (
SiennaUpgraderandrun_sienna_upgrades) that normalizes legacy files before parseA typed model library (
r2x_sienna.models) with topology, generation, branch, load, services, costs, attributes, and enum typesA unit system (
r2x_sienna.units) built onpint/infrasysbase quantities, including per-unit support through model mixins
Documentation Map¶
Explanations: architecture, parser/exporter/upgrader lifecycle, models, and units
How-To Guides: script-based workflows and practical examples
Reference: API summary, model catalog, and units reference
Core Workflow¶
Create parser configuration (
SiennaConfig) pointing to an input JSON.Build a
PluginContextand runSiennaParser.from_context(ctx).run().Work with the resulting
infrasys.Systemin your script.Create exporter configuration (
SiennaExporterConfigor compatible config withoutput_path).Run
SiennaExporter.from_context(export_ctx).run()to emit PSY JSON (+ HDF5 when enabled).
The parser automatically invokes upgrade steps before deserialization when json_path is provided,
which helps keep old datasets compatible with current model definitions.
Quick Example¶
from pathlib import Path
from r2x_core import DataStore, PluginContext
from r2x_sienna import SiennaConfig, SiennaExporter, SiennaExporterConfig, SiennaParser
input_json = Path("tests/data/case5_pjm_rt/c_sys5_pjm_rt.json")
output_json = Path("output/system.json")
# Parse
parse_cfg = SiennaConfig(model_year=2029, system_name="PJM-5", json_path=str(input_json))
parse_ctx = PluginContext(config=parse_cfg, store=DataStore(path=input_json.parent))
system = SiennaParser.from_context(parse_ctx).run().system
# Export
export_cfg = SiennaExporterConfig(output_path=str(output_json))
export_ctx = PluginContext(config=export_cfg, system=system, store=DataStore(path=output_json.parent))
SiennaExporter.from_context(export_ctx).run()