NREL / floris

A controls-oriented engineering wake model.
http://nrel.github.io/floris
BSD 3-Clause "New" or "Revised" License
202 stars 153 forks source link

Issue loading csv files in examples -> working directory not same as file directory for VS Code on Windows #873

Open jfrederik-nrel opened 5 months ago

jfrederik-nrel commented 5 months ago

When I'm running the examples using VS Code through Anaconda Navigator on my Windows computer, it automatically makes floris (i.e., the base folder) the running directory, instead of the folder in which the example is located (i.e., floris/examples). As a result, when the examples (e.g., 003_wind_data_objects.py or 006_get_farm_aep) try to load the inputs/wind_rose.csv file, it can't be found because it's looking in a non-existing directory.

This issue can easily be solved by the user adding examples to the path when loading the wind rose, but we probably want users on Windows to also be able to run the examples without having to change anything in the code. It also seems that someone at some point was aware of this issue, as I have noticed that FlorisModel does load the yaml files correctly due to this little try-except added to floris_model.py:

image

Perhaps we'll want to add a similar code snippet to other functions that load data from files, such as WindRose.read_csv_long() used to load wind_rose.csv in some of the examples.

I'm experiencing this issue on the v4 branch, but it seems to be a general problem not related to a specific version of FLORIS.

paulf81 commented 5 months ago

This is a good catch @jfrederik-nrel , maybe the easiest solution is then to add such code to the load_csv_long function so we don't clutter the example scripts themselves?

jfrederik-nrel commented 5 months ago

Yes that was my thinking too. I'm just not sure how straightforward that would be and whether there are other functions that have the same issue but are not used in the examples.