Post-Process
Wrapping the tessif-fine post-processing.
- class tessif_fine_2_2_2.post_process.FINEResultier(optimized_es, **kwargs)[source]
Bases:
ResultierTransform nodes and edges into their name representation. Child of
Resultierand mother of all fine Resultiers.- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results
- class tessif_fine_2_2_2.post_process.IntegratedGlobalResultier(optimized_es, **kwargs)[source]
Bases:
FINEResultier,IntegratedGlobalResultierGlobal Results Extracting the integrated global results out of the energy system and conveniently aggregating them (rounded to unit place) inside a dictionairy keyed by result name.
Integrated global results (IGR) mapped by result name.
Integrated global results currently consist of meta and non-meta results. the meta results are handled by the
analyzemodule (seetessif.analyze.Comparatier.integrated_global_results) and consist of:timememory
results. whereas the non-meta results usually consist of:
emissionscosts
results, which are handled here. Tessif’s energy system, however, allow to formulate a number of
global_constraintswhich then would automatically be post processed here.The befornamed strings serve as key inside the mapping.
Note
Capacity costs calculated within the optimizing process in fine are related to the overall capacities which are installed in the energy system and not only to the new build capacity of the component. This results in differences in simulated costs compared to the post processed costs.
- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results
See also
For functionality documentation see the respective
base class.Examples
1. Accessing the global results, containing simulated costs and emissions, as well as post processed flow and capacity costs:
>>> import tessif.examples.data.fine.py_hard as coded_fine_examples >>> import tessif.transform.es2mapping.fine as post_process_fine >>> resultier = post_process_fine.IntegratedGlobalResultier( ... coded_fine_examples.create_expansion_example()) >>> print(resultier.global_results) {'emissions (sim)': 20.0, 'costs (sim)': 41.0, 'opex (ppcd)': 40.0, 'capex (ppcd)': 1.0}
- class tessif_fine_2_2_2.post_process.ScaleResultier(optimized_es, **kwargs)[source]
Bases:
FINEResultier,ScaleResultierExtract number of constraints and store them as int.
- Parameters:
optimized_es¶ – Model specific, optimized energy system containing its results.
See also
For functionality documentation see the respective
base class.Examples
1. Call and optimize a FINE energy system model. >>> # import post fine processing and example modules: >>> import tessif.examples.data.fine.py_hard as coded_fine_examples >>> import tessif.transform.es2mapping.fine as post_process_fine
>>> # optimize the energy system: >>> fine_es = coded_fine_examples.create_mwe()
>>> # post process the capacity results: >>> resultier = post_process_fine.ScaleResultier(fine_es)
Access the number of constraints.
>>> print(resultier.number_of_constraints) 27
- class tessif_fine_2_2_2.post_process.LoadResultier(optimized_es, **kwargs)[source]
Bases:
FINEResultier,LoadResultierLoads2mapping Transforming flow results into dictionairies keyed by node uid string representation.
- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results
See also
For functionality documentation see the respective
base class.Examples
Accessing a node’s outflows as positive numbers and a node’s inflows as negative numbers: (See
tessif.transform.es2mapping.base.LoadResultier.node_loadfor more documentation):>>> import tessif.examples.data.fine.py_hard as coded_fine_examples >>> import tessif.transform.es2mapping.fine as post_process_fine >>> resultier = post_process_fine.LoadResultier( ... coded_fine_examples.chp_example()) >>> print(resultier.node_load['CHP']) CHP Gas Grid Heat Grid Power Line 1990-07-13 00:00:00 -33.333333 6.666667 10.0 1990-07-13 01:00:00 -33.333333 6.666667 10.0 1990-07-13 02:00:00 -33.333333 6.666667 10.0 1990-07-13 03:00:00 -33.333333 6.666667 10.0
Accessing a node’s inflows as positive numbers (See
tessif.transform.es2mapping.base.LoadResultier.node_inflowsfor more documentation):>>> import tessif.examples.data.fine.py_hard as coded_fine_examples >>> import tessif.transform.es2mapping.fine as post_process_fine >>> resultier = post_process_fine.LoadResultier( ... coded_fine_examples.chp_example()) >>> print(resultier.node_inflows['CHP']) CHP Gas Grid 1990-07-13 00:00:00 33.333333 1990-07-13 01:00:00 33.333333 1990-07-13 02:00:00 33.333333 1990-07-13 03:00:00 33.333333
Accessing a node’s outflows as positive numbers (See
tessif.transform.es2mapping.base.LoadResultier.node_outflowsfor more documentation):>>> import tessif.examples.data.fine.py_hard as coded_fine_examples >>> import tessif.transform.es2mapping.fine as post_process_fine >>> resultier = post_process_fine.LoadResultier( ... coded_fine_examples.chp_example()) >>> print(resultier.node_outflows['CHP']) CHP Heat Grid Power Line 1990-07-13 00:00:00 6.666667 10.0 1990-07-13 01:00:00 6.666667 10.0 1990-07-13 02:00:00 6.666667 10.0 1990-07-13 03:00:00 6.666667 10.0
Accessing a node’s summed inflows as positive numbers (in case it is of component
sink) or a node’s summed outflows (in case it is not a sink). (Seetessif.transform.es2mapping.base.LoadResultier.node_summed_loadsfor more documentation):>>> import tessif.examples.data.fine.py_hard as coded_fine_examples >>> import tessif.transform.es2mapping.fine as post_process_fine >>> resultier = post_process_fine.LoadResultier(coded_fine_examples.chp_example()) >>> print(resultier.node_summed_loads['CHP']) 1990-07-13 00:00:00 16.666667 1990-07-13 01:00:00 16.666667 1990-07-13 02:00:00 16.666667 1990-07-13 03:00:00 16.666667 Freq: H, dtype: float64
- class tessif_fine_2_2_2.post_process.CapacityResultier(optimized_es, **kwargs)[source]
Bases:
CapacityResultier,LoadResultierCapacities2mapping Transforming installed capacity results dictionairies keyed by node.
- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results
Examples
Accessing the installed capacities and the characteristic values of the
minimum working example(See
tessif.transform.es2mapping.base.CapacityResultier.node_installed_capacityfor more documentation):>>> # import post fine processing and example modules: >>> import tessif.examples.data.fine.py_hard as coded_fine_examples >>> import tessif.transform.es2mapping.fine as post_process_fine
>>> # optimize the energy system: >>> fine_es = coded_fine_examples.create_mwe()
>>> # post process the capacity results: >>> resultier = post_process_fine.CapacityResultier(fine_es)
>>> # access the capacity results: >>> for node, capacity in resultier.node_installed_capacity.items(): ... print(f'{node}: {capacity}') PowerLine: None CBET: None Demand: 10.0 Renewable: 10.0 Gas Station: 23.81 Transformer: 10.0
>>> # acces the characteristic value results: >>> for node, cv in resultier.node_characteristic_value.items(): ... if cv is not None: ... cv = round(cv, 2) ... print(f'{node}: {cv}') PowerLine: None CBET: None Demand: 1.0 Renewable: 0.75 Gas Station: 0.25 Transformer: 0.25
Accessing the installed capacities and the characteristic value of the
Storage Example>>> # import fine postprocessing and example modules: >>> import tessif.examples.data.fine.py_hard as coded_fine_examples >>> import tessif.transform.es2mapping.fine as post_process_fine
>>> # optimize the energy system: >>> fine_es = coded_fine_examples.storage_example()
>>> # post process the capacity results: >>> resultier = post_process_fine.CapacityResultier(fine_es)
>>> # access the capacity results: >>> for node, capacity in resultier.node_installed_capacity.items(): ... print(f'{node}: {capacity}') Power Line: None Demand: 10.0 Generator: 20.0 Storage: 10.0
>>> # acces the characteristic value results: >>> for node, cv in resultier.node_characteristic_value.items(): ... if cv is not None: ... cv = round(cv, 2) ... print(f'{node}: {cv}') Power Line: None Demand: 0.94 Generator: 0.47 Storage: 0.34
- property node_characteristic_value
Mapped characteristic values to node uid representations.
Characteristic values of the energy system components mapped to their node uid representation.
Components of variable size or have a characteristic value as stated in
tessif.frused.defaults.energy_system_nodes.Characteristic value in this context means:
\(cv = \frac{\text{characteristic flow}} {\text{installed capacity}}\) for:
SourceobjectsSinkobjectsTransformerobjects
\(cv = \frac{\text{mean}\left(\text{SOC}\right)} {\text{capacity}}\) for:
Storage
Characteristic flow in this context means:
mean(LoadResultier.node_summed_loads)SourceobjectsSinkobjects
mean(0th outflow)for:Transformerobjects
The node fillsize of the advanced system visualization scales with the characteristic value. If no capacity is defined (i.e for nodes of variable size, like busses or excess sources and sinks, node size is set to it’s default (
nxgrph_visualize_defaults[node_fill_size]).
- class tessif_fine_2_2_2.post_process.StorageResultier(optimized_es, **kwargs)[source]
Bases:
FINEResultier,StorageResultierTransforming storage results into dictionairies keyed by node.
- Parameters:
optimized_es¶ (fine energy system) – An optimized fine energy system containing its results
See also
For functionality documentation see the respective
base class.Examples
Display a storage-node’s capacity:
Setting
spellings.get_from'slogging level to debug for decluttering doctest output:>>> from tessif.frused import configurations >>> configurations.spellings_logging_level = 'debug'
Actual Example:
>>> # import post fine processing and example modules: >>> import tessif.examples.data.fine.py_hard as coded_fine_examples >>> import tessif.transform.es2mapping.fine as post_process_fine
>>> # optimize the energy system: >>> fine_es = coded_fine_examples.storage_example()
>>> # post process the capacity results: >>> resultier = post_process_fine.StorageResultier(fine_es)
>>> print(post_process_fine.StorageResultier(fine_es).node_soc['Storage']) 1990-07-13 00:00:00 0.0 1990-07-13 01:00:00 0.0 1990-07-13 02:00:00 7.0 1990-07-13 03:00:00 0.0 1990-07-13 04:00:00 10.0 Freq: H, Name: Storage, dtype: float64
- class tessif_fine_2_2_2.post_process.NodeCategorizer(optimized_es, **kwargs)[source]
Bases:
FINEResultier,NodeCategorizerCategorizing the nodes of an optimized fine energy system.
Categorization utilizes
Uid.Nodes are categorized by:
Energy
component(One of the ‘Bus’, ‘Sink’, etc..)Energy
sector(‘power’, ‘heat’, ‘mobility’, ‘coupled’)Region(‘arbitrary label’)Coordinates(latitude, longitude in degree)Energy
carrier(‘solar’, ‘wind’, ‘electricity’, ‘steam’ …)Node type(‘arbitrary label’)
- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results
See also
For functionality documentation see the respective
base class.Examples
Display the energy system component’s
Coordinates:>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.NodeCategorizer(fine_examples.create_mwe()) >>> pprint.pprint(resultier.node_coordinates) {'CBET': Coordinates(latitude=53, longitude=10), 'Demand': Coordinates(latitude=53, longitude=10), 'Gas Station': Coordinates(latitude=53, longitude=10), 'PowerLine': Coordinates(latitude=53, longitude=10), 'Renewable': Coordinates(latitude=53, longitude=10), 'Transformer': Coordinates(latitude=53, longitude=10)}
Group energy system components by their
region:>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.NodeCategorizer(fine_examples.create_mwe()) >>> pprint.pprint(resultier.node_region_grouped) {'Germany': ['PowerLine', 'CBET', 'Demand', 'Renewable', 'Gas Station', 'Transformer']}
Group energy system components by their
sector>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.NodeCategorizer(fine_examples.create_mwe()) >>> pprint.pprint(resultier.node_sector_grouped) {'Power': ['PowerLine', 'CBET', 'Demand', 'Renewable', 'Gas Station', 'Transformer']}
Group energy system components by their
node_type:>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.NodeCategorizer(fine_examples.create_mwe()) >>> pprint.pprint(resultier.node_type_grouped) {'AC-bus': ['PowerLine'], 'AC-source': ['Renewable'], 'Gas import': ['Gas Station'], 'Gas-bus': ['CBET'], 'Gas-powerplant': ['Transformer'], 'Sink': ['Demand']}
Group energy system components by their energy
carrier:>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.NodeCategorizer(fine_examples.create_mwe()) >>> pprint.pprint(resultier.node_carrier_grouped) {'Electricity': ['PowerLine', 'Demand', 'Renewable'], 'Gas': ['CBET', 'Gas Station', 'Transformer']}
Map the node uid representation <Labeling_Concept> of each component of the energy system to their energy
carrier:>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.NodeCategorizer(fine_examples.create_mwe()) >>> pprint.pprint(resultier.node_energy_carriers) {'CBET': 'gas', 'Demand': 'Electricity', 'Gas Station': 'gas', 'PowerLine': 'Electricity', 'Renewable': 'Electricity', 'Transformer': 'gas'}
Map the node uid representation <Labeling_Concept> of each component of the energy system to their
component:>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.NodeCategorizer(fine_examples.emission_objective()) >>> pprint.pprint(resultier.node_components) {'Bus': ['Power Line', 'CBET'], 'Sink': ['Demand'], 'Source': ['CBE', 'Renewable'], 'Transformer': ['Transformer']}
- class tessif_fine_2_2_2.post_process.FlowResultier(optimized_es, **kwargs)[source]
Bases:
FlowResultier,LoadResultierFlows2mapping Transforming flow results into dictionairies keyed by edges.
- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results
See also
For functionality documentation see the respective
base class.Examples
Display the net energy flows of a small energy system:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.FlowResultier(fine_examples.emission_objective()) >>> pprint.pprint(resultier.edge_net_energy_flow) {Edge(source='CBE', target='CBET'): 30.0, Edge(source='CBET', target='Transformer'): 30.0, Edge(source='Power Line', target='Demand'): 40.0, Edge(source='Renewable', target='Power Line'): 27.4, Edge(source='Transformer', target='Power Line'): 12.6}
Display the total costs incurred sorted by edge/flow:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.FlowResultier(fine_examples.emission_objective()) >>> pprint.pprint(resultier.edge_total_costs_incurred) {Edge(source='CBE', target='CBET'): 0.0, Edge(source='CBET', target='Transformer'): 0.0, Edge(source='Power Line', target='Demand'): 0.0, Edge(source='Renewable', target='Power Line'): 137.0, Edge(source='Transformer', target='Power Line'): 60.0}
Display the total emissions caused sorted by edge/flow:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.FlowResultier(fine_examples.emission_objective()) >>> pprint.pprint(resultier.edge_total_emissions_caused) {Edge(source='CBE', target='CBET'): 0.0, Edge(source='CBET', target='Transformer'): 0.0, Edge(source='Power Line', target='Demand'): 0.0, Edge(source='Renewable', target='Power Line'): 0.0, Edge(source='Transformer', target='Power Line'): 5.292}
Display the specific flow costs of this energy system:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.FlowResultier(fine_examples.emission_objective()) >>> pprint.pprint(resultier.edge_specific_flow_costs) {Edge(source='CBE', target='CBET'): 0.0, Edge(source='CBET', target='Transformer'): 0.0, Edge(source='Power Line', target='Demand'): 0.0, Edge(source='Renewable', target='Power Line'): 5.0, Edge(source='Transformer', target='Power Line'): 4.761904761904762}
Display the specific emission of this energy system:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.FlowResultier(fine_examples.emission_objective()) >>> pprint.pprint(resultier.edge_specific_emissions) {Edge(source='CBE', target='CBET'): 0.0, Edge(source='CBET', target='Transformer'): 0.0, Edge(source='Power Line', target='Demand'): 0.0, Edge(source='Renewable', target='Power Line'): 0.0, Edge(source='Transformer', target='Power Line'): 0.42}
Show the caluclated edge weights of this energy system:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> resultier = fine.FlowResultier(fine_examples.emission_objective()) >>> pprint.pprint(resultier.edge_weight) {Edge(source='CBE', target='CBET'): 0.1, Edge(source='CBET', target='Transformer'): 0.1, Edge(source='Power Line', target='Demand'): 0.1, Edge(source='Renewable', target='Power Line'): 1.0, Edge(source='Transformer', target='Power Line'): 0.9523809523809523}
Access the reference emissions and net energy flow:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> resultier = fine.FlowResultier(fine_examples.emission_objective())
>>> print(resultier.edge_reference_emissions) 0.42
>>> print(resultier.edge_reference_net_energy_flow) 40.0
- class tessif_fine_2_2_2.post_process.AllResultier(optimized_es, **kwargs)[source]
Bases:
CapacityResultier,FlowResultier,StorageResultier,ScaleResultierTransform energy system results into a dictionary keyed by attribute.
Incorporates all the functionalities from its bases.
- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results
Note
This class allows interfacing with ALL framework processing utilities. It extracts every bit of info the author ever needed in his postprocessing.
It is meant to be a “one fits all” solution for small energy systems. Perfectly fit for showing “proof of concepts” or debugging energy system components.
Not meant to be used with large energy systems.
- class tessif_fine_2_2_2.post_process.LabelFormatier(optimized_es, **kwargs)[source]
Bases:
LabelFormatier,FlowResultier,CapacityResultierGenerate component summaries as multiline label dictionairy entries.
- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results
See also
For functionality documentation see the respective
base class.Examples
Compile and display a node’s summary:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> formatier = fine.LabelFormatier(fine_examples.create_mwe()) >>> pprint.pprint(formatier.node_summaries['Demand']) {'Demand': 'Demand\n10 MW\ncf: 1.0'}
Compile and display an edge’s summary:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> formatier = fine.LabelFormatier(fine_examples.create_mwe()) >>> pprint.pprint(formatier.edge_summaries[ ... ('Renewable', 'PowerLine')]) {('Renewable', 'PowerLine'): '30 MWh\n1.0 €/MWh\n0.0 t/MWh'}
- class tessif_fine_2_2_2.post_process.NodeFormatier(optimized_es, cgrp='name', drawutil='nx', **kwargs)[source]
Bases:
NodeFormatier,CapacityResultierTransforming energy system results into node visuals.
- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results.`
Which group of color attribute(s) to return. One of:
{'name', 'carrer', 'sector'}
Color related attributes are grouped by
tessif.frused.namedtuples.NodeColorGroupingsand are thus returned as atyping.NamedTuple. Certain api functionalities expect those attributes to be dicts. (Usually those working only onESTransformerinput). Use this parameter on Formatier creation to provide the expected dictionairy.drawutil¶ (str, default='nx') – Which drawuing utility backend to format node size, fil_size and shape to.
'dc'forplotly-dash-cytoscapeor'nx'fornetworkx-matplotlib.
See also
For functionality documentation see the respective
base class.Examples
Generate and display a small energy system’s node shape mapping:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> formatier = fine.NodeFormatier(fine_examples.create_mwe()) >>> pprint.pprint(formatier.node_shape) {'CBET': 'o', 'Demand': '8', 'Gas Station': 'o', 'PowerLine': 'o', 'Renewable': 'o', 'Transformer': '8'}
Compare these to the
dcgrphready shapes:>>> formatier = fine.NodeFormatier( ... fine_examples.create_mwe(), ... drawutil='dc') >>> pprint.pprint(formatier.node_shape) {'CBET': 'ellipse', 'Demand': 'ellipse', 'Gas Station': 'round-rectangle', 'PowerLine': 'ellipse', 'Renewable': 'round-rectangle', 'Transformer': 'round-octagon'}
Generate and display a small energy system’s node size mapping:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> formatier = fine.NodeFormatier(fine_examples.create_mwe()) >>> pprint.pprint(formatier.node_size) {'CBET': 'variable', 'Demand': 1260, 'Gas Station': 3000, 'PowerLine': 'variable', 'Renewable': 1260, 'Transformer': 1260}
Compare these to the
dcgrphready sizes scaled to a different default node size:>>> formatier = fine.NodeFormatier( ... fine_examples.create_mwe(), ... drawutil='dc') >>> pprint.pprint(formatier.node_size) {'CBET': 'variable', 'Demand': 38, 'Gas Station': 90, 'PowerLine': 'variable', 'Renewable': 38, 'Transformer': 38}
Generate and display a small energy system’s node fill size mapping:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> formatier = fine.NodeFormatier(fine_examples.create_mwe()) >>> pprint.pprint(formatier.node_fill_size) {'CBET': None, 'Demand': 1260.0, 'Gas Station': 750.0, 'PowerLine': None, 'Renewable': 945.0, 'Transformer': 315.0}
Compare these to the
dcgrphready sizes scaled to a different default node size:>>> formatier = fine.NodeFormatier( ... fine_examples.create_mwe(), ... drawutil='dc') >>> pprint.pprint(formatier.node_fill_size) {'CBET': None, 'Demand': 38.0, 'Gas Station': 22.0, 'PowerLine': None, 'Renewable': 28.0, 'Transformer': 10.0}
Generate and display a small energy system’s node color mapping basd on the grouping:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> formatier = fine.NodeFormatier( ... fine_examples.create_mwe(), cgrp='all') >>> pprint.pprint(formatier.node_color.name) {'CBET': '#AFAFAF', 'Demand': '#330099', 'Gas Station': '#336666', 'PowerLine': '#ffff33', 'Renewable': '#AFAFAF', 'Transformer': '#9999ff'}
>>> pprint.pprint(formatier.node_color.carrier) {'CBET': '#336666', 'Demand': '#FFD700', 'Gas Station': '#336666', 'PowerLine': '#FFD700', 'Renewable': '#FFD700', 'Transformer': '#336666'}
>>> pprint.pprint(formatier.node_color.sector) {'CBET': '#ffff33', 'Demand': '#ffff33', 'Gas Station': '#ffff33', 'PowerLine': '#ffff33', 'Renewable': '#ffff33', 'Transformer': '#ffff33'}
Generate and display a small energy system’s node color map (colors that are cycled through for each component type) mapping basd on the grouping:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> from tessif.transform.es2mapping import fine >>> import pprint >>> formatier = fine.NodeFormatier( ... fine_examples.create_mwe(), cgrp='all') >>> pprint.pprint({k: type(v) ... for k,v in formatier.node_color_maps.name.items()}) {'CBET': <class 'str'>, 'Demand': <class 'str'>, 'Gas Station': <class 'str'>, 'PowerLine': <class 'str'>, 'Renewable': <class 'str'>, 'Transformer': <class 'str'>} >>> pprint.pprint({k: type(v) ... for k,v in formatier.node_color_maps.carrier.items()}) {'CBET': <class 'str'>, 'Demand': <class 'str'>, 'Gas Station': <class 'str'>, 'PowerLine': <class 'str'>, 'Renewable': <class 'str'>, 'Transformer': <class 'str'>} >>> pprint.pprint({k: type(v) ... for k,v in formatier.node_color_maps.sector.items()}) {'CBET': <class 'str'>, 'Demand': <class 'str'>, 'Gas Station': <class 'str'>, 'PowerLine': <class 'str'>, 'Renewable': <class 'str'>, 'Transformer': <class 'str'>}
(Hint for devs: Which color string is mapped depends on order of mapping. Therefore only the type is printed and not its string value since it may differ from doctest to doctest.)
- class tessif_fine_2_2_2.post_process.MplLegendFormatier(optimized_es, cgrp='all', markers='formatier', **kwargs)[source]
Bases:
MplLegendFormatier,CapacityResultierGenerating visually enhanced matplotlib legends for nodes and edges.
- Parameters:
optimized_es¶ (fine energy system) – An optimized fine energy system containing its results.`
Which group of color attribute(s) to return. One of:
{'name', 'carrier', 'sector'}
Color related attributes are grouped by
tessif.frused.namedtuples.NodeColorGroupingsand are thus returned as atyping.NamedTuple. Certain api functionalities expect those attributes to be dicts. (Usually those working only onESTransformerinput). Use this parameter on Formatier creation to provide the expected dictionairy.markers¶ (str, default='formatier') –
What marker to use for legend entries. Either
'formatier'or one of thematplotlib.markers.If
'formatier'is used, markers will be inferred fromNodeFormatier.node_shape.
See also
For functionality documentation see the respective
base class.Examples
Handle the imports of the following examples and simulate the energy system:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> import tessif.transform.es2mapping.fine as post_process_fine >>> import pprint
Generate and display name grouped legend labels of a small energy system:
>>> formatier = post_process_fine.MplLegendFormatier( ... fine_examples.create_mwe(), cgrp='all') >>> pprint.pprint(formatier.node_legend.name['legend_labels']) ['CBET', 'Demand', 'Gas Station', 'PowerLine', 'Renewable', 'Transformer']
Generate and display matplotlib legend attributes to describe
fency node styles. Fency as in:variable node size being outer fading circles
cycle filling being proportional capacity factors
outer diameter being proportional installed capacities
>>> formatier = post_process_fine.MplLegendFormatier( ... fine_examples.create_mwe(), cgrp='all') >>> pprint.pprint({k: type(v) ... for k,v in formatier.node_style_legend.items()}) {'legend_bbox_to_anchor': <class 'tuple'>, 'legend_borderaxespad': <class 'int'>, 'legend_handles': <class 'list'>, 'legend_labels': <class 'list'>, 'legend_labelspacing': <class 'int'>, 'legend_loc': <class 'str'>, 'legend_title': <class 'str'>}
- class tessif_fine_2_2_2.post_process.EdgeFormatier(optimized_es, drawutil='nx', cls=None, **kwargs)[source]
Bases:
EdgeFormatier,FlowResultierTransforming energy system results into edge visuals.
- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results
drawutil¶ (str, default='nx') – Which drawuing utility backend to format node size, fil_size and shape to.
'dc'forplotly-dash-cytoscapeor'nx'fornetworkx-matplotlib.2-Tuple /
CLS namedtupledefining the relative flow cost thresholds and the respective style specifications. Used to map specific flow costs to edge line style representations.If
None, default implementation is used based ondrawutil.For
drawutil='nx'Networkx-Matplotlib:cls = ([0, .33, .66], ['dotted', 'dashed', 'solid'])
For
drawutil='dc'Dash-Cytoscape styles are used:cls = ([0, .33, .66], ['dotted', 'dashed', 'solid'])
Translating to all edges of relative specific flows costs, between
0and.33are correlated to have a':'/'dotted'linestyle.
See also
For functionality documentation see the respective
base class.Examples
Handle the imports:
>>> import tessif.examples.data.fine.py_hard as fine_examples >>> import tessif.transform.es2mapping.fine as post_process_fine >>> import pprint
Generate and display a small energy system’s edge withs:
>>> formatier = post_process_fine.EdgeFormatier( ... fine_examples.create_mwe()) >>> pprint.pprint(list(sorted(formatier.edge_width.items()))) [(Edge(source='CBET', target='Transformer'), 0.6), (Edge(source='Gas Station', target='CBET'), 0.6), (Edge(source='PowerLine', target='Demand'), 1.0), (Edge(source='Renewable', target='PowerLine'), 0.75), (Edge(source='Transformer', target='PowerLine'), 0.25)]
Compare these to the
dcgrphready widths, scaled to a different default edge width:>>> formatier = post_process_fine.EdgeFormatier( ... fine_examples.create_mwe(), ... drawutil='dc') >>> pprint.pprint(list(sorted(formatier.edge_width.items()))) [(Edge(source='CBET', target='Transformer'), 4.17), (Edge(source='Gas Station', target='CBET'), 4.17), (Edge(source='PowerLine', target='Demand'), 7.0), (Edge(source='Renewable', target='PowerLine'), 5.25), (Edge(source='Transformer', target='PowerLine'), 1.75)]
Generate and display a small energy system’s edge colors:
>>> formatier = post_process_fine.EdgeFormatier( ... fine_examples.create_mwe()) >>> pprint.pprint(list(sorted(formatier.edge_color.items()))) [(Edge(source='CBET', target='Transformer'), [0.15]), (Edge(source='Gas Station', target='CBET'), [0.15]), (Edge(source='PowerLine', target='Demand'), [0.15]), (Edge(source='Renewable', target='PowerLine'), [0.15]), (Edge(source='Transformer', target='PowerLine'), [0.15])]
(
draw_networkx_edges()expects iterable of floats when using a colormap)Compare these to the
dcgrphready colors, directly scaling the relativ specific emissions to a hex-color value.>>> formatier = post_process_fine.EdgeFormatier( ... fine_examples.create_mwe(), ... drawutil='dc') >>> pprint.pprint(list(sorted(formatier.edge_color.items()))) [(Edge(source='CBET', target='Transformer'), '#d8d8d8'), (Edge(source='Gas Station', target='CBET'), '#d8d8d8'), (Edge(source='PowerLine', target='Demand'), '#d8d8d8'), (Edge(source='Renewable', target='PowerLine'), '#d8d8d8'), (Edge(source='Transformer', target='PowerLine'), '#d8d8d8')]
Generate and display a small energy system’s edge line styles:
>>> formatier = post_process_fine.EdgeFormatier( ... fine_examples.create_mwe()) >>> pprint.pprint(list(sorted(formatier.edge_linestyle.items()))) [(Edge(source='CBET', target='Transformer'), ':'), (Edge(source='Gas Station', target='CBET'), ':'), (Edge(source='PowerLine', target='Demand'), ':'), (Edge(source='Renewable', target='PowerLine'), ':'), (Edge(source='Transformer', target='PowerLine'), '-')]
Compare these to the
dcgrphready styles, using different specifiers:>>> formatier = post_process_fine.EdgeFormatier( ... fine_examples.create_mwe(), ... drawutil='dc') >>> pprint.pprint(list(sorted(formatier.edge_linestyle.items()))) [(Edge(source='CBET', target='Transformer'), 'dotted'), (Edge(source='Gas Station', target='CBET'), 'dotted'), (Edge(source='PowerLine', target='Demand'), 'dotted'), (Edge(source='Renewable', target='PowerLine'), 'dotted'), (Edge(source='Transformer', target='PowerLine'), 'solid')]
- class tessif_fine_2_2_2.post_process.AllFormatier(optimized_es, cgrp='all', markers='formatier', drawutil='nx', cls=None, **kwargs)[source]
Bases:
LabelFormatier,MplLegendFormatier,NodeFormatier,EdgeFormatierTransforming ES results into visual expression dicts keyed by attribute. Incorperates all the functionalities from its parents.
- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results
Which group of color attribute(s) to return. One of:
{'name', 'carrer', 'sector'}
Color related attributes are grouped by
tessif.frused.namedtuples.NodeColorGroupingsand are thus returned as atyping.NamedTuple. Certain api functionalities expect those attributes to be dicts. (Usually those working only onESTransformerinput). Use this parameter on Formatier creation to provide the expected dictionairy.Used by
NodeFormatierandMplLegendFormatiermarkers¶ (str, default='formatier') –
What marker to use for legend entries. Either
'formatier'or one of thematplotlib.markers.If
'formatier'is used, markers will be inferred fromNodeFormatier.node_shape.Used by
MplLegendFormatierdrawutil¶ (str, default='nx') – Which drawuing utility backend to format node size, fil_size and shape to.
'dc'forplotly-dash-cytoscapeor'nx'fornetworkx-matplotlib.2-Tuple /
CLS namedtupledefining the relative flow cost thresholds and the respective style specifications. Used to map specific flow costs to edge line style representations.If
None, default implementation is used based ondrawutil.For
drawutil='nx'Networkx-Matplotlib:cls = ([0, .33, .66], ['dotted', 'dashed', 'solid'])
For
drawutil='dc'Dash-Cytoscape styles are used:cls = ([0, .33, .66], ['dotted', 'dashed', 'solid'])
Translating to all edges of relative specific flows costs, between
0and.33are correlated to have a':'/'dotted'linestyle.
Note
This class allows interfacing with ALL framework processing utilities. It extracts every bit of info the author ever needed in his postprocessing.
It is meant to be a “one fits all” solution for small energy systems. Perfectly fit for showing “proof of concepts” or debugging energy system components.
Not meant to be used with large energy systems.
- class tessif_fine_2_2_2.post_process.ICRHybridier(optimized_es, colored_by='name', **kwargs)[source]
Bases:
FINEResultier,ICRHybridierAggregate numerical and visual information for visualizing the Integrated_Component_Results (ICR).
- Parameters:
optimized_es¶ (fine energy system model) – An optimized fine energy system containing its results
See also
For non model specific attributes see the respective
base class.- property node_characteristic_value
Map node label to characteristic value.
Components of variable size have a characteristic value of
None.The node fillsize of integrated compnent results graphs scales with the characteristic value. If no capacity is defined (i.e for nodes of variable size, like busses or excess sources and sinks, node size is set to it’s default (
nxgrph_visualize_defaults[node_fill_size]).