def test_calculate_external_single_deployment(self): tr = TimeRange(3.65342400e+09, 3.65351040e+09) coefficients = {k: [{'start': tr.start-1, 'stop': tr.stop+1, 'value': v, 'deployment': 1}] for k, v in self.ctd_nutnr_cals.iteritems()} coefficients = CalibrationCoefficientStore(coefficients, 'UNIT') ctd_ds = xr.open_dataset(os.path.join(DATA_DIR, self.ctdpf_fn), decode_times=False) nut_ds = xr.open_dataset(os.path.join(DATA_DIR, self.nutnr_fn), decode_times=False) ctd_ds = ctd_ds[['obs', 'time', 'deployment', 'temperature', 'pressure', 'pressure_temp', 'conductivity', 'ext_volt0']] nut_ds = nut_ds[['obs', 'time', 'deployment', 'spectral_channels', 'frame_type', 'nutnr_dark_value_used_for_fit']] ctd_stream_dataset = StreamDataset(self.ctdpf_sk, coefficients, {}, [], 'UNIT') ctd_stream_dataset._insert_dataset(ctd_ds) ctd_stream_dataset.calculate_internal() nut_stream_dataset = StreamDataset(self.nutnr_sk, coefficients, {}, [self.ctdpf_sk], 'UNIT') nut_stream_dataset._insert_dataset(nut_ds) nut_stream_dataset.calculate_internal() nut_stream_dataset.interpolate_needed({self.ctdpf_sk: ctd_stream_dataset}) nut_stream_dataset.calculate_external() expected_params = ['ctdpf_sbe43_sample-seawater_temperature', 'ctdpf_sbe43_sample-practical_salinity', 'temp_sal_corrected_nitrate'] self.assert_parameters_in_datasets(nut_stream_dataset.datasets, expected_params)
def test_calculate_internal_multiple_deployments(self): tr = TimeRange(3.65342400e+09, 3.65351040e+09) coefficients = {k: [{'start': tr.start-1, 'stop': tr.stop+1, 'value': v, 'deployment': 1}, {'start': tr.start-1, 'stop': tr.stop+1, 'value': v, 'deployment': 2}] for k, v in self.ctd_nutnr_cals.iteritems()} coefficients = CalibrationCoefficientStore(coefficients, 'UNIT') ctd_ds = xr.open_dataset(os.path.join(DATA_DIR, self.ctdpf_fn), decode_times=False) ctd_ds = ctd_ds[['obs', 'time', 'deployment', 'temperature', 'pressure', 'pressure_temp', 'conductivity', 'ext_volt0']] ctd_ds.deployment.values[:100000] = 1 ctd_ds.deployment.values[100000:] = 2 ctd_stream_dataset = StreamDataset(self.ctdpf_sk, coefficients, {}, [], 'UNIT') ctd_stream_dataset._insert_dataset(ctd_ds) ctd_stream_dataset.calculate_internal() for ds in ctd_stream_dataset.datasets.itervalues(): tempwat = ctd_sbe16plus_tempwat(ds.temperature, self.ctd_nutnr_cals['CC_a0'], self.ctd_nutnr_cals['CC_a1'], self.ctd_nutnr_cals['CC_a2'], self.ctd_nutnr_cals['CC_a3']) np.testing.assert_array_equal(ds.seawater_temperature, tempwat) pracsal = ctd_pracsal(ds.seawater_conductivity, ds.seawater_temperature, ds.seawater_pressure) np.testing.assert_array_equal(ds.practical_salinity, pracsal)