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

Feature request: clear error message when calculate_wake is forgotten #431

Closed
Bartdoekemeijer opened this issue May 12, 2022 · 4 comments
Closed
Assignees
Labels
enhancement An improvement of an existing feature floris.tools v3 Label to denote focus on v3

Comments

@Bartdoekemeijer
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
Feature request.

Describe the solution you'd like
Requesting a clear error message when the user forgets to call calculate_wake before calling get_farm_power or get_turbine_powers in the FlorisInterface class.

Describe alternatives you've considered
N/A

Additional context
This the current error message the user gets:

Exception has occurred: AttributeError       (note: full exception trace is shown but execution is paused at: <module>)
'Farm' object has no attribute 'turbine_type_map'
  File "/home/bartdoekemeijer/python_scripts/floris/floris/tools/floris_interface.py", line 573, in get_turbine_powers
    turbine_type_map=self.floris.farm.turbine_type_map,
  File "/home/bartdoekemeijer/python_scripts/floris/examples/04_sweep_wind_directions.py", line 61, in <module> (Current frame)
    turbine_powers = fi.get_turbine_powers() / 1E3 # In kW
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)

Which can take a while to trace back to the actual problem.

@Bartdoekemeijer Bartdoekemeijer added enhancement An improvement of an existing feature good first issue v3 Label to denote focus on v3 labels May 12, 2022
@paulf81
Copy link
Collaborator

paulf81 commented May 12, 2022

I made #432 to take a pass, what do you think?

@Bartdoekemeijer
Copy link
Collaborator Author

@paulf81 I think that's good! Perhaps check_calc_wake_run can become a private function, _check_calc_wake_run, and we would also need to raise the warning in get_farm_power, and perhaps another couple functions?

@paulf81 paulf81 closed this as completed May 13, 2022
@paulf81 paulf81 reopened this May 13, 2022
@paulf81
Copy link
Collaborator

paulf81 commented May 13, 2022

Clicked the wrong button, I'll try that out thanks Bart!

@rafmudaf rafmudaf self-assigned this Jul 12, 2023
@rafmudaf
Copy link
Collaborator

This has been addressed in #432.

Given this script:

from floris.tools import FlorisInterface
fi = FlorisInterface("inputs/gch.yaml")
# fi.calculate_wake()
turbine_powers = fi.get_turbine_powers()

The following error message is given:

>>$ python 01_opening_floris_computing_power.py 
Traceback (most recent call last):
  File "removed /floris/examples/01_opening_floris_computing_power.py", line 9, in <module>
    turbine_powers = fi.get_turbine_powers()
  File "removed /floris/floris/tools/floris_interface.py", line 594, in get_turbine_powers
    raise RuntimeError(
RuntimeError: Can't run function `FlorisInterface.get_turbine_powers` without first running `FlorisInterface.calculate_wake`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature floris.tools v3 Label to denote focus on v3
Projects
None yet
Development

No branches or pull requests

3 participants