Import scripts API documentation¶
-
addBehaviors
(scope, behavior, infos, idFilter='.*' , zoneFilter='.*' , typeFilter='.*' )¶ Add a behavior to a container of assets/contracts/transmissions/modeObjects for a given scope
Parameters: - scope (string) – scope name
- behavior (string) – behavior name
- infos (InfosContainer) – infos container (possible type for infos are assets/contracts/transmissions/modeObject)
- idFilter (list of string, regex) – ID filter (the ID is the info name)
- zoneFilter (list of string, regex) – zone filter
- typeFilter (list of string, regex) – info type filter
-
allButFilter
(elementsToRemove, exactMatch=True )¶ Create a regex filter that excludes all patterns (either strings of regex) of the elementsToRemove list.
- If exactMatch = True:
The regex returned will exclude a string if one of the elements in elementsToRemove list matches exactly the string.
Example : elementsToRemove = [‘old’,’new’].
‘old’ string will not match the returned regex, but either ‘assetold’ or ‘oldasset’ will.
- If exactMatch = False:
The regex returned will exclude a string if one of the elements in elementsToRemove list matches part of the string.
Example : elementsToRemove = [‘old’,’new’].
‘old’ string will not match the returned regex, and neither ‘assetold’, nor ‘oldasset’ will.
Parameters: - elementsToRemove (list of str) – list of patterns to remove
- exactMatch (Boolean) – Boolean to decide if the returned regex should excludes exactly or partially elements of elementsToRemove list
Returns: regex
Return type: str
-
convertListToRegex
(listOfElement)¶ Create a regex that match any pattern present in listOfElement.
If
listOfElement = ['elt1','elt2',...,'eltn']
, it returns the regex'elt1|elt2|...|eltn'
If listOfElement is already a string, it returns it without modifications
Parameters: listOfElement (list of str (or str)) – list of elements Returns: regex Return type: str
-
createContext
(contextName, assetsInfos, contractsInfos, transmissionsInfos, modelObjectInfos, zonesInfos, temporalInfos, temporalDataMapping, startDate, numTimeSteps, timeStepDuration, operationalHorizon, tacticHorizon, timeZone='Etc/GMT-1' )¶ Create a context in the current study with name contextName
1. Assets creation
This function creates a scenario with the zones listed in zonesInfos, with the different assets listed in assetsInfos, contractsInfos, transmissionsInfos and modelObjectInfos.
2. Temporal information
All required temporal infos (for example a power demand profile, or a renewable availability) are loaded from temporalInfos. The number of weather realizations that should be loaded and the version of the data that should be used are defined in temporalDataMapping. To create this mapping dictionary, use the
createTemporalDataMapping
method.3. Simulation parameters
The temporal period of the context is defined with several parameters : it starts at startDate, with numTimeSteps temporal time steps (for example 365 for a context of one year with daily data). The time step duration is defined in timeStepDuration (expressed in number of minutes), and the time zone with timeZone. Operational and tactical horizon are defined with operationalHorizon and tacticHorizon parameters (Please refer to the technical documentation for more information about the different horizons of the simulation).
Parameters: - contextName (str) – Name of the context
- assetsInfos (AssetInfoContainer) – list of AssetInfo
- contractsInfos (ContractInfoContainer) – list of ContractInfo
- transmissionsInfos (TransmissionInfoContainer) – list of TransmissionInfo
- modelObjectInfos (modelObjectInfoContainer) – list of ModelObjectInfo
- zonesInfos (ZonesInfosContainer) – list of ZonesInfo
- temporalInfos (TemporalInfosContainer) – Temporal infos
- temporalDataMapping (dict) – mapping dictionary
- startDate (java.util.Date) – Starting date of the simulation
- numTimeSteps (int) – Number of time steps of the simulation
- timeStepDuration (int) – Time steps duration in minutes
- operationalHorizon (int) – Operational horizon
- tacticHorizon (int) – Tactical horizon
- timeZone (str) – time zone of the temporal data
-
createTemporalDataMapping
(testCaseList, year, version_DB)¶ Create the mapping for temporal data, according to the target Year, the test case list and the version of the data that should be imported
Please note that this mapping should be consistent with what is included in the loadaded temporal data. Then, if a required data does not have the specified test cases and version_DB (“Source” tag in the DB-Temporal.csv file), the import process will fail.
Parameters: - testCaseList (list of string) – list of test cases that should be imported
- year (int) – Target year of the context
- version_DB (string) – Version used in the DataBase (“Source” tag in the DB-Temporal.csv file)
Returns: mapping dictionary
Return type: dict
-
infosFilter
(infos, idFilter='.*' , zoneFilter='.*' , typeFilter='.*' )¶ Select elements from infos according to the id, zone and type filters
Parameters: - infos (InfosContainer) – list of infos (possible type for infos are assets/contracts/transmissions/modeObject)
- idFilter (list of string, regex) – ID filter (the ID is the info name)
- zoneFilter (list of string, regex) – zone filter
- typeFilter (list of string, regex) – info type filter
Returns: selected infos
Return type: InfosContainer (same type as infos)
-
loadModelObjects
(modelObjectFilePath, idFilter, modelObjectTypeFilter)¶ Load model objects data from an Excel file, and return the ones matching the specified ID and type filters
- All filters can either be:
- a list of string. In this case, all model objects matching one of the string are selected
- a regex. In this case, all model objects matching the given regex are selected
- Example :
modelObjectTypeFilter = ['Reserve Dimensioning','Reserve Symmetry Requirement']
: select model objects whose type is Reserve Dimensioning or Reserve Symmetry RequirementmodelObjectTypeFilter = 'Reserve.*'
: select model objects whose types match the given regex, in this case this means the ones starting with “Reserve” (eg “Reserve Dimensioning”, or “Reserve Symmetry Requirement”)
Parameters: - modelObjectFilePath (string) – Path to the model objects Excel file
- idFilter (list of string, regex) – ID filter (the ID is the model object name)
- modelObjectTypeFilter (list of string, regex) – model object type filter
Returns: list of ModelObjectInfo
Return type: modelObjectInfoContainer
-
loadScenarioAssets
(assetFilePath, idFilter, zoneFilter, assetTypeFilter, temporalInfos)¶ Load assets data from an Excel file, and return the ones matching the specified ID, zones and type ID filters.
- All filters can either be:
- a list of string. In this case, all assets matching one of the string are selected
- a regex. In this case, all assets matching the given regex are selected
- Example :
assetTypeFilter = ['CCGT','OCGT']
: select assets whose type is CCGT or OCGTassetTypeFilter = 'Hydro.*'
: select assets whose types match the given regex, in this case this means the ones starting with “Hydro” (eg “Hydro fleet”, or “Hydro RoR fleet”)
Parameters: - assetFilePath (string) – Path to the asset Excel file
- idFilter (list of string, regex) – ID filter (the ID is the asset name)
- zoneFilter (list of string, regex) – zone filter
- assetTypeFilter (list of string, regex) – asset type filter
- temporalInfos (TemporalInfosContainer) – Temporal infos
Returns: list of AssetInfo
Return type: AssetInfoContainer
-
loadScenarioContracts
(contractFilePath, idFilter, zoneFilter, contractTypeFilter, temporalInfos)¶ Load contracts data from an Excel file, and return the ones matching the specified ID, zones and type ID filters.
- All filters can either be:
- a list of string. In this case, all contracts matching one of the string are selected
- a regex. In this case, all contracts matching the given regex are selected
- Example :
contractTypeFilter = ['Well','Power demand']
: select contracts whose type is Well or Power demandcontractTypeFilter = '.*supply'
: select contracts whose types match the given regex, in this case this means the ones ending with “supply” (eg “Gas supply”, or “Coal supply”)
Parameters: - contractFilePath (string) – Path to the contract Excel file
- idFilter (list of string, regex) – ID filter (the ID is the contract name)
- zoneFilter (list of string, regex) – zone filter
- contractTypeFilter (list of string, regex) – contract type filter
- temporalInfos (TemporalInfosContainer) – Temporal infos
Returns: list of ContractInfo
Return type: ContractInfoContainer
-
loadScenarioTransmissions
(transmissionFilePath, idFilter, zoneFilter, transmissionTypeFilter, temporalInfos)¶ Load transmissions data from an Excel file, and return the ones matching the specified ID, zones and type ID filters.
- All filters can either be:
- a list of string. In this case, all transmissions matching one of the string are selected
- a regex. In this case, all transmissions matching the given regex are selected
- Example :
transmissionTypeFilter = ['Transmissions']
: select transmissions whose type is TransmissionstransmissionTypeFilter = '.*supply'
: select transmissions whose types match the given regex, in this case this means the ones ending with “supply” (eg “Gas supply”, or “Coal supply”)
Parameters: - transmissionFilePath (string) – Path to the transmissions Excel file
- idFilter (list of string, regex) – ID filter (the ID is the transmissions name)
- zoneFilter (list of string, regex) – zone filter (both input and output zones of the transmission should match zoneFilter)
- transmissionTypeFilter (list of string, regex) – transmission type filter
- temporalInfos (TemporalInfosContainer) – Temporal infos
Returns: list of TransmissionInfo
Return type: TransmissionInfoContainer
-
loadTemporalData
(temporalDataPath, targetYear)¶ Load temporal data from a temporal database.
Parameters: - temporalDataPath (string) – path to the temporal database
- targetYear (int) – year that should be displayed in the Graphical User Interface
Returns: TemporalInfosContainer
The temporal database must follow a specific format : the temporalDataPath data folder must contain one folder named DB-temporal and a csv file named DB-temporal.csv. If multiple csv files are present in the temporalDataPath data folder, only the last one in alphabetical order is considered.
Warning
So far the year present in the dataBase is ignored during the import. Then the prevailing year is the targetYear, and if the dataBase year is different, the year is shifted to the target year.
-
loadZones
(zoneFilePath, shapefileID, zoneFilter)¶ Load zones from a shapefile, and return the ones whose field shapefileID matches the specifed zone filter
- zoneFilter can either be:
- a list of string. In this case, all zones matching one of the string are selected
- a regex. In this case, all model objects matching the given regex are selected
- Example :
zoneFilter = ['AT','DE']
: select zones whose field shapefileID is equal to AT or DEzoneFilter = 'B.*'
: select zones whose fields shapefileID match the given regex, in this case this means the ones starting with “B” (eg “BE”, or “BG”)
Parameters: - zoneFilePath (string) – Path to the shapefile
- shapefileID (string) – shapefileID is the name of the field that should be used to filter zone in the shapefile
- zoneFilter (list of string, regex) – zone filter
Returns: list of ZonesInfo
Return type: ZonesInfosContainer
-
mergeInfos
(infos1, infos2)¶ Merge infos2 into infos1. Please note that this is a in-place merge into infos1 container
Warning
If the same info is present in both infos1 and infos2 (ie two infos with the same ID), then the ones from infos2 are ignored.
Parameters: - infos1 (InfosContainer (possible info container type : zone, temporal, asset, contract, transmission, modelObject)) – first infos containter
- infos2 (InfosContainer (possible info container type : zone, temporal, asset, contract, transmission, modelObject)) – second infos containter
Returns: Merged temporal infos (since the function is an in-place merge, it only returns the reference to infos1)
Return type: InfosContainer
-
multiplyParameter
(infos, parameter, factor, idFilter='.*' , zoneFilter='.*' , typeFilter='.*' )¶ Multiply a parameter by the given factor for all infos matching the specified filters (ID, zone and type)
Parameters: - infos (InfosContainer) – Infos containter (possible type for infos are assets/contracts/transmissions/modeObject)
- parameter (string) – parameter name
- value (float) – Multiplying factor
- idFilter (list of string, regex) – ID filter (the ID is the info name)
- zoneFilter (list of string, regex) – zone filter
- typeFilter (list of string, regex) – info type filter
-
resetBehaviors
(scope, infos)¶ Reset all behaviors (ie set their value to False) of each info of infos for the given scope
Parameters: - scope (string) – scope name
- infos (InfosContainer) – list of assets, contracts, transmissions whose behavior is initialized
-
setInfosParameter
(infos, parameter, value, idFilter='.*' , zoneFilter='.*' , typeFilter='.*' )¶ Set or modify a parameter value for infos matching the specified filters (ID, zone and type)
Parameters: - infos (InfosContainer) – Infos containter (possible type for infos are assets/contracts/transmissions/modeObject)
- parameter (string) – parameter name
- value (float) – new value for parameter
- idFilter (list of string, regex) – ID filter (the ID is the info name)
- zoneFilter (list of string, regex) – zone filter
- typeFilter (list of string, regex) – info type filter
-
saveScenarioData
(modelObjectInfos, zonesListBeforeAggregation, zoneAggregationMap, assetsInfos, contractsInfos, temporalInfosContainer, temporalRealizations, year, version_DB)¶ Save various scenario data into a model object “Scenario data” of type “Scenario”. Most of them are used during the reserve sizing process.
- _databaseTestcase : Original test case number in the database
- _databaseYear : target year of the scenario
- _databaseVersion : Version used in the DataBase (“Source” tag in the DB-Temporal.csv file)
- _aggregatedZones : Define for each new aggregated zone a int ID
- _originalZones : Specify for each zone (before aggregation) the int ID of the new aggregated zone they belong to
- _installedCapacities : Installed capacities per zone of several technologies (“CCGT fleet”, “Coal fleet”, “Lignite fleet”, “Nuclear fleet”, “Solar fleet”, “Wind offshore fleet”, “Wind onshore fleet”)
- _meanDemands : Mean demand per zone
Parameters: - modelObjectInfos (modelObjectInfoContainer) – List of model objects of the scenario
- zonesListBeforeAggregation (modelObjectInfoContainer) – Original list of zone (before aggregation)
- zoneAggregationMap (dict) – dictionary, whose keys are the new zone names and its elements are the corresponding aggregated zones
- assetsInfos (AssetInfoContainer) – List of assets of the scenario
- contractsInfos (ContractInfoContainer) – List of contracts of the scenario
- temporalInfosContainer (TemporalInfosContainer) – Temporal infos of the scenario
- temporalRealizations (List of str) – List of test cases of the scenario
- year (str) – Target year of the scenario
- version_DB (string) – Version used in the DataBase (“Source” tag in the DB-Temporal.csv file)
Returns: The “Scenario data” model object
Return type: ModelObject of type “Scenario”
-
completeAggregation
(assetsInfos, contractsInfos, transmissionsInfos, zonesInfos, zoneToAggregateDict, temporalInfos, assetsTypesFilter, contractsTypesFilter, transmissionsTypesFilter, aggregationTypesToSeparate=None )¶ Aggregate several zones into a single one, and merge their assets to get a single asset for each type in the newly created aggregated zone.
The aggregation is applied for all assets of the same type (from assetsInfos, contractsInfos and transmissionsInfos) belonging to the same aggregated zone (defined in zoneToAggregateDict). The asset parameters are aggregated according to specific rules, in order to have for the aggregated asset the same behaviour as the separated assets.
1. Format of zoneToAggregateDict
Specify how zones should be aggregated together.
zoneToAggregateDict is a dictionary, whose keys are the names of the aggregated zones, and the value for each aggregated zone is the list of zones that should be aggregated together :
- example :
{'Iberia': ['ES','PT'], 'NordPool': ['NO','FI','SE'] }
The new aggregated zones (e.g ‘Iberia’, ‘NordPool’) should not contain any underscore ” _ ” in their name.
2. Partial aggregation
It is possible to aggregate only a subset of all assets, depending on their type. In this case, other assets will not be aggregated (but will still belong to the newly aggregated zone). These type filters should be defined in assetsTypesFilter, contractsTypesFilter and transmissionsTypesFilter parameters.
All filters can either be:
- a list of string. In this case, all assets matching one of the string are selected
- a regex. In this case, all assets matching the given regex are selected
Example :
assetTypeFilter = ['CCGT','OCGT']
: select assets whose type is CCGT or OCGTassetTypeFilter = 'Hydro.*'
: select assets whose types match the given regex, in this case this means the ones starting with “Hydro” (eg “Hydro fleet”, or “Hydro RoR fleet”)
3. Aggregate assets based on their names
For assets in assetsInfos (not available for contractsInfos and transmissionsInfos), it is possible to have more than one aggregation category per asset type. This can be usefull to keep a distinction between different assets of the same type (for example Old and young CCGT present in all countries).
The different categories are defined in aggregationTypesToSeparate. A list should be provided for each asset type, whose values represent the different categories. All assets whose name include the given category will be aggregated together.
aggregationTypesToSeparate should have the following form:
aggregationTypesToSeparate = {"CCGT Fleet" : ["old", "medium", "young"], "OCGT Fleet" : ["old", "medium", "young"]}
In this case, all assets of type “CCGT Fleet” whose name contains “old” would be aggregated together (for example, “CCGT_FR_old” and “CCGT_DE_old”)
Warning
For an asset whose type is listed in the aggregationTypesToSeparate dict, but whose name does not match any of the possible category, no aggregation is done. This means that several assets from different countries could remain if their type is listed in the dict but their id does not match any category. (for example “state-of-the-art_CCGT_FR” and “state-of-the-art_CCGT_DE” with the example of the section 2)
Parameters: - assetsInfos (AssetInfosContainer) – Assets infos
- contractsInfos (ContractInfosContainer) – Contracts infos
- transmissionsInfos (TransmissionInfosContainer) – Transmissions infos
- zonesInfos (ZonesInfosContainer) – Zones infos
- zoneToAggregateDict (dict of list) – Dictionary whose keys are the names of the aggregated zones, and values are lists of original zones that should be aggregated together
- temporalInfos (TemporalInfosContainer) – Temporal infos
- assetTypeFilter (list of string, regex) – asset type filter
- contractTypeFilter (list of string, regex) – contract type filter
- transmissionsTypesFilter (list of string, regex) – transmission type filter
- aggregationTypesToSeparate (dict of list) – Dictionnary of types to separate, with their repective name categories
Returns: Newly aggregated [assetsInfos, contractsInfos, transmissionsInfos, zonesInfos] in a list of 4 elements
Return type: list
- example :