You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
I was originally going to suggest a warning, rather than an error, might be most appropriate; but finally, anyone calling run() will then want to call on of the postprocessing calls, and those calls won't work properly (or worse, may extract a previous run()'s results) if an error is not raised. So, I'm in favor of raising an error (possibly a RuntimeError?) in this situation. Any external algorithm that calls run() (but possibly with n_findex = 0) can then have a try/except clause built in to catch the error and deal with it.
They could be made to be related, but that one is focused on adding error checks to WindData objects and this one to FlorisModel. We could however make #1007 more general and include fixes to that as well since they are both about dealing with NaNs and then NaNs leading to 0-length inputs
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)Has output:
Proposed solution
Raise an error on
run()
when n_findex = 0?The text was updated successfully, but these errors were encountered: