def process_local_range_test(self, coverage, parameter, input_name, datlim, datlimz, dims): qc_array = coverage.get_parameter_values(parameter.name) indexes = np.where(qc_array == -88)[0] from ion_functions.qc.qc_functions import dataqc_localrangetest_wrapper # dat value_array = coverage.get_parameter_values(input_name) time_array = coverage.get_parameter_values(coverage.temporal_parameter_name) # datlim is an argument and comes from the lookup table # datlimz is an argument and comes from the lookup table # dims is an argument and is created using the column headings # pval_callback, well as for that... # TODO: slice_ is the window of the site data product, but for # now we'll just use a global slice slice_ = slice(None) def parameter_callback(param_name): return coverage.get_parameter_values(param_name, slice_) qc_array = dataqc_localrangetest_wrapper(value_array, datlim, datlimz, dims, parameter_callback) return_dictionary = { coverage.temporal_parameter_name : time_array[indexes], parameter.name : qc_array[indexes] } log.error("Here's what it would look like\n%s", return_dictionary)
def process_local_range_test(self, coverage, parameter, input_name, datlim, datlimz, dims): return # Not ready qc_array = self.get_parameter_values(coverage, parameter.name) indexes = np.where(qc_array == -88)[0] from ion_functions.qc.qc_functions import dataqc_localrangetest_wrapper # dat value_array = self.get_parameter_values(coverage, input_name)[indexes] time_array = self.get_parameter_values( coverage, coverage.temporal_parameter_name)[indexes] # datlim is an argument and comes from the lookup table # datlimz is an argument and comes from the lookup table # dims is an argument and is created using the column headings # pval_callback, well as for that... # TODO: slice_ is the window of the site data product, but for # now we'll just use a global slice slice_ = slice(None) def parameter_callback(param_name): return coverage.get_parameter_values(param_name, slice_) qc_array = dataqc_localrangetest_wrapper(value_array, datlim, datlimz, dims, parameter_callback) return_dictionary = { coverage.temporal_parameter_name: time_array[indexes], parameter.name: qc_array[indexes] } log.error("Here's what it would look like\n%s", return_dictionary)
def test_lrt_wrapper(self): t = np.array( [ 3580144703.7555027, 3580144704.7555027, 3580144705.7555027, 3580144706.7555027, 3580144707.7555027, 3580144708.7555027, 3580144709.7555027, 3580144710.7555027, 3580144711.7555027, 3580144712.7555027, ] ) pressure = np.random.rand(10) * 2 + 33.0 t_v = ntp_to_month(t) dat = t_v + pressure + np.arange(16, 26) def lim1(p, m): return p + m + 10 def lim2(p, m): return p + m + 20 def callback(f): if f == "time": return t if f == "pressure": return pressure pressure_grid, month_grid = np.meshgrid(np.arange(0, 150, 10), np.arange(11)) points = np.column_stack([pressure_grid.flatten(), month_grid.flatten()]) datlim_0 = lim1(points[:, 0], points[:, 1]) datlim_1 = lim2(points[:, 0], points[:, 1]) datlim = np.column_stack([datlim_0, datlim_1]) datlimz = points qc_out = qcfunc.dataqc_localrangetest_wrapper(dat, datlim, datlimz, ["pressure", "month"], callback) np.testing.assert_array_equal(qc_out, [1, 1, 1, 1, 1, 0, 0, 0, 0, 0])
def test_lrt_wrapper(self): t = np.array([3580144703.7555027, 3580144704.7555027, 3580144705.7555027, 3580144706.7555027, 3580144707.7555027, 3580144708.7555027, 3580144709.7555027, 3580144710.7555027, 3580144711.7555027, 3580144712.7555027]) pressure = np.random.rand(10) * 2 + 33.0 t_v = ntp_to_month(t) dat = t_v + pressure + np.arange(16,26) def lim1(p,m): return p+m+10 def lim2(p,m): return p+m+20 def callback(f): if f=='time': return t if f=='pressure': return pressure pressure_grid, month_grid = np.meshgrid(np.arange(0,150,10), np.arange(11)) points = np.column_stack([pressure_grid.flatten(), month_grid.flatten()]) datlim_0 = lim1(points[:,0], points[:,1]) datlim_1 = lim2(points[:,0], points[:,1]) datlim = np.column_stack([datlim_0, datlim_1]) datlimz = points qc_out = qcfunc.dataqc_localrangetest_wrapper(dat, datlim, datlimz, ['pressure', 'month'], callback) np.testing.assert_array_equal(qc_out, [1 ,1 ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0])