Results Module

Module containing the PowerGAMA Results class

class powergama.Results.Results(grid, databasefile, replace=True, sip=False)

Class for storing and analysing/presenting results from PowerGAMA

Parameters:

grid : GridData

PowerGAMA GridData object

databasefile : string

name of sqlite3 file for storage of results

replace : boolean

whether to replace existing sqlite file (default=true). replace=false is useful to analyse previously generated results

Methods

addResultsFromTimestep(timestep, objective_function, generator_power, generator_pumped, branch_power, dcbranch_power, node_angle, sensitivity_branch_capacity, sensitivity_dcbranch_capacity, sensitivity_node_power, storage, inflow_spilled, loadshed_power, marginalprice, flexload_power, flexload_storage, flexload_storagevalue)

Store results from optimal power flow for a new timestep

timestep : int
timestamp of results
objective_function : float
value of objective function
generator_power : list
generator output (list of same length and order as generators)
generator_pumped : list
position according to grid.getIdxGeneratorsWithPumping()
branch_power : list
AC branch power flow (list of same length and order as branches)
dcbranch_power : list
DC branch power flow (list of same length and order as dcbranches)
node_angles : list
voltage angles (list of same length and order as nodes)
sensitivity_branch_capacity : list
dual, position according to grid.getIdxBranchesWithFlowConstraints()
sensitivity_dcbranch_capacity : list
dual, capacity (list of same length and order as dcbranches)
sensitivity_node_power : list
dual, node demand(list of same length and order as nodes)
storage : list
position accordint to grid.getIdxGeneratorsWithStorage()
inflow_spilled : list
spileld power (list of same length and order as generators)
loadshed_power : list
same length and order as nodes
marginalprice : list
position according to grid.getIdxGeneratorsWithStorage()
flexload_power : list
position according to grid.getIdxConsumersWithFlexibleLoad()
flexload_storage : list
position according to grid.getIdxConsumersWithFlexibleLoad()
flexload_storagevalue : list
position according to grid.getIdxConsumersWithFlexibleLoad()
getAllGeneratorProductionOBSOLETE(timeMaxMin=None)

Returns all production [MWh] for all generators

getAreaPrices(area, timeMaxMin=None)

Weighted average nodal price timeseries for given area

getAreaPricesAverage(areas=None, timeMaxMin=None)

Time average of weighted average nodal price per area

getAverageBranchFlows(timeMaxMin=None, branchtype='ac')

Average flow on branches over a given time period

Parameters:

timeMaxMin : list (default = None)

[min, max] - lower and upper time interval

branchtype : string

‘ac’ (default) or ‘dc’

Returns:

List with values for each branch:

[flow from 1 to 2, flow from 2 to 1, average absolute flow]

getAverageBranchSensitivity(timeMaxMin=None)

Average branch capacity sensitivity over a given time period

Parameters:

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

Returns:

1-dim Array of sensitivities (one per branch)

getAverageEnergyBalance(timeMaxMin=None)

Average energy balance (generation minus demand) over a time period

timeMaxMin (list) (default = None)
[min, max] - lower and upper time interval
Returns:1-dim Array of nodal prices (one per node)
getAverageImportExport(area, timeMaxMin=None)

Return average import and export for a specified area

getAverageInterareaBranchFlow(filename=None, timeMaxMin=None)

Calculate average flow in each direction and total flow for inter-area branches. Requires sqlite version newer than 3.6

Parameters:

filename : string, optional

if a filename is given then the information is stored to file.

timeMaxMin : list with two integer values, or None, optional

time interval for the calculation [start,end]

Returns:

List with values for each inter-area branch:

[flow from 1 to 2, flow from 2 to 1, average absolute flow]

getAverageNodalPrices(timeMaxMin=None)

Average nodal price over a given time period

Parameters:

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

Returns:

1-dim Array of nodal prices (one per node)

getAverageUtilisation(timeMaxMin=None)

Average branch utilisation over a given time period

Parameters:

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

Returns:

1-dim Array of branch utilisation (power flow/capacity)

getDemandPerArea(area, timeMaxMin=None)

Returns demand timeseries for given area, as dictionary with fields “fixed”, “flex”, and “sum”

Parameters:

area (string)

area to get demand for

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

getEnergyBalanceInArea(area, spillageGen, resolution='H', fileName=None, timeMaxMin=None, start_date='2014-01-01')

Print time series of energy balance in an area, including production, spillage, load shedding, storage, pump consumption and imports

