Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Export Data Tables" = true in examples/monte_carlo leads to AttributeError: 'PyDssScenarioResults' object has no attribute '_elem_classes' #111

Open
nlaws-camus opened this issue Oct 14, 2022 · 3 comments

Comments

@nlaws-camus
Copy link
Contributor

If I change the simulation.toml in the examples/monte_carlo to have

"Export Data Tables" = true

I get

2022-10-14 11:56:33,245 - ERROR [PyDSS.pydss_project pydss_project.py:384] : Simulation failed
Traceback (most recent call last):
  File "/Users/nick/projects/pydss/PyDSS/PyDSS/pydss_project.py", line 378, in run
    scenario.export_data()
  File "/Users/nick/projects/pydss/PyDSS/PyDSS/pydss_results.py", line 350, in export_data
    self._export_element_timeseries(path, fmt, compress)
  File "/Users/nick/projects/pydss/PyDSS/PyDSS/pydss_results.py", line 356, in _export_element_timeseries
    for elem_class in self.list_element_classes():
  File "/Users/nick/projects/pydss/PyDSS/PyDSS/pydss_results.py", line 725, in list_element_classes
    return self._elem_classes[:]
AttributeError: 'PyDssScenarioResults' object has no attribute '_elem_classes'
Traceback (most recent call last):
  File "/Users/nick/projects/pydss/env/bin/pydss", line 33, in <module>
    sys.exit(load_entry_point('dsspy', 'console_scripts', 'pydss')())
  File "/Users/nick/projects/pydss/env/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/nick/projects/pydss/env/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/nick/projects/pydss/env/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/nick/projects/pydss/env/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/nick/projects/pydss/env/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/nick/projects/pydss/PyDSS/PyDSS/cli/run.py", line 105, in run
    project.run(tar_project=tar_project, zip_project=zip_project, dry_run=dry_run)
  File "/Users/nick/projects/pydss/PyDSS/PyDSS/pydss_project.py", line 378, in run
    scenario.export_data()
  File "/Users/nick/projects/pydss/PyDSS/PyDSS/pydss_results.py", line 350, in export_data
    self._export_element_timeseries(path, fmt, compress)
  File "/Users/nick/projects/pydss/PyDSS/PyDSS/pydss_results.py", line 356, in _export_element_timeseries
    for elem_class in self.list_element_classes():
  File "/Users/nick/projects/pydss/PyDSS/PyDSS/pydss_results.py", line 725, in list_element_classes
    return self._elem_classes[:]
AttributeError: 'PyDssScenarioResults' object has no attribute '_elem_classes'

I did some debugging and discovered that this line:

if name not in self._hdf_store["Exports"]:

evaluates to True, which returns before PyDssScenarioResults._group and PyDssScenarioResults_elem_classes are defined.

Maybe not understanding the Exports options, which looks outdated. I was hoping to understand the Monte Carlo capability better and what I can get in the results exports.

@daniel-thom
Copy link
Collaborator

The problem is that the project scenario names get defined in the simulation.toml but then at runtime, for Monte Carlo simulations, each iteration gets a new scenario name, like my_scenario_MC0. The code that processes the results does not know about the name changes, and so that's why it crashes.

It probably wouldn't be hard to fix this. In the meantime, if you want to see the raw data, it is in the store.h5 file.

@nlaws-camus
Copy link
Contributor Author

Is there documentation of what is in the tables that come with "Export Data Tables" = true ? I am looking for bus voltages specifically; so wondering if I should spend the time to figure out how to fix this issue or if I can get a bus voltage report another way?

@daniel-thom
Copy link
Collaborator

You have to define exports for each scenario specifically. Here is an example of exporting bus voltages: https://github.com/NREL/PyDSS/blob/master/tests/data/custom_exports_project/Scenarios/scenario1/ExportLists/Exports.toml#L19.

This is loosely covered in https://nrel.github.io/PyDSS/tutorial.html, but it could be improved. Anyway, once you define the exports, that data will get stored in <your-project-path>/store.h5. The docs give instructions about how to read the data into pandas DataFrames. If you prefer CSV files, you can set Export Data Tables to true and those CSVs files will get recorded to <your-project-path>/Exports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants