Skip to content

Commit

Permalink
Feature: Reworked examples: FCT-style Jupyter notebooks for raw data …
Browse files Browse the repository at this point in the history
…processing (#94)

* Add `load_floris_artificial` and `load_floris_smarteole` functions in `flasc.examples.models` for artificial and smarteole data, in similar fashion as flasc_cookiecutter_template (FCT).
* Add minimal artificial data files directly to the repository, zipped into a 3.5MB file.
* Merge all artificial data flasc_cookiecutter_template examples to FLASC.
* Move table_analysis folder to _legacy since the code is now commented out
* Update `ws_pow_filtering` in raw_data_processing artificial data example: add floris curve in median power curves, change save location
* Rerun examples with updated develop branch -- resolving deprecation issues and speeding up code
  • Loading branch information
Bartdoekemeijer authored Jul 3, 2023
1 parent d3b2deb commit 8d481f9
Show file tree
Hide file tree
Showing 56 changed files with 6,048 additions and 3,119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,28 @@
from flasc.dataframe_operations import (
dataframe_manipulations as dfm,
)

from flasc.examples.models import load_floris_artificial as load_floris
from flasc import floris_tools as fsatools


def load_data():
# Load dataframe with scada data
root_dir = os.path.dirname(os.path.abspath(__file__))
ftr_path = os.path.join(
root_dir, "..", "demo_dataset", "demo_dataset_scada_60s.ftr"
root_dir, "..", "raw_data_processing", "data", "demo_dataset_scada_600s.csv"
)
if not os.path.exists(ftr_path):
raise FileNotFoundError(
"Please run ./examples_artificial_data/demo_dataset/"
+ "generate_demo_dataset.py before try"
+ "ing any of the other examples."
)
df = pd.read_feather(ftr_path)
df = pd.read_csv(ftr_path)
return df


def load_floris():
# Initialize the FLORIS interface fi
print("Initializing the FLORIS object for our demo wind farm")
file_path = os.path.dirname(os.path.abspath(__file__))
fi_path = os.path.join(
file_path, "../demo_dataset/demo_floris_input.json"
)
fi = wfct.floris_interface.FlorisInterface(fi_path)
return fi


if __name__ == "__main__":
# Set a random seed
np.random.seed(0)

# Load data and FLORIS
df = load_data()
fi = load_floris()
fi, _ = load_floris()

# We first need to define a wd against which we plot the energy ratios
# In this example, we set the wind direction to be equal to the mean
Expand Down
293 changes: 0 additions & 293 deletions examples_artificial_data/demo_dataset/generate_demo_dataset.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from flasc.dataframe_operations import dataframe_manipulations as dfm
from flasc.energy_ratio import energy_ratio_suite
from flasc.visualization import plot_floris_layout
from flasc.examples.models import load_floris_artificial as load_floris

from floris.tools.visualization import visualize_cut_plane
from floris.utilities import wrap_360
Expand All @@ -29,26 +30,17 @@ def load_data():
# Load dataframe with artificial SCADA data
root_dir = os.path.dirname(os.path.abspath(__file__))
ftr_path = os.path.join(
root_dir, '..', 'demo_dataset', 'demo_dataset_scada_60s.ftr'
root_dir, '..', 'raw_data_processing', 'postprocessed', 'df_scada_data_600s_filtered_and_northing_calibrated.ftr'
)
if not os.path.exists(ftr_path):
raise FileNotFoundError('Please run ./examples_artifical/demo_dataset/' +
'generate_demo_dataset.py before try' +
'ing any of the other examples.')
raise FileNotFoundError(
'Please run the scripts in /raw_data_processing/' +
'before trying any of the other examples.'
)
df = pd.read_feather(ftr_path)
return df


def load_floris():
# Load the FLORIS model for the artificial wind farm
from floris import tools as wfct
print('Initializing the FLORIS object for our demo wind farm')
file_path = os.path.dirname(os.path.abspath(__file__))
fi_path = os.path.join(file_path, "../demo_dataset/demo_floris_input.yaml")
fi = wfct.floris_interface.FlorisInterface(fi_path)
return fi


def _get_angle(fi, turbine_array):
# Determine the geometrical angle between the upmost and downmost turbine
# in an array. This is equal to the wind direction that maximally overlaps
Expand Down Expand Up @@ -160,7 +152,7 @@ def plot_energy_ratios(turbine_array, results_energy_ratio, ax=None, label=None)
N_bootstrapping = 50

# Load FLORIS and load SCADA data
fi = load_floris()
fi, _ = load_floris()
df = load_data()

# Note that we normalize everything in our results to the first turbine in the array
Expand Down
Loading

0 comments on commit 8d481f9

Please sign in to comment.