예제 #1
0
 def test_pixflat(self):
     image = preproc(self.rawimage, self.header, primary_header = self.primary_header, pixflat=False)
     pixflat = np.ones_like(image.pix)
     image = preproc(self.rawimage, self.header, primary_header = self.primary_header, pixflat=pixflat)
     fits.writeto(self.calibfile, pixflat)
     image = preproc(self.rawimage, self.header, primary_header = self.primary_header, pixflat=self.calibfile)
     with self.assertRaises(ValueError):
         image = preproc(self.rawimage, self.header, primary_header = self.primary_header, pixflat=pixflat[0:10, 0:10])
예제 #2
0
 def test_pixflat(self):
     image = preproc(self.rawimage, self.header, pixflat=False)
     pixflat = np.ones_like(image.pix)
     image = preproc(self.rawimage, self.header, pixflat=pixflat)
     fits.writeto(self.calibfile, pixflat)
     image = preproc(self.rawimage, self.header, pixflat=self.calibfile)
     with self.assertRaises(ValueError):
         image = preproc(self.rawimage, self.header, pixflat=pixflat[0:10, 0:10])
예제 #3
0
 def test_bias(self):
     image = preproc(self.rawimage, self.header, bias=False)
     bias = np.zeros(self.rawimage.shape)
     image = preproc(self.rawimage, self.header, bias=bias)
     fits.writeto(self.calibfile, bias)
     image = preproc(self.rawimage, self.header, bias=self.calibfile)
     with self.assertRaises(ValueError):
         image = preproc(self.rawimage, self.header, bias=bias[0:10, 0:10])
예제 #4
0
 def test_bias(self):
     image = preproc(self.rawimage, self.header, bias=False)
     bias = np.zeros(self.rawimage.shape)
     image = preproc(self.rawimage, self.header, bias=bias)
     fits.writeto(self.calibfile, bias)
     image = preproc(self.rawimage, self.header, bias=self.calibfile)
     with self.assertRaises(ValueError):
         image = preproc(self.rawimage, self.header, bias=bias[0:10, 0:10])
예제 #5
0
 def test_mask(self):
     image = preproc(self.rawimage, self.header, mask=False)
     mask = np.random.randint(0, 2, size=image.pix.shape)
     image = preproc(self.rawimage, self.header, mask=mask)
     self.assertTrue(np.all(image.mask == mask))
     fits.writeto(self.calibfile, mask)
     image = preproc(self.rawimage, self.header, mask=self.calibfile)
     self.assertTrue(np.all(image.mask == mask))
     with self.assertRaises(ValueError):
         image = preproc(self.rawimage, self.header, mask=mask[0:10, 0:10])
예제 #6
0
 def test_mask(self):
     image = preproc(self.rawimage, self.header, mask=False)
     mask = np.random.randint(0, 2, size=image.pix.shape)
     image = preproc(self.rawimage, self.header, mask=mask)
     self.assertTrue(np.all(image.mask == mask))
     fits.writeto(self.calibfile, mask)
     image = preproc(self.rawimage, self.header, mask=self.calibfile)
     self.assertTrue(np.all(image.mask == mask))
     with self.assertRaises(ValueError):
         image = preproc(self.rawimage, self.header, mask=mask[0:10, 0:10])
예제 #7
0
 def test_pixflat_mask(self):
     from desispec.maskbits import ccdmask
     pixflat = np.ones((2 * self.ny, 2 * self.nx))
     pixflat[0:10, 0:10] = 0.0
     pixflat[10:20, 10:20] = 0.05
     image = preproc(self.rawimage, self.header, pixflat=pixflat)
     self.assertTrue(np.all(image.mask[0:10, 0:10] & ccdmask.PIXFLATZERO))
     self.assertTrue(np.all(image.mask[10:20, 10:20] & ccdmask.PIXFLATLOW))
