コード例 #1
0
    def __init__(self, config, mpasClimatologyTask, controlConfig=None):  # {{{
        """
        Construct the analysis task.

        Parameters
        ----------
        config :  ``MpasAnalysisConfigParser``
            Configuration options

        mpasClimatologyTask : ``MpasClimatologyTask``
            The task that produced the climatology to be remapped and plotted

        controlConfig :  ``MpasAnalysisConfigParser``, optional
            Configuration options for a control run (if any)
        """
        # Authors
        # -------
        # Xylar Asay-Davis

        fields = \
            [{'prefix': 'temperature',
              'mpas': '******',
              'units': r'$\degree$C',
              'obs': 'botTheta',
              'title': 'Potential Temperature'},
             {'prefix': 'salinity',
              'mpas': '******',
              'units': r'PSU',
              'obs': 'botSalinity',
              'title': 'Salinity'},
             {'prefix': 'potentialDensity',
              'mpas': '******',
              'units': r'kg m$^{-3}$',
              'obs': 'botPotentialDensity',
              'title': 'Potential Density'}]

        tags = ['climatology', 'horizontalMap', 'antarctic'] \
            + [field['prefix'] for field in fields]

        # call the constructor from the base class (AnalysisTask)
        super(ClimatologyMapSchmidtko,
              self).__init__(config=config,
                             taskName='climatologyMapSchmidtko',
                             componentName='ocean',
                             tags=tags)

        sectionName = self.taskName

        # read in what seasons we want to plot
        seasons = config.getExpression(sectionName, 'seasons')

        if len(seasons) == 0:
            raise ValueError('config section {} does not contain valid list '
                             'of seasons'.format(sectionName))

        comparisonGridNames = config.getExpression(sectionName,
                                                   'comparisonGrids')

        if len(comparisonGridNames) == 0:
            raise ValueError('config section {} does not contain valid list '
                             'of comparison grids'.format(sectionName))

        observationsDirectory = build_obs_path(config, 'ocean',
                                               'schmidtkoSubdirectory')

        obsFileName = '{}/Schmidtko_et_al_2014_bottom_PT_S_PD_' \
                      '6000.0x6000.0km_10.0km_Antarctic_stereo.nc' \
                      ''.format(observationsDirectory)

        # the variable 'timeMonthly_avg_landIceFreshwaterFlux' will be added to
        # mpasClimatologyTask along with the seasons.
        remapClimatologySubtask = RemapDepthSlicesSubtask(
            mpasClimatologyTask=mpasClimatologyTask,
            parentTask=self,
            climatologyName='schmidtko',
            variableList=[field['mpas'] for field in fields],
            seasons=seasons,
            depths=['bot'],
            comparisonGridNames=comparisonGridNames)

        if controlConfig is None:
            refTitleLabel = 'Observations: Schmidtko et al. (2014)'
            diffTitleLabel = 'Model - Observations'
            groupSubtitle = refTitleLabel
        else:
            controlRunName = controlConfig.get('runs', 'mainRunName')
            refTitleLabel = 'Control: {}'.format(controlRunName)
            diffTitleLabel = 'Main - Control'
            groupSubtitle = None

        for field in fields:
            fieldPrefix = field['prefix']
            upperFieldPrefix = fieldPrefix[0].upper() + fieldPrefix[1:]
            if controlConfig is None:
                refFieldName = field['obs']
                outFileLabel = '{}Schmidtko'.format(fieldPrefix)

                remapObservationsSubtask = RemapSchmidtko(
                    parentTask=self,
                    seasons=seasons,
                    fileName=obsFileName,
                    outFilePrefix='{}Schmidtko'.format(fieldPrefix),
                    fieldName=refFieldName,
                    comparisonGridNames=comparisonGridNames,
                    subtaskName='remapObservations{}'.format(upperFieldPrefix))

                self.add_subtask(remapObservationsSubtask)

            else:
                remapObservationsSubtask = None
                refFieldName = field['mpas']
                outFileLabel = '{}Bottom'.format(fieldPrefix)
                diffTitleLabel = 'Main - Control'

            for comparisonGridName in comparisonGridNames:
                for season in seasons:
                    subtask = PlotClimatologyMapSubtask(
                        parentTask=self,
                        season=season,
                        comparisonGridName=comparisonGridName,
                        remapMpasClimatologySubtask=remapClimatologySubtask,
                        remapObsClimatologySubtask=remapObservationsSubtask,
                        controlConfig=controlConfig,
                        depth='bot',
                        subtaskName='plot{}_{}_{}'.format(
                            upperFieldPrefix, season, comparisonGridName))

                    subtask.set_plot_info(
                        outFileLabel=outFileLabel,
                        fieldNameInTitle=field['title'],
                        mpasFieldName=field['mpas'],
                        refFieldName=refFieldName,
                        refTitleLabel=refTitleLabel,
                        diffTitleLabel=diffTitleLabel,
                        unitsLabel=field['units'],
                        imageCaption=field['title'],
                        galleryGroup='Seafloor Maps',
                        groupSubtitle=groupSubtitle,
                        groupLink='seafloor',
                        galleryName=field['title'],
                        configSectionName='climatologyMapSchmidtko{}'.format(
                            upperFieldPrefix))

                    self.add_subtask(subtask)
