Example #1
0
 def MtX(self, x):
     r"""Adjoint to degradation operator :func:`MX`."""
     x = utils.reg_format(x * self.SNR_weights)
     upsamp_x = np.array(
         [nf * utils.adjoint_degradation_op(x_i, shift_ker, self.D) for
          nf, x_i, shift_ker
          in zip(self.normfacs, x, utils.reg_format(self.ker_rot))])
     x, upsamp_x = utils.rca_format(x), utils.rca_format(upsamp_x)
     return utils.apply_transform(upsamp_x.dot(self.A.T), self.filters)
Example #2
0
 def recombine(self, transf_S):
     r"""Recombine new S and return it."""
     S = np.array([
         filter_convolve(transf_Sj, self.filters, filter_rot=True)
         for transf_Sj in transf_S
     ])
     return utils.rca_format(S).dot(self.A)
Example #3
0
 def update_H_glob(self, new_H_glob):
     r"""Update current global model."""
     self.H_glob = new_H_glob
     dec_H_glob = np.array(
         [nf * utils.degradation_op(H_i, shift_ker, self.D)
          for nf, shift_ker, H_i in zip(self.normfacs,
                                        utils.reg_format(self.ker),
                                        utils.reg_format(self.H_glob))])
     self.FdH_glob = utils.rca_format(dec_H_glob)
Example #4
0
 def update_H_loc(self, new_H_loc):
     r"""Update current local models."""
     self.H_loc = new_H_loc
     dec_H_loc = np.array([nf * utils.degradation_op(H_i, shift_ker, self.D)
                           for nf, shift_ker, H_i in
                           zip(self.normfacs,
                               utils.reg_format(self.ker),
                               utils.reg_format(self.H_loc))])
     self.FdH_loc = utils.rca_format(dec_H_loc)
Example #5
0
    def MX(self, transf_S):
        r"""Apply degradation operator and renormalize.

        Parameters
        ----------
        transf_S : numpy.ndarray
            Current eigenPSFs in Starlet space.

        Returns
        -------
        numpy.ndarray result

        """
        S = utils.rca_format(
            np.array([filter_convolve(transf_Sj, self.filters, filter_rot=True)
                      for transf_Sj in transf_S]))
        dec_rec = np.array(
            [nf * utils.degradation_op(S.dot(A_i), shift_ker, self.D)
             for nf, A_i, shift_ker in zip(self.normfacs,
                                           self.A.T,
                                           utils.reg_format(self.ker))])
        self._current_rec = utils.rca_format(dec_rec)
        return self._current_rec
Example #6
0
    def prep_mccd_inputs(self, starcat_array):
        r"""Prepare the inputs for mccd algorithm.

        Taks done:

        - Translate from local to global coordinate system.

        - Apply mask to stars.

        - Normalize star values.

        - Modify the star format.


        Parameters
        ----------
        starcat_array: numpy.ndarray
            Array with (starcat_id, ccd_n, path) for every file in one
            starcat_id (exposure ID).

        Returns
        -------
        star_list: list
            List containing the masked star stamps.
        position_list: list
            List containing the positions in the global coordinate system.
        mask_list: list
            List containing the masks corresponding to the star stamps.
        ccd_list: list
            List containing the CCD ids for the stars.
        SNR_list: list
            List containing the estimated SNR values for the stars.
            Will be None if there are no SNR values available.
        RA_list: list
            List containing the RA coordinate for the stars.
            Will be None if there are no RA coordinates available.
        DEC_list: list
            List containing the DEC coordinate for the stars.
            Will be None if there are no DEC coordinates available.

        """
        number_ccd = starcat_array.shape[0]

        star_list = []
        position_list = []
        mask_list = []
        ccd_list = []
        SNR_list = []
        RA_list = []
        DEC_list = []

        for it in range(number_ccd):
            starcat = fits.open(starcat_array[it, 2])
            ccd = starcat_array[it, 1].astype('int')

            positions = np.array([
                self.loc2glob.loc2glob_img_coord(ccd, x, y)
                for x, y in zip(starcat[2].data[self.coord_x_descriptor],
                                starcat[2].data[self.coord_y_descriptor])
            ])

            stars = utils.rca_format(starcat[2].data['VIGNET'])
            masks = self.handle_mask(stars,
                                     thresh=self.mask_thresh,
                                     apply_to_stars=True)

            star_list.append(stars)
            position_list.append(positions)
            mask_list.append(masks)
            ccd_list.append(ccd)

            try:
                SNR = starcat[2].data['SNR_WIN']
                SNR_list.append(SNR)
            except Exception:
                SNR_list = None

            try:
                RA_list.append(starcat[2].data['XWIN_WORLD'])
                DEC_list.append(starcat[2].data['YWIN_WORLD'])
            except Exception:
                RA_list = None
                DEC_list = None

        self.SNR_list = SNR_list
        self.star_list = star_list
        self.position_list = position_list
        self.mask_list = mask_list
        self.ccd_list = ccd_list
        self.RA_list = RA_list
        self.DEC_list = DEC_list

        return star_list, position_list, mask_list, ccd_list, SNR_list,\
            RA_list, DEC_list