def setup_and_check(self):  # {{{
        """
        Perform steps to set up the analysis and check for errors in the setup.

        Raises
        ------
        OSError
            If files are not present
        """
        # Authors
        # -------
        # Xylar Asay-Davis

        # first, call setup_and_check from the base class (AnalysisTask),
        # which will perform some common setup, including storing:
        #   self.inDirectory, self.plotsDirectory, self.namelist, self.streams
        #   self.calendar
        super(TimeSeriesSST, self).setup_and_check()

        config = self.config

        self.startDate = self.config.get('timeSeries', 'startDate')
        self.endDate = self.config.get('timeSeries', 'endDate')

        self.variableList = \
            ['timeMonthly_avg_avgValueWithinOceanRegion_avgSurfaceTemperature']
        self.mpasTimeSeriesTask.add_variables(variableList=self.variableList)

        if config.get('runs', 'preprocessedReferenceRunName') != 'None':
            check_path_exists(
                config.get('oceanPreprocessedReference', 'baseDirectory'))

        self.inputFile = self.mpasTimeSeriesTask.outputFile

        mainRunName = config.get('runs', 'mainRunName')
        regions = config.getExpression('timeSeriesSST', 'regions')

        self.xmlFileNames = []
        self.filePrefixes = {}

        for region in regions:
            filePrefix = 'sst_{}_{}'.format(region, mainRunName)
            self.xmlFileNames.append('{}/{}.xml'.format(
                self.plotsDirectory, filePrefix))
            self.filePrefixes[region] = filePrefix

        return  # }}}
示例#2
0
    def setup_and_check(self):  # {{{
        """
        Perform steps to set up the analysis and check for errors in the setup.

        Raises
        ------
        OSError
            If files are not present
        """
        # Authors
        # -------
        # Xylar Asay-Davis

        # first, call setup_and_check from the base class (AnalysisTask),
        # which will perform some common setup, including storing:
        #     self.runDirectory , self.historyDirectory, self.plotsDirectory,
        #     self.namelist, self.runStreams, self.historyStreams,
        #     self.calendar
        super(TimeSeriesSeaIce, self).setup_and_check()

        config = self.config

        self.startDate = self.config.get('timeSeries', 'startDate')
        self.endDate = self.config.get('timeSeries', 'endDate')

        self.variableList = ['timeMonthly_avg_iceAreaCell',
                             'timeMonthly_avg_iceVolumeCell']
        self.mpasTimeSeriesTask.add_variables(variableList=self.variableList)

        self.inputFile = self.mpasTimeSeriesTask.outputFile

        if config.get('runs', 'preprocessedReferenceRunName') != 'None':
            check_path_exists(config.get('seaIcePreprocessedReference',
                                         'baseDirectory'))

        # get a list of timeSeriesStatsMonthly output files from the streams
        # file, reading only those that are between the start and end dates
        streamName = 'timeSeriesStatsMonthlyOutput'
        self.startDate = config.get('timeSeries', 'startDate')
        self.endDate = config.get('timeSeries', 'endDate')
        self.inputFiles = \
            self.historyStreams.readpath(streamName,
                                         startDate=self.startDate,
                                         endDate=self.endDate,
                                         calendar=self.calendar)

        if len(self.inputFiles) == 0:
            raise IOError('No files were found in stream {} between {} and '
                          '{}.'.format(streamName, self.startDate,
                                       self.endDate))

        self.simulationStartTime = get_simulation_start_time(self.runStreams)

        try:
            self.restartFileName = self.runStreams.readpath('restart')[0]
        except ValueError:
            raise IOError('No MPAS-SeaIce restart file found: need at least '
                          'one restart file to perform remapping of '
                          'climatologies.')

        # these are redundant for now.  Later cleanup is needed where these
        # file names are reused in run()
        self.xmlFileNames = []

        polarPlot = config.getboolean('timeSeriesSeaIceAreaVol', 'polarPlot')
        mainRunName = config.get('runs', 'mainRunName')
        preprocessedReferenceRunName = \
            config.get('runs', 'preprocessedReferenceRunName')
        compareWithObservations = config.getboolean('timeSeriesSeaIceAreaVol',
                                                    'compareWithObservations')

        polarXMLFileNames = []

        if (not compareWithObservations and
                preprocessedReferenceRunName == 'None'):
            for variableName in ['iceArea', 'iceVolume']:
                filePrefix = '{}.{}'.format(mainRunName,
                                            variableName)

                self.xmlFileNames.append('{}/{}.xml'.format(
                    self.plotsDirectory, filePrefix))
                polarXMLFileNames.append('{}/{}_polar.xml'.format(
                    self.plotsDirectory, filePrefix))
        else:

            for hemisphere in ['NH', 'SH']:
                for variableName in ['iceArea', 'iceVolume']:
                    filePrefix = '{}{}_{}'.format(variableName,
                                                  hemisphere,
                                                  mainRunName)

                    self.xmlFileNames.append('{}/{}.xml'.format(
                        self.plotsDirectory, filePrefix))
                    polarXMLFileNames.append('{}/{}_polar.xml'.format(
                        self.plotsDirectory, filePrefix))

        if polarPlot:
            self.xmlFileNames.extend(polarXMLFileNames)
        return  # }}}