Example #1
0
    def get_applicable_variables(self, ds):
        '''
        Returns a list of variable names that are applicable to ACDD Metadata
        Checks for variables. This includes geophysical and coordinate
        variables only.

        :param netCDF4.Dataset ds: An open netCDF dataset
        '''
        if self._applicable_variables is None:
            self.applicable_variables = cfutil.get_geophysical_variables(ds)
            varname = cfutil.get_time_variable(ds)
            # avoid duplicates by checking if already present
            if varname and (varname not in self.applicable_variables):
                self.applicable_variables.append(varname)
            varname = cfutil.get_lon_variable(ds)
            if varname and (varname not in self.applicable_variables):
                self.applicable_variables.append(varname)
            varname = cfutil.get_lat_variable(ds)
            if varname and (varname not in self.applicable_variables):
                self.applicable_variables.append(varname)
            varname = cfutil.get_z_variable(ds)
            if varname and (varname not in self.applicable_variables):
                self.applicable_variables.append(varname)

        return self.applicable_variables
    def get_applicable_variables(self, ds):
        """
        Returns a list of variable names that are applicable to ACDD Metadata
        Checks for variables. This includes geophysical and coordinate
        variables only.

        :param netCDF4.Dataset ds: An open netCDF dataset
        """
        if self._applicable_variables is None:
            self.applicable_variables = cfutil.get_geophysical_variables(ds)
            varname = cfutil.get_time_variable(ds)
            # avoid duplicates by checking if already present
            if varname and (varname not in self.applicable_variables):
                self.applicable_variables.append(varname)
            varname = cfutil.get_lon_variable(ds)
            if varname and (varname not in self.applicable_variables):
                self.applicable_variables.append(varname)
            varname = cfutil.get_lat_variable(ds)
            if varname and (varname not in self.applicable_variables):
                self.applicable_variables.append(varname)
            varname = cfutil.get_z_variable(ds)
            if varname and (varname not in self.applicable_variables):
                self.applicable_variables.append(varname)

        return self.applicable_variables
    def test_grid_mapping(self):
        '''
        Ensures that grid mapping variables are properly identified
        '''
        with Dataset(resources.STATIC_FILES['rotated_pole_grid']) as nc:
            grid_mapping = util.get_grid_mapping_variables(nc)
            coordinate_variables = util.get_coordinate_variables(nc)
            axis_variables = util.get_axis_variables(nc)

            assert 'rotated_pole' in grid_mapping
            assert set(['rlon', 'rlat', 'lev']) == set(coordinate_variables)
            assert set(['rlon', 'rlat', 'lev']) == set(axis_variables)
            assert 'lat' == util.get_lat_variable(nc)
            assert 'lon' == util.get_lon_variable(nc)
    def test_grid_mapping(self):
        """
        Ensures that grid mapping variables are properly identified
        """
        with Dataset(resources.STATIC_FILES["rotated_pole_grid"]) as nc:
            grid_mapping = util.get_grid_mapping_variables(nc)
            coordinate_variables = util.get_coordinate_variables(nc)
            axis_variables = util.get_axis_variables(nc)

            assert "rotated_pole" in grid_mapping
            assert set(["rlon", "rlat", "lev"]) == set(coordinate_variables)
            assert set(["rlon", "rlat", "lev"]) == set(axis_variables)
            assert "lat" == util.get_lat_variable(nc)
            assert "lon" == util.get_lon_variable(nc)
    def test_grid_mapping(self):
        '''
        Ensures that grid mapping variables are properly identified
        '''
        with Dataset(resources.STATIC_FILES['rotated_pole_grid']) as nc:
            grid_mapping = util.get_grid_mapping_variables(nc)
            coordinate_variables = util.get_coordinate_variables(nc)
            axis_variables = util.get_axis_variables(nc)

            assert 'rotated_pole' in grid_mapping
            assert set(['rlon', 'rlat', 'lev']) == set(coordinate_variables)
            assert set(['rlon', 'rlat', 'lev']) == set(axis_variables)
            assert 'lat' == util.get_lat_variable(nc)
            assert 'lon' == util.get_lon_variable(nc)
Example #6
0
    def get_applicable_variables(self, ds):
        '''
        Returns a list of variable names that are applicable to ACDD Metadata
        Checks for variables. This includes geophysical and coordinate
        variables only.

        :param netCDF4.Dataset ds: An open netCDF dataset
        '''
        if self._applicable_variables is None:
            self.applicable_variables = cfutil.get_geophysical_variables(ds)
            varname = cfutil.get_time_variable(ds)
            if varname:
                self.applicable_variables.append(varname)
            varname = cfutil.get_lon_variable(ds)
            if varname:
                self.applicable_variables.append(varname)
            varname = cfutil.get_lat_variable(ds)
            if varname:
                self.applicable_variables.append(varname)
            varname = cfutil.get_z_variable(ds)
            if varname:
                self.applicable_variables.append(varname)
        return self.applicable_variables