def test_generatemask(): maxsl = 1000 nslits = 2 reg = "80:" tstmsk = np.zeros((1000, 1000)) tstmsk[:, 744:901] = 1 status, regs = skysub.read_userregions(reg, nslits, maxslitlength=maxsl) slits = SlitTraceSet(left_init=np.full((1000, 1), 120, dtype=float), right_init=np.full((1000, 1), 900, dtype=float), binspec=1, binspat=1, pypeline='IFU', nspat=1000, PYP_SPEC='dummy') skymask = skysub.generate_mask("IFU", regs, slits, slits.left_init, slits.right_init) assert (np.array_equal(skymask, tstmsk))
def get_result(self): """Save a mask containing the skysub regions, and print information for what the user should include in their .pypeit file """ # Only do this if the user wishes to save the result if self._use_updates: # Generate the mask inmask = skysub.generate_mask(self.pypeline, self._skyreg, self.slits, self.slits_left, self.slits_right) # Save the mask outfil = self._outname if os.path.exists(self._outname) and not self._overwrite: outfil = 'temp.fits' msgs.warn("File exists:\n{0:s}\nSaving regions to 'temp.fits'") self._overwrite = True msskyreg = buildimage.SkyRegions(image=inmask.astype(np.float), PYP_SPEC=self.spectrograph) msskyreg.to_master_file(master_filename=outfil) return