Ejemplo n.º 1
0
 def test_timeseries_profile_multi_station(self):
     '''
     Ensures timeseries profile multi station detection works
     '''
     with Dataset(resources.STATIC_FILES['timeseries-profile-multi-station']) as nc:
         for variable in util.get_geophysical_variables(nc):
             assert util.is_timeseries_profile_multi_station(nc, variable), "{} is timeseries-profile-multi-station".format(variable)
Ejemplo n.º 2
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consistent with a timeseries-profile-orthogonal dataset.

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(
            BaseCheck.HIGH,
            'All geophysical variables are timeseries-profile-ortho-time-incomplete-depth feature types'
        )

        message = '{} must be a valid timeseries-profile-ortho-time-incomplete-depth feature type.'
        message += ' If it\'s multiple stations, it must have dimensions (station, time, z).'
        message += ' If it\'s a single station, it must have dimensions (time, z). x and y dimensions must be scalar or have'
        message += ' dimensions (station). time must be a coordinate variable with dimension (time) and z must'
        message += ' have dimensions (time, z) or (station, time, z) if it\'s a multi-station dataset.'

        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_timeseries_profile_single_ortho_time(
                dataset, variable)
            is_valid = is_valid or util.is_timeseries_profile_multi_ortho_time(
                dataset, variable)
            required_ctx.assert_true(is_valid, message.format(variable))
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 3
0
 def test_profile_orthogonal(self):
     '''
     Ensures profile-orthogonal detection works
     '''
     with Dataset(resources.STATIC_FILES['profile-orthogonal']) as nc:
         for variable in util.get_geophysical_variables(nc):
             assert util.is_profile_orthogonal(nc, variable), "{} is profile-orthogonal".format(variable)
Ejemplo n.º 4
0
 def test_multi_timeseries_incomplete(self):
     '''
     Ensures multi-timeseries-incomplete detection works
     '''
     with Dataset(resources.STATIC_FILES['multi-timeseries-incomplete']) as nc:
         for variable in util.get_geophysical_variables(nc):
             assert util.is_multi_timeseries_incomplete(nc, variable), "{} is multi-timeseries incomplete".format(variable)
Ejemplo n.º 5
0
 def test_trajectory_single(self):
     '''
     Ensures trajectory-single detection works
     '''
     with Dataset(resources.STATIC_FILES['trajectory-single']) as nc:
         for variable in util.get_geophysical_variables(nc):
             assert util.is_single_trajectory(nc, variable), "{} is trajectory-single".format(variable)
Ejemplo n.º 6
0
 def test_timeseries(self):
     '''
     Ensures timeseries detection works
     '''
     with Dataset(resources.STATIC_FILES['timeseries']) as nc:
         for variable in util.get_geophysical_variables(nc):
             assert util.is_timeseries(nc, variable), "{} is timeseries".format(variable)
Ejemplo n.º 7
0
 def test_multi_timeseries_orthogonal(self):
     '''
     Ensures multi-timeseries-orthogonal detection works
     '''
     with Dataset(resources.STATIC_FILES['multi-timeseries-orthogonal']) as nc:
         for variable in util.get_geophysical_variables(nc):
             assert util.is_multi_timeseries_orthogonal(nc, variable), "{} is multi-timeseries orthogonal".format(variable)
Ejemplo n.º 8
0
 def test_point(self):
     '''
     Ensures point detection works
     '''
     with Dataset(resources.STATIC_FILES['point']) as nc:
         for variable in util.get_geophysical_variables(nc):
             assert util.is_point(nc, variable), "{} is point".format(variable)
Ejemplo n.º 9
0
 def test_3d_regular_grid(self):
     '''
     Ensures 2U Regular Grid detection works
     '''
     with Dataset(resources.STATIC_FILES['3d-regular-grid']) as nc:
         for variable in util.get_geophysical_variables(nc):
             assert util.is_3d_regular_grid(nc, variable), "{} is 3d regular grid".format(variable)
Ejemplo n.º 10
0
 def test_timeseries_profile_ortho_depth(self):
     '''
     Ensures timeseries profile ortho depth detection works
     '''
     with Dataset(resources.STATIC_FILES['timeseries-profile-ortho-depth']) as nc:
         for variable in util.get_geophysical_variables(nc):
             assert util.is_timeseries_profile_ortho_depth(nc, variable), "{} is timeseries-profile-ortho-depth".format(variable)
Ejemplo n.º 11
0
 def test_profile_incomplete(self):
     '''
     Ensures profile-incomplete detection works
     '''
     with Dataset(resources.STATIC_FILES['profile-incomplete']) as nc:
         for variable in util.get_geophysical_variables(nc):
             assert util.is_profile_incomplete(nc, variable), "{} is profile-incomplete".format(variable)
