From f072f2e89ec259b116aaf97463a5fdcc40a1da3f Mon Sep 17 00:00:00 2001 From: Nikhar Abbas Date: Thu, 4 Feb 2021 17:27:34 -0700 Subject: [PATCH] Use generic full file paths --- Examples/example_01.py | 9 +++++---- Examples/example_02.py | 3 ++- Examples/example_03.py | 7 ++++--- Examples/example_04.py | 7 ++++--- Examples/example_05.py | 2 +- Examples/example_06.py | 7 ++++--- Examples/example_08.py | 2 +- Examples/example_09.py | 2 +- Examples/example_10.py | 6 +++--- 9 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Examples/example_01.py b/Examples/example_01.py index 2433be296..f5de2dd72 100644 --- a/Examples/example_01.py +++ b/Examples/example_01.py @@ -18,7 +18,8 @@ from ROSCO_toolbox import turbine as ROSCO_turbine # Load yaml file -parameter_filename = os.path.join(os.path.dirname(__file__),'NREL5MW_example.yaml') +this_dir = os.path.dirname(os.path.abspath(__file__)) +parameter_filename = os.path.join(this_dir,'NREL5MW_example.yaml') inps = yaml.safe_load(open(parameter_filename)) path_params = inps['path_params'] turbine_params = inps['turbine_params'] @@ -28,13 +29,13 @@ turbine.load_from_fast( path_params['FAST_InputFile'], - os.path.join(os.path.dirname(__file__),path_params['FAST_directory']), + os.path.join(this_dir,path_params['FAST_directory']), dev_branch=True, - rot_source='txt',txt_filename=os.path.join(os.path.dirname(__file__),path_params['rotor_performance_filename']) + rot_source='txt',txt_filename=os.path.join(this_dir,path_params['rotor_performance_filename']) ) # Print some basic turbine info print(turbine) # Save the turbine model -turbine.save(os.path.join(os.path.dirname(__file__),'NREL5MW_saved.p')) \ No newline at end of file +turbine.save(os.path.join(this_dir,'NREL5MW_saved.p')) \ No newline at end of file diff --git a/Examples/example_02.py b/Examples/example_02.py index 12c1db70a..51254f47a 100644 --- a/Examples/example_02.py +++ b/Examples/example_02.py @@ -19,7 +19,8 @@ turbine = ROSCO_turbine.Turbine # Load quick from python pickle -turbine = turbine.load(os.path.join(os.path.dirname(__file__),'NREL5MW_saved.p')) +this_dir = os.path.dirname(os.path.abspath(__file__)) +turbine = turbine.load(os.path.join(this_dir,'NREL5MW_saved.p')) # plot rotor performance print('Plotting Cp data') diff --git a/Examples/example_03.py b/Examples/example_03.py index 8a352da34..c262ede97 100644 --- a/Examples/example_03.py +++ b/Examples/example_03.py @@ -19,7 +19,8 @@ control_params = {} # Load yaml file -parameter_filename = os.path.join(os.path.dirname(__file__),'NREL5MW_example.yaml') +this_dir = os.path.dirname(os.path.abspath(__file__)) +parameter_filename = os.path.join(this_dir,'NREL5MW_example.yaml') inps = yaml.safe_load(open(parameter_filename)) path_params = inps['path_params'] turbine_params = inps['turbine_params'] @@ -29,11 +30,11 @@ turbine = ROSCO_turbine.Turbine(turbine_params) turbine.load_from_fast( path_params['FAST_InputFile'], - os.path.join(os.path.dirname(__file__),path_params['FAST_directory']), + os.path.join(this_dir,path_params['FAST_directory']), dev_branch=True, rot_source='cc-blade', txt_filename=None) # Write rotor performance text file -txt_filename = os.path.join(os.path.dirname(__file__),'Cp_Ct_Cq.Ex03.txt') +txt_filename = os.path.join(this_dir,'Cp_Ct_Cq.Ex03.txt') write_rotor_performance(turbine,txt_filename=txt_filename) diff --git a/Examples/example_04.py b/Examples/example_04.py index 431749eb1..9da8a7ca1 100644 --- a/Examples/example_04.py +++ b/Examples/example_04.py @@ -20,7 +20,8 @@ from ROSCO_toolbox.utilities import write_DISCON # Load yaml file -parameter_filename = os.path.join(os.path.dirname(__file__),'NREL5MW_example.yaml') +this_dir = os.path.dirname(os.path.abspath(__file__)) +parameter_filename = os.path.join(this_dir,'NREL5MW_example.yaml') inps = yaml.safe_load(open(parameter_filename)) path_params = inps['path_params'] turbine_params = inps['turbine_params'] @@ -33,9 +34,9 @@ # Load turbine data from OpenFAST and rotor performance text file turbine.load_from_fast( path_params['FAST_InputFile'], - os.path.join(os.path.dirname(__file__),path_params['FAST_directory']), + os.path.join(this_dir,path_params['FAST_directory']), dev_branch=True, - rot_source='txt',txt_filename=os.path.join(os.path.dirname(__file__),path_params['rotor_performance_filename']) + rot_source='txt',txt_filename=os.path.join(this_dir,path_params['rotor_performance_filename']) ) # Tune controller diff --git a/Examples/example_05.py b/Examples/example_05.py index c97dc472f..f88a779fb 100644 --- a/Examples/example_05.py +++ b/Examples/example_05.py @@ -25,7 +25,7 @@ from ROSCO_toolbox import control_interface as ROSCO_ci # Specify controller dynamic library path and name -this_dir = os.path.dirname(__file__) +this_dir = os.path.dirname(os.path.abspath(__file__)) lib_name = os.path.join(this_dir,'../ROSCO/build/libdiscon.dylib') param_filename = os.path.join(this_dir,'DISCON.IN') diff --git a/Examples/example_06.py b/Examples/example_06.py index 584c893d8..5e038527a 100644 --- a/Examples/example_06.py +++ b/Examples/example_06.py @@ -19,10 +19,10 @@ from ROSCO_toolbox.utilities import write_DISCON, run_openfast from ROSCO_toolbox import sim as ROSCO_sim -this_dir = os.path.dirname(__file__) +this_dir = os.path.dirname(os.path.abspath(__file__)) # Load yaml file -parameter_filename = '/Users/dzalkind/Tools/ROSCO_toolbox/Tune_Cases/BAR.yaml' #os.path.join(this_dir,'NREL5MW_example.yaml') # +parameter_filename = os.path.join(os.path.dirname(this_dir), 'Tune_Cases', 'IEA15MW.yaml') inps = yaml.safe_load(open(parameter_filename)) path_params = inps['path_params'] turbine_params = inps['turbine_params'] @@ -47,7 +47,8 @@ # Run OpenFAST # --- May need to change fastcall if you use a non-standard command to call openfast -run_openfast(path_params['FAST_directory'], fastcall='openfast', fastfile=path_params['FAST_InputFile'], chdir=True) +fastcall = 'openfast' +run_openfast(path_params['FAST_directory'], fastcall=fastcall, fastfile=path_params['FAST_InputFile'], chdir=True) diff --git a/Examples/example_08.py b/Examples/example_08.py index 22841a9e2..43786e823 100644 --- a/Examples/example_08.py +++ b/Examples/example_08.py @@ -19,7 +19,7 @@ from ROSCO_toolbox.ofTools.fast_io import output_processing import os -this_dir = os.path.dirname(__file__) +this_dir = os.path.dirname(os.path.abspath(__file__)) # Define openfast output filenames filenames = ["../Test_Cases/NREL-5MW/NREL-5MW.outb"] diff --git a/Examples/example_09.py b/Examples/example_09.py index b736c729e..2e909ebcc 100644 --- a/Examples/example_09.py +++ b/Examples/example_09.py @@ -14,7 +14,7 @@ from ROSCO_toolbox.utilities import run_openfast import os -this_dir = os.path.dirname(__file__) +this_dir = os.path.dirname(os.path.abspath(__file__)) # Define openfast output filenames wind_directory = os.path.join(this_dir,'../Test_Cases/Wind/') diff --git a/Examples/example_10.py b/Examples/example_10.py index ed98aa481..b9b261868 100644 --- a/Examples/example_10.py +++ b/Examples/example_10.py @@ -21,10 +21,10 @@ from ROSCO_toolbox import turbine as ROSCO_turbine from ROSCO_toolbox import controller as ROSCO_controller -rt_dir = os.path.dirname(os.path.dirname(__file__)) +this_dir = os.path.dirname(os.path.abspath(__file__)) # Load yaml file -parameter_filename = os.path.join(rt_dir,'Tune_Cases/BAR.yaml') +parameter_filename = os.path.join(os.path.dirname(this_dir),'Tune_Cases/BAR.yaml') inps = yaml.safe_load(open(parameter_filename)) path_params = inps['path_params'] turbine_params = inps['turbine_params'] @@ -34,7 +34,7 @@ turbine = ROSCO_turbine.Turbine(turbine_params) # turbine.load_from_fast(path_params['FAST_InputFile'],path_params['FAST_directory'],dev_branch=True,rot_source='txt',txt_filename=path_params['rotor_performance_filename']) turbine.load_from_fast(path_params['FAST_InputFile'], \ - os.path.join(rt_dir,path_params['FAST_directory']),dev_branch=True) + os.path.join(this_dir,path_params['FAST_directory']),dev_branch=True) # Tune controller controller = ROSCO_controller.Controller(controller_params)