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

Multidimensional Cp and Ct IEA 15MW definition can fail to load #737

Closed
rafmudaf opened this issue Nov 11, 2023 · 1 comment
Closed

Multidimensional Cp and Ct IEA 15MW definition can fail to load #737

rafmudaf opened this issue Nov 11, 2023 · 1 comment
Assignees
Labels
bug Something isn't working floris.simulation
Milestone

Comments

@rafmudaf
Copy link
Collaborator

rafmudaf commented Nov 11, 2023

Multidimensional Cp and Ct IEA 15MW definition can fail to load

The multidimensional Cp and Ct modeling feature in FLORIS requires the turbine definition to include a CSV file with the higher dimension tables. The CSV file is passed to the turbine definition via the power_thrust_data_file: input field. In the set of turbine definitions includes with FLORIS, referred to as the "turbine library", the multidimensional Cp and Ct definition for the IEA 15MW points to the CSV file with a relative path assuming that the calling script is in the examples directory (or more generally, in a directory parallel to the floris/ directory):

power_thrust_data_file: '../floris/turbine_library/iea_15MW_multi_dim_Tp_Hs.csv'

Since the turbine library should be available for any analysis script, the turbine definitions there should be path-agnostic.
This is part of the cause of #733.

How to reproduce

To test this, I first copied a couple of examples to a new directory outside of the floris repository along with their associated input files. The first example, 01_opening_floris_computing_power.py , uses the NREL 5MW turbine definition from the turbine library, and it runs fine. The next example using the multidimensional Cp and Ct feature, 30_multi_dimensional_cp_ct.py, selects iea_15MW_floating_multi_dim_cp_ct as the turbine type. Since the relative path to the CSV file now does not exist, the bug is exposed.

The files used to show this are:

(floris_pip) >>mbp@~/Desktop/floris_examples $ tree .
.
├── 01_opening_floris_computing_power.py
├── 30_multi_dimensional_cp_ct.py
├── gch.yaml
└── gch_multi_dim_cp_ct.yaml

The error when running the multidimensional Cp and Ct example is:

(floris_pip) >>mbp@~/Desktop/floris_examples $ python 30_multi_dimensional_cp_ct.py 
Traceback (most recent call last):
  File "/Users/rmudafor/Desktop/floris_examples/30_multi_dimensional_cp_ct.py", line 59, in <module>
    fi = FlorisInterface("gch_multi_dim_cp_ct.yaml")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/floris/tools/floris_interface.py", line 58, in __init__
    self.floris = Floris.from_file(self.configuration)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/floris/simulation/floris.py", line 350, in from_file
    return Floris.from_dict(input_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/floris/type_dec.py", line 160, in from_dict
    return cls(**kwargs)
           ^^^^^^^^^^^^^
  File "<attrs generated init floris.simulation.floris.Floris>", line 11, in __init__
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/floris/simulation/floris.py", line 85, in __attrs_post_init__
    self.farm.construct_turbine_map()
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/floris/simulation/farm.py", line 254, in construct_turbine_map
    TurbineMultiDimensional.from_dict(turb) for turb in self.turbine_definitions
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/floris/type_dec.py", line 160, in from_dict
    return cls(**kwargs)
           ^^^^^^^^^^^^^
  File "<attrs generated init floris.simulation.turbine_multi_dim.TurbineMultiDimensional>", line 21, in __init__
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/floris/simulation/turbine_multi_dim.py", line 452, in __attrs_post_init__
    df = pd.read_csv(self.power_thrust_data_file)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/pandas/io/parsers/readers.py", line 948, in read_csv
    return _read(filepath_or_buffer, kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/pandas/io/parsers/readers.py", line 611, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/pandas/io/parsers/readers.py", line 1448, in __init__
    self._engine = self._make_engine(f, self.engine)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/pandas/io/parsers/readers.py", line 1705, in _make_engine
    self.handles = get_handle(
                   ^^^^^^^^^^^
  File "/Users/rmudafor/miniconda3/envs/floris_pip/lib/python3.12/site-packages/pandas/io/common.py", line 863, in get_handle
    handle = open(
             ^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '../floris/turbine_library/iea_15MW_multi_dim_Tp_Hs.csv'

Floris version

To test this, I created a new virtual environment and installed floris from PyPI. Specifically, this is not a local editable install. This was tested with FLORIS v3.5.

@rafmudaf rafmudaf added bug Something isn't working floris.simulation labels Nov 11, 2023
@rafmudaf rafmudaf added this to the v3.6 milestone Nov 11, 2023
@rafmudaf rafmudaf self-assigned this Nov 11, 2023
@rafmudaf
Copy link
Collaborator Author

Ultimately, the question is how to refer to one file from another in a path-safe manner. The fix should support the following conditions:

  • Path-agnostic from within the installation of FLORIS on any system
  • Relative paths from the primary input file when given as part of a user-supplied turbine definition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working floris.simulation
Projects
None yet
Development

No branches or pull requests

1 participant