コード例 #2
0
    def __init__(self, config, mpasClimatologyTask, refConfig=None):  # {{{
        """
        Construct the analysis task.

        Parameters
        ----------
        config :  ``MpasAnalysisConfigParser``
            Configuration options

        mpasClimatologyTask : ``MpasClimatologyTask``
            The task that produced the climatology to be remapped and plotted

        refConfig :  ``MpasAnalysisConfigParser``, optional
            Configuration options for a reference run (if any)
        """
        # Authors
        # -------
        # Luke Van Roekel, Xylar Asay-Davis

        fieldName = 'temperatureArgo'
        # call the constructor from the base class (AnalysisTask)
        super(ClimatologyMapArgoTemperature, self).__init__(
            config=config,
            taskName='climatologyMapArgoTemperature',
            componentName='ocean',
            tags=['climatology', 'horizontalMap', 'argo', fieldName])

        sectionName = self.taskName

        mpasFieldName = 'timeMonthly_avg_activeTracers_temperature'
        iselValues = None

        # read in what seasons we want to plot
        seasons = config.getExpression(sectionName, 'seasons')

        if len(seasons) == 0:
            raise ValueError('config section {} does not contain valid list '
                             'of seasons'.format(sectionName))

        comparisonGridNames = config.getExpression(sectionName,
                                                   'comparisonGrids')

        if len(comparisonGridNames) == 0:
            raise ValueError('config section {} does not contain valid list '
                             'of comparison grids'.format(sectionName))

        depths = config.getExpression(sectionName, 'depths')

        if len(depths) == 0:
            raise ValueError('config section {} does not contain valid '
                             'list of depths'.format(sectionName))

        # the variable 'timeMonthly_avg_landIceFreshwaterFlux' will be added to
        # mpasClimatologyTask along with the seasons.
        remapClimatologySubtask = RemapDepthSlicesSubtask(
            mpasClimatologyTask=mpasClimatologyTask,
            parentTask=self,
            climatologyName=fieldName,
            variableList=[mpasFieldName],
            seasons=seasons,
            depths=depths,
            comparisonGridNames=comparisonGridNames,
            iselValues=iselValues)

        if refConfig is None:

            refTitleLabel = 'Roemmich-Gilson Argo Climatology: Temperature'

            observationsDirectory = build_config_full_path(
                config, 'oceanObservations', 'argoSubdirectory')

            obsFileName = \
                '{}/ArgoClimatology_TS.nc'.format(
                        observationsDirectory)
            refFieldName = 'theta'
            outFileLabel = 'tempArgo'
            galleryName = 'Roemmich-Gilson Climatology: Argo'
            diffTitleLabel = 'Model - Argo'

            remapObservationsSubtask = RemapArgoClimatology(
                parentTask=self,
                seasons=seasons,
                fileName=obsFileName,
                outFilePrefix='{}Argo'.format(refFieldName),
                fieldName=refFieldName,
                depths=depths,
                comparisonGridNames=comparisonGridNames)

            self.add_subtask(remapObservationsSubtask)

        else:
            remapObservationsSubtask = None
            refRunName = refConfig.get('runs', 'mainRunName')
            galleryName = 'Ref: {}'.format(refRunName)
            refTitleLabel = galleryName

            refFieldName = mpasFieldName
            outFileLabel = 'temp'
            diffTitleLabel = 'Main - Reference'

        for comparisonGridName in comparisonGridNames:
            for season in seasons:
                for depth in depths:
                    subtask = PlotClimatologyMapSubtask(
                        parentTask=self,
                        season=season,
                        comparisonGridName=comparisonGridName,
                        remapMpasClimatologySubtask=remapClimatologySubtask,
                        remapObsClimatologySubtask=remapObservationsSubtask,
                        refConfig=refConfig,
                        depth=depth)

                    subtask.set_plot_info(
                        outFileLabel=outFileLabel,
                        fieldNameInTitle='Temperature',
                        mpasFieldName=mpasFieldName,
                        refFieldName=refFieldName,
                        refTitleLabel=refTitleLabel,
                        diffTitleLabel=diffTitleLabel,
                        unitsLabel=r'$^\circ$C',
                        imageCaption='Model temperature compared with Argo '
                        'observations',
                        galleryGroup='Argo Temperature',
                        groupSubtitle=None,
                        groupLink='tempArgo',
                        galleryName=galleryName)

                    self.add_subtask(subtask)
