deflex.fetch_attributes_of_commodity_sources¶
-
deflex.
fetch_attributes_of_commodity_sources
(results)[source]¶ Get the attributes of the commodity sources.
Transformers like power plants are connected to commodity buses. This function can be used to get specific emission or the variable costs of the connected commodity source. Use the to_node column to find the data row of the commodity Bus of the Transformer.
Parameters: results (dict) – Deflex results dictionary. Returns: The attributes of all commodities Return type: pandas.DataFrame Examples
>>> import deflex as dflx >>> fn = dflx.fetch_test_files("de03_fictive.dflx") >>> my_results = dflx.restore_results(fn) >>> cdf = dflx.fetch_attributes_of_commodity_sources(my_results) >>> hard_coal = cdf.loc["hard coal", "DE"] >>> hard_coal.pop("from_node").label Label(cat='source', tag='commodity', subtag='hard coal', region='DE') >>> hard_coal.pop("to_node").label Label(cat='commodity', tag='all', subtag='hard coal', region='DE') >>> hard_coal emission 0.337 nominal_value NaN summed_max NaN max 1.0 min 0.0 negative_gradient_costs 0.0 positive_gradient_costs 0.0 variable_costs 19.944 Name: (hard coal, DE), dtype: object >>> flow_to_power_plant = [ ... bk for bk in my_results["main"].keys() ... if bk[1] is not None ... and bk[1].label.cat == "power plant" ... and bk[1].label.subtag == "natural gas" ... ][0] >>> float(cdf.loc[cdf.to_node == flow_to_power_plant[0]].emission) 0.201