Esempio n. 1
0
    def computeRoundAperCorrFromPSF(self,
                                    radii,
                                    useLookupTable=True,
                                    display=True,
                                    displayAperture=True):
        """
        This computes the aperture correction directly from the PSF. These vaules will be used for interpolation to
        other values. The aperture correction is with respect tothe largest aperture provided in radii. I recommend
        4*FWHM.

        radii is an array of radii on which to calculate the aperture corrections. I recommend at least 10 values
        between 1 and 4 FWHM.
        useLookupTable=True/False to calculate either with just the moffat profile, or with lookuptable included.
        display=True to show you some plots.
        displayAperture=True to show you the aperture at each radius.
        """

        self.aperCorrRadii = radii * 1.0
        aperCorrs = []

        (A, B) = self.PSF.shape
        if useLookupTable:
            phot = pillPhot(self.fullPSF, repFact=1)
        else:
            phot = pillPhot(self.PSF, repFact=1)
        """
        #old individual radii call version
        for iii in range(len(self.aperCorrRadii)):
            r=radii[iii]
            width=A/2#int(A/(r*self.repFact*2)+0.5)*0.75
            phot(B/2.,A/2.,radius=r*self.repFact,l=0.,a=0.,skyRadius=None,zpt=0.0,width=width,display=displayAperture)
            m=phot.magnitude
            aperCorrs.append(m)
        """

        #more efficient version with all radii passed at once.
        width = A / 2
        phot(B / 2.,
             A / 2.,
             radius=radii * self.repFact,
             l=0.,
             a=0.,
             skyRadius=None,
             zpt=0.0,
             width=width,
             display=displayAperture)
        aperCorrs = phot.magnitude

        self.aperCorrs = np.array(aperCorrs)
        self.aperCorrFunc = interp.interp1d(self.aperCorrRadii * 1.,
                                            self.aperCorrs * 1.)

        if display:
            fig = pyl.figure('psf')
            pyl.plot(self.aperCorrRadii, self.aperCorrs, 'k-o')
            pyl.xlabel('Aperture Radius (pix')
            pyl.ylabel('Normalized Magnitude')
            pyl.show()
Esempio n. 2
0
File: psf.py Progetto: mpj17/trippy
    def computeLineAperCorrFromTSF(self,radii,l,a,display=True,displayAperture=True):
        """
        This computes the aperture correction directly from the TSF. These vaules will be used for interpolation to
        other values. The aperture correction is with respect tothe largest aperture provided in radii. I recommend
        4*FWHM.

        radii is an array of radii on which to calculate the aperture corrections. I recommend at least 10 values
        between 1 and 4 FWHM.
        l and a are the length (in pixels) and angle of the pill aperture
        useLookupTable=True/False to calculate either with just the moffat profile, or with lookuptable included.
        display=True to show you some plots.
        displayAperture=True to show you the aperture at each radius.
        """

        self.lineAperCorrRadii=radii*1.0
        self.lineAperCorrs=[]

        (A,B)=self.PSF.shape
        phot=pillPhot(self.longPSF,repFact=1)
        for ii in range(len(self.lineAperCorrRadii)):
            r=self.lineAperCorrRadii[ii]
            width=A/2#int(A/(r*self.repFact*2))
            phot(B/2.,A/2.,radius=r*self.repFact,l=l*self.repFact,a=a,skyRadius=None,zpt=0.0,width=width,display=displayAperture)
            m=phot.magnitude
            print '   ',r,phot.sourceFlux,m
            self.lineAperCorrs.append(m)
        self.lineAperCorrs=num.array(self.lineAperCorrs)
        self.lineAperCorrFunc=interp.interp1d(self.lineAperCorrRadii,self.lineAperCorrs)
        
        if display:
            fig=pyl.figure('psf')
            pyl.plot(self.lineAperCorrRadii,self.lineAperCorrs,'k-o')
            pyl.xlabel('Aperture Radius (pix')
            pyl.ylabel('Normalized Magnitude')
            pyl.show()
