Parsers#
Concrete class to handler parser models.
This module provides the abstract class to create parser objects.
- class r2x.parser.handler.BaseParser(config, data=<factory>)
Class that defines the shared methods of parsers.
Note
This class is meant to be use for developing new parsers. Do not use it directly.
- config
Scenario configuration
- Type:
- data
We save each file read in a data dictionary
- Type:
- read_file(fpath='load.csv')
Read load data.
- parse_data()
Read all files from a configuration file map.
- abstract build_system()
Create the infra_sys model.
- Return type:
- parse_data(*, base_folder, fmap, filter_func=None, **kwargs)
Parse all the data for the given translation.
- read_file(fpath, filter_funcs=None, **kwargs)
Read input model data from the file system.
- Currently supported formats:
.csv
.h5
.xml
More to come!
- class r2x.parser.handler.PCMParser(config, data=<factory>)
Class defining shared methods for PCM (currently plexos and sienna) parsers.
- r2x.parser.handler.create_model_instance(model_class, skip_validation=False, **field_values)
Create R2X model instance.
- r2x.parser.handler.file_handler(fpath, parser_class=None, optional=False, **kwargs)
Return FileHandler based on file extension.
- Raises:
FileNotFoundError – If the file is not found.
NotImplementedError – If the file format is not yet supported or the file format is not supported for the parser.
- Parameters:
- Return type:
LazyFrame | DataFrame | Sequence | XMLHandler | None
- r2x.parser.handler.get_parser_data(config, parser_class, filter_funcs=None, **kwargs)
Return parsed system.
This function will create the ReEDS DataPortal and populate with the most common set of data needed
Paremters#
config Scenario configuration class parser
Parser to process
- filter_func
Functions that will applied to read_data process
- param kwargs:
- year
For filtering by solve year
- year_column
To change the column to apply the filter
- column_mapping
For renaming columns
See also
BaseParser
,pl_filter_year
,pl_lower_case
,pl_rename
ReEDS#
Functions related to parsers.
- class r2x.parser.reeds.ReEDSParser(*args, **kwargs)#
ReEDS parser class.
- parse_data(*, base_folder, fmap, filter_func=None, **kwargs)#
Parse all the data for the given translation.
- read_file(fpath, filter_funcs=None, **kwargs)#
Read input model data from the file system.
- Currently supported formats:
.csv
.h5
.xml
More to come!
- r2x.parser.reeds.cli_arguments(parser)#
CLI arguments for the plugin.
- Parameters:
parser (ArgumentParser)
Plexos#
Plexos parser class.
- class r2x.parser.plexos.PlexosParser(*args, xml_file=None, **kwargs)#
Plexos parser class.
- Parameters:
xml_file (str | None)
- parse_data(*, base_folder, fmap, filter_func=None, **kwargs)#
Parse all the data for the given translation.
- read_file(fpath, filter_funcs=None, **kwargs)#
Read input model data from the file system.
- Currently supported formats:
.csv
.h5
.xml
More to come!
- r2x.parser.plexos.cli_arguments(parser)#
CLI arguments for the plugin.
- Parameters:
parser (ArgumentParser)