API Reference¶
Complete API documentation for all r2x-plexos classes and functions.
Parser¶
Configuration¶
- pydantic model r2x_plexos.PLEXOSConfig[source]¶
Configuration for PLEXOS model parser.
This configuration class defines all parameters needed to parse PLEXOS model data, including model identification, time series handling, and simulation settings. Model-specific defaults and constants should be loaded using the load_defaults() class method and used in parser logic.
- Parameters:
fpath (str, optional) – Path to the PLEXOS run directory or XML file. If not provided, the parser will attempt to locate the model using default paths or configuration.
model_name (str, optional) – Name of the PLEXOS model. Defaults to “default”.
timeseries_dir (DirectoryPath, optional) – Optional subdirectory containing time series files. If passed it must exist.
horizon_year (int, optional) – Horizon year for the model simulation
solve_year (int, optional) – Solve year for simulation configuration. If not provided, it will be set to the same value
output_path (str, optional) – Alias for output directory. If provided, it will override timeseries_dir for time
template (str, optional) –
Selects the base XML template used to initialise the PLEXOS database. Accepts either:
A supported PLEXOS version key. The corresponding master XML is taken from the
plexosdbpackage (plexosdb/config/):Key
File (from plexosdb)
PLEXOS9.0master_9.2R6_btu.xml
PLEXOS10.0master_10.0R2_btu.xml
PLEXOS11.0master_11.0R4_btu.xml
PLEXOS12.0master_12.0R3_btu.xml
An absolute or relative file path to a custom XML template.
When omitted the default template (
PLEXOS10.0) is used.simulation_config (SimulationConfig, optional) – Simulation configuration parameters
Examples
Basic configuration with model name:
>>> config = PLEXOSConfig( ... model_name="MyPLEXOSModel", ... horizon_year=2030, ... )
Full configuration with time series and simulation:
>>> config = PLEXOSConfig( ... model_name="MyPLEXOSModel", ... timeseries_dir=Path("./timeseries"), ... horizon_year=2030, ... template="PLEXOS9.0", ... simulation_config=SimulationConfig(...), ... )
See also
r2x_core.plugin_config.PluginConfigBase configuration class
r2x_plexos.utils_simulation.SimulationConfigSimulation configuration class
load_defaultsClass method to load default constants from JSON
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Fields:
fpath (str | None)horizon_year (int | None)model_name (str)output_path (str | None)simulation_config (r2x_plexos.utils_simulation.SimulationConfig | None)template (str | None)timeseries_dir (pathlib.Path | None)weather_year (int | None)
- field fpath: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Path to the PLEXOS run directory or XML file')] = None¶
Path to the PLEXOS run directory or XML file
- field horizon_year: Annotated[int | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Horizon year')] = None¶
Horizon year
- field model_name: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='default', description='Name of the PLEXOS model.')] = 'default'¶
Name of the PLEXOS model.
- field output_path: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Alias for output directory')] = None¶
Alias for output directory
- field simulation_config: Annotated[SimulationConfig | None, FieldInfo(annotation=NoneType, required=True, description='Simulation configuration')] = None¶
Simulation configuration
- field template: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description="Selects the base XML template from the plexosdb package. Accepted version keys: 'PLEXOS9.0', 'PLEXOS10.0', 'PLEXOS11.0', 'PLEXOS12.0'. May also be a path to a custom XML file. Defaults to 'PLEXOS10.0' when omitted.")] = None¶
Selects the base XML template from the plexosdb package. Accepted version keys: ‘PLEXOS9.0’, ‘PLEXOS10.0’, ‘PLEXOS11.0’, ‘PLEXOS12.0’. May also be a path to a custom XML file. Defaults to ‘PLEXOS10.0’ when omitted.
- field timeseries_dir: Annotated[Annotated[Path, PathType(path_type=dir)] | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Optional subdirectory containing time series files. If passed it must exist.')] = None¶
Optional subdirectory containing time series files. If passed it must exist.
- field weather_year: Annotated[int | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Weather year')] = None¶
Weather year
See Also¶
How-To Guides - How-to guides