Пример #1
0
    def test_7(self): #oversample=2, verbose=True, wavelength=2e-6):
 
    #def test_7(oversample=2, verbose=True, wavelength=10.65e-6, radius=0.0):
        """ Perfect circular case  with FQPM with fieldMask off-axis
        
        Test  ideal FQPM, with field mask. Verify proper behavior in Lyot plane"""

        poppy._IMAGECROP = 5 # plot images w/out zooming in on just the center.
        #oversample = 2
        #pixelscale = 0.1

        fov = 6

        osys1 = poppy.OpticalSystem(" no FQPM, offset", oversample=self.oversample)
        osys1.addPupil('Circle', radius=6.5/2)
        osys1.addPupil('FQPM_FFT_aligner')
        osys1.addImage('fieldstop', size=20.0)  
        osys1.addPupil('FQPM_FFT_aligner', direction='backward')
        osys1.addPupil('Circle', radius=6.5/2)
        osys1.addDetector(pixelscale=self.pixelscale, fov_arcsec=fov)

        osys2 = poppy.OpticalSystem("FQPM offset", oversample=self.oversample)
        osys2.addPupil('Circle', radius=6.5/2)
        osys2.addPupil('FQPM_FFT_aligner')
        osys2.addImage('FQPM', wavelength=self.wavelength)  # perfect FQPM for this wavelength
        osys2.addImage('fieldstop', size=20.0)  
        osys2.addPupil('FQPM_FFT_aligner', direction='backward')
        osys2.addPupil('Circle', radius=6.5/2)
        osys2.addDetector(pixelscale=self.pixelscale, fov_arcsec=fov)

        myoffset = 3.0
        osys1.source_offset_r = myoffset
        osys1.source_offset_theta = 45.
        osys2.source_offset_r = myoffset
        osys2.source_offset_theta = 45.
 
        poppy._FLUXCHECK=True
        plt.figure(1)
        plt.clf()
        psf1 = osys1.calcPSF(wavelength=self.wavelength, display_intermediates=True, save_intermediates=False)
        plt.figure(2)
        plt.clf()
        psf2 = osys2.calcPSF(wavelength=self.wavelength, display_intermediates=True, save_intermediates=False)

        plt.figure(3)
        plt.subplot(211)
        webbpsf.display_PSF(psf1, title=osys1.name)
        plt.subplot(212)
        webbpsf.display_PSF(psf2, title=osys2.name)

        pos1 = webbpsf.fwcentroid(psf1[0].data, halfwidth=10, threshold=1e-2)
        pos2 = webbpsf.fwcentroid(psf2[0].data, halfwidth=10, threshold=1e-2)

        rel_offset = np.sqrt(((np.array(pos1) - np.array(pos2))**2).sum())
        self.assertTrue(rel_offset < 1e-3 ) 
        _log.info("Source position does not appear to be affected by FQPMs for far off-axis sources")
Пример #2
0
    def do_test_8(self):
        """ Test point source shifting, given variable pupil array padding. """

        angle = 36.
        for pad_factor in [1.0, 1.1, 1.5, 2.0]: 
            osys = poppy.OpticalSystem("test", oversample=self.oversample)
            osys.addPupil('Circle', radius=6.5/2, pad_factor = pad_factor)
            osys.addImage()
            osys.addPupil('Circle', radius=6.5/2)
            osys.addDetector(pixelscale=self.pixelscale, fov_arcsec=3.0)
            
            plt.clf()
            poppy._FLUXCHECK=True
            poppy._USE_FFTW3 = False


            osys.source_offset_theta = angle
            osys.source_offset_r =  0.5
            psf = osys.calcPSF(wavelength=self.wavelength, display_intermediates=True)
            #psf.writeto('test3_psf.fits', clobber=True)
            # TODO check position
            pos = webbpsf.fwcentroid(psf[0].data, halfwidth=10, threshold=1e-2)
            # pos is the pixel coords in y,x in pixel units.
            cenx = (psf[0].data.shape[0]-1)/2.0
            offset = np.sqrt( (pos[0]-cenx)**2 + (pos[1]-cenx)**2)* self.pixelscale/self.oversample
            _log.info("Desired offset is %f, measured is %f " % (osys.source_offset_r, offset))
            self.assertAlmostEqual(osys.source_offset_r, offset, 3)
Пример #3
0
    def do_4_source_offsets(self, angle=0):
        #oversample=2, verbose=True, wavelength=2e-6, angle=0):
        """ Perfect circular case  no FQPM no field mask, off-axis PSF location

        Test point source shifting. no FQPM, no field mask. Verify point source goes to right spot in image plane"""

        osys = poppy.OpticalSystem("test", oversample=self.oversample)
        osys.addPupil('Circle', radius=6.5/2)
        osys.addImage()
        osys.addPupil('Circle', radius=6.5/2)
        osys.addDetector(pixelscale=self.pixelscale, fov_arcsec=3.0)

        plt.clf()
        poppy._FLUXCHECK=True

        osys.source_offset_theta = angle
        for i in range(15):
            osys.source_offset_r = i * 0.1
            psf = osys.calcPSF(wavelength=self.wavelength, display_intermediates=True)

            pos = webbpsf.fwcentroid(psf[0].data, halfwidth=10, threshold=1e-2)
            # pos is the pixel coords in y,x in pixel units.
            cenx = (psf[0].data.shape[0]-1)/2.0
            offset = np.sqrt( (pos[0]-cenx)**2 + (pos[1]-cenx)**2)* self.pixelscale/self.oversample
            _log.info("Desired offset is %f, measured is %f " % (osys.source_offset_r, offset))
            self.assertAlmostEqual(osys.source_offset_r, offset, 3)