예제 #8
0
 def test_pixflat_mask(self):
     from desispec.maskbits import ccdmask
     pixflat = np.ones((2*self.ny, 2*self.nx))
     pixflat[0:10, 0:10] = 0.0
     pixflat[10:20, 10:20] = 0.05
     image = preproc(self.rawimage, self.header, pixflat=pixflat)
     self.assertTrue(np.all(image.mask[0:10,0:10] & ccdmask.PIXFLATZERO))
     self.assertTrue(np.all(image.mask[10:20,10:20] & ccdmask.PIXFLATLOW))
예제 #9
0
    def test_preproc1234(self):
        """Should also work with old amp names 1-4 instead of A-D"""
        hdr = self.header.copy()
        for prefix in ('ORSEC', 'BIASSEC', 'DATASEC', 'CCDSEC'):
            for amp, ampnum in zip(('A','B','C','D'), ('1','2','3','4')):
                if prefix+amp in hdr:
                    hdr[prefix+ampnum] = hdr[prefix+amp]
                    del hdr[prefix+amp]

        image = preproc(self.rawimage, hdr, primary_header=self.primary_header)
예제 #10
0
 def test_preproc(self):
     image = preproc(self.rawimage, self.header)
     self.assertEqual(image.pix.shape, (2*self.ny, 2*self.nx))
     self.assertTrue(np.all(image.ivar <= 1/image.readnoise**2))
     for amp in ('1', '2', '3', '4'):
         pix = image.pix[self.quad[amp]]
         rdnoise = np.median(image.readnoise[self.quad[amp]])
         npixover = self.ny * self.noverscan
         self.assertAlmostEqual(np.mean(pix), 0.0, delta=3*rdnoise/np.sqrt(npixover))
         self.assertAlmostEqual(np.std(pix), self.rdnoise[amp], delta=0.2)
         self.assertAlmostEqual(rdnoise, self.rdnoise[amp], delta=0.2)
예제 #11
0
 def test_preproc(self):
     image = preproc(self.rawimage, self.header, primary_header = self.primary_header)
     self.assertEqual(image.pix.shape, (2*self.ny, 2*self.nx))
     self.assertTrue(np.all(image.ivar <= 1/image.readnoise**2))
     for amp in ('A', 'B', 'C', 'D'):
         pix = image.pix[self.quad[amp]]
         rdnoise = np.median(image.readnoise[self.quad[amp]])
         npixover = self.ny * self.noverscan
         self.assertAlmostEqual(np.mean(pix), 0.0, delta=5*rdnoise/np.sqrt(npixover)) # JXP increased this
         self.assertAlmostEqual(np.std(pix), self.rdnoise[amp], delta=0.2)
         self.assertAlmostEqual(rdnoise, self.rdnoise[amp], delta=0.2)
예제 #12
0
 def test_pedantic(self):
     with self.assertRaises(ValueError):
         _parse_sec_keyword('blat')
     #- should log a warning about large readnoise
     rawimage = self.rawimage + np.random.normal(scale=2,
                                                 size=self.rawimage.shape)
     image = preproc(rawimage, self.header)
     #- should log an error about huge readnoise
     rawimage = self.rawimage + np.random.normal(scale=10,
                                                 size=self.rawimage.shape)
     image = preproc(rawimage, self.header)
     #- should log a warning about small readnoise
     rdnoise = 0.7 * np.mean(self.rdnoise.values())
     rawimage = np.random.normal(scale=rdnoise, size=self.rawimage.shape)
     image = preproc(rawimage, self.header)
     #- should log a warning about tiny readnoise
     rdnoise = 0.01 * np.mean(self.rdnoise.values())
     rawimage = np.random.normal(scale=rdnoise, size=self.rawimage.shape)
     image = preproc(rawimage, self.header)
     #- Missing expected RDNOISE keywords shouldn't be fatal
     hdr = self.header.copy()
     del hdr['RDNOISE1']
     del hdr['RDNOISE2']
     del hdr['RDNOISE3']
     del hdr['RDNOISE4']
     image = preproc(self.rawimage, hdr)
     #- Missing expected GAIN keywords should log error but not crash
     hdr = self.header.copy()
     del hdr['GAIN1']
     del hdr['GAIN2']
     del hdr['GAIN3']
     del hdr['GAIN4']
     image = preproc(self.rawimage, hdr)
