Exemple #1
0
    def __init__(self, data, fourier_op):

        GradBasic.__init__(self, data, fourier_op.op, fourier_op.adj_op)
        self.fourier_op = fourier_op
        PowerMethod.__init__(self, self.trans_op_op, self.fourier_op.shape,
                             data_type=np.complex, auto_run=False)
        self.get_spec_rad(extra_factor=1.1)
Exemple #2
0
    def __init__(self, data, weights, A, H_loc, flux, sig,
                 ker, ker_rot, SNR_weights, D, filters, save_iter_cost=False,
                 data_type='float'):
        r"""Initialize class attributes."""
        self._grad_data_type = data_type
        self.obs_data = data
        self.obs_weights = weights
        self.op = self.MX
        self.trans_op = self.MtX
        self.A = np.copy(A)
        self.H_loc = np.copy(H_loc)
        self.flux = flux
        self.sig = sig
        self.normfacs = self.flux / (np.median(self.flux) * self.sig)
        self.ker = ker
        self.ker_rot = ker_rot
        self.D = D
        self.filters = filters
        self.SNR_weights = SNR_weights
        self.iter_cost = []
        self.save_iter_cost = save_iter_cost
        self.FdH_loc = None

        hr_shape = np.array(data.shape[:2]) * D
        PowerMethod.__init__(self, self.trans_op_op,
                             (A.shape[0], filters.shape[0]) + tuple(hr_shape),
                             auto_run=False)

        self._current_rec = None
Exemple #3
0
    def __init__(self, data, supp, neighbors_graph, weights_neighbors, spectrums, \
                P, flux, sig, ker, ker_rot, D, basis, data_type=float):

        self._grad_data_type = data_type
        self.obs_data = data
        self.op = self.MX
        self.trans_op = self.MtX
        shap = data.shape
        self.shape = (shap[0] * D, shap[1] * D)
        self.D = D
        self.supp = supp
        self.neighbors_graph = neighbors_graph
        self.weights_neighbors = weights_neighbors
        self.spectrums = spectrums
        self.P = np.copy(P)
        self.flux = flux
        self.sig = sig
        self.ker = ker
        self.ker_rot = ker_rot
        self.basis = basis

        PowerMethod.__init__(self, self.trans_op_op,
                             (P.shape[-1], self.basis.shape[0]))

        self._current_rec = None  # stores latest application of self.MX
Exemple #4
0
    def __init__(self,
                 data,
                 weights,
                 S,
                 VT,
                 flux,
                 sig,
                 ker,
                 ker_rot,
                 D,
                 data_type='float'):
        self._grad_data_type = data_type
        self.obs_data = data
        self.obs_weights = weights
        self.op = self.MX
        self.trans_op = self.MtX
        self.VT = VT
        self.flux = flux
        self.sig = sig
        self.ker = ker
        self.ker_rot = ker_rot
        self.D = D
        # initialize Power Method to compute spectral radius
        PowerMethod.__init__(self,
                             self.trans_op_op, (S.shape[-1], VT.shape[0]),
                             auto_run=False)
        self.update_S(np.copy(S), update_spectral_radius=False)

        self._current_rec = None  # stores latest application of self.MX
Exemple #5
0
    def __init__(self,
                 data,
                 weights,
                 A,
                 flux,
                 sig,
                 ker,
                 ker_rot,
                 D,
                 filters,
                 data_type='float'):
        self._grad_data_type = data_type
        self.obs_data = data
        self.obs_weights = weights
        self.op = self.MX
        self.trans_op = self.MtX
        self.A = np.copy(A)
        self.flux = flux
        self.sig = sig
        self.ker = ker
        self.ker_rot = ker_rot
        self.D = D
        self.filters = filters
        # initialize Power Method to compute spectral radius
        hr_shape = np.array(data.shape[:2]) * D
        PowerMethod.__init__(self,
                             self.trans_op_op,
                             (A.shape[0], filters.shape[0]) + tuple(hr_shape),
                             auto_run=False)

        self._current_rec = None  # stores latest application of self.MX
