コード例 #1
0
ファイル: ssa_siple.py プロジェクト: juliusgarbe/pism_pik
    def initialize(self, x, y, target_misfit):
        """
        Hook called at the start of :meth:`solve`.  This gives the class a chance to massage the input.

        The remaining arguments are passed directly from solve, and can be used for determining the
        final stopping criterion.

        Returns vectors corresponding to the initial value of `x` and the desired value of `y` where :math:`y=F(x)`.
        """
        xv = PISMLocalVector(x)
        yv = PISMLocalVector(y)

        return (xv, yv, target_misfit)
コード例 #2
0
    def solveForward(self, zeta, out=None):
        r"""Given a parameterized design variable value :math:`\zeta`, solve the SSA.
        See :cpp:class:`IP_TaucParam` for a discussion of parameterizations.

        :param zeta: :cpp:class:`IceModelVec` containing :math:`\zeta`.
        :param out: optional :cpp:class:`IceModelVec` for storage of the computation result.
        :returns: An :cpp:class:`IceModelVec` contianing the computation result.
        """
        if out is None:
            out = self.forward_problem.F(PISMLocalVector(zeta))
        else:
            out = self.forward_problem.F(PISMLocalVector(zeta), out=PISMLocalVector(out))
        return out.core()
コード例 #3
0
    def rangeVector(self):
        """Constructs a brand new vector from the range (i.e. state) vector space"""
        v = PISM.IceModelVec2V()
        v.create(self.grid, "", True, WIDE_STENCIL)

        # Add appropriate meta data.
        intent = "?inverse?"  # FIXME
        desc = "SSA velocity computed by inversion"
        v.set_attrs(intent, "%s%s" % ("X-component of the ", desc), "m s-1",
                    "m year-1", "", 0)
        v.set_attrs(intent, "%s%s" % ("Y-component of the ", desc), "m s-1",
                    "m year-1", "", 1)

        huge_vel = convert(1e6, "m/year", "m/second")
        attrs = [("valid_min", -huge_vel), ("valid_max", huge_vel),
                 ("_FillValue", 2 * huge_vel)]
        for a in attrs:
            for component in range(2):
                v.metadata(component).set_number(a[0], a[1])

        return PISMLocalVector(v)
コード例 #4
0
    def rangeVector(self):
        """Constructs a brand new vector from the range (i.e. state) vector space"""
        v = PISM.IceModelVec2V()
        v.create(self.grid, "", True, WIDE_STENCIL)

        # Add appropriate meta data.
        intent = "?inverse?"  # FIXME
        desc = "SSA velocity computed by inversion"
        v.set_attrs(intent, "%s%s" % ("X-component of the ", desc), "m s-1", "", 0)
        v.set_attrs(intent, "%s%s" % ("Y-component of the ", desc), "m s-1", "", 1)
        v.metadata(0).set_string("glaciological_units", "m year-1")
        v.metadata(1).set_string("glaciological_units", "m year-1")
        v.write_in_glaciological_units = True
        sys = self.grid.ctx().unit_system()
        huge_vel = PISM.convert(sys, 1e6, "m/year", "m/second")
        attrs = [("valid_min", -huge_vel), ("valid_max", huge_vel), ("_FillValue", 2 * huge_vel)]
        for a in attrs:
            for component in range(2):
                v.metadata(component).set_double(a[0], a[1])

        return PISMLocalVector(v)
コード例 #5
0
ファイル: ssa_siple.py プロジェクト: juliusgarbe/pism_pik
 def domainVector(self):
     """Constructs a brand new vector from the domain (i.e. design) vector space"""
     v = PISM.IceModelVec2S()
     v.create(self.grid, "", True, WIDE_STENCIL)
     return PISMLocalVector(v)