예제 #13
0
 def test_pedantic(self):
     with self.assertRaises(ValueError):
         _parse_sec_keyword('blat')
     #- should log a warning about large readnoise
     rawimage = self.rawimage + np.random.normal(scale=2, size=self.rawimage.shape)
     image = preproc(rawimage, self.header)
     #- should log an error about huge readnoise
     rawimage = self.rawimage + np.random.normal(scale=10, size=self.rawimage.shape)
     image = preproc(rawimage, self.header)
     #- should log a warning about small readnoise
     rdnoise = 0.7 * np.mean(self.rdnoise.values())
     rawimage = np.random.normal(scale=rdnoise, size=self.rawimage.shape)
     image = preproc(rawimage, self.header)
     #- should log a warning about tiny readnoise
     rdnoise = 0.01 * np.mean(self.rdnoise.values())
     rawimage = np.random.normal(scale=rdnoise, size=self.rawimage.shape)
     image = preproc(rawimage, self.header)
     #- Missing expected RDNOISE keywords shouldn't be fatal
     hdr = self.header.copy()
     del hdr['RDNOISE1']
     del hdr['RDNOISE2']
     del hdr['RDNOISE3']
     del hdr['RDNOISE4']
     image = preproc(self.rawimage, hdr)
     #- Missing expected GAIN keywords should log error but not crash
     hdr = self.header.copy()
     del hdr['GAIN1']
     del hdr['GAIN2']
     del hdr['GAIN3']
     del hdr['GAIN4']
     image = preproc(self.rawimage, hdr)
예제 #14
0
 def test_preproc_no_orsec(self):
     # Strip out ORSEC
     old_header = self.header.copy()
     old_image = self.rawimage.copy()
     for amp in ('A', 'B', 'C', 'D'):
         old_header.pop('ORSEC{}'.format(amp))
         xy = parse_sec_keyword(self.header['DATASEC'+amp])
         #old_image[xy] -= np.int32(self.offset_row[amp]) -- OR_SEC now zero
     #
     image = preproc(old_image, old_header, primary_header = self.primary_header)
     self.assertEqual(image.pix.shape, (2*self.ny, 2*self.nx))
     self.assertTrue(np.all(image.ivar <= 1/image.readnoise**2))
     for amp in ('A', 'B', 'C', 'D'):
         pix = image.pix[self.quad[amp]]
         rdnoise = np.median(image.readnoise[self.quad[amp]])
         npixover = self.ny * self.noverscan
         self.assertAlmostEqual(np.mean(pix), 0.0, delta=1)  # Using np.int32 pushed this to 1
         self.assertAlmostEqual(np.std(pix), self.rdnoise[amp], delta=0.2)
         self.assertAlmostEqual(rdnoise, self.rdnoise[amp], delta=0.2)
예제 #15
0
 def test_default_mask(self):
     image = preproc(self.rawimage, self.header, mask=True)
예제 #16
0
 def test_default_pixflat(self):
     image = preproc(self.rawimage, self.header, pixflat=True)
예제 #17
0
 def test_default_bias(self):
     image = preproc(self.rawimage, self.header, bias=True)
예제 #18
0
 def test_default_bias(self):
     image = preproc(self.rawimage, self.header, bias=True)
예제 #19
0
 def test_default_pixflat(self):
     image = preproc(self.rawimage, self.header, pixflat=True)
예제 #20
0
 def test_default_mask(self):
     image = preproc(self.rawimage, self.header, mask=True)