コード例 #1
0
ファイル: desmedsio.py プロジェクト: kstory8/ngmixer
 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]
コード例 #2
0
ファイル: desmedsio.py プロジェクト: kstory8/ngmixer
    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
コード例 #3
0
ファイル: desmedsio.py プロジェクト: danielgruen/ngmixer
    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
コード例 #4
0
ファイル: desmedsio.py プロジェクト: danielgruen/ngmixer
 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]
コード例 #5
0
ファイル: lmfit.py プロジェクト: esheldon/gmix_meds
    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
コード例 #6
0
ファイル: simpsimmedsio.py プロジェクト: danielgruen/ngmixer
    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
コード例 #7
0
ファイル: desmedsio.py プロジェクト: esheldon/ngmixer
    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