Parameters:

area : string

area code

spillageGen : list

generator types for which to show spillage (renewables)

resolution : string

resolution of output, see pandas:resample

fileName : string (default=None)

name of file to export results

timeMaxMin : list

time range to consider

start_date : date string

date when time series start

getGeneratorOutputSumPerArea(timeMaxMin=None)

Description Sums up generation per area.

Parameters:

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

Returns:

array of dictionary of generation sorted per area

getGeneratorSpilled(generatorindx, timeMaxMin=None)

Get spilled inflow time series for given generator

Parameters:

generatorindx (int)

index ofgenerator

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

getGeneratorSpilledSums(timeMaxMin=None)

Get sum of spilled inflow for all generators

Parameters:

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

getGeneratorStorageAll(timestep)

Get stored energy for all storage generators at given time

Parameters:

timestep : int

timestep when storage is requested

getGeneratorStorageValues(timestep)

Get value of stored energy for given time

Parameters:

timestep : int

when to compute value

Returns:

list of int

Value of stored energy for all storage generators

The method uses the storage value absolute level (basecost) per

generator to compute total storage value

getLoadheddingInArea(area, timeMaxMin=None)
getLoadheddingSums(timeMaxMin=None)

get loadshedding sum per area

getLoadsheddingPerNode(timeMaxMin=None)

get loadshedding sum per node

getNetImport(area, timeMaxMin=None)

Return time series for net import for a specified area

getNodalPrices(node, timeMaxMin=None)
getStorageFillingInAreas(areas, generator_type, relative_storage=True, timeMaxMin=None)

Gets time-series with aggregated storage filling for specified area(s) for a specific generator type.

Parameters:

areas : list

list of area codes (e.g. [‘DE’,’FR’])

generator_type : string

generator type string (e.g. ‘hydro’)

relative_storage : boolean

show relative (True) or absolute (False) storage

timeMaxMin : list

time range to consider (e.g. [0,8760])

getSystemCost(timeMaxMin=None)

Calculates system cost for energy produced by using generator fuel cost.

Parameters:

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

Returns:

array of dictionary of cost of generation sorted per area

getSystemCostOBSOLETE(timeMaxMin=None)

Calculates system cost for energy produced by using generator fuel cost.

Parameters:

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

Returns:

array of tuples of total cost of energy per area for all areas

[(area, costs), ...]

plotAreaPrice(areas, timeMaxMin=None, showTitle=True)

Show area price(s)

Parameters:

areas (list)

list of areas to show

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

plotDemandAtLoad(consumer_index, timeMaxMin=None, relativestorage=True, showTitle=True)

Make a time-series plot of consumption of a specified load

Parameters:

consumer_index (int)

index of consumer for which to make the plot

timeMaxMin [int,int] (default=None)

time interval for the plot [start,end]

relativestorage (default=True)

use filling fraction as y axis label for storage

plotDemandPerArea(areas, timeMaxMin=None, showTitle=True)

Show demand in area(s)

Parameters:

areas (list?)

list of areas to be plotted

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

plotEnergyMix(areas=None, timeMaxMin=None, relative=False, showTitle=True, variable='energy', gentypes=None)

Plot energy, generation capacity or spilled energy as stacked bars

Parameters:

areas : list of sting

Which areas to include, default=None means include all

timeMaxMin : list of two integers

Time range, [min,max]

relative : boolean

Whether to plot absolute (false) or relative (true) values

variable : string (“energy”,”capacity”,”spilled”)

Which variable to plot (default is energy production)

gentypes : list

List of generator types to include. None gives all.

plotFlexibleLoadStorageValues(consumerindx, timeMaxMin=None, showTitle=True)

Plot storage valuesfor flexible loads

Parameters:

consumerindx : int

index of consumer for which to make the plot

timeMaxMin : list, [int,int]

time interval for the plot [start,end], or None for entire range

plotGenerationPerArea(area, timeMaxMin=None, fill=True, reversed_order=False, net_import=True, loadshed=True, showTitle=True)

Show generation per area

Parameters:

area (str)

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

fill (Boolean) - whether use filled plot

reversed_order - whether to reverse order of generator types

net_import - whether to include net import in graph

loadshed - whether to include unmet demand

plotGenerationScatter(area, tech=[], dotsize=300, annotations=True)

Scatter plot of generation capacity and correlation of inflow with load.

Parameters:

area : string

area to plot

tech : list of strings

production technologies to plot. Empty list = all

dotsize : integer

