def check_qc_variables(self, dataset): ''' Verifies the dataset has all the required QC variables ''' level = BaseCheck.MEDIUM score = 0 out_of = 0 qc_variables = [ "{}_qc".format(s) for s in [ 'time', 'lat', 'lon', 'pressure', 'depth', 'temperature', 'conductivity', 'density', 'profile_time', 'profile_lat', 'profile_lon', 'time_uv', 'lat_uv', 'lon_uv', 'u', 'v' ] ] # The None means just check the attribute exists, not a value required_attributes = { 'flag_meanings': None, 'flag_values': None, 'long_name': None, 'standard_name': None, 'valid_max': None, 'valid_min': None } messages = [] for qc_var in qc_variables: pass_stat, num_checks, msgs = util._check_variable_attrs( dataset, qc_var, required_attributes) out_of += num_checks score += int(pass_stat) messages.extend(msgs) return self.make_result(level, score, out_of, 'QC Variables', messages)
def check_trajectory_variables(self, dataset): ''' The trajectory variable stores a character array that identifies the deployment during which the data was gathered. This variable is used by the DAC to aggregate all individual NetCDF profiles containing the same trajectory value into a single trajectory profile data set. This value should be a character array that uniquely identifies the deployment and each individual NetCDF file from the deployment data set should have the same value. ''' level = BaseCheck.MEDIUM out_of = 0 score = 0 messages = [] if 'trajectory' not in dataset.variables: return test = dataset.variables['trajectory'].dimensions == ('traj_strlen',) score += int(test) out_of += 1 if not test: messages.append('trajectory has an invalid dimension') pass_stat, num_checks, attr_msgs = util._check_variable_attrs(dataset, 'trajectory') score += int(pass_stat) out_of += num_checks messages.extend(attr_msgs) return self.make_result(level, score, out_of, 'Trajectory Variable', messages)
def check_profile_variable_attributes_and_types(self, dataset): ''' Verifies that the profile variables are the of the correct data type and contain the correct metadata ''' level = BaseCheck.HIGH out_of = 0 score = 0 messages = [] check_vars = [ 'profile_id', 'profile_time', 'profile_lat', 'profile_lon', 'lat_uv', 'lon_uv', 'u', 'v' ] for var in check_vars: stat, num_checks, msgs = util._check_variable_attrs(dataset, var) score += int(stat) out_of += num_checks messages.extend(msgs) return self.make_result(level, score, out_of, 'Profile Variables', messages)
def check_trajectory_variables(self, dataset): ''' The trajectory variable stores a character array that identifies the deployment during which the data was gathered. This variable is used by the DAC to aggregate all individual NetCDF profiles containing the same trajectory value into a single trajectory profile data set. This value should be a character array that uniquely identifies the deployment and each individual NetCDF file from the deployment data set should have the same value. ''' level = BaseCheck.MEDIUM out_of = 0 score = 0 messages = [] if 'trajectory' not in dataset.variables: return test = dataset.variables['trajectory'].dimensions == ('traj_strlen', ) score += int(test) out_of += 1 if not test: messages.append('trajectory has an invalid dimension') pass_stat, num_checks, attr_msgs = util._check_variable_attrs( dataset, 'trajectory') score += int(pass_stat) out_of += num_checks messages.extend(attr_msgs) return self.make_result(level, score, out_of, 'Trajectory Variable', messages)
def check_time_attributes(self, dataset): ''' Verifies that the time coordinate variable is correct ''' level = BaseCheck.HIGH score, out_of, messages = util._check_variable_attrs(dataset, 'time') return self.make_result(level, score, out_of, 'Time Variable', messages)
def check_ctd_variable_attributes(self, dataset): ''' Verifies that the CTD Variables are the correct data type and contain the correct metadata ''' level = BaseCheck.HIGH out_of = 0 score = 0 messages = [] check_vars = ['temperature', 'conductivity', 'salinity', 'density'] for var in check_vars: stat, num_checks, msgs = util._check_variable_attrs(dataset, var) score += int(stat) out_of += num_checks messages.extend(msgs) return self.make_result(level, score, out_of, 'CTD Variables', messages)
def check_qc_variables(self, dataset): ''' Verifies the dataset has all the required QC variables ''' level = BaseCheck.MEDIUM score = 0 out_of = 0 qc_variables = ["{}_qc".format(s) for s in [ 'time', 'lat', 'lon', 'pressure', 'depth', 'temperature', 'conductivity', 'density', 'profile_time', 'profile_lat', 'profile_lon', 'time_uv', 'lat_uv', 'lon_uv', 'u', 'v' ]] # The None means just check the attribute exists, not a value required_attributes = { 'flag_meanings': None, 'flag_values': None, 'long_name': None, 'standard_name': None, 'valid_max': None, 'valid_min': None } messages = [] for qc_var in qc_variables: pass_stat, num_checks, msgs = util._check_variable_attrs(dataset, qc_var, required_attributes) out_of += num_checks score += int(pass_stat) messages.extend(msgs) return self.make_result(level, score, out_of, 'QC Variables', messages)
def check_pressure_depth_attributes(self, dataset): ''' Verifies that the pressure coordinate/data variable is correct ''' level = BaseCheck.HIGH out_of = 0 score = 0 messages = [] check_vars = ['pressure', 'depth'] for var in check_vars: stat, num_checks, msgs = util._check_variable_attrs(dataset, var) score += int(stat) out_of += num_checks messages.extend(msgs) return self.make_result(level, score, out_of, 'Depth/Pressure variable attributes', messages)
def check_lat_lon_attributes(self, dataset): ''' Validates that lat and lon have correct attributes TODO: Does this need to be its own check? Is it high priority? ''' level = BaseCheck.HIGH out_of = 0 score = 0 messages = [] check_vars = ['lat', 'lon'] for var in check_vars: stat, num_checks, msgs = util._check_variable_attrs(dataset, var) score += int(stat) out_of += num_checks messages.extend(msgs) return self.make_result(level, score, out_of, 'Lat and Lon attributes', messages)
def check_ctd_variable_attributes(self, dataset): ''' Verifies that the CTD Variables are the correct data type and contain the correct metadata ''' level = BaseCheck.HIGH out_of = 0 score = 0 messages = [] check_vars = [ 'temperature', 'conductivity', 'salinity', 'density' ] for var in check_vars: stat, num_checks, msgs = util._check_variable_attrs(dataset, var) score += int(stat) out_of += num_checks messages.extend(msgs) return self.make_result(level, score, out_of, 'CTD Variables', messages)
def check_container_variables(self, dataset): ''' Verifies that the dimensionless container variables are the correct data type and contain the required metadata ''' level = BaseCheck.MEDIUM out_of = 0 score = 0 messages = [] check_vars = [ 'platform', 'instrument_ctd', ] for var in check_vars: stat, num_checks, msgs = util._check_variable_attrs(dataset, var) score += int(stat) out_of += num_checks messages.extend(msgs) return self.make_result(level, score, out_of, 'Container Variables', messages)