diff --git a/nbs/12_yaw_module.ipynb b/nbs/12_yaw_module.ipynb index e396caf0..39a56389 100644 --- a/nbs/12_yaw_module.ipynb +++ b/nbs/12_yaw_module.ipynb @@ -236,6 +236,29 @@ " 'training_steps': 500000,\n", " }\n", "\n", + " start, stop = get_indexes(model_params, properties)\n", + " # start = model_params['start_index']\n", + " # stop = model_params['stop_index']\n", + "\n", + " # if 'range' in properties:\n", + " # if properties['range']=='test':\n", + " # start = model_params['start_index_test']\n", + " # stop = model_params['stop_index_test']\n", + " # elif properties['range']=='all':\n", + " # stop = model_params['stop_index_test']\n", + "\n", + " return wind_timeseries,start, stop, model_params,yaw_params,keep_history" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "17d37902", + "metadata": {}, + "outputs": [], + "source": [ + "#| export\n", + "def get_indexes(model_params, properties):\n", " start = model_params['start_index']\n", " stop = model_params['stop_index']\n", "\n", @@ -246,7 +269,7 @@ " elif properties['range']=='all':\n", " stop = model_params['stop_index_test']\n", "\n", - " return wind_timeseries,start, stop, model_params,yaw_params,keep_history" + " return start, stop" ] }, { @@ -257,7 +280,7 @@ "outputs": [], "source": [ "#| export\n", - "def test_trad_control(wind_timeseries, wind_timeseries_not_agg,agg, start, end, experiment=None,datatype='baseline_simu'):\n", + "def test_trad_control(wind_timeseries, wind_timeseries_not_agg,agg, start, end, experiment=None,datatype='baseline_simu', outdir=None):\n", " '''\n", " test CYCA-S and CYCA-L\n", "\n", @@ -282,7 +305,7 @@ "\n", " plt.legend()\n", " plotly_fig = tls.mpl_to_plotly(fig)\n", - " plot_file = f'res-{datatype}.html'\n", + " plot_file = f'{outdir}{sep}res-{datatype}.html'\n", " plotly_fig.write_html(plot_file)\n", "\n", " if experiment:\n", diff --git a/pct/_modidx.py b/pct/_modidx.py index d6809326..37806983 100644 --- a/pct/_modidx.py +++ b/pct/_modidx.py @@ -984,6 +984,7 @@ 'pct.yaw_module.YawEnv.step': ('yaw_module.html#yawenv.step', 'pct/yaw_module.py'), 'pct.yaw_module.get_comparaison_metrics': ('yaw_module.html#get_comparaison_metrics', 'pct/yaw_module.py'), 'pct.yaw_module.get_dataset_from_simu': ('yaw_module.html#get_dataset_from_simu', 'pct/yaw_module.py'), + 'pct.yaw_module.get_indexes': ('yaw_module.html#get_indexes', 'pct/yaw_module.py'), 'pct.yaw_module.get_properties': ('yaw_module.html#get_properties', 'pct/yaw_module.py'), 'pct.yaw_module.get_time_yawing': ('yaw_module.html#get_time_yawing', 'pct/yaw_module.py'), 'pct.yaw_module.get_yaw_count': ('yaw_module.html#get_yaw_count', 'pct/yaw_module.py'), diff --git a/pct/yaw_module.py b/pct/yaw_module.py index 6049a4fc..de1d536f 100644 --- a/pct/yaw_module.py +++ b/pct/yaw_module.py @@ -1,8 +1,8 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/12_yaw_module.ipynb. # %% auto 0 -__all__ = ['get_yaw_count', 'get_time_yawing', 'oriented_angle', 'get_dataset_from_simu', 'get_properties', 'test_trad_control', - 'YawEnv', 'get_comparaison_metrics', 'test_model_wind', 'test_hpct_wind'] +__all__ = ['get_yaw_count', 'get_time_yawing', 'oriented_angle', 'get_dataset_from_simu', 'get_properties', 'get_indexes', + 'test_trad_control', 'YawEnv', 'get_comparaison_metrics', 'test_model_wind', 'test_hpct_wind'] # %% ../nbs/12_yaw_module.ipynb 3 import warnings @@ -161,6 +161,21 @@ def get_properties(properties): 'training_steps': 500000, } + start, stop = get_indexes(model_params, properties) + # start = model_params['start_index'] + # stop = model_params['stop_index'] + + # if 'range' in properties: + # if properties['range']=='test': + # start = model_params['start_index_test'] + # stop = model_params['stop_index_test'] + # elif properties['range']=='all': + # stop = model_params['stop_index_test'] + + return wind_timeseries,start, stop, model_params,yaw_params,keep_history + +# %% ../nbs/12_yaw_module.ipynb 9 +def get_indexes(model_params, properties): start = model_params['start_index'] stop = model_params['stop_index'] @@ -171,10 +186,10 @@ def get_properties(properties): elif properties['range']=='all': stop = model_params['stop_index_test'] - return wind_timeseries,start, stop, model_params,yaw_params,keep_history + return start, stop -# %% ../nbs/12_yaw_module.ipynb 9 -def test_trad_control(wind_timeseries, wind_timeseries_not_agg,agg, start, end, experiment=None,datatype='baseline_simu'): +# %% ../nbs/12_yaw_module.ipynb 10 +def test_trad_control(wind_timeseries, wind_timeseries_not_agg,agg, start, end, experiment=None,datatype='baseline_simu', outdir=None): ''' test CYCA-S and CYCA-L @@ -199,7 +214,7 @@ def test_trad_control(wind_timeseries, wind_timeseries_not_agg,agg, start, end, plt.legend() plotly_fig = tls.mpl_to_plotly(fig) - plot_file = f'res-{datatype}.html' + plot_file = f'{outdir}{sep}res-{datatype}.html' plotly_fig.write_html(plot_file) if experiment: @@ -238,7 +253,7 @@ def test_trad_control(wind_timeseries, wind_timeseries_not_agg,agg, start, end, -# %% ../nbs/12_yaw_module.ipynb 10 +# %% ../nbs/12_yaw_module.ipynb 11 class YawEnv(Env): def initialise(self, properties ): @@ -439,7 +454,7 @@ def reset(self): return self.state -# %% ../nbs/12_yaw_module.ipynb 11 +# %% ../nbs/12_yaw_module.ipynb 12 def get_comparaison_metrics(wind_direction,power_control,power_simu,res_model, res_baseline_simu, yaw_rate, yaw_power, width_bin) : res_model_diff = pd.Series(res_model).diff(1).fillna(0) res_baseline_simu_diff = pd.Series(res_baseline_simu).diff(1).fillna(0) @@ -475,7 +490,7 @@ def get_comparaison_metrics(wind_direction,power_control,power_simu,res_model, r -# %% ../nbs/12_yaw_module.ipynb 12 +# %% ../nbs/12_yaw_module.ipynb 13 def test_model_wind(wind_timeseries,start_index,stop_index,ancestors,filter_duration,yaw_parameters,experiment=None,datatype='test'): ''' test RLYCA @@ -553,7 +568,7 @@ def test_model_wind(wind_timeseries,start_index,stop_index,ancestors,filter_dura env.history["power_trad"], -# %% ../nbs/12_yaw_module.ipynb 13 +# %% ../nbs/12_yaw_module.ipynb 14 def test_hpct_wind(file=None,plots=None,history=None,verbose=None,outdir=None,early=None,environment_properties=None,start_index=None,stop_index=None,experiment=None,datatype='test', draw_file=None, model_file=None): ''' test RLYCA