Example #1
0
def FAST_IO_timeseries(fname):
    # interface to FAST_IO data load
    try:
        test = ROSCO_toolbox.__file__
    except:
        print(
            'WARNING: ROSCO_toolbox required for wisdem.aeroelasticse.FAST_post.FAST_IO_timeseries'
        )

    fast_out = output_processing()
    fast_data = fast_out.load_fast_out(fname, verbose=True)[0]
    return fast_data
Example #2
0
    def full_loads_analysis(self,
                            filenames,
                            get_load_ranking=True,
                            names=[],
                            return_FastData=False):
        '''
        Load openfast data - get statistics - get load ranking - return data
        NOTE: Can be called to run in parallel if get_load_ranking=False (see Processing.batch_processing)

        Parameters:
        -------
        filenames: list
            List of filenames to load and analyse
        get_load_ranking: bool, optional
            Get the load ranking for all cases
        names: list of strings, optional (for load_ranking)
            names corresponding to each dataset
        return_FastData, bool
            Return a dictionary or list constaining OpenFAST output data

        Outputs:
        --------
        sum_stats: dict
            dictionary of summary statistics
        load_rankings: dict
            dictionary of load rankings
        fast_data: list or dict
            list or dictionary containing OpenFAST output data
        '''
        # Load openfast data
        fast_io = output_processing()
        fast_data = fast_io.load_fast_out(filenames,
                                          tmin=self.t0,
                                          tmax=self.tf,
                                          verbose=self.verbose)

        # Get summary statistics
        sum_stats = self.summary_stats(fast_data)

        # Get load rankings
        if get_load_ranking:
            load_rankings = self.load_ranking(sum_stats, names=names)

        if return_FastData:
            return sum_stats, fast_data
        if get_load_ranking:
            return sum_stats, load_rankings
        if return_FastData and get_load_ranking:
            return sum_stats, load_rankings, fast_data
        else:
            return sum_stats
    def print_results(self,outfiles):

        op = output_processing.output_processing()
        FAST_Output = op.load_fast_out(outfiles, tmin=0)

        figs_fname = 'test_outputs.pdf'        
        with PdfPages(os.path.join(self.runDir,figs_fname)) as pdf:
            for fast_out in FAST_Output:
                if self.FAST_InputFile == 'NREL-5MW.fst':
                    plots2make = {'Baseline': ['Wind1VelX', 'GenPwr', 'RotSpeed', 'BldPitch1', 'GenTq']}
                else:
                    plots2make = {'Baseline': ['Wind1VelX', 'GenPwr', 'RotSpeed', 'BldPitch1', 'GenTq','PtfmPitch']}

                numplots    = len(plots2make)
                maxchannels = np.max([len(plots2make[key]) for key in plots2make.keys()])
                fig = plt.figure(figsize=(8,6), constrained_layout=True)
                gs_all = fig.add_gridspec(1, numplots)
                for pnum, (gs, pname) in enumerate(zip(gs_all, plots2make.keys())):
                    gs0 = gs.subgridspec(len(plots2make[pname]),1)
                    for cid, channel in enumerate(plots2make[pname]):
                        subplt = fig.add_subplot(gs0[cid])
                        try:
                            subplt.plot(fast_out['Time'], fast_out[channel])
                            unit_idx = fast_out['meta']['channels'].index(channel)
                            subplt.set_ylabel('{:^} \n ({:^})'.format(
                                                channel,
                                                fast_out['meta']['attribute_units'][unit_idx]))
                            subplt.grid(True)
                            subplt.set_xlabel('Time (s)')
                        except:
                            print('Cannot plot {}'.format(channel))
                        if cid == 0:
                            subplt.set_title(pname)
                        if cid != len(plots2make[pname])-1:
                            subplt.axes.get_xaxis().set_visible(False)

                    plt.suptitle(fast_out['meta']['name'])
                pdf.savefig(fig)
                plt.close()
