Exemplo n.º 1
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')
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
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)