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

Give more helpful error when n_findex = 0 #1011

Open
paulf81 opened this issue Oct 29, 2024 · 0 comments
Open

Give more helpful error when n_findex = 0 #1011

paulf81 opened this issue Oct 29, 2024 · 0 comments

Comments

@paulf81
Copy link
Collaborator

paulf81 commented Oct 29, 2024

Give more helpful error when n_findex = 0

Working with FLORIS and FLASC, it can sometimes happen that FLORIS is set to have n_findex = 0 (for example there are no rows in the FlascDataframe that is being assigned to FLORIS. In this cases, it could be useful for FLORIS to give a more helpful error. Right now this code (run in the examples folder)


import numpy as np

from floris import FlorisModel



fmodel = FlorisModel("inputs/gch.yaml")
fmodel.set(
    wind_directions=np.array([]), wind_speeds=np.array([]), turbulence_intensities=np.array([])
)
print(f"NFINDEX: {fmodel.n_findex}\n")
fmodel.run()

Has output:

pfleming$ python 001_opening_floris_computing_power.py 
NFINDEX: 0

Traceback (most recent call last):
  File "/Users/pfleming/Projects/FLORIS/floris/examples/001_opening_floris_computing_power.py", line 14, in <module>
    fmodel.run()
  File "/Users/pfleming/Projects/FLORIS/floris/floris/floris_model.py", line 490, in run
    self.core.initialize_domain()
  File "/Users/pfleming/Projects/FLORIS/floris/floris/core/core.py", line 147, in initialize_domain
    self.farm.initialize(self.grid.sorted_indices)
  File "/Users/pfleming/Projects/FLORIS/floris/floris/core/farm.py", line 260, in initialize
    self.awc_modes_sorted = np.take_along_axis(
                            ^^^^^^^^^^^^^^^^^^^
  File "/Users/pfleming/opt/anaconda3/envs/floris/lib/python3.11/site-packages/numpy/lib/shape_base.py", line 166, in take_along_axis
    axis = normalize_axis_index(axis, arr.ndim)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
numpy.exceptions.AxisError: axis 1 is out of bounds for array of dimension 1

Proposed solution

Raise an error on run() when n_findex = 0?

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

1 participant