コード例 #3
0
    def __init__(self, config, mpasClimatologyTask, controlConfig=None):  # {{{
        """
        Construct the analysis task.

        Parameters
        ----------
        config :  ``MpasAnalysisConfigParser``
            Configuration options

        mpasClimatologyTask : ``MpasClimatologyTask``
            The task that produced the climatology to be remapped and plotted

        controlConfig :  ``MpasAnalysisConfigParser``, optional
            Configuration options for a control run (if any)
        """
        # Authors
        # -------
        # Milena Veneziani

        fields = \
            [{'prefix': 'temperature',
              'mpas': '******',
              'units': r'$\degree$C',
              'titleName': 'Potential Temperature',
              'obsFieldName': 't_an'},
             {'prefix': 'salinity',
              'mpas': '******',
              'units': r'PSU',
              'titleName': 'Salinity',
              'obsFieldName': 's_an'}]

        tags = ['climatology', 'horizontalMap', 'woa', 'publicObs'] + \
            [field['prefix'] for field in fields]

        # call the constructor from the base class (AnalysisTask)
        super(ClimatologyMapWoa, self).__init__(config=config,
                                                taskName='climatologyMapWoa',
                                                componentName='ocean',
                                                tags=tags)

        sectionName = self.taskName

        fieldList = config.getExpression(sectionName, 'fieldList')
        fields = [field for field in fields if field['prefix'] in fieldList]

        # read in what seasons we want to plot
        seasons = config.getExpression(sectionName, 'seasons')

        if len(seasons) == 0:
            raise ValueError('config section {} does not contain valid list '
                             'of seasons'.format(sectionName))

        comparisonGridNames = config.getExpression(sectionName,
                                                   'comparisonGrids')

        if len(comparisonGridNames) == 0:
            raise ValueError('config section {} does not contain valid list '
                             'of comparison grids'.format(sectionName))

        depths = config.getExpression(sectionName, 'depths')

        if len(depths) == 0:
            raise ValueError('config section {} does not contain valid '
                             'list of depths'.format(sectionName))

        variableList = [field['mpas'] for field in fields]

        shallowVsDeepColormapDepth = config.getfloat(
            sectionName, 'shallowVsDeepColormapDepth')

        shallow = []
        for depth in depths:
            if depth == 'top':
                shallow.append(True)
            elif depth == 'bot':
                shallow.append(False)
            else:
                shallow.append(depth >= shallowVsDeepColormapDepth)

        remapMpasSubtask = RemapDepthSlicesSubtask(
            mpasClimatologyTask=mpasClimatologyTask,
            parentTask=self,
            climatologyName='WOA',
            variableList=variableList,
            seasons=seasons,
            depths=depths,
            comparisonGridNames=comparisonGridNames,
            iselValues=None)

        remapAnnObsSubtask = None
        remapMonObsSubtask = None

        if controlConfig is None:
            # Since we have a WOA18 annual climatology file and
            # another file containing the 12 WOA18 monthly climatologies,
            # do the remapping for each season separately

            observationsDirectory = build_obs_path(config, 'ocean',
                                                   'woa18Subdirectory')

            refFieldNames = [field['obsFieldName'] for field in fields]

            if 'ANN' in seasons:
                obsFileName = \
                    '{}/woa18_decav_04_TS_ann_20190829.nc'.format(
                        observationsDirectory)
                remapAnnObsSubtask = RemapWoaClimatology(
                    parentTask=self,
                    seasons=['ANN'],
                    fileName=obsFileName,
                    outFilePrefix='woa18_ann',
                    fieldNames=refFieldNames,
                    depths=depths,
                    comparisonGridNames=comparisonGridNames,
                    subtaskName='remapObservationsAnn')
                self.add_subtask(remapAnnObsSubtask)

            seasonsMinusAnn = list(seasons)
            if 'ANN' in seasonsMinusAnn:
                seasonsMinusAnn.remove('ANN')
            if len(seasonsMinusAnn) > 0:
                obsFileName = \
                    '{}/woa18_decav_04_TS_mon_20190829.nc'.format(
                        observationsDirectory)
                remapMonObsSubtask = RemapWoaClimatology(
                    parentTask=self,
                    seasons=seasonsMinusAnn,
                    fileName=obsFileName,
                    outFilePrefix='woa18_mon',
                    fieldNames=refFieldNames,
                    depths=depths,
                    comparisonGridNames=comparisonGridNames,
                    subtaskName='remapObservationsMon')

                self.add_subtask(remapMonObsSubtask)

        for field in fields:
            fieldPrefix = field['prefix']
            upperFieldPrefix = fieldPrefix[0].upper() + fieldPrefix[1:]
            sectionName = '{}{}'.format(self.taskName, upperFieldPrefix)

            if controlConfig is None:

                refTitleLabel = 'WOA18 Climatology'

                refFieldName = field['obsFieldName']
                outFileLabel = '{}WOA18'.format(fieldPrefix)
                galleryName = 'WOA18 Climatology'
                diffTitleLabel = 'Model - Climatology'

            else:
                controlRunName = controlConfig.get('runs', 'mainRunName')
                galleryName = 'Control: {}'.format(controlRunName)
                refTitleLabel = galleryName

                refFieldName = field['mpas']
                outFileLabel = '{}WOA18'.format(fieldPrefix)
                diffTitleLabel = 'Main - Control'

            for comparisonGridName in comparisonGridNames:
                for depthIndex, depth in enumerate(depths):
                    for season in seasons:
                        if season == 'ANN':
                            remapObsSubtask = remapAnnObsSubtask
                        else:
                            remapObsSubtask = remapMonObsSubtask

                        subtaskName = 'plot{}_{}_{}_depth_{}'.format(
                            upperFieldPrefix, season, comparisonGridName,
                            depth)

                        subtask = PlotClimatologyMapSubtask(
                            parentTask=self,
                            season=season,
                            comparisonGridName=comparisonGridName,
                            remapMpasClimatologySubtask=remapMpasSubtask,
                            remapObsClimatologySubtask=remapObsSubtask,
                            controlConfig=controlConfig,
                            depth=depth,
                            subtaskName=subtaskName)

                        configSectionName = 'climatologyMapWoa{}'.format(
                            upperFieldPrefix)

                        # if available, use a separate color map for shallow
                        # and deep
                        if depth is not None:
                            if shallow[depthIndex]:
                                suffix = 'Shallow'
                            else:
                                suffix = 'Deep'
                            testSectionName = '{}{}'.format(
                                configSectionName, suffix)
                            if config.has_section(testSectionName):
                                configSectionName = testSectionName

                        subtask.set_plot_info(
                            outFileLabel=outFileLabel,
                            fieldNameInTitle=field['titleName'],
                            mpasFieldName=field['mpas'],
                            refFieldName=refFieldName,
                            refTitleLabel=refTitleLabel,
                            diffTitleLabel=diffTitleLabel,
                            unitsLabel=field['units'],
                            imageCaption=field['titleName'],
                            galleryGroup=field['titleName'],
                            groupSubtitle=None,
                            groupLink='{}_woa'.format(fieldPrefix),
                            galleryName=galleryName,
                            configSectionName=configSectionName)

                        self.add_subtask(subtask)