Esempio n. 3
0
    def computeRoundAperCorrFromPSF(self,radii,useLookupTable=True,display=True,displayAperture=True):
        """
        This computes the aperture correction directly from the PSF. These vaules will be used for interpolation to
        other values. The aperture correction is with respect tothe largest aperture provided in radii. I recommend
        4*FWHM.

        radii is an array of radii on which to calculate the aperture corrections. I recommend at least 10 values
        between 1 and 4 FWHM.
        useLookupTable=True/False to calculate either with just the moffat profile, or with lookuptable included.
        display=True to show you some plots.
        displayAperture=True to show you the aperture at each radius.
        """

        self.aperCorrRadii=radii*1.0
        aperCorrs=[]

        (A,B)=self.PSF.shape
        if useLookupTable:
            phot=pillPhot(self.fullPSF,repFact=1)
        else:
            phot=pillPhot(self.PSF,repFact=1)

        """
        #old individual radii call version
        for iii in range(len(self.aperCorrRadii)):
            r=radii[iii]
            width=A/2#int(A/(r*self.repFact*2)+0.5)*0.75
            phot(B/2.,A/2.,radius=r*self.repFact,l=0.,a=0.,skyRadius=None,zpt=0.0,width=width,display=displayAperture)
            m=phot.magnitude
            aperCorrs.append(m)
        """

        #more efficient version with all radii passed at once.
        width=A/2
        phot(B / 2., A / 2., radius=radii * self.repFact, l=0., a=0., skyRadius=None, zpt=0.0, width=width,
             display=displayAperture)
        aperCorrs = phot.magnitude

        self.aperCorrs=num.array(aperCorrs)
        self.aperCorrFunc=interp.interp1d(self.aperCorrRadii*1.,self.aperCorrs*1.)

        if display:
            fig=pyl.figure('psf')
            pyl.plot(self.aperCorrRadii,self.aperCorrs,'k-o')
            pyl.xlabel('Aperture Radius (pix')
            pyl.ylabel('Normalized Magnitude')
            pyl.show()
Esempio n. 4
0
    def computeLineAperCorrFromTSF(self,
                                   radii,
                                   l,
                                   a,
                                   display=True,
                                   displayAperture=True):
        """
        This computes the aperture correction directly from the TSF. These vaules will be used for interpolation to
        other values. The aperture correction is with respect tothe largest aperture provided in radii. I recommend
        4*FWHM.

        radii is an array of radii on which to calculate the aperture corrections. I recommend at least 10 values
        between 1 and 4 FWHM.
        l and a are the length (in pixels) and angle of the pill aperture
        useLookupTable=True/False to calculate either with just the moffat profile, or with lookuptable included.
        display=True to show you some plots.
        displayAperture=True to show you the aperture at each radius.
        """

        self.lineAperCorrRadii = radii * 1.0
        self.lineAperCorrs = []

        (A, B) = self.PSF.shape
        phot = pillPhot(self.longPSF, repFact=1)
        """
        #old version where all radii are passed individually
        for ii in range(len(self.lineAperCorrRadii)):
            r=self.lineAperCorrRadii[ii]
            width=A/2#int(A/(r*self.repFact*2))
            phot(B/2.,A/2.,radius=r*self.repFact,l=l*self.repFact,a=a,skyRadius=None,zpt=0.0,width=width,display=displayAperture)
            m=phot.magnitude
            print '   ',r,phot.sourceFlux,m
            self.lineAperCorrs.append(m)
        """

        #new version where all radii are passed at once
        width = A / 2
        phot(B / 2.,
             A / 2.,
             radius=radii * self.repFact,
             l=l * self.repFact,
             a=a,
             skyRadius=None,
             zpt=0.0,
             width=width,
             display=displayAperture)
        fluxes = phot.sourceFlux
        self.lineAperCorrs = phot.magnitude
        print "    Radius  Flux      Magnitude"
        for ii in range(len(self.lineAperCorrRadii)):
            print '    {:6.2f} {:10.3f}  {:8.3f}'.format(
                radii[ii], phot.sourceFlux[ii], phot.magnitude[ii])

        self.lineAperCorrs = np.array(self.lineAperCorrs)
        self.lineAperCorrFunc = interp.interp1d(self.lineAperCorrRadii,
                                                self.lineAperCorrs)

        if display:
            fig = pyl.figure('psf')
            pyl.plot(self.lineAperCorrRadii, self.lineAperCorrs, 'k-o')
            pyl.xlabel('Aperture Radius (pix')
            pyl.ylabel('Normalized Magnitude')
            pyl.show()