Post-Process
Wrapping the tessif-calliope post-processing.
- class tessif_calliope_0_6_6post1.post_process.CalliopeResultier(optimized_es, **kwargs)[source]
Bases:
tessif.post_process.ResultierTransform nodes and edges into their name representation. Child of
Resultierand mother of all calliope Resultiers.- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as results.
Note
Calliope does not support Tessif’s UID notation. To get as much as possible information the UID is stored as one string with separation via dot in the technology names. Sine Busses and Connectors are only calliope locations and no technologies they dont have a name parameter and thus do not have all UID information..
- class tessif_calliope_0_6_6post1.post_process.IntegratedGlobalResultier(optimized_es, **kwargs)[source]
Bases:
tessif_calliope_0_6_6post1.post_process.CalliopeResultier,tessif.post_process.IntegratedGlobalResultierExtracting 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.
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as results.
Note
Overall costs might differ from sum of OPEX and CAPEX on expansion problems due to rounding errors on calliope specific calculation using the lifetime, which is very small on small timeframes (lifetime = timesteps/8760).
The Calliope objective differs from Tessif output if expansion problems with installed capacities are analysed. This is due to calliope not considering installed capacities by default and thus using the expansion minimum as installed capacity in tessif. The occuring costs are then erased in the mapping.
See also
For functionality documentation see the respective
base class.Examples
Using
emission_objective()to quickly access a tessif energy system to use for doctesting, or trying out this frameworks utilities.>>> import tessif.examples.data.tsf.py_hard as tsf_examples >>> tsf_es = tsf_examples.emission_objective()
Transform the energy system to an oemof energy system:
>>> import tessif.transform.es2es.cllp as tessif_to_calliope >>> calliope_es = tessif_to_calliope.transform(tsf_es)
Optmize the energy system:
>>> import tessif.simulate as simulate >>> optimized_calliope_es = simulate.cllp_from_es(calliope_es, solver='cbc')
Extract the global results:
>>> import pprint >>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> resultier = calliope_post_process.IntegratedGlobalResultier( ... optimized_calliope_es) >>> pprint.pprint(resultier.global_results) {'capex (ppcd)': 0.0, 'costs (sim)': 252.0, 'emissions (sim)': 60.0, 'opex (ppcd)': 252.0}
Using a native calliope model. Calling and optimize a calliope energy system model.
>>> from tessif.frused.paths import example_dir >>> import calliope >>> calliope.set_log_verbosity('ERROR', include_solver_output=False) >>> calliope_es = calliope.Model(f'{example_dir}/data/calliope/fpwe/model.yaml') >>> calliope_es.run()
>>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> import pprint >>> resultier = calliope_post_process.IntegratedGlobalResultier(calliope_es) >>> pprint.pprint(resultier.global_results) {'capex (ppcd)': 0.0, 'costs (sim)': 105.0, 'emissions (sim)': 53.0, 'opex (ppcd)': 105.0}
- class tessif_calliope_0_6_6post1.post_process.ScaleResultier(optimized_es, **kwargs)[source]
Bases:
tessif_calliope_0_6_6post1.post_process.CalliopeResultier,tessif.post_process.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
Call and optimize a calliope energy system model.
>>> from tessif.frused.paths import example_dir >>> import calliope as native_calliope >>> native_calliope.set_log_verbosity('ERROR', include_solver_output=False) >>> calliope_es = native_calliope.Model(f'{example_dir}/data/calliope/fpwe/model.yaml') >>> calliope_es.run() >>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> resultier = calliope_post_process.ScaleResultier(calliope_es)
Access the number of constraints.
>>> print(resultier.number_of_constraints) 194
- class tessif_calliope_0_6_6post1.post_process.LoadResultier(optimized_es, **kwargs)[source]
Bases:
tessif_calliope_0_6_6post1.post_process.CalliopeResultier,tessif.post_process.LoadResultierTransforming flow results into dictionairies keyed by node.
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as results.
See also
For functionality documentation see the respective
base class.Examples
Calling and optimize a calliope energy system model.
>>> from tessif.frused.paths import example_dir >>> import calliope as native_calliope >>> native_calliope.set_log_verbosity('ERROR', include_solver_output=False) >>> calliope_es = native_calliope.Model(f'{example_dir}/data/calliope/fpwe/model.yaml') >>> calliope_es.run() >>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> resultier = calliope_post_process.LoadResultier(calliope_es)
Accessing a node’s outflows as positive numbers and a node’s inflows as negative numbers:
>>> print(resultier.node_load['Powerline']) Powerline Battery Generator Solar Panel Battery Demand 1990-07-13 00:00:00 -0.0 -0.0 -12.0 1.0 11.0 1990-07-13 01:00:00 -8.0 -0.0 -3.0 0.0 11.0 1990-07-13 02:00:00 -0.9 -3.1 -7.0 0.0 11.0
Accessing a node’s inflows as positive numbers:
>>> print(resultier.node_inflows['Powerline']) Powerline Battery Generator Solar Panel 1990-07-13 00:00:00 0.0 0.0 12.0 1990-07-13 01:00:00 8.0 0.0 3.0 1990-07-13 02:00:00 0.9 3.1 7.0
Accessing a node’s outflows as positive numbers:
>>> print(resultier.node_outflows['Powerline']) Powerline Battery Demand 1990-07-13 00:00:00 1.0 11.0 1990-07-13 01:00:00 0.0 11.0 1990-07-13 02:00:00 0.0 11.0
Accessing the sum of a node’s inflow (in case it’s a
Sink) or the sum of a node’s outflows (in case it’s NOT aSink):>>> print(resultier.node_summed_loads['Powerline']) 1990-07-13 00:00:00 12.0 1990-07-13 01:00:00 11.0 1990-07-13 02:00:00 11.0 dtype: float64
- class tessif_calliope_0_6_6post1.post_process.CapacityResultier(optimized_es, **kwargs)[source]
Bases:
tessif.post_process.CapacityResultier,tessif_calliope_0_6_6post1.post_process.LoadResultierTransforming installed capacity results dictionairies keyed by node.
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as results.
See also
For functionality documentation see the respective
base class.Note
Expansion costs on CHP’s will look different than they have been set in model. This is due to the fact, that calliope only considers one cost parameter, thus the different CHP parameters are put together to one value and later on cannot be separated again.
Examples
Transforming and optimize a tessif energy system using calliope.
>>> import tessif.examples.data.tsf.py_hard as tsf_examples >>> import tessif.transform.es2es.cllp as tessif_to_calliope >>> import tessif.simulate as simulate >>> tsf_es = tsf_examples.create_mwe() >>> calliope_es = tessif_to_calliope.transform(tsf_es) >>> optimized_calliope_es = simulate.cllp_from_es(calliope_es, solver='cbc') >>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> import pprint
Display a small energy system’s installed capacities after optimization as well as their original capacities:
>>> resultier = calliope_post_process.CapacityResultier(optimized_calliope_es) >>> pprint.pprint(resultier.node_installed_capacity) {'Battery': 20.0, 'Demand': 10.0, 'Gas Station': 23.809524, 'Generator': 10.0, 'Pipeline': None, 'Powerline': None} >>> pprint.pprint(resultier.node_original_capacity) {'Battery': 20.0, 'Demand': 10.0, 'Gas Station': 0.0, 'Generator': 0.0, 'Pipeline': None, 'Powerline': None}
Display a small energy system’s characteristic values after optimization:
>>> pprint.pprint(resultier.node_characteristic_value) {'Battery': 0.0, 'Demand': 1.0, 'Gas Station': 0.75, 'Generator': 0.75, 'Pipeline': None, 'Powerline': None}
Display a small energy system’s reference capacity:
>>> pprint.pprint(resultier.node_reference_capacity) 23.809524
Display capacity data for a multi output transformer:
>>> tsf_es = tsf_examples.create_component_es(expansion_problem=True) >>> calliope_es = tessif_to_calliope.transform(tsf_es) >>> optimized_calliope_es = simulate.cllp_from_es(calliope_es, solver='cbc') >>> resultier = calliope_post_process.CapacityResultier(optimized_calliope_es) >>> print(resultier.node_installed_capacity['Biogas CHP']) Heatline 250.0 Powerline 200.0 dtype: float64 >>> print(resultier.node_expansion_costs['Biogas CHP']) Heatline 0.0 Powerline 3828125.0 dtype: float64
Note how the CHP expansion costs are only one value in Calliope even if they are splitted for each output in the Tessif energy system:
>>> for transformer in tsf_es.transformers: ... if transformer.uid.name == 'Biogas CHP': ... print(transformer.expansion_costs) {'biogas': 0, 'electricity': 3500000, 'hot_water': 262500}
- 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_calliope_0_6_6post1.post_process.StorageResultier(optimized_es, **kwargs)[source]
Bases:
tessif_calliope_0_6_6post1.post_process.CalliopeResultier,tessif.post_process.StorageResultierTransforming storage results into dictionaries keyed by node.
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as results.
See also
For functionality documentation see the respective
base class.Examples
Transforming and optimize a tessif energy system using calliope.
>>> import tessif.examples.data.tsf.py_hard as tsf_examples >>> import tessif.transform.es2es.cllp as tessif_to_calliope >>> import tessif.simulate as simulate >>> tsf_es = tsf_examples.create_storage_example() >>> calliope_es = tessif_to_calliope.transform(tsf_es) >>> optimized_calliope_es = simulate.cllp_from_es(calliope_es, solver='cbc') >>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> import pprint
Display a storage-node’s capacity:
>>> resultier = calliope_post_process.StorageResultier(optimized_calliope_es) >>> print(resultier.node_soc['Storage']) 1990-07-13 00:00:00 8.100000 1990-07-13 01:00:00 16.200000 1990-07-13 02:00:00 27.000000 1990-07-13 03:00:00 15.888889 1990-07-13 04:00:00 4.777778 Freq: H, Name: Storage, dtype: float64
- class tessif_calliope_0_6_6post1.post_process.NodeCategorizer(optimized_es, **kwargs)[source]
Bases:
tessif_calliope_0_6_6post1.post_process.CalliopeResultier,tessif.post_process.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¶ (
Model) – An optimized calliope energy system containing its inputs as well as results.
See also
For functionality documentation see the respective
base class.Note
Calliope does not fully support tessif’s uid notation. The UID is given inside the calliope technology name. Busses and connector are only locations and no techs, so they don’t have any UID information besides the coordinates and the Carrier which information can be recreated using the in and output. The tessif component type can be identified since each calliope technology inherits from a parent technology which can be linked to a tessif component. Busses can be identified by the fact of not having a parent, due to not being a tech.
Examples
Calling and optimize a calliope energy system model.
>>> from tessif.frused.paths import example_dir >>> import calliope as native_calliope >>> native_calliope.set_log_verbosity('ERROR', include_solver_output=False) >>> calliope_es = native_calliope.Model(f'{example_dir}/data/calliope/fpwe/model.yaml') >>> calliope_es.run() >>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> import pprint
Group energy system components by their
Coordinates:>>> resultier = calliope_post_process.NodeCategorizer(calliope_es) >>> pprint.pprint(resultier.node_coordinates) {'Battery': Coordinates(latitude=42.0, longitude=42.0), 'Demand': Coordinates(latitude=42.0, longitude=42.0), 'Gas Station': Coordinates(latitude=42.0, longitude=42.0), 'Generator': Coordinates(latitude=42.0, longitude=42.0), 'Pipeline': Coordinates(latitude=42.0, longitude=42.0), 'Powerline': Coordinates(latitude=42.0, longitude=42.0), 'Solar Panel': Coordinates(latitude=42.0, longitude=42.0)}
Group energy system components by their
region:>>> pprint.pprint(resultier.node_region_grouped) {'Germany': ['Battery', 'Demand', 'Gas Station', 'Generator', 'Solar Panel'], 'Unspecified': ['Pipeline', 'Powerline']}
Group energy system components by their
sector>>> pprint.pprint(resultier.node_sector_grouped) {'Power': ['Battery', 'Demand', 'Gas Station', 'Generator', 'Solar Panel'], 'Unspecified': ['Pipeline', 'Powerline']}
Group energy system components by their
node_type:>>> pprint.pprint(resultier.node_type_grouped) {'Demand': ['Demand'], 'Renewable': ['Solar Panel'], 'Source': ['Gas Station'], 'Storage': ['Battery'], 'Transformer': ['Generator'], 'Unspecified': ['Pipeline', 'Powerline']}
Group energy system components by their energy
carrier:>>> pprint.pprint(resultier.node_carrier_grouped) {'Electricity': ['Battery', 'Demand', 'Generator', 'Powerline', 'Solar Panel'], 'Fuel': ['Pipeline'], 'Gas': ['Gas Station']}
Map the node uid representation <Labeling_Concept> of each component of the energy system to their energy
carrier:>>> pprint.pprint(resultier.node_energy_carriers) {'Battery': 'electricity', 'Demand': 'electricity', 'Gas Station': 'Gas', 'Generator': 'electricity', 'Pipeline': 'fuel', 'Powerline': 'electricity', 'Solar Panel': 'electricity'}
Map the node uid representation <Labeling_Concept> of each component of the energy system to their
component:>>> pprint.pprint(resultier.node_components) {'Bus': ['Pipeline', 'Powerline'], 'Sink': ['Demand'], 'Source': ['Gas Station', 'Solar Panel'], 'Storage': ['Battery'], 'Transformer': ['Generator']}
Note how the many of the uid’s data from busses (same for connectors) are unspecified due to their implementation in calliope not as a technologie but a combination of empty location and transmissions between each location.
- class tessif_calliope_0_6_6post1.post_process.FlowResultier(optimized_es, **kwargs)[source]
Bases:
tessif.post_process.FlowResultier,tessif_calliope_0_6_6post1.post_process.LoadResultierTransforming flow results into dictionairies keyed by edges.
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as results.
See also
For functionality documentation see the respective
base class.Note
Calliope can not assign different costs and emissions for each output of a CHP. To take those costs and emissions into account they are added to the input costs and emissions.
Examples
Calling and optimize a calliope energy system model.
>>> from tessif.frused.paths import example_dir >>> import calliope >>> calliope.set_log_verbosity('ERROR', include_solver_output=False) >>> calliope_es = calliope.Model(f'{example_dir}/data/calliope/fpwe/model.yaml') >>> calliope_es.run() >>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> import pprint
Display the net energy flows of a small energy system:
>>> resultier = calliope_post_process.FlowResultier(calliope_es) >>> pprint.pprint(resultier.edge_net_energy_flow) {Edge(source='Battery', target='Powerline'): 8.9, Edge(source='Gas Station', target='Pipeline'): 7.38, Edge(source='Generator', target='Powerline'): 3.1, Edge(source='Pipeline', target='Generator'): 7.38, Edge(source='Powerline', target='Battery'): 1.0, Edge(source='Powerline', target='Demand'): 33.0, Edge(source='Solar Panel', target='Powerline'): 22.0}
Display the total costs incurred sorted by edge/flow:
>>> pprint.pprint(resultier.edge_total_costs_incurred) {Edge(source='Battery', target='Powerline'): 0.0, Edge(source='Gas Station', target='Pipeline'): 73.8, Edge(source='Generator', target='Powerline'): 31.0, Edge(source='Pipeline', target='Generator'): 0.0, Edge(source='Powerline', target='Battery'): 0.0, Edge(source='Powerline', target='Demand'): 0.0, Edge(source='Solar Panel', target='Powerline'): 0.0}
Display the total emissions caused sorted by edge/flow:
>>> pprint.pprint(resultier.edge_total_emissions_caused) {Edge(source='Battery', target='Powerline'): 0.0, Edge(source='Gas Station', target='Pipeline'): 22.14, Edge(source='Generator', target='Powerline'): 31.0, Edge(source='Pipeline', target='Generator'): 0.0, Edge(source='Powerline', target='Battery'): 0.0, Edge(source='Powerline', target='Demand'): 0.0, Edge(source='Solar Panel', target='Powerline'): 0.0}
Display the specific flow costs of this energy system:
>>> pprint.pprint(resultier.edge_specific_flow_costs) {Edge(source='Battery', target='Powerline'): 0.0, Edge(source='Gas Station', target='Pipeline'): 10.0, Edge(source='Generator', target='Powerline'): 10.0, Edge(source='Pipeline', target='Generator'): 0.0, Edge(source='Powerline', target='Battery'): 0, Edge(source='Powerline', target='Demand'): 0.0, Edge(source='Solar Panel', target='Powerline'): 0.0}
Display the specific emission of this energy system:
>>> pprint.pprint(resultier.edge_specific_emissions) {Edge(source='Battery', target='Powerline'): 0.0, Edge(source='Gas Station', target='Pipeline'): 3.0, Edge(source='Generator', target='Powerline'): 10.0, Edge(source='Pipeline', target='Generator'): 0.0, Edge(source='Powerline', target='Battery'): 0, Edge(source='Powerline', target='Demand'): 0.0, Edge(source='Solar Panel', target='Powerline'): 0.0}
Show the caluclated edge weights of this energy system:
>>> pprint.pprint(resultier.edge_weight) {Edge(source='Battery', target='Powerline'): 0.1, Edge(source='Gas Station', target='Pipeline'): 1.0, Edge(source='Generator', target='Powerline'): 1.0, Edge(source='Pipeline', target='Generator'): 0.1, Edge(source='Powerline', target='Battery'): 0.1, Edge(source='Powerline', target='Demand'): 0.1, Edge(source='Solar Panel', target='Powerline'): 0.1}
Access the reference emissions and net energy flow:
>>> print(resultier.edge_reference_emissions) 10.0
>>> print(resultier.edge_reference_net_energy_flow) 33.0
- class tessif_calliope_0_6_6post1.post_process.AllResultier(optimized_es, **kwargs)[source]
Bases:
tessif_calliope_0_6_6post1.post_process.CapacityResultier,tessif_calliope_0_6_6post1.post_process.FlowResultier,tessif_calliope_0_6_6post1.post_process.StorageResultier,tessif_calliope_0_6_6post1.post_process.ScaleResultierTransform energy system results into a dictionary keyed by attribute.
Incorporates all the functionalities from its bases.
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as 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_calliope_0_6_6post1.post_process.LabelFormatier(optimized_es, **kwargs)[source]
Bases:
tessif.post_process.LabelFormatier,tessif_calliope_0_6_6post1.post_process.FlowResultier,tessif_calliope_0_6_6post1.post_process.CapacityResultierGenerate component summaries as multiline label dictionairy entries.
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as results.
See also
For functionality documentation see the respective
base class.Examples
Calling and optimize a calliope energy system model.
>>> from tessif.frused.paths import example_dir >>> import calliope as native_calliope >>> native_calliope.set_log_verbosity('ERROR', include_solver_output=False) >>> calliope_es = native_calliope.Model(f'{example_dir}/data/calliope/fpwe/model.yaml') >>> calliope_es.run()
Compile and display a node’s summary:
>>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> formatier = calliope_post_process.LabelFormatier(calliope_es) >>> print(formatier.node_summaries['Demand']) {'Demand': 'Demand\n11 MW\ncf: 1.0'}
Compile and display an edge’s summary:
>>> print(formatier.edge_summaries[('Solar Panel', 'Powerline')]) {('Solar Panel', 'Powerline'): '22 MWh\n0.0 €/MWh\n0.0 t/MWh'}
- class tessif_calliope_0_6_6post1.post_process.NodeFormatier(optimized_es, cgrp='name', **kwargs)[source]
Bases:
tessif.post_process.NodeFormatier,tessif_calliope_0_6_6post1.post_process.CapacityResultierTransforming energy system results into node visuals.
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as 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.
See also
For functionality documentation see the respective
base class.Examples
Calling and optimize a calliope energy system model.
>>> from tessif.frused.paths import example_dir >>> import calliope as native_calliope >>> native_calliope.set_log_verbosity('ERROR', include_solver_output=False) >>> calliope_es = native_calliope.Model(f'{example_dir}/data/calliope/fpwe/model.yaml') >>> calliope_es.run()
Generate and display a small energy system’s node shape mapping:
>>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> import pprint >>> formatier = calliope_post_process.NodeFormatier(calliope_es) >>> pprint.pprint(formatier.node_shape) {'Battery': 's', 'Demand': '8', 'Gas Station': 'o', 'Generator': '8', 'Pipeline': 'o', 'Powerline': 'o', 'Solar Panel': 's'}
Generate and display a small energy system’s node size mapping:
>>> pprint.pprint(formatier.node_size) {'Battery': 300, 'Demand': 330, 'Gas Station': 3000, 'Generator': 450, 'Pipeline': 'variable', 'Powerline': 'variable', 'Solar Panel': 600}
Generate and display a small energy system’s node fill size mapping:
>>> pprint.pprint(formatier.node_fill_size) {'Battery': 110.0, 'Demand': 330.0, 'Gas Station': 74.0, 'Generator': 31.0, 'Pipeline': None, 'Powerline': None, 'Solar Panel': 220.0}
Generate and display a small energy system’s node color mapping basd on the grouping:
>>> formatier = calliope_post_process.NodeFormatier(calliope_es, cgrp='all') >>> pprint.pprint(formatier.node_color.name) {'Battery': '#ccff00', 'Demand': '#330099', 'Gas Station': '#336666', 'Generator': '#ff6600', 'Pipeline': '#336666', 'Powerline': '#ffcc00', 'Solar Panel': '#ff9900'}
>>> pprint.pprint(formatier.node_color.carrier) {'Battery': '#FFD700', 'Demand': '#FFD700', 'Gas Station': '#336666', 'Generator': '#FFD700', 'Pipeline': '#AFAFAF', 'Powerline': '#FFD700', 'Solar Panel': '#FFD700'}
>>> pprint.pprint(formatier.node_color.sector) {'Battery': '#ffff33', 'Demand': '#ffff33', 'Gas Station': '#ffff33', 'Generator': '#ffff33', 'Pipeline': '#AFAFAF', 'Powerline': '#AFAFAF', 'Solar Panel': '#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:
>>> pprint.pprint({k: type(v) ... for k,v in formatier.node_color_maps.name.items()}) {'Battery': <class 'str'>, 'Demand': <class 'str'>, 'Gas Station': <class 'str'>, 'Generator': <class 'str'>, 'Pipeline': <class 'str'>, 'Powerline': <class 'str'>, 'Solar Panel': <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_calliope_0_6_6post1.post_process.MplLegendFormatier(optimized_es, cgrp='all', markers='formatier', **kwargs)[source]
Bases:
tessif.post_process.MplLegendFormatier,tessif_calliope_0_6_6post1.post_process.CapacityResultierGenerating visually enhanced matplotlib legends for nodes and edges.
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as 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.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
Calling and optimize a calliope energy system model.
>>> from tessif.frused.paths import example_dir >>> import calliope as native_calliope >>> native_calliope.set_log_verbosity('ERROR', include_solver_output=False) >>> calliope_es = native_calliope.Model(f'{example_dir}/data/calliope/fpwe/model.yaml') >>> calliope_es.run()
Generate and display label grouped legend labels of a small energy system:
>>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> import pprint >>> formatier = calliope_post_process.MplLegendFormatier(calliope_es) >>> pprint.pprint(formatier.node_legend.name['legend_labels']) ['Battery', 'Demand', 'Gas Station', 'Generator', 'Pipeline', 'Powerline', 'Solar Panel']
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
>>> 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_calliope_0_6_6post1.post_process.EdgeFormatier(optimized_es, **kwargs)[source]
Bases:
tessif.post_process.EdgeFormatier,tessif_calliope_0_6_6post1.post_process.FlowResultierTransforming energy system results into edge visuals.
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as results.
See also
For functionality documentation see the respective
base class.Examples
Calling and optimize a calliope energy system model.
>>> from tessif.frused.paths import example_dir >>> import calliope as native_calliope >>> native_calliope.set_log_verbosity('ERROR', include_solver_output=False) >>> calliope_es = native_calliope.Model(f'{example_dir}/data/calliope/fpwe/model.yaml') >>> calliope_es.run()
Generate and display a small energy system’s edge withs:
>>> import tessif.transform.es2mapping.cllp as calliope_post_process >>> import pprint >>> formatier = calliope_post_process.EdgeFormatier(calliope_es) >>> pprint.pprint(list(sorted(formatier.edge_width.items()))) [(Edge(source='Battery', target='Powerline'), 0.27), (Edge(source='Gas Station', target='Pipeline'), 0.22), (Edge(source='Generator', target='Powerline'), 0.1), (Edge(source='Pipeline', target='Generator'), 0.22), (Edge(source='Powerline', target='Battery'), 0.1), (Edge(source='Powerline', target='Demand'), 1.0), (Edge(source='Solar Panel', target='Powerline'), 0.67)]
>>> dc_formatier = calliope_post_process.EdgeFormatier( ... calliope_es, ... drawutil="dc") >>> pprint.pprint(list(sorted(dc_formatier.edge_width.items()))) [(Edge(source='Battery', target='Powerline'), 1.89), (Edge(source='Gas Station', target='Pipeline'), 1.57), (Edge(source='Generator', target='Powerline'), 0.66), (Edge(source='Pipeline', target='Generator'), 1.57), (Edge(source='Powerline', target='Battery'), 0.5), (Edge(source='Powerline', target='Demand'), 7.0), (Edge(source='Solar Panel', target='Powerline'), 4.67)]
Generate and display a small energy system’s edge colors:
>>> pprint.pprint(list(sorted(formatier.edge_color.items()))) [(Edge(source='Battery', target='Powerline'), [0.15]), (Edge(source='Gas Station', target='Pipeline'), [0.3]), (Edge(source='Generator', target='Powerline'), [1.0]), (Edge(source='Pipeline', target='Generator'), [0.15]), (Edge(source='Powerline', target='Battery'), [0.15]), (Edge(source='Powerline', target='Demand'), [0.15]), (Edge(source='Solar Panel', target='Powerline'), [0.15])]
(
draw_networkx_edges()expects iterable of floats when using a colormap)>>> pprint.pprint(list(sorted(dc_formatier.edge_color.items()))) [(Edge(source='Battery', target='Powerline'), '#d8d8d8'), (Edge(source='Gas Station', target='Pipeline'), '#b2b2b2'), (Edge(source='Generator', target='Powerline'), '#000000'), (Edge(source='Pipeline', target='Generator'), '#d8d8d8'), (Edge(source='Powerline', target='Battery'), '#d8d8d8'), (Edge(source='Powerline', target='Demand'), '#d8d8d8'), (Edge(source='Solar Panel', target='Powerline'), '#d8d8d8')]
- class tessif_calliope_0_6_6post1.post_process.AllFormatier(optimized_es, cgrp='all', markers='formatier', **kwargs)[source]
Bases:
tessif_calliope_0_6_6post1.post_process.LabelFormatier,tessif_calliope_0_6_6post1.post_process.NodeFormatier,tessif_calliope_0_6_6post1.post_process.MplLegendFormatier,tessif_calliope_0_6_6post1.post_process.EdgeFormatierTransforming ES results into visual expression dicts keyed by attribute. Incorporates all the functionalities from its parents.
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as 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 dictionary.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
MplLegendFormatier
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_calliope_0_6_6post1.post_process.ICRHybridier(optimized_es, colored_by='name', **kwargs)[source]
Bases:
tessif_calliope_0_6_6post1.post_process.CalliopeResultier,tessif.post_process.ICRHybridierAggregate numerical and visual information for visualizing the Integrated_Component_Results (ICR).
- Parameters
optimized_es¶ (
Model) – An optimized calliope energy system containing its inputs as well as 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.Characteristic value in this context means:
\(cv = \frac{\text{characteristic flow}} {\text{installed capacity}}\) for:
Sourceobjects ( generator in pypsa)Sinkobjects ( load in pypsa)Transformerobjects ( generator in pypsa)Connectorobjects ( link or transformer in pypsa)
\(cv = \frac{\text{mean}\left(\text{SOC}\right)} {\text{capacity}}\) for:
Storage( generator in pypsa)
Characteristic flow in this context means:
mean(LoadResultier.node_summed_loads)SourceobjectsSinkobjects
mean(0th outflow)for:Transformerobjects
The node fillsize of integrated component 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]).