Create function to trim output json file from not necessary data#625
Create function to trim output json file from not necessary data#625Bachibouzouk merged 19 commits intodevfrom
Conversation
e42d019 to
6c65ce0
Compare
110a923 to
fcc5f6c
Compare
Nice
Do you want to address this as well in this PR? It will be huge that way. Also, if I understood correctly, ICOM will ignore/drop unknown parameters/entries, so we would not have to put work into that right now (especially as we get feedback from the end users next friday, whether they would like to keep the parameters you would need to drop).
I should create another issue for this, and we should remove it seperately, from my point of view. If we drop it from our outputs, eventhough it is still part of our processing in
Makes sense, should not be too hard to do? However, do we want to have this for our general MVS output as well (local execution) or only for the json file sent to the EPA? I think it would be good to keep inputs and outputs together for local execution.
Yeah, if they use the assets individually to plot this is true. Not sure why they do that, though. |
smartie2076
left a comment
There was a problem hiding this comment.
Notes:
-
You also created the function
C0.compute_timeseries_properties(), which is not in the changelog. Have you written a test for that? f0cad40 -
In 61555b8 you wrote a lot of tests, but can you add debug assertion messages?
-
I need to remember c1b4908 for the energyBus issue
-
In 60dcc9d you have left a number of parameters as strings instead of constant variables.
-
Is there an overview on the helper functions that you create in the
utils?data_parser.pydoes not have extensive docstrings that could explain what you can do with the function. -
In 82a0868 you replace
==etc. withis. Can you add this to the changelog?
| logging.debug(f"Not loading {group} asset {asset} from file") | ||
| compute_timeseries_properties(dict_values[group][asset]) |
There was a problem hiding this comment.
I am actually not sure what that debug message tells me.
There was a problem hiding this comment.
* You also created the function `C0.compute_timeseries_properties()`, which is not in the changelog. Have you written a test for that? [f0cad40](https://github.com/rl-institut/multi-vector-simulator/commit/f0cad40d86fa47d45e66895820b8d771a12021db)
I move this code into a function because I wanted to be able to execute this also when not loading timeseries from csv, I did not write tests for it (here the function applies standard sum and max to a timeseries. There was already a kind of local test of the normalized timeseries which I kept. testing that sum does the sum is already done by the builtin test suite on the sum function in that case.
| # If Filename defines the generation timeseries, then we have an asset with a lack of dispatchability | ||
| dict_values[group][asset].update({DISPATCHABILITY: False}) | ||
| else: | ||
| logging.debug(f"Not loading {group} asset {asset} from file") |
There was a problem hiding this comment.
I am actually not sure what that debug message tells me.
| ) | ||
| return | ||
| else: | ||
| logging.debug(f"Not loading {group} asset {asset} from file") |
There was a problem hiding this comment.
I am actually not sure what that debug message tells me.
| return answer | ||
|
|
||
|
|
||
| def select_essential_results(dict_values): |
There was a problem hiding this comment.
Docstrings can be improved
| for asset_group in [ | ||
| ECONOMIC_DATA, | ||
| SIMULATION_SETTINGS, | ||
| FIX_COST, | ||
| ENERGY_BUSSES, | ||
| PATHS_TO_PLOTS, | ||
| OPTIMIZED_FLOWS, |
There was a problem hiding this comment.
This may work for now, but in a different pr we should find a way to define energy busses manually
There was a problem hiding this comment.
Not sure if we will run into issues this way, as energyBusses bay be overwritten with C
There was a problem hiding this comment.
That is possible, I did not check how the output looked, I only checked that the simulation was running through with the provided energyBusses, thinking we will then iterate on EPA outputs which are then input of MVS etc...
| ENERGY_PROVIDERS: [ | ||
| "asset_type", | ||
| LABEL, | ||
| OEMOF_ASSET_TYPE, | ||
| "energy_vector", | ||
| INFLOW_DIRECTION, | ||
| OUTFLOW_DIRECTION, | ||
| CONNECTED_CONSUMPTION_SOURCE, | ||
| CONNECTED_FEEDIN_SINK, | ||
| DEVELOPMENT_COSTS, | ||
| DISPATCH_PRICE, | ||
| ENERGY_PRICE, | ||
| FEEDIN_TARIFF, | ||
| "installed_capacity", | ||
| LIFETIME, | ||
| "optimize_capacity", |
There was a problem hiding this comment.
Arent energy_vector, installed_capacity, optimize_capacity also constant variables? Or are you using EPA names here?
There was a problem hiding this comment.
These are EPA names, I wanted to specifically not have constant variables for EPA names, so that we see the ones that are different and we are aware of them. It is also helpful in the future to know which constant variable values need to be adapted as they differ than the EPA ones
| # TODO fix input from time parameters for simulation settings | ||
| # def test_load_json_parse_pandas_series(self): | ||
| # """ """ | ||
| # k = TYPE_SERIES | ||
| # assert self.value_dict[k].equals(JSON_TEST_DICTIONARY[k]) | ||
| # | ||
| # def test_load_json_parse_pandas_series_tuple_name(self): | ||
| # """ """ | ||
| # k = "pandas_series_tuple_name" | ||
| # assert self.value_dict[k].equals(JSON_TEST_DICTIONARY[k]) |
There was a problem hiding this comment.
Have you addressed this in a later commit?
There was a problem hiding this comment.
It requires a definition of simulation time parameters prior to running these tests #626 (comment)
|
|
||
| epa_dict_values = data_parser.convert_mvs_params_to_epa(dict_values) | ||
|
|
||
| output_processing.select_essential_results(epa_dict_values) | ||
|
|
||
| json_values = output_processing.store_as_json(epa_dict_values) | ||
|
|
||
| return json.loads(json_values) |
There was a problem hiding this comment.
This means that there is only the option to store the data in EPA-format. Would it not make sense to have the option to keep the json output as it is, without dropping duplicates? This would keep all data intact and in one place for future consideration/comparision. Does ´mvs_report.py` also work with the lightweight json output?
There was a problem hiding this comment.
There are three things:
- dropping indexes of timeseries to reduce size is done anyway (store_as_json)
- convert from EPA to MVS
- drop some fields that might be redundant (project_data, energy_busses etc)
We can add an option for the server enable or not the last two. I just considered that server.py is primarily meant for MVS/EPA communication so I made this the default.
python mvs_tool.py -i ... (which btw you can replace now by mvs_tool -i ....) calls main function of cli.py, so it is only concerned by the changes which are dropping indexes of timeseries to reduce size (store_as_json).
fcc5f6c to
b3eabdc
Compare
b3eabdc to
66e2b7e
Compare
Address part of #606
Changes proposed in this pull request:
retrieve_date_time_infofromC0toB0Tasks from #606 (comment):
2. After closely inspecting the JSON file (~29MB), we observed
timestampsare the same for all timeseries. We can significantly reduce the size and redundancy of the file by removing all timestamps vectors from the file. The period can be deduced by simulation settings.3. We also spotted attributes which do not exist in the EPA side (e.g. costs_investment_over_lifetime). These can be left-out at first and added by the end user.
4. “EnergyBusses" field should be provided directly by EPA as MVS input, it can therefore be dropped
5. Data which are NOT modified by MVS (e.g. economic_data, EnergyConsumption{
development_costs, age_installed, optimizedCap, input timeSeries, etc.}) shall not be send back to EPA to prevent redundancy.7.
“path_to_plots”seem to be referencingplotly dashgenerated figures. We can omit it.8. cost_matrix, scalar_matrix
not sure if needed
9.
optimizedFlowsis a duplicate of the flows of each asset, it can be omitted in the returned jsonblack . --exclude docs/)EXECUTE_TESTS_ON=master pytest)For more information on how to contribute check the CONTRIBUTING.md.