Exemple #6
0
 def __init__(self, operator, trans_operator, shape,
              lips_calc_max_iter=10, lipschitz_cst=None, num_check_lips=10,
              verbose=0):
     # Initialize the GradBase with dummy data
     super(GradBaseMRI, self).__init__(
         np.array(0),
         operator,
         trans_operator,
     )
     if lipschitz_cst is not None:
         self.spec_rad = lipschitz_cst
         self.inv_spec_rad = 1.0 / self.spec_rad
     else:
         calc_lips = PowerMethod(self.trans_op_op, shape,
                                 data_type=np.complex, auto_run=False)
         calc_lips.get_spec_rad(extra_factor=1.1,
                                max_iter=lips_calc_max_iter)
         self.spec_rad = calc_lips.spec_rad
         self.inv_spec_rad = calc_lips.inv_spec_rad
     if verbose > 0:
         print("Lipschitz constant is " + str(self.spec_rad))
     if num_check_lips > 0:
         is_lips = check_lipschitz_cst(f=self.trans_op_op,
                                       x_shape=shape,
                                       lipschitz_cst=self.spec_rad,
                                       max_nb_of_iter=num_check_lips)
         if not is_lips:
             raise ValueError('The lipschitz constraint is not satisfied')
         else:
             if verbose > 0:
                 print('The lipschitz constraint is satisfied')
Exemple #7
0
    def __init__(self, data, weights, S, VT, H_glob, flux, sig, ker,
                 ker_rot, SNR_weights, D, save_iter_cost=False,
                 data_type='float'):
        r"""Initialize class attributes."""
        self._grad_data_type = data_type
        self.obs_data = data
        self.obs_weights = weights
        self.op = self.MX
        self.trans_op = self.MtX
        self.VT = VT
        self.H_glob = H_glob
        self.flux = flux
        self.sig = sig
        self.normfacs = self.flux / (np.median(self.flux) * self.sig)
        self.ker = ker
        self.ker_rot = ker_rot
        self.D = D
        self.SNR_weights = SNR_weights
        self.iter_cost = []
        self.save_iter_cost = save_iter_cost

        self.S = None
        self.FdS = None
        self.FdH_glob = None

        PowerMethod.__init__(self, self.trans_op_op,
                             (S.shape[-1], VT.shape[0]), auto_run=False)
        self.update_S(np.copy(S), update_spectral_radius=False)

        self._current_rec = None
Exemple #8
0
 def __init__(self, data, linear_op, fourier_op):
     GradBasic.__init__(self, data, self._op_method, self._trans_op_method)
     self.fourier_op = fourier_op
     self.linear_op = linear_op
     coef = linear_op.op(np.zeros(fourier_op.shape).astype(np.complex))
     PowerMethod.__init__(self, self.trans_op_op, coef.shape,
                          data_type=np.complex, auto_run=False)
     self.get_spec_rad(extra_factor=1.1)
Exemple #9
0
 def update_S(self, new_S, update_spectral_radius=True):
     r"""Update current eigenPSFs."""
     self.S = new_S
     self.FdS = np.array([[nf * utils.degradation_op(S_j, shift_ker, self.D)
                           for nf, shift_ker in
                           zip(self.normfacs, utils.reg_format(self.ker))]
                          for S_j in utils.reg_format(self.S)])
     if update_spectral_radius:
         PowerMethod.get_spec_rad(self)
Exemple #10
0
 def update_S(self, new_S, update_spectral_radius=True):
     """ Update current eigenPSFs."""
     self.S = new_S
     # Apply degradation operator to components
     normfacs = self.flux / (np.median(self.flux) * self.sig)
     self.FdS = np.array([[
         nf * degradation_op(S_j, shift_ker, self.D)
         for nf, shift_ker in zip(normfacs, utils.reg_format(self.ker))
     ] for S_j in utils.reg_format(self.S)])
     if update_spectral_radius:
         PowerMethod.get_spec_rad(self)