adjust the size of scatterplots

annotations: boolean

whether to plot annotations

plotGeneratorOutput(generator_index, timeMaxMin=None, relativestorage=True, showTitle=True)

Show output of a generator

Parameters:

generator_index (int)

index of generator for which to make the plot

timeMaxMin [int,int] (default=None)

time interval for the plot [start,end]

relativestorage (default=True)

use filling fraction as y axis label for storage

plotMapGrid(nodetype=None, branchtype=None, dcbranchtype=None, show_node_labels=False, branch_style='c', latlon=None, timeMaxMin=None, dotsize=40, filter_node=None, filter_branch=None, draw_par_mer=False, showTitle=True, colors=True)

Plot results to map

Parameters:

nodetype : string

“”, “area”, “nodalprice”, “energybalance”, “loadshedding”

branchtype : string

“”, “capacity”, “area”, “utilisation”, “flow”, “sensitivity”

dcbranchtype : string

“”, “capacity”

show_node_labels : boolean

whether to show node names (true/false)

branch_style : string or list of strings (optional)

How branch capacity and flow should be visualised. “c” = colour, “t” = thickness. The two options may be combined.

dotsize : integer (optional)

set dot size for each plotted node

latlon: list of four floats (optional)

map area [lat_min, lon_min, lat_max, lon_max]

filter_node : list of two floats (optional)

[min,max] - lower and upper cutoff for node value

filter_branch : list of two floats

[min,max] - lower and upper cutoff for branch value

draw_par_mer : boolean

whether to draw parallels and meridians on map

showTitle : boolean

colors : boolean

Whether to use colours or not

plotNodalPrice(nodeIndx, timeMaxMin=None, showTitle=True)

Show nodal price in single node

Parameters:

nodeIndx (int)

index of node to plot from

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

plotRelativeGenerationCapacity(tech, show_node_labels=False, latlon=None, dotsize=40, draw_par_mer=False, colours=True, showTitle=True)

Plots the relative input generation capacity.

Parameters:

tech : string

production technology to be plotted

show_node_labels : boolean

whether to show node names (true/false)

latlon : list of four floats

map area [lat_min, lon_min, lat_max, lon_max]

draw_par_mer : boolean

whether to draw parallels and meridians on map

colours : boolean

whether to draw the map in colours or black and white

plotRelativeLoadDistribution(show_node_labels=False, latlon=None, dotsize=40, draw_par_mer=False, colours=True, showTitle=True)

Plots the relative input load distribution.

Parameters:

show_node_labels : boolean

whether to show node names (true/false)

latlon : list of four floats

map area [lat_min, lon_min, lat_max, lon_max]

draw_par_mer : boolean

whether to draw parallels and meridians on map

colours : boolean

whether to draw the map in colours or black and white

plotStorageFilling(generatorIndx, timeMaxMin=None, showTitle=True)

Show storage filling level (MWh) for generators with storage

Parameters:

generatorIndx (int)

index of generator to plot from

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

plotStoragePerArea(area, absolute=False, timeMaxMin=None, showTitle=True)

Show generation storage accumulated per area

Parameters:

area (str)

absolute (bool)(default=False)

plot storage value in absolute or relative to maximum

timeMaxMin (list) (default = None)

[min, max] - lower and upper time interval

plotStorageValues(genindx, timeMaxMin=None, showTitle=True)

Plot storage values (marginal prices) for generators with storage

Parameters:

genindx (int)

index of generator for which to make the plot

timeMaxMin [int,int] (default=None)

time interval for the plot [start,end]

plotTimeseriesColour(areas, value='nodalprice')

Plot timeseries values with days on x-axis and hour of day on y-axis

Parameters:

areas : list of strings

which areas to include, default=None means include all

value : ‘nodalprice’ (default),

‘demand’, ‘gen%<type1>%<type2>.. (where type=gentype)

which times series value to plot

Example: res.plotTimeseriescolour([‘ES’],value=’gen%solar_csp%wind’)

writeProductionOverview(areas, types, filename=None, timeMaxMin=None, TimeUnitCorrectionFactor=1)

Export production overview to CSV file

Write a .csv overview of the production[MWh] in timespan ‘timeMaxMin’ with the different areas and types as headers. The vectors ‘areas’ and ‘types’ becomes headers (column- and row headers), but the different elements of ‘types’ and ‘areas’ are also the key words in the search function ‘getAreaTypeProduction’. The vectors ‘areas’ and ‘types’ can be of any length.