Exemple #1
0
    def _get_band_observation(self, band, mindex, icut):
        """
        Get an Observation for a single band.
        """
        meds = self.meds_list[band]

        fname = self._get_meds_orig_filename(meds, mindex, icut)
        im = self._get_meds_image(meds, mindex, icut)
        wt, wt_us, seg = self._get_meds_weight(meds, mindex, icut)
        jacob = self._get_jacobian(meds, mindex, icut)

        # for the psf fitting code
        wt = wt.clip(min=0.0)

        psf_obs = self._get_psf_observation(band, mindex, icut, jacob)

        obs = Observation(im, weight=wt.copy(), jacobian=jacob, psf=psf_obs)
        if wt_us is not None:
            obs.weight_us = wt_us.copy()
        else:
            obs.weight_us = None
        obs.weight_raw = wt.copy()
        obs.seg = seg
        obs.filename = fname

        return obs
Exemple #2
0
    def _get_band_observation(self, band, mindex, icut):
        """
        Get an Observation for a single band.
        """

        meds=self.meds_list[band]

        bmask,skip = self._get_meds_bmask(meds, mindex, icut)
        if skip:
            return None


        wt,wt_us,wt_raw,seg,skip = self._get_meds_weight(meds, mindex, icut)
        if skip:
            return None

        im = self._get_meds_image(meds, mindex, icut)

        jacob = self._get_jacobian(meds, mindex, icut)


        if self.conf['ignore_zero_images'] and 0.0==im.sum():
            print("    image all zero, skipping")
            return None

        psf_obs = self._get_psf_observation(band, mindex, icut, jacob)

        obs=Observation(im,
                        weight=wt,
                        bmask=bmask,
                        jacobian=jacob,
                        psf=psf_obs)
        if wt_us is not None:
            obs.weight_us = wt_us
        else:
            obs.weight_us = None

        obs.weight_raw = wt_raw
        obs.seg = seg

        fname = self._get_meds_orig_filename(meds, mindex, icut)
        obs.filename=fname

        if 'trim_image' in self.conf:
            self._trim_obs(obs)

        return obs
Exemple #3
0
    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
Exemple #4
0
    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