Call graphs from eesyplan methods#479
Conversation
8b96118 to
db15e10
Compare
db15e10 to
e2e4a81
Compare
Fetches timeseries data from database based on foreignkeys and rebuilds the original datapackage structure
e2e4a81 to
21a33ef
Compare
Bachibouzouk
left a comment
There was a problem hiding this comment.
Thanks for tackling this @paulapreuss - I think it looks nice. However I would wait that the PR oemof/oemof-datapackage#4 is merged (or check that with this version of oemof-datapackage it still works as expected)
| # TODO this sankey implementation does not allow for single timesteps | ||
| # if ts is not None: | ||
| # ts = int(ts) | ||
| rebuilt_dp = add_timeseries_to_database_datapackage(scenario) |
There was a problem hiding this comment.
I am wondering whether we should add this as a method of the Scenario model. However this might add confusion if there are too many methods to get a datapackage or a jsonified datapackage from the Scenario. Because then one has to be sure where the datapackages comes from, from the DB or generated on the fly. And what if the user changed some components without resimulating and would like to export this as a datapackage.
If we decide to go for the method I would
rebuilt_dp = scenario.rebuilt_datapackage() and this method should return an error message if the datapackage attribute wasn't present (or it could generate it on the fly)
There was a problem hiding this comment.
You're right, I think it makes a lot of sense to add this as a Scenario method instead.
| qs = FancyResults.objects.filter(simulation=scenario.simulation) | ||
|
|
||
| if qs.exists(): | ||
| flows = { | ||
| (asset, bus): json.loads(flow_data) | ||
| for asset, bus, flow_data in qs.values_list("asset", "bus", "flow_data") | ||
| } | ||
| flows_df = pd.DataFrame(flows) | ||
| flows_df.index = scenario.get_timestamps()[: len(flows_df)] | ||
| fig, links_df = eesyplan_graphs.sankey(flows=flows_df, es=es) |
There was a problem hiding this comment.
In the future we should then get all this from the results datapackage I guess
|
I updated the EZP simulation server with |
|
Not sure about why, but now with these changes I get an |
Goal
Notes:
Scenarioinstead ofSimulationto not have to worry about if a simulation object already existsstore_database_recordtoto_jsonified_datapackagemethod instead of calling again withn_timestamps=0to only build the datapackage once and strip the timeseries instead of building twice (once for simulation and once for db)EnergySystemcan be rebuilt from db datapackage after repopulating with Timeseries values