diff --git a/goodman_pipeline/core/core.py b/goodman_pipeline/core/core.py index bde02ea0..f8042066 100644 --- a/goodman_pipeline/core/core.py +++ b/goodman_pipeline/core/core.py @@ -2288,7 +2288,7 @@ def name_master_flats(header, dome_sky = '*' if technique == 'Spectroscopy': - if header['GRATING'] != '': + if header['GRATING'] not in ['', 'NO_GRATING']: flat_grating = '_' + re.sub('[A-Za-z_ ]', '', header['GRATING']) @@ -2297,7 +2297,7 @@ def name_master_flats(header, spectroscopic_mode = SpectroscopicMode() wavmode = spectroscopic_mode(header=header) else: - flat_grating = '_no_grating' + flat_grating = '_NO_GRATING' wavmode = '' flat_slit = re.sub('[A-Za-z_ ]', @@ -2305,7 +2305,7 @@ def name_master_flats(header, header['SLIT']) filter2 = header['FILTER2'] - if filter2 == '': + if filter2 in ['', 'NO_FILTER']: filter2 = '' else: filter2 = '_' + filter2 @@ -2320,9 +2320,9 @@ def name_master_flats(header, + '.fits' elif technique == 'Imaging': - if header['FILTER'] != 'NO_FILTER': + if header['FILTER'] not in ['', 'NO_FILTER']: flat_filter = header['FILTER'] - elif header['FILTER2'] != 'NO_FILTER': + elif header['FILTER2'] not in ['', 'NO_FILTER']: flat_filter = header['FILTER2'] else: flat_filter = "NO_FILTER" @@ -4084,30 +4084,30 @@ def __init__(self): """ self.log = logging.getLogger(__name__) - columns = ['grating_freq', 'wavmode', 'camtarg', 'grttarg', 'ob_filter'] - spec_mode = [['400', 'm1', '11.6', '5.8', 'None'], - ['400', 'm2', '16.1', '7.5', 'GG455'], - ['600', 'UV', '15.25', '7.0', 'None'], - ['600', 'Blue', '17.0', '7.0', 'None'], - ['600', 'Mid', '20.0', '10.0', 'GG385'], - ['600', 'Red', '27.0', '12.0', 'GG495'], - ['930', 'm1', '20.6', '10.3', 'None'], - ['930', 'm2', '25.2', '12.6', 'None'], - ['930', 'm3', '29.9', '15.0', 'GG385'], - ['930', 'm4', '34.6', '18.3', 'GG495'], - ['930', 'm5', '39.4', '19.7', 'GG495'], - ['930', 'm6', '44.2', '22.1', 'OG570'], - ['1200', 'm0', '26.0', '16.3', 'None'], - ['1200', 'm1', '29.5', '16.3', 'None'], - ['1200', 'm2', '34.4', '18.7', 'None'], - ['1200', 'm3', '39.4', '20.2', 'None'], - ['1200', 'm4', '44.4', '22.2', 'GG455'], - ['1200', 'm5', '49.6', '24.8', 'GG455'], - ['1200', 'm6', '54.8', '27.4', 'GG495'], - ['1200', 'm7', '60.2', '30.1', 'OG570'], - ['1800', 'Custom', 'None', 'None', 'None'], - ['2100', 'Custom', 'None', 'None', 'None'], - ['2400', 'Custom', 'None', 'None', 'None'] + columns = ['grating_freq', 'wavmode', 'camtarg', 'grttarg', 'ob_filter', 'ob_filter_old'] + spec_mode = [['400', 'm1', '11.6', '5.8', 'NO_FILTER', ''], + ['400', 'm2', '16.1', '7.5', 'GG455', 'GG455'], + ['600', 'UV', '15.25', '7.0', 'NO_FILTER', ''], + ['600', 'Blue', '17.0', '7.0', 'NO_FILTER', ''], + ['600', 'Mid', '20.0', '10.0', 'GG385', 'GG385'], + ['600', 'Red', '27.0', '12.0', 'GG495', 'GG495'], + ['930', 'm1', '20.6', '10.3', 'NO_FILTER', ''], + ['930', 'm2', '25.2', '12.6', 'NO_FILTER', ''], + ['930', 'm3', '29.9', '15.0', 'GG385', 'GG385'], + ['930', 'm4', '34.6', '18.3', 'GG495', 'GG495'], + ['930', 'm5', '39.4', '19.7', 'GG495', 'GG495'], + ['930', 'm6', '44.2', '22.1', 'OG570', 'OG570'], + ['1200', 'm0', '26.0', '16.3', 'NO_FILTER', ''], + ['1200', 'm1', '29.5', '16.3', 'NO_FILTER', ''], + ['1200', 'm2', '34.4', '18.7', 'NO_FILTER', ''], + ['1200', 'm3', '39.4', '20.2', 'NO_FILTER', ''], + ['1200', 'm4', '44.4', '22.2', 'GG455', 'GG455'], + ['1200', 'm5', '49.6', '24.8', 'GG455', 'GG455'], + ['1200', 'm6', '54.8', '27.4', 'GG495', 'GG495'], + ['1200', 'm7', '60.2', '30.1', 'OG570', 'OG570'], + ['1800', 'Custom', 'None', 'None', 'NO_FILTER', ''], + ['2100', 'Custom', 'None', 'None', 'NO_FILTER', ''], + ['2400', 'Custom', 'None', 'None', 'NO_FILTER', ''] ] self.modes_data_frame = pandas.DataFrame(spec_mode, columns=columns) @@ -4186,7 +4186,8 @@ def get_mode(self, grating, camera_targ, grating_targ, blocking_filter): ((self.modes_data_frame['grating_freq'] == grating) & (self.modes_data_frame['camtarg'] == camera_targ) & (self.modes_data_frame['grttarg'] == grating_targ) & - (self.modes_data_frame['ob_filter'] == blocking_filter))] + ((self.modes_data_frame['ob_filter'] == blocking_filter) | + (self.modes_data_frame['ob_filter_old'] == blocking_filter)))] if _mode.empty: central_wavelength = get_central_wavelength( grating=grating, diff --git a/goodman_pipeline/core/tests/test_core.py b/goodman_pipeline/core/tests/test_core.py index 2708489e..a2f7543e 100644 --- a/goodman_pipeline/core/tests/test_core.py +++ b/goodman_pipeline/core/tests/test_core.py @@ -1425,8 +1425,6 @@ class NameMasterFlatsTest(TestCase): def setUp(self): self.reduced_data = os.getcwd() - - #reference date = '2019-08-28' self.twilight_start_evening = '2019-08-27T23:45:00.022' self.twilight_end_morning = '2019-08-28T09:43:20.023' @@ -1462,7 +1460,7 @@ def test_name_master_flats_spectroscopy(self): def test_name_master_flats_spectroscopy_no_grating_no_filter2(self): - expected_name = 'master_flat_TestSubject_no_grating_1.0_sky.fits' + expected_name = 'master_flat_TestSubject_NO_GRATING_1.0_sky.fits' self.header.set('GRATING', value='') self.header.set('DATE-OBS', value='2019-08-27T23:40:00.022') @@ -2059,24 +2057,15 @@ def setUp(self): def test_get_slit_trim_section__slit_within_data(self): slit_trim = get_slit_trim_section(master_flat=self.fake_image) - # print(fake_image.data[:,5]) - # print(slit_trim) self.assertEqual(slit_trim, self.reference_slit_trim) def test_get_slit_trim_section__slit_full_data(self): self.fake_image.data[:, :] = 100 slit_trim = get_slit_trim_section(master_flat=self.fake_image) - # print(fake_image.data[:,5]) self.assertEqual(slit_trim, '[1:100,1:100]') def test_image_trim_slit(self): - # # define - # slit_low_limit = 5 - # slit_high_limit = 95 - # - # slit_trim = '[1:100,{:d}:{:d}]'.format(slit_low_limit + 10 + 1, - # slit_high_limit - 10) self.fake_image = image_trim(ccd=self.fake_image, trim_section=self.reference_slit_trim, trim_type='slit') @@ -2089,8 +2078,6 @@ def test_image_trim_slit(self): self.reference_slit_trim) - - class SpectroscopicModeTest(TestCase): def setUp(self): @@ -2117,7 +2104,7 @@ def test__call__(self): self.assertEqual(mode_m2_keywords, 'm2') - def test_get_mode(self): + def test_get_modes(self): mode_m2 = self.sm.get_mode(grating='400', camera_targ='16.1', grating_targ='7.5', @@ -2137,6 +2124,39 @@ def test_get_mode(self): blocking_filter='GG455') self.assertEqual(mode_custom_2100, 'Custom_1334nm') + def test_get_mode_400_m1_from_header(self): + header = fits.Header() + header.set('GRATING', value='400_SYZY') + header.set('CAM_TARG', value='11.6') + header.set('GRT_TARG', value='5.8') + header.set('FILTER2', value='NO_FILTER') + + spectroscopic_mode = self.sm(header=header) + + self.assertEqual(spectroscopic_mode, 'm1') + + def test_get_mode_400_m1_from_old_header(self): + header = fits.Header() + header.set('GRATING', value='SYZY_400') + header.set('CAM_TARG', value='11.6') + header.set('GRT_TARG', value='5.8') + header.set('FILTER2', value='') + + spectroscopic_mode = self.sm(header=header) + + self.assertEqual(spectroscopic_mode, 'm1') + + def test_get_mode_1200_m3_from_header(self): + header = fits.Header() + header.set('GRATING', value='1200') + header.set('CAM_TARG', value='39.4') + header.set('GRT_TARG', value='20.2') + header.set('FILTER2', value='NO_FILTER') + + spectroscopic_mode = self.sm(header=header) + + self.assertEqual(spectroscopic_mode, 'm3') + def test_get_cam_grt_targ_angle(self): cam_targ, grt_targ = self.sm.get_cam_grt_targ_angle(1800, 'm10') @@ -2181,15 +2201,6 @@ def setUp(self): self.ccd.data[:, i] *= profile_sum(range(self.ccd.data.shape[0])) self.ccd2.data[:, i] *= self.profile_3( range(self.ccd2.data.shape[0])) - # this add noise to test the removal of masked values - # self.ccd.data[ - # random.randrange(self.ccd.data.shape[0]), - # random.randrange(self.ccd.data.shape[1])] *= 300 - # self.ccd2.data[ - # random.randrange(self.ccd2.data.shape[0]), - # random.randrange(self.ccd2.data.shape[1])] *= 300 - - def tearDown(self): del self.ccd @@ -2331,4 +2342,3 @@ def test_validate_ccd_region_valid(self): def test_validate_ccd_region_invalid(self): self.assertRaises(SyntaxError, validate_ccd_region, "10:10:10]") -