def test_slit_projection_on_detector(): step = assign_wcs_step.AssignWcsStep() hdul = create_nirspec_fs_file(grating="G395M", filter="OPAQUE", lamp="ARGON") hdul[0].header['DETECTOR'] = 'NRS2' im = datamodels.ImageModel(hdul) refs = {} for reftype in step.reference_file_types: refs[reftype] = step.get_reference_file(im, reftype) open_slits = nirspec.get_open_slits(im, refs) assert len(open_slits) == 1 assert open_slits[0].name == "S200B1" hdul[0].header['DETECTOR'] = 'NRS1' im = datamodels.ImageModel(hdul) open_slits = nirspec.get_open_slits(im, refs) assert len(open_slits) == 4 names = [s.name for s in open_slits] assert "S200A1" in names assert "S200A2" in names assert "S400A1" in names assert "S1600A1" in names
def setup_class(self): self.nrs = ImageModel() self.nrs.meta.instrument.name = "NIRSPEC" self.nrs.meta.instrument.filter = "CLEAR" self.nrs.meta.instrument.grating = "MIRROR" self.nrs.meta.exposure.type = 'NRS_FIXEDSLIT' self.nrs.meta.instrument.detector = 'NRS1' self.slits = { 'S200A1': 'SLIT_A_200_1', 'S200A2': 'SLIT_A_200_2', 'S400A1': 'SLIT_A_400', 'S1600A1': 'SLIT_A_1600', #'S200B1': 'SLIT_B_200', #'IFU': 'IFU_window' } self.reference = fits.open( get_pkg_data_filename( "data/onSkyAndOnDetectorProjectionSLIT.fits.gz")) self.field_names = list(self.reference[1].data.field('name')) print(self.field_names) step = assign_wcs_step.AssignWcsStep() self.model = step.process(self.nrs) self.lam = 2e-6 self.wcs_S200A1 = self.model.meta.wcs_S200A1 self.wcs_S200A2 = self.model.meta.wcs_S200A2 self.wcs_S400A1 = self.model.meta.wcs_S400A1 self.wcs_S1600A1 = self.model.meta.wcs_S1600A1
def create_reference_files(datamodel): """ Create a dict {reftype: reference_file}. """ refs = {} step = assign_wcs_step.AssignWcsStep() for reftype in assign_wcs_step.AssignWcsStep.reference_file_types: refs[reftype] = step.get_reference_file(datamodel, reftype) return refs