def test_calculate_external_multiple_deployments(self): 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']] # remap times to make this two separate deployments dep1_start = self.ctd_events.deps[1].ntp_start dep2_stop = self.ctd_events.deps[2].ntp_start + 864000 ctd_ds.time.values = np.linspace(dep1_start + 1, dep2_stop - 1, num=ctd_ds.time.shape[0]) nut_ds.time.values = np.linspace(dep1_start + 1, dep2_stop - 1, num=nut_ds.time.shape[0]) ctd_stream_dataset = StreamDataset(self.ctdpf_sk, {}, [], 'UNIT') ctd_stream_dataset.events = self.ctd_events ctd_stream_dataset._insert_dataset(ctd_ds) ctd_stream_dataset.calculate_all() nut_stream_dataset = StreamDataset(self.nutnr_sk, {}, [self.ctdpf_sk], 'UNIT') nut_stream_dataset.events = self.nut_events nut_stream_dataset._insert_dataset(nut_ds) nut_stream_dataset.calculate_all() nut_stream_dataset.interpolate_needed({self.ctdpf_sk: ctd_stream_dataset}) nut_stream_dataset.calculate_all() expected_params = ['ctdpf_sbe43_sample-seawater_temperature', 'ctdpf_sbe43_sample-practical_salinity', 'salinity_corrected_nitrate'] self.assert_parameters_in_datasets(nut_stream_dataset.datasets, expected_params)
def test_calculate_external_single_deployment(self): 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, {}, [], 'UNIT') ctd_stream_dataset.events = self.ctd_events ctd_stream_dataset._insert_dataset(ctd_ds) ctd_stream_dataset.calculate_all() nut_stream_dataset = StreamDataset(self.nutnr_sk, {}, [self.ctdpf_sk], 'UNIT') nut_stream_dataset.events = self.nut_events nut_stream_dataset._insert_dataset(nut_ds) nut_stream_dataset.calculate_all() nut_stream_dataset.interpolate_needed({self.ctdpf_sk: ctd_stream_dataset}) nut_stream_dataset.calculate_all() expected_params = ['ctdpf_sbe43_sample-seawater_temperature', 'ctdpf_sbe43_sample-practical_salinity', 'salinity_corrected_nitrate'] self.assert_parameters_in_datasets(nut_stream_dataset.datasets, expected_params)
def test_calculate_external_multiple_deployments(self): 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']] # remap times to make this two separate deployments dep1_start = self.ctd_events.deps[1].ntp_start dep2_stop = self.ctd_events.deps[2].ntp_start + 864000 ctd_ds.time.values = np.linspace(dep1_start + 1, dep2_stop - 1, num=ctd_ds.time.shape[0]) nut_ds.time.values = np.linspace(dep1_start + 1, dep2_stop - 1, num=nut_ds.time.shape[0]) ctd_stream_dataset = StreamDataset(self.ctdpf_sk, {}, [], 'UNIT') ctd_stream_dataset.events = self.ctd_events ctd_stream_dataset._insert_dataset(ctd_ds) ctd_stream_dataset.calculate_all() nut_stream_dataset = StreamDataset(self.nutnr_sk, {}, [self.ctdpf_sk], 'UNIT') nut_stream_dataset.events = self.nut_events nut_stream_dataset._insert_dataset(nut_ds) nut_stream_dataset.calculate_all() nut_stream_dataset.interpolate_needed({self.ctdpf_sk: ctd_stream_dataset}) nut_stream_dataset.calculate_all() expected_params = ['ctdpf_sbe43_sample-seawater_temperature', 'ctdpf_sbe43_sample-practical_salinity', 'salinity_corrected_nitrate'] self.assert_parameters_in_datasets(nut_stream_dataset.datasets, expected_params)
def test_calculate_external_single_deployment(self): 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, {}, [], 'UNIT') ctd_stream_dataset.events = self.ctd_events ctd_stream_dataset._insert_dataset(ctd_ds) ctd_stream_dataset.calculate_all() nut_stream_dataset = StreamDataset(self.nutnr_sk, {}, [self.ctdpf_sk], 'UNIT') nut_stream_dataset.events = self.nut_events nut_stream_dataset._insert_dataset(nut_ds) nut_stream_dataset.calculate_all() nut_stream_dataset.interpolate_needed({self.ctdpf_sk: ctd_stream_dataset}) nut_stream_dataset.calculate_all() expected_params = ['ctdpf_sbe43_sample-seawater_temperature', 'ctdpf_sbe43_sample-practical_salinity', 'salinity_corrected_nitrate'] self.assert_parameters_in_datasets(nut_stream_dataset.datasets, expected_params)
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_external_12035(self): velpt_ds = xr.open_dataset(os.path.join(DATA_DIR, self.velpt_fn), decode_times=False) metbk_ds = xr.open_dataset(os.path.join(DATA_DIR, self.metbk_fn), decode_times=False) velpt_ds = velpt_ds[[ 'obs', 'time', 'deployment', 'velocity_beam1', 'velocity_beam2', 'velocity_beam3', 'amplitude_beam1', 'amplitude_beam2', 'amplitude_beam3' ]] metbk_ds = metbk_ds[[ 'obs', 'time', 'deployment', 'barometric_pressure', 'relative_humidity', 'air_temperature', 'longwave_irradiance', 'precipitation', 'sea_surface_temperature', 'sea_surface_conductivity', 'shortwave_irradiance', 'eastward_wind_velocity', 'northward_wind_velocity' ]] velpt_stream_dataset = StreamDataset(self.velpt_sk, {}, [], 'UNIT') velpt_stream_dataset.events = self.velpt_events velpt_stream_dataset._insert_dataset(velpt_ds) velpt_stream_dataset.calculate_all() metbk_stream_dataset = StreamDataset(self.metbk_sk, {}, [self.velpt_sk], 'UNIT') metbk_stream_dataset.events = self.metbk_events metbk_stream_dataset._insert_dataset(metbk_ds) metbk_stream_dataset.calculate_all() metbk_stream_dataset.interpolate_needed( {self.velpt_sk: velpt_stream_dataset}) metbk_stream_dataset.calculate_all() expected_params = [ 'met_barpres', 'met_windavg_mag_corr_east', 'met_windavg_mag_corr_north', 'met_current_direction', 'met_current_speed', 'met_relwind_direction', 'met_relwind_speed', 'met_netsirr', 'met_salsurf', 'met_spechum', 'met_heatflx_minute', 'met_latnflx_minute', 'met_netlirr_minute', 'met_sensflx_minute', ] self.assert_parameters_in_datasets(metbk_stream_dataset.datasets, expected_params)
def test_calculate_external_12035(self): velpt_ds = xr.open_dataset(os.path.join(DATA_DIR, self.velpt_fn), decode_times=False) metbk_ds = xr.open_dataset(os.path.join(DATA_DIR, self.metbk_fn), decode_times=False) velpt_ds = velpt_ds[['obs', 'time', 'deployment', 'velocity_beam1', 'velocity_beam2', 'velocity_beam3', 'amplitude_beam1', 'amplitude_beam2', 'amplitude_beam3']] metbk_ds = metbk_ds[['obs', 'time', 'deployment', 'barometric_pressure', 'relative_humidity', 'air_temperature', 'longwave_irradiance', 'precipitation', 'sea_surface_temperature', 'sea_surface_conductivity', 'shortwave_irradiance', 'eastward_wind_velocity', 'northward_wind_velocity']] velpt_stream_dataset = StreamDataset(self.velpt_sk, {}, [], 'UNIT') velpt_stream_dataset.events = self.velpt_events velpt_stream_dataset._insert_dataset(velpt_ds) velpt_stream_dataset.calculate_all() metbk_stream_dataset = StreamDataset(self.metbk_sk, {}, [self.velpt_sk], 'UNIT') metbk_stream_dataset.events = self.metbk_events metbk_stream_dataset._insert_dataset(metbk_ds) metbk_stream_dataset.calculate_all() metbk_stream_dataset.interpolate_needed({self.velpt_sk: velpt_stream_dataset}) metbk_stream_dataset.calculate_all() expected_params = ['met_barpres', 'met_windavg_mag_corr_east', 'met_windavg_mag_corr_north', 'met_current_direction', 'met_current_speed', 'met_relwind_direction', 'met_relwind_speed', 'met_netsirr', 'met_salsurf', 'met_spechum', 'met_heatflx_minute', 'met_latnflx_minute', 'met_netlirr_minute', 'met_sensflx_minute', ] self.assert_parameters_in_datasets(metbk_stream_dataset.datasets, expected_params)