Exemplo n.º 1
0
    def solveInverse(self, zeta0, u_obs, zeta_inv):
        r"""Executes the inversion algorithm.

        :param zeta0: The best `a-priori` guess for the value of the parameterized design variable value :math:`\zeta`.
                      Ignored by siple gradient algorithms in deference to `zeta_inv`.
        :param u_obs: :cpp:class:`IceModelVec2V` of observed surface velocities.
        :param zeta_inv: :cpp:class:`zeta_inv` starting value of :math:`\zeta` for iterative minimization.
        :returns: A :cpp:class:`TerminationReason`.
        """
        try:
            vecs = self.ssarun.modeldata.vecs
            if vecs.has('zeta_fixed_mask'):
                self.ssarun.ssa.set_tauc_fixed_locations(vecs.zeta_fixed_mask)

            (self.zeta_i,
             self.u_i) = self.siple_solver.solve(zeta_inv, u_obs,
                                                 self.target_misfit)
        except Exception:
            import traceback
            exc_type, exc_value, exc_traceback = sys.exc_info()
            description = ""
            for l in traceback.format_exception(exc_type, exc_value,
                                                exc_traceback):
                description += l
            # It would be nice to make siple so that if the inverse solve fails
            # you can still keep the most recent iteration.
            self.u_i = None
            self.zeta_i = None
            return PISM.GenericTerminationReason(-1, description)
        return PISM.GenericTerminationReason(1, "Morozov Discrepancy Met")