예제 #1
0
파일: medsio.py 프로젝트: NiallMac/ngmixer
    def _get_band_observations(self, band, mindex):
        """
        Get an ObsList for the coadd observations in each band
        If psf fitting fails, the ObsList will be zero length
        note we have already checked that we have a coadd and a single epoch
        without flags
        """

        meds = self.meds_list[band]
        ncutout = meds['ncutout'][mindex]

        image_flags = self._get_image_flags(band, mindex)

        coadd_obs_list = ObsList()
        obs_list = ObsList()

        fake = numpy.zeros((0, 0))
        for icut in xrange(ncutout):

            flags = 0
            if not self._should_use_obs(band, mindex, icut):
                obs = Observation(fake)
                flags = IMAGE_FLAGS
            else:
                iflags = image_flags[icut]
                if iflags != 0:
                    flags = IMAGE_FLAGS
                    obs = Observation(fake)
                else:
                    obs = self._get_band_observation(band, mindex, icut)
                    if obs is None:
                        flags = IMAGE_FLAGS
                        obs = Observation(fake)

            # fill the meta data
            self._fill_obs_meta_data(obs, band, mindex, icut)

            # set flags
            meta = {'flags': flags}
            obs.update_meta_data(meta)

            if icut == 0:
                coadd_obs_list.append(obs)
            else:
                obs_list.append(obs)

        if self.conf['reject_outliers'] and len(obs_list) > 0:
            self._reject_outliers(obs_list)

        obs_list.update_meta_data({'band_num': band})
        coadd_obs_list.update_meta_data({'band_num': band})

        return coadd_obs_list, obs_list
예제 #2
0
파일: medsio.py 프로젝트: esheldon/ngmixer
    def _get_band_observations(self, band, mindex):
        """
        Get an ObsList for the coadd observations in each band
        If psf fitting fails, the ObsList will be zero length
        note we have already checked that we have a coadd and a single epoch
        without flags
        """

        meds=self.meds_list[band]
        ncutout=meds['ncutout'][mindex]

        image_flags=self._get_image_flags(band, mindex)

        coadd_obs_list = ObsList()
        obs_list       = ObsList()

        fake=numpy.zeros((0,0))
        for icut in xrange(ncutout):

            flags=0
            if not self._should_use_obs(band, mindex, icut):
                obs = Observation(fake)
                flags = IMAGE_FLAGS
            else:
                iflags = image_flags[icut]
                if iflags != 0:
                    flags = IMAGE_FLAGS
                    obs = Observation(fake)
                else:
                    obs = self._get_band_observation(band, mindex, icut)
                    if obs is None:
                        flags = IMAGE_FLAGS
                        obs = Observation(fake)

            # fill the meta data
            self._fill_obs_meta_data(obs,band,mindex,icut)

            # set flags
            meta = {'flags':flags}
            obs.update_meta_data(meta)

            if icut==0:
                coadd_obs_list.append(obs)
            else:
                obs_list.append(obs)

        if self.conf['reject_outliers'] and len(obs_list) > 0:
            self._reject_outliers(obs_list)

        obs_list.update_meta_data({'band_num':band})
        coadd_obs_list.update_meta_data({'band_num':band})

        return coadd_obs_list, obs_list
예제 #3
0
파일: medsio.py 프로젝트: kstory8/ngmixer
    def _get_band_observations(self, band, mindex):
        """
        Get an ObsList for the coadd observations in each band
        If psf fitting fails, the ObsList will be zero length
        note we have already checked that we have a coadd and a single epoch
        without flags
        """

        meds = self.meds_list[band]
        ncutout = meds["ncutout"][mindex]

        image_flags = self._get_image_flags(band, mindex)

        coadd_obs_list = ObsList()
        obs_list = ObsList()

        for icut in xrange(ncutout):
            iflags = image_flags[icut]
            if iflags != 0:
                flags = IMAGE_FLAGS
                obs = Observation(numpy.zeros((0, 0)))
            else:
                obs = self._get_band_observation(band, mindex, icut)
                flags = 0

            # fill the meta data
            self._fill_obs_meta_data(obs, band, mindex, icut)

            # set flags
            meta = {"flags": flags}
            obs.update_meta_data(meta)

            if icut == 0:
                coadd_obs_list.append(obs)
            else:
                obs_list.append(obs)

        """
        if ncutout == 0:
            for o in [coadd_obs_list,obs_list]:
                flags = IMAGE_FLAGS
                obs = Observation(numpy.zeros((0,0)))
                meta = {'flags':flags}
                obs.update_meta_data(meta)            
                o.append(obs)
        """

        if self.conf["reject_outliers"] and len(obs_list) > 0:
            self._reject_outliers(obs_list)

        return coadd_obs_list, obs_list
예제 #4
0
파일: medsio.py 프로젝트: kstory8/ngmixer
    def _get_psf_observation(self, band, mindex, icut, image_jacobian):
        """
        Get an Observation representing the PSF and the "sigma"
        from the psf model
        """
        im, cen, sigma_pix, fname = self._get_psf_image(band, mindex, icut)

        psf_jacobian = image_jacobian.copy()
        psf_jacobian.set_cen(cen[0], cen[1])

        psf_obs = Observation(im, jacobian=psf_jacobian)
        psf_obs.filename = fname

        # convert to sky coords
        sigma_sky = sigma_pix * psf_jacobian.get_scale()

        psf_obs.update_meta_data({"sigma_sky": sigma_sky})
        psf_obs.update_meta_data({"Tguess": sigma_sky * sigma_sky})
        psf_obs.update_meta_data({"psf_norm": im.sum()})

        return psf_obs
예제 #5
0
파일: medsio.py 프로젝트: NiallMac/ngmixer
    def _get_psf_observation(self, band, mindex, icut, image_jacobian):
        """
        Get an Observation representing the PSF and the "sigma"
        from the psf model
        """
        im, cen, sigma_pix, fname = self._get_psf_image(band, mindex, icut)

        psf_jacobian = image_jacobian.copy()
        psf_jacobian.set_cen(row=cen[0], col=cen[1])

        psf_obs = Observation(im, jacobian=psf_jacobian)
        psf_obs.filename = fname

        # convert to sky coords
        sigma_sky = sigma_pix * psf_jacobian.get_scale()

        psf_obs.update_meta_data({'sigma_sky': sigma_sky})
        psf_obs.update_meta_data({'Tguess': sigma_sky * sigma_sky})
        psf_obs.update_meta_data({'psf_norm': im.sum()})

        return psf_obs