当前位置: 首页>>代码示例>>Python>>正文


Python PISM.optionsInt方法代码示例

本文整理汇总了Python中PISM.optionsInt方法的典型用法代码示例。如果您正苦于以下问题:Python PISM.optionsInt方法的具体用法?Python PISM.optionsInt怎么用?Python PISM.optionsInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PISM的用法示例。


在下文中一共展示了PISM.optionsInt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: options_test

# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsInt [as 别名]
def options_test():
    "Test command-line option handling"
    ctx = PISM.Context()

    o = PISM.PETSc.Options()

    M = PISM.optionsInt("-M", "description", default=100)
    M = PISM.optionsInt("-M", "description", default=None)

    S = PISM.optionsString("-S", "description", default="string")
    S = PISM.optionsString("-S", "description", default=None)

    R = PISM.optionsReal("-R", "description", default=1.5)
    R = PISM.optionsReal("-R", "description", default=None)

    o.setValue("-B", "on")
    B = PISM.optionsFlag("-B", "description", default=False)
    B = PISM.optionsFlag("B", "description", default=False)
    B = PISM.optionsFlag("-B", "description", default=None)

    o.setValue("-no_C", "on")
    C = PISM.optionsFlag("C", "description", default=None)

    D = PISM.optionsFlag("D", "description", default=None)
    D = PISM.optionsFlag("D", "description", default=True)

    o.setValue("-no_D", "on")
    o.setValue("-D", "on")
    try:
        # should throw RuntimeError
        D = PISM.optionsFlag("D", "description", default=None)
        return False
    except RuntimeError:
        pass

    o.setValue("-IA", "1,2,3")
    IA = PISM.optionsIntArray("-IA", "description", default=[1, 2])
    IA = PISM.optionsIntArray("-IA", "description", default=None)
    IA2 = PISM.optionsIntArray("-IA2", "description", default=None)
    IA2 = PISM.optionsIntArray("-IA2", "description", default=[1, 2])

    o.setValue("-RA", "1,2,3")
    RA = PISM.optionsRealArray("-RA", "description", default=[2, 3])
    RA = PISM.optionsRealArray("-RA", "description", default=None)
    RA2 = PISM.optionsRealArray("-RA2", "description", default=[2, 3])
    RA2 = PISM.optionsRealArray("-RA2", "description", default=None)

    o.setValue("-SA", "1,2,3")
    SA = PISM.optionsStringArray("-SA", "description", default="one,two")
    SA = PISM.optionsStringArray("-SA", "description", default=None)
    SA2 = PISM.optionsStringArray("-SA2", "description", default="two,three")
    SA2 = PISM.optionsStringArray("-SA2", "description", default=None)

    M = PISM.optionsList("-L", "description", choices="one,two", default="one")
    M = PISM.optionsList("-L", "description", choices="one,two", default=None)
开发者ID:crodehacke,项目名称:PISMcr,代码行数:57,代码来源:nosetests.py

示例2: __init__

# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsInt [as 别名]
    def __init__(self, ssarun, method):
        """
        :param ssarun: The :class:`PISM.ssa.SSARun` defining the forward problem. See :class:`PISM.inv_ssa.SSAForwardRunFromInputFile`.
        :param method: String describing the actual ``siple`` algorithm to use. One of ``sd``, ``nlcg`` or ``ign``."""
        InvSSASolver.__init__(self, ssarun, method)

        self.target_misfit = PISM.optionsReal("-inv_target_misfit", "m/year; desired root misfit for inversions", default=None)

        monitor_adjoint = PISM.optionsFlag("-inv_monitor_adjoint", "Track accuracy of the adjoint during computation", default=False)
        morozov_scale_factor = PISM.optionsFlag("-inv_morozov_scale", "Scale factor (>=1) for Morozov discrepancy principle", default=1.0)
        ls_verbose = PISM.optionsFlag("-inv_ls_verbose", "Turn on a verbose linesearch.", default=False)
        ign_theta = PISM.optionsReal("-ign_theta", "theta parameter for IGN algorithm", default=0.5)
        max_it = PISM.optionsInt("-inv_max_it", "maximum iteration count", default=1000)

        if self.target_misfit is None:
            raise RuntimeError("Missing required option -inv_target_misfit")

        velocity_scale = ssarun.grid.ctx().config().get_double("inv_ssa_velocity_scale", "m/year")
        self.target_misfit /= velocity_scale

        self.forward_problem = SSAForwardProblem(ssarun)

        # Determine the inversion algorithm, and set up its arguments.
        if self.method == "ign":
            Solver = InvertSSAIGN
        else:
            Solver = InvertSSANLCG

        self.u_i = None
        self.zeta_i = None

        params = Solver.defaultParameters()
        params.ITER_MAX = max_it
        if self.method == "sd":
            params.steepest_descent = True
            params.ITER_MAX = 10000
        elif self.method == "ign":
            params.linearsolver.ITER_MAX = 10000
            params.linearsolver.verbose = True
        if ls_verbose:
            params.linesearch.verbose = True
        params.verbose = True
        params.thetaMax = ign_theta
        params.mu = morozov_scale_factor

        params.deriv_eps = 0.

        self.siple_solver = Solver(self.forward_problem, params=params)

        if monitor_adjoint:
            self.addIterationListener(MonitorAdjoint())
            if self.method == 'ign':
                self.addLinearIterationListener(MonitorAdjointLin())
开发者ID:crodehacke,项目名称:PISMcr,代码行数:55,代码来源:ssa_siple.py

示例3: stream_tauc

# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsInt [as 别名]
def stream_tauc(x, y):
    x0 = -Lx + Lext
    if x < x0:
        return tauc_free_bedrock
    if x < x0 + Lstream_x:
        if abs(y) < Lstream_y / 2:
            return tauc_lo
    return tauc_hi


# The main code for a run follows:
if __name__ == '__main__':
    PISM.set_abort_on_sigint(True)
    context = PISM.Context()

    Mx = PISM.optionsInt("-Mx", "Number of grid points in x-direction", default=Mx)
    My = PISM.optionsInt("-My", "Number of grid points in y-direction", default=My)
    output_filename = PISM.optionsString("-o", "output file", default="tiny.nc")
    verbosity = PISM.optionsInt("-verbose", "verbosity level", default=3)

    # Build the grid.
    config = PISM.Context().config

    p = PISM.GridParameters(config)
    p.Mx = Mx
    p.My = My
    p.Lx = Lx
    p.Ly = Ly
    z = PISM.IceGrid.compute_vertical_levels(Lz, Mz, PISM.EQUAL, 4.0)
    p.z = PISM.DoubleVector(z)
    p.ownership_ranges_from_options(context.size)
开发者ID:crodehacke,项目名称:PISMcr,代码行数:33,代码来源:build_tiny.py


注:本文中的PISM.optionsInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。