Ejemplo n.º 12
0
 def test_timeseries_profile_single_ortho_time(self):
     '''
     Ensures timeseries profile single station ortho time detection works
     '''
     with Dataset(resources.STATIC_FILES['timeseries-profile-single-ortho-time']) as nc:
         for variable in util.get_geophysical_variables(nc):
             assert util.is_timeseries_profile_single_ortho_time(nc, variable), "{} is timeseries-profile-single-ortho-time".format(variable)
Ejemplo n.º 13
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consitent with a time series incomplete dataset

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        required_ctx = TestCtx(
            BaseCheck.HIGH,
            'All geophysical variables are time-series incomplete feature types'
        )
        message = '{} must be a valid timeseries feature type. It must have dimensions of (timeSeries, time).'
        message += ' And all coordinates must have dimensions of (timeSeries)'
        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_multi_timeseries_incomplete(dataset, variable)
            required_ctx.assert_true(is_valid, message.format(variable))
        return required_ctx.to_result()
Ejemplo n.º 14
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consitent with a time series orthogonal dataset

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        required_ctx = TestCtx(BaseCheck.HIGH, 'All geophysical variables are time-series orthogonal feature types')
        message = '{} must be a valid timeseries feature type. It must have dimensions of (timeSeries, time) or (time).'
        message += ' And x, y and z coordinates must have dimensions (timeSeries) or be dimensionless'
        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_timeseries(dataset, variable) or util.is_multi_timeseries_orthogonal(dataset, variable)
            required_ctx.assert_true(
                is_valid,
                message.format(variable)
            )
        return required_ctx.to_result()
Ejemplo n.º 15
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consistent with a profile-incomplete dataset.

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(
            BaseCheck.HIGH,
            'All geophysical variables are profile-incomplete feature types')

        message = '{} must be a valid profile-incomplete feature type. It must have dimensions of (profile, depth).'
        message += ' x and y should have dimensions of (profile), z should have dimension of (profile, depth) and t should have dimension (profile)'
        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_profile_incomplete(dataset, variable)
            required_ctx.assert_true(is_valid, message.format(variable))
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 16
0
    def check_dimensions(self, dataset):
        """
        Checks that the feature types of this dataset are consitent with a point dataset
        """
        required_ctx = TestCtx(BaseCheck.HIGH, "All geophysical variables are point feature types")
        t = util.get_time_variable(dataset)

        # Exit prematurely
        if not t:
            required_ctx.assert_true(False, "A dimension representing time is required for point feature types")
            return required_ctx.to_result()
        t_dims = dataset.variables[t].dimensions
        o = None or (t_dims and t_dims[0])

        message = "{} must be a valid timeseries feature type. It must have dimensions of ({}), and all coordinates must have dimensions of ({})"
        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_point(dataset, variable)
            required_ctx.assert_true(is_valid, message.format(variable, o, o))
        return required_ctx.to_result()