Exemple #11
0
    def __init__(self, data, psf, psf_type='fixed', convolve_method='astropy'):

        self.obs_data = data
        self.op = self._H_op_method
        self.trans_op = self._Ht_op_method
        check_float(psf)
        check_npndarray(psf, writeable=False)
        self._psf = psf
        self._psf_type = psf_type
        self._convolve_method = convolve_method

        PowerMethod.__init__(self, self.trans_op_op, self.obs_data.shape)
Exemple #12
0
    def __init__(self, data, fourier_op, S):
        """ Initilize the 'GradSynthesis2' class.
        """

        self.fourier_op = fourier_op
        self.S = S
        GradBasic.__init__(self, data, self._analy_op_method,
                           self._analy_rsns_op_method)
        PowerMethod.__init__(self,
                             self.trans_op_op,
                             self.fourier_op.shape,
                             data_type="complex128",
                             auto_run=False)
        self.get_spec_rad(extra_factor=1.1)
Exemple #13
0
    def __init__(self, data, fourier_op, linear_op, S):
        """ Initilize the 'GradSynthesis2' class.
        """

        self.fourier_op = fourier_op
        self.linear_op = linear_op
        self.S = S
        GradBasic.__init__(self, data, self._synth_op_method,
                           self._synth_trans_op_method)
        coef = linear_op.op(np.zeros(fourier_op.shape).astype(np.complex))
        self.linear_op_coeffs_shape = coef.shape
        PowerMethod.__init__(self,
                             self.trans_op_op,
                             coef.shape,
                             data_type="complex128",
                             auto_run=False)
        self.get_spec_rad(extra_factor=1.1)
Exemple #14
0
    def __init__(self, data, supp, neighbors_graph, weights_neighbors, spectrums, \
                A, flux, sig, ker, ker_rot, D, data_type=float):
        self._grad_data_type = data_type
        self.obs_data = data
        self.op = self.MX
        self.trans_op = self.MtX
        shap = data.shape
        self.shape = (shap[0] * D, shap[1] * D)
        self.D = D
        self.supp = supp
        self.neighbors_graph = neighbors_graph
        self.weights_neighbors = weights_neighbors
        self.spectrums = spectrums
        self.A = np.copy(A)
        self.flux = flux
        self.sig = sig
        self.ker = ker
        self.ker_rot = ker_rot
        PowerMethod.__init__(
            self, self.trans_op_op,
            (np.prod(self.shape), np.prod(self.shape), A.shape[0]))
        print " > SPECTRAL RADIUS:\t{}".format(self.spec_rad)

        self._current_rec = None  # stores latest application of self.MX
Exemple #15
0
 def set_flux(self, flux_new, pwr_en=False):
     self.flux = np.copy(flux_new)
     if pwr_en:
         PowerMethod.__init__(
             self, self.trans_op_op,
             (np.prod(self.shape), np.prod(self.shape), self.A.shape[0]))
Exemple #16
0
 def set_A(self, A_new, pwr_en=True):
     self.A = np.copy(A_new)
     if pwr_en:
         PowerMethod.__init__(
             self, self.trans_op_op,
             (np.prod(self.shape), np.prod(self.shape), self.A.shape[0]))
Exemple #17
0
 def set_flux(self, flux_new, pwr_en=False):
     self.flux = np.copy(flux_new)
     if pwr_en:
         PowerMethod.__init__(self, self.trans_op_op,
                              (self.P.shape[-1], self.basis.shape[0]))
Exemple #18
0
 def set_P(self, P_new, pwr_en=True):
     self.P = np.copy(P_new)
     if pwr_en:
         PowerMethod.__init__(self, self.trans_op_op,
                              (self.P.shape[-1], self.basis.shape[0]))
Exemple #19
0
 def update_A(self, new_A, update_spectral_radius=True):
     r"""Update current coefficients."""
     self.A = new_A
     if update_spectral_radius:
         PowerMethod.get_spec_rad(self)