Example #4
0
    def print_results(self, outfiles):

        figs_fname = 'test_outputs.pdf'

        # remove initial transients if more than two minutes if simulation time
        if self.TMax > 120:
            tmin = 60
        else:
            tmin = 0

        # Comparison plot
        if self.comp_dir:
            tmin = 100  # if comparing, I'd like to start the comparison at 100 seconds
            op_comp = output_processing.output_processing()
            outfiles_comp = [
                os.path.join(self.comp_dir,
                             os.path.split(of)[1]) for of in outfiles
            ]
            try:
                FAST_Comp = op_comp.load_fast_out(outfiles_comp, tmin=tmin)
                figs_fname = 'comp_outputs.pdf'
            except:
                print(
                    'Could not load openfast outputs for comparison, only plotting current test'
                )
                tmin = 0
                figs_fname = 'test_outputs.pdf'

        op = output_processing.output_processing()
        FAST_Output = op.load_fast_out(outfiles, tmin=tmin)

        with PdfPages(os.path.join(self.runDir, figs_fname)) as pdf:
            for i_out, fast_out in enumerate(FAST_Output):
                if self.FAST_InputFile == 'NREL-5MW.fst':
                    plots2make = {
                        'Baseline': [
                            'Wind1VelX', 'GenPwr', 'RotSpeed', 'BldPitch1',
                            'GenTq'
                        ]
                    }
                else:
                    plots2make = {
                        'Baseline': [
                            'Wind1VelX', 'GenPwr', 'RotSpeed', 'BldPitch1',
                            'GenTq', 'PtfmPitch', 'TwrBsMyt'
                        ]
                    }

                numplots = len(plots2make)
                maxchannels = np.max(
                    [len(plots2make[key]) for key in plots2make.keys()])
                fig = plt.figure(figsize=(8, 6), constrained_layout=True)
                gs_all = fig.add_gridspec(1, numplots)
                for pnum, (gs,
                           pname) in enumerate(zip(gs_all, plots2make.keys())):
                    gs0 = gs.subgridspec(len(plots2make[pname]), 1)
                    for cid, channel in enumerate(plots2make[pname]):
                        subplt = fig.add_subplot(gs0[cid])
                        try:
                            subplt.plot(fast_out['Time'], fast_out[channel])
                            if self.comp_dir:
                                subplt.plot(FAST_Comp[i_out]['Time'],
                                            FAST_Comp[i_out][channel])

                            unit_idx = fast_out['meta']['channels'].index(
                                channel)
                            subplt.set_ylabel('{:^} \n ({:^})'.format(
                                channel,
                                fast_out['meta']['attribute_units'][unit_idx]))
                            subplt.grid(True)
                            subplt.set_xlabel('Time (s)')
                        except:
                            print('Cannot plot {}'.format(channel))
                        if cid == 0:
                            subplt.set_title(pname)
                        if cid != len(plots2make[pname]) - 1:
                            subplt.axes.get_xaxis().set_visible(False)

                    plt.suptitle(fast_out['meta']['name'])
                pdf.savefig(fig)
                plt.close()
Example #5
0
# ROSCO toolbox modules
from ROSCO_toolbox import utilities as ROSCO_utilities
from ROSCO_toolbox.ofTools.fast_io import output_processing
import os

this_dir = os.path.dirname(__file__)

# Define openfast output filenames
filenames = ["../Test_Cases/NREL-5MW/NREL-5MW.outb"]
# ---- Note: Could load and plot multiple cases, textfiles, and binaries...
# filenames = ["../Test_Cases/NREL-5MW/NREL-5MW.outb",
#             "../Test_Cases/NREL-5MW/NREL-5MW_ex8.outb"]

filenames = [os.path.join(this_dir, file) for file in filenames]

#  Define Plot cases
#  --- Comment,uncomment, create, and change these as desired...
cases = {}
cases['Baseline'] = ['Wind1VelX', 'BldPitch1', 'GenTq', 'RotSpeed']
cases['Rotor'] = ['BldPitch1', 'GenTq', 'GenPwr']

# Instantiate fast_IO
fast_out = output_processing.output_processing()
# Can also do:
# fast_out = output_processing.output_processing(filenames=filenames, cases=cases)
# fast_out.plot_fast_out()

# Load and plot
fastout = fast_out.load_fast_out(filenames, tmin=10)
fast_out.plot_fast_out(cases=cases)