Ejemplo n.º 17
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consistent with a profile-orthogonal dataset.

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(BaseCheck.HIGH, 'All geophysical variables are profile-orthogonal feature types')

        message = '{} must be a valid profile-orthogonal feature type. It must have dimensions of (profile, depth).'
        message += ' x and y should have dimensions of (profile), z should have dimension of (depth) and t should have dimension (profile)'
        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_profile_orthogonal(dataset, variable)
            required_ctx.assert_true(
                is_valid,
                message.format(variable)
            )
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 18
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consitent with a trajectory dataset

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(
            BaseCheck.HIGH,
            'All geophysical variables are trajectory feature types')

        message = (
            "{} must be a valid trajectory feature type. It must have dimensions of (trajectoryID, time)."
            " And all coordinates must have dimensions (trajectoryID, time)")
        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_cf_trajectory(dataset, variable)
            is_valid = is_valid or util.is_single_trajectory(dataset, variable)
            required_ctx.assert_true(is_valid, message.format(variable))
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 19
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consitent with a trajectory dataset

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(BaseCheck.HIGH, 'All geophysical variables are trajectory feature types')

        message = ("{} must be a valid trajectory feature type. It must have dimensions of (trajectoryID, time)."
                   " And all coordinates must have dimensions (trajectoryID, time)")
        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_cf_trajectory(dataset, variable)
            is_valid = is_valid or util.is_single_trajectory(dataset, variable)
            required_ctx.assert_true(
                is_valid,
                message.format(variable)
            )
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 20
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consitent with a trajectory profile incomplete dataset

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(
            BaseCheck.HIGH,
            'All geophysical variables are trajectory profile incomplete feature types'
        )

        message = '{} must be a valid trajectory profile incomplete feature type. It and z must have dimensions of (trajectory, obs, nzMax).'
        message += ' Also, x, y, and t must have dimensions (trajectory, obs).'

        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_trajectory_profile_incomplete(dataset, variable)
            required_ctx.assert_true(is_valid, message.format(variable))
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 21
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consitent with a trajectory profile orthogonal dataset

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(BaseCheck.HIGH, 'All geophysical variables are trajectory profile orthogonal feature types')

        message = '{} must be a valid trajectory profile orthogonal feature type. It must have dimensions of (trajectory, obs, z).'
        message += ' Also, x, y, and t must have dimensions (trajectory, obs). z must be a coordinate variable with dimensions (z).'

        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_trajectory_profile_orthogonal(dataset, variable)
            required_ctx.assert_true(
                is_valid,
                message.format(variable)
            )
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 22
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consistent with a regular gridded dataset

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(
            BaseCheck.HIGH,
            'All geophysical variables are regular gridded feature types')

        message = '{} must be a valid regular gridded feature type. It must have dimensions (t, z, y, x)'
        message += ' and each dimension must be a coordinate variable with a dimension with the same name'
        message += ' as the variable. z is optional.'

        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_2d_regular_grid(dataset, variable)
            is_valid = is_valid or util.is_3d_regular_grid(dataset, variable)
            required_ctx.assert_true(is_valid, message.format(variable))
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 23
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consistent with a timeseries-profile-incomplete dataset.

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(BaseCheck.HIGH, 'All geophysical variables are timeseries-profile-incomplete feature types')

        message = '{} must be a valid timeseries-profile-incomplete feature type.'
        message += ' it must have dimensions (station, nTimeMax, zMax). x and y must have dimensions (station).'
        message += ' time must have dimensions (station, nTimeMax). And z must have dimensions (station, nTimeMax, zMax).'

        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_timeseries_profile_incomplete(dataset, variable)
            required_ctx.assert_true(
                is_valid,
                message.format(variable)
            )
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 24
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consistent with a timeseries-profile-incomplete dataset.

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(
            BaseCheck.HIGH,
            'All geophysical variables are timeseries-profile-incomplete feature types'
        )

        message = '{} must be a valid timeseries-profile-incomplete feature type.'
        message += ' it must have dimensions (station, nTimeMax, zMax). x and y must have dimensions (station).'
        message += ' time must have dimensions (station, nTimeMax). And z must have dimensions (station, nTimeMax, zMax).'

        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_timeseries_profile_incomplete(dataset, variable)
            required_ctx.assert_true(is_valid, message.format(variable))
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 25
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consistent with a regular gridded dataset

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(BaseCheck.HIGH, 'All geophysical variables are regular gridded feature types')

        message = '{} must be a valid regular gridded feature type. It must have dimensions (t, z, y, x)'
        message += ' and each dimension must be a coordinate variable with a dimension with the same name'
        message += ' as the variable. z is optional.'

        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_2d_regular_grid(dataset, variable)
            is_valid = is_valid or util.is_3d_regular_grid(dataset, variable)
            required_ctx.assert_true(
                is_valid,
                message.format(variable)
            )
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 26
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consistent with a timeseries-profile-orthogonal dataset.

        :param netCDF4.Dataset dataset: An open netCDF dataset
        '''
        results = []
        required_ctx = TestCtx(BaseCheck.HIGH, 'All geophysical variables are timeseries-profile-orthogonal feature types')

        message = '{} must be a valid profile-orthogonal feature type. It must have dimensions of (station, time, z).'
        message += ' If it\'s a single station, it must have dimensions (time, z). x and y dimensions must be scalar or have'
        message += ' dimensions (station). time must be a coordinate variable with dimension (time) and z must be a'
        message += ' coordinate variabel with dimension (z).'

        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_timeseries_profile_single_station(dataset, variable)
            is_valid = is_valid or util.is_timeseries_profile_multi_station(dataset, variable)
            required_ctx.assert_true(
                is_valid,
                message.format(variable)
            )
        results.append(required_ctx.to_result())
        return results
Ejemplo n.º 27
0
    def check_dimensions(self, dataset):
        '''
        Checks that the feature types of this dataset are consitent with a point dataset
        '''
        required_ctx = TestCtx(
            BaseCheck.HIGH,
            'All geophysical variables are point feature types')
        t = util.get_time_variable(dataset)

        # Exit prematurely
        if not t:
            required_ctx.assert_true(
                False,
                'A dimension representing time is required for point feature types'
            )
            return required_ctx.to_result()
        t_dims = dataset.variables[t].dimensions
        o = None or (t_dims and t_dims[0])

        message = '{} must be a valid timeseries feature type. It must have dimensions of ({}), and all coordinates must have dimensions of ({})'
        for variable in util.get_geophysical_variables(dataset):
            is_valid = util.is_point(dataset, variable)
            required_ctx.assert_true(is_valid, message.format(variable, o, o))
        return required_ctx.to_result()