Example #1
0
 def _get_meds_orig_filename(self, meds, mindex, icut):
     """
     Get the original filename
     """
     file_id=meds['file_id'][mindex, icut]
     ii=meds.get_image_info()
     return ii['image_path'][file_id]
Example #2
0
    def _get_psfex_objects(self, meds, band):
        """
        Load psfex objects for all images, including coadd
        """
        from psfex import PSFExError, PSFEx

        psfex_list=[]

        info=meds.get_image_info()
        nimage=info.size
        for i in xrange(nimage):
            pex=None

            # don't even bother if we are going to skip this image
            flags = self.all_image_flags[band][i]
            if (flags & self.conf['image_flags2check']) == 0:

                impath=info['image_path'][i].strip()
                psfpath = self._psfex_path_from_image_path(meds, impath)

                if not os.path.exists(psfpath):
                    print("warning: missing psfex: %s" % psfpath)
                    self.all_image_flags[band][i] |= self.conf['image_flags2check']
                else:
                    print_with_verbosity("loading: %s" % psfpath,verbosity=2)
                    try:
                        pex=PSFEx(psfpath)
                    except PSFExError as err:
                        print("problem with psfex file: %s " % str(err))
                        pex=None

            psfex_list.append(pex)

        return psfex_list
Example #3
0
    def _get_psfex_objects(self, meds, band):
        """
        Load psfex objects for all images, including coadd
        """

        psfex_list=[]

        info=meds.get_image_info()
        nimage=info.size
        nflagged=0
        for i in xrange(nimage):
            pex=None

            # don't even bother if we are going to skip this image
            flags = self.all_image_flags[band][i]
            if (flags & self.conf['image_flags2check']) == 0:

                impath=info['image_path'][i].strip()
                psfpath = self._psfex_path_from_image_path(meds, impath)

                # pex might be None with flags set
                pex, psf_flags = self._get_psfex_object(psfpath)
                if psf_flags != 0:
                    self.all_image_flags[band][i] |= psf_flags
                    nflagged += 1


            psfex_list.append(pex)

        print("    flagged %d/%d psfex for band %s" % (nflagged,nimage,band))
        return psfex_list
Example #4
0
 def _get_meds_orig_filename(self, meds, mindex, icut):
     """
     Get the original filename
     """
     file_id=meds['file_id'][mindex, icut]
     ii=meds.get_image_info()
     return ii['image_path'][file_id]
Example #5
0
    def _get_all_psfex_objects(self, meds):
        """
        Load psfex objects for each of the SE images
        include the coadd so we get  the index right
        """
        desdata=os.environ['DESDATA']
        meds_desdata=meds._meta['DESDATA'][0]

        psfex_list=[]
        info=meds.get_image_info()
        nimage=info.size

        for i in xrange(nimage):
            impath=info['image_path'][i].strip()
            psfpath=impath.replace('.fits.fz','_psfcat.psf')

            if desdata not in psfpath:
                psfpath=psfpath.replace(meds_desdata,desdata)

            pex=psfex.PSFEx(psfpath)
            psfex_list.append(pex)

        return psfex_list
Example #6
0
    def _get_psfex_objects(self, meds):
        """
        Load psfex objects for all images, including coadd
        """
        import psfex

        psfex_list = []

        info = meds.get_image_info()
        nimage = info.size
        for i in xrange(nimage):

            impath = info['image_path'][i]
            psf_ext = self._psfex_ext_from_image_path(info, impath)

            pex = psfex.PSFEx(
                meds._fits,
                ext=psf_ext,
            )

            psfex_list.append(pex)

        return psfex_list
Example #7
0
    def _get_psfex_objects(self, meds, band):
        """
        Load psfex objects for all images
        """

        psfex_list=[]

        info=meds.get_image_info()
        nimage=info.size
        nflagged=0
        for i in xrange(nimage):
            pex=None

            # don't even bother if we are going to skip this image
            flags = self.all_image_flags[band][i]

            if (i==0) and not self.conf['fit_coadd_galaxy']:
                print("skipping coadd psf")
                self.all_image_flags[band][i] |= 1
            else:
                if (flags & self.conf['image_flags2check']) == 0:

                    impath=info['image_path'][i].strip()
                    psfpath = self._psfex_path_from_image_path(meds, impath)

                    # pex might be None with flags set
                    pex, psf_flags = self._get_psfex_object(psfpath)
                    if psf_flags != 0:
                        self.all_image_flags[band][i] |= psf_flags
                        nflagged += 1


            psfex_list.append(pex)

        print("    flagged %d/%d psfex for band %s" % (nflagged,nimage,band))
        return psfex_list