edisgo.tools.config.Config ========================== .. py:class:: edisgo.tools.config.Config(**kwargs) Container for all configurations. :param config_path: Path to the config directory. Options are: * 'default' (default): The provided default config files are used directly. * str: Configs will be loaded from the directory specified by `config_path`. If the directory does not exist, it is created. If config files don't exist, the default config files are copied into the directory. * dict: A dictionary can be used to specify different paths to the different config files. Keys are 'config_db_tables', 'config_grid', 'config_grid_expansion', and 'config_timeseries'. Values are paths to the corresponding config file. The directories and config files must exist and are not automatically created. * None: Configs are loaded from the edisgo default config directory (~/.edisgo). If the directory does not exist, it is created. If config files don't exist, the default config files are copied into the directory. Default: "default". :type config_path: None or str or dict :param from_json: Set to True to load config data from json file. In that case the json file is assumed to be located in path specified through `config_path`. Per default this is set to False in which case config data is loaded from cfg files. Default: False. :type from_json: bool :param json_filename: Filename of the json file. If None, it is loaded from file with name "configs.json". Default: None. :type json_filename: str :param from_zip_archive: Set to True to load json config file from zip archive. Default: False. :type from_zip_archive: bool .. rubric:: Notes The Config object can be used like a dictionary. See example on how to use it. .. rubric:: Examples Create Config object from default config files >>> from edisgo.tools.config import Config >>> config = Config() Get reactive power factor for generators in the MV network >>> config['reactive_power_factor']['mv_generator'] .. py:property:: db_table_mapping .. py:property:: db_schema_mapping .. py:method:: get_database_alias_dictionaries() Retrieves the database alias dictionaries for table and schema mappings. :returns: A tuple containing two dictionaries: - name_mapping: A dictionary mapping source table names to target table names. - schema_mapping: A dictionary mapping source schema names to target schema names. :rtype: tuple .. py:method:: import_tables_from_oep(engine, table_names, schema_name) Imports tables from the OEP database based on the provided table names and schema name. :param engine: The SQLAlchemy engine to use for database connection. :type engine: sqlalchemy.engine.Engine :param table_names: List of table names to import. :type table_names: list of str :param schema_name: The schema name to use for importing tables. :type schema_name: str :returns: A list of SQLAlchemy Table objects corresponding to the imported tables. :rtype: list of sqlalchemy.Table .. py:method:: from_cfg(config_path=None) Load config files. :param config_path: See class definition for more information. :type config_path: None or str or dict :returns: eDisGo configuration data from config files. :rtype: :obj:`collections.OrderedDict` .. py:method:: to_json(directory, filename=None) Saves config data to json file. :param directory: Directory, the json file is saved to. :type directory: str :param filename: Filename the json file is saved under. If None, it is saved under the filename "configs.json". Default: None. :type filename: str or None .. py:method:: from_json(directory, filename=None, from_zip_archive=False) Imports config data from json file as dictionary. :param directory: Directory, the json file is loaded from. :type directory: str :param filename: Filename of the json file. If None, it is loaded from file with name "configs.json". Default: None. :type filename: str or None :param from_zip_archive: Set to True if data is archived in a zip archive. Default: False. :type from_zip_archive: bool :returns: Dictionary with config data loaded from json file. :rtype: dict