本文整理汇总了Python中PISM.optionsString方法的典型用法代码示例。如果您正苦于以下问题:Python PISM.optionsString方法的具体用法?Python PISM.optionsString怎么用?Python PISM.optionsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PISM
的用法示例。
在下文中一共展示了PISM.optionsString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: options_test
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [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)
示例2: abs
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [as 别名]
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)
p.periodicity = PISM.NOT_PERIODIC
grid = PISM.IceGrid(context.ctx, p)
示例3: vel_bc
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [as 别名]
vel_bc(i,j).v = v;
for v in vars:
v.beginGhostComm(); v.endGhostComm()
def exactSolution(self,i,j,x,y):
earth_grav = self.config.get("standard_gravity");
f = self.ice.rho * earth_grav * H0* dhdx;
ynd = y/L
u = 0.5*(f**3)*(L**4)/((B0*H0)**3)*(1-ynd**4);
return [u,0]
# The main code for a run follows:
if __name__ == '__main__':
context = PISM.Context()
PISM.set_abort_on_sigint(True)
for o in PISM.OptionsGroup(context.com,"","Test J"):
Mx = PISM.optionsInt("-Mx","Number of grid points in x-direction",default=61)
My = PISM.optionsInt("-My","Number of grid points in y-direction",default=61)
output_file = PISM.optionsString("-o","output file",default="test_plug.nc")
verbosity = PISM.optionsInt("-verbose","verbosity level",default=3)
PISM.setVerbosityLevel(verbosity)
tc = test_plug(Mx,My)
tc.solve()
tc.report()
tc.write(output_file)
示例4: run
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [as 别名]
def run():
context = PISM.Context()
config = context.config
com = context.com
PISM.set_abort_on_sigint(True)
WIDE_STENCIL = int(config.get_double("grid_max_stencil_width"))
usage = \
""" pismi.py [-i IN.nc [-o OUT.nc]]/[-a INOUT.nc] [-inv_data inv_data.nc] [-inv_forward model]
[-inv_design design_var] [-inv_method meth]
where:
-i IN.nc is input file in NetCDF format: contains PISM-written model state
-o OUT.nc is output file in NetCDF format to be overwritten
-a INOUT.nc is input/output file in NetCDF format to be appended to
-inv_data inv_data.nc is data file containing extra inversion data (e.g. observed surface velocities)
-inv_forward model forward model: only 'ssa' supported
-inv_design design_var design variable name; one of 'tauc'/'hardav' for SSA inversions
-inv_method meth algorithm for inversion [sd,nlcg,ign,tikhonov_lmvm]
notes:
* only one of -i/-a is allowed; both specify the input file
* only one of -o/-a is allowed; both specify the output file
* if -o is used, only the variables involved in inversion are written to the output file.
* if -a is used, the varaibles involved in inversion are appended to the given file. No
original variables in the file are changed.
"""
append_mode = False
PISM.setVerbosityLevel(1)
input_filename = PISM.optionsString("-i", "input file")
append_filename = PISM.optionsString("-a", "append file", default=None)
output_filename = PISM.optionsString("-o", "output file", default=None)
if (input_filename is None) and (append_filename is None):
PISM.verbPrintf(1, com, "\nError: No input file specified. Use one of -i [file.nc] or -a [file.nc].\n")
sys.exit(0)
if (input_filename is not None) and (append_filename is not None):
PISM.verbPrintf(1, com, "\nError: Only one of -i/-a is allowed.\n")
sys.exit(0)
if (output_filename is not None) and (append_filename is not None):
PISM.verbPrintf(1, com, "\nError: Only one of -a/-o is allowed.\n")
sys.edit(0)
if append_filename is not None:
input_filename = append_filename
output_filename = append_filename
append_mode = True
inv_data_filename = PISM.optionsString("-inv_data", "inverse data file", default=input_filename)
verbosity = PISM.optionsInt("-verbose", "verbosity level", default=2)
do_plotting = PISM.optionsFlag("-inv_plot", "perform visualization during the computation", default=False)
do_final_plot = PISM.optionsFlag("-inv_final_plot", "perform visualization at the end of the computation", default=False)
Vmax = PISM.optionsReal("-inv_plot_vmax", "maximum velocity for plotting residuals", default=30)
design_var = PISM.optionsList("-inv_ssa",
"design variable for inversion",
"tauc,hardav", "tauc")
do_pause = PISM.optionsFlag("-inv_pause", "pause each iteration", default=False)
do_restart = PISM.optionsFlag("-inv_restart", "Restart a stopped computation.", default=False)
use_design_prior = PISM.optionsFlag("-inv_use_design_prior", "Use prior from inverse data file as initial guess.", default=True)
prep_module = PISM.optionsString("-inv_prep_module", "Python module used to do final setup of inverse solver", default=None)
is_regional = PISM.optionsFlag("-regional", "Compute SIA/SSA using regional model semantics", default=False)
using_zeta_fixed_mask = PISM.optionsFlag("-inv_use_zeta_fixed_mask",
"Enforce locations where the parameterized design variable should be fixed. (Automatically determined if not provided)", default=True)
inv_method = config.get_string("inv_ssa_method")
if output_filename is None:
output_filename = "pismi_" + os.path.basename(input_filename)
saving_inv_data = (inv_data_filename != output_filename)
PISM.setVerbosityLevel(verbosity)
forward_run = SSAForwardRun(input_filename, inv_data_filename, design_var)
forward_run.setup()
design_param = forward_run.designVariableParameterization()
solver = PISM.invert.ssa.createInvSSASolver(forward_run)
modeldata = forward_run.modeldata
vecs = modeldata.vecs
grid = modeldata.grid
# Determine the prior guess for tauc/hardav. This can be one of
# a) tauc/hardav from the input file (default)
# b) tauc/hardav_prior from the inv_datafile if -inv_use_design_prior is set
design_prior = createDesignVec(grid, design_var, '%s_prior' % design_var)
long_name = design_prior.metadata().get_string("long_name")
units = design_prior.metadata().get_string("units")
design_prior.set_attrs("", "best prior estimate for %s (used for inversion)" % long_name, units, "")
if PISM.util.fileHasVariable(inv_data_filename, "%s_prior" % design_var) and use_design_prior:
PISM.logging.logMessage(" Reading '%s_prior' from inverse data file %s.\n" % (design_var, inv_data_filename))
#.........这里部分代码省略.........
示例5: view
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [as 别名]
view(d_TStarR, d_TStarR_viewer)
PISM.logging.pause()
# Main code starts here
if __name__ == "__main__":
context = PISM.Context()
config = context.config
com = context.com
PISM.set_abort_on_sigint(True)
append_mode = False
PISM.setVerbosityLevel(1)
input_filename = PISM.optionsString("-i", "input file")
inv_data_filename = PISM.optionsString("-inv_data", "inverse data file", default=input_filename)
verbosity = PISM.optionsInt("-verbose", "verbosity level", default=2)
use_design_prior = PISM.optionsFlag("-inv_use_design_prior", "Use prior from inverse data file as initial guess.", default=True)
design_var = PISM.optionsList("-inv_ssa", "design variable for inversion", ["tauc", "hardav"], "tauc")
using_zeta_fixed_mask = PISM.optionsFlag("-inv_use_zeta_fixed_mask",
"Enforce locations where the parameterized design variable should be fixed. (Automatically determined if not provided)", default=True)
ssarun = PISM.invert.ssa.SSAForwardRunFromInputFile(input_filename, inv_data_filename, design_var)
ssarun.setup()
vecs = ssarun.modeldata.vecs
grid = ssarun.grid
# Determine the prior guess for tauc/hardav. This can be one of
# a) tauc/hardav from the input file (default)
示例6:
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [as 别名]
sia_forward.py -i IN.nc [-o file.nc]
where:
-i IN.nc is input file in NetCDF format: contains PISM-written model state
notes:
* -i is required
"""
PISM.verbosityLevelFromOptions()
PISM.show_usage_check_req_opts(context.com, "sia_forward.py", ["-i"], usage)
input_file, input_set = PISM.optionsStringWasSet("-i", "input file")
if not input_set:
import sys
sys.exit(1)
output_file = PISM.optionsString("-o", "output file",
default="sia_" + os.path.basename(input_file))
is_regional = PISM.optionsFlag("-regional",
"Compute SIA using regional model semantics", default=False)
verbosity = PISM.optionsInt("-verbose", "verbosity level", default=2)
periodicity = PISM.XY_PERIODIC
if is_regional:
periodicity = PISM.NOT_PERIODIC
grid = PISM.IceGrid.FromFile(context.ctx, input_file, "enthalpy", periodicity)
config.set_boolean("do_pseudo_plastic_till", False)
enthalpyconverter = PISM.EnthalpyConverter(config)
modeldata = PISM.model.ModelData(grid)
modeldata.setPhysics(enthalpyconverter)
示例7: exactSolution
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [as 别名]
vel_bc[i, j].u = V0
vel_bc[i, j].v = 0.
else:
bc_mask[i, j] = 0
vel_bc[i, j].u = 0.
vel_bc[i, j].v = 0.
def exactSolution(self, i, j, x, y):
if x <= 0:
u = u_exact(x + self.grid.Lx())
else:
u = 0
return [u, 0]
if __name__ == '__main__':
# if PISM.optionsSet('-usage') or PISM.optionsSet('-help'):
# PISM.verbPrintf(1,context.com,help)
# PISM.verbPrintf(1,context.com,usage)
Mx = PISM.optionsInt("-Mx", "Number of grid points in x-direction", default=61)
My = PISM.optionsInt("-My", "Number of grid points in y-direction", default=61)
output_file = PISM.optionsString("-o", "output file", default="ssa_test_cfbc.nc")
verbosity = PISM.optionsInt("-verbose", "verbosity level", default=3)
PISM.setVerbosityLevel(verbosity)
context.config.set_string('ssa_method', 'fd')
tc = test_cfbc(Mx, My)
tc.run(output_file)
示例8: pow
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [as 别名]
context = PISM.Context()
config = context.config
PISM.set_abort_on_sigint(True)
usage = \
""" %s -i IN.nc [-o file.nc]
where:
-i IN.nc is input file in NetCDF format: contains PISM-written model state
notes:
* -i is required
""" % (sys.argv[0])
PISM.show_usage_check_req_opts(context.com, sys.argv[0], ["-i"], usage)
bootfile = PISM.optionsString("-i", "input file")
output_file = PISM.optionsString("-o", "output file", default="tauc2tillphi_" + os.path.basename(bootfile))
verbosity = PISM.optionsInt("-verbose", "verbosity level", default=2)
PISM.set_config_from_options(context.com, config)
grid = PISM.IceGrid.FromFile(context.ctx, bootfile, ["enthalpy", "temp"], PISM.XY_PERIODIC)
enthalpyconverter = PISM.EnthalpyConverter(config)
if PISM.getVerbosityLevel() > 3:
enthalpyconverter.viewConstants(PETSc.Viewer.STDOUT())
if PISM.OptionBool("-ssa_glen", "SSA flow law Glen exponent"):
B_schoof = 3.7e8 # Pa s^{1/3}; hardness
config.set_string("ssa_flow_law", "isothermal_glen")
config.set_double("ice_softness", pow(B_schoof, -config.get_double("Glen_exponent")))
示例9: add
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [as 别名]
run %s -i IN.nc -Mx number -My number [-o file.nc]
where:
-i IN.nc is input file in NetCDF format: contains PISM-written model state
-Mx number of grid points in the x direction
-My number of grid points in the y direction
notes:
* -i is required
""" % (sys.argv[0], sys.argv[0])
PISM.show_usage_check_req_opts(com, sys.argv[0], ["-i"], usage)
config = context.config
if not PISM.OptionString("-ssa_method", "").is_set():
config.set_string("ssa_method", "fem")
input_file_name = PISM.optionsString("-i",
"file to bootstrap from")
output_file_name = PISM.optionsString("-o",
"output file",
default="make_synth_ssa.nc")
design_prior_scale = PISM.optionsReal("-design_prior_scale",
"initial guess for design variable to be this factor of the true value",
default=design_prior_scale)
design_prior_const = PISM.optionsReal("-design_prior_const",
"initial guess for design variable to be this constant",
default=design_prior_const)
noise = PISM.optionsReal("-rms_noise",
"pointwise rms noise to add (in m/a)",
示例10: or
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [as 别名]
usage = \
""" ssa_forward.py -i IN.nc -Mx number -My number [-o file.nc]
or (at python prompt)
run ssa_forward -i IN.nc -Mx number -My number [-o file.nc]
where:
-i IN.nc is input file in NetCDF format: contains PISM-written model state
-Mx number of grid points in the x direction
-My number of grid points in the y direction
notes:
* -i is required
"""
PISM.show_usage_check_req_opts(com,"ssa_forward",["-i"],usage)
config = context.config()
for o in PISM.OptionsGroup(com,"","SSA Forward"):
Mx = PISM.optionsInt("-Mx","Number of grid points in the X-direction",default=None)
My = PISM.optionsInt("-My","Number of grid points in the Y-direction",default=None)
boot_file = PISM.optionsString("-i","file to bootstrap from")
output_file = PISM.optionsString("-o","output file",default="ssa_forward.nc")
test_case = ssa_from_boot_file(Mx,My,boot_file)
solve_t0 = time.clock()
test_case.solve()
solve_t = time.clock()-solve_t0
PISM.verbPrintf(2,context.com,"Solve time %g seconds.\n",solve_t)
test_case.write(output_file)
示例11: or
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [as 别名]
or (at python prompt)
run ssa_forward -i IN.nc -Mx number -My number [-o file.nc]
where:
-i IN.nc is input file in NetCDF format: contains PISM-written model state
-Mx number of grid points in the x direction
-My number of grid points in the y direction
notes:
* -i is required
"""
PISM.show_usage_check_req_opts(com, "ssa_forward", ["-i"], usage)
input_file, input_file_set = PISM.optionsStringWasSet("-i", "input file with PISM model data")
if not input_file_set:
import sys
sys.exit(1)
output_file = PISM.optionsString("-o", "output file", default="ssa_forward.nc")
ssa_run = PISM.ssa.SSAFromInputFile(input_file)
ssa_run.setup()
solve_t0 = time.clock()
vel_ssa = ssa_run.solve()
solve_t = time.clock() - solve_t0
PISM.verbPrintf(2, context.com, "Solve time %g seconds.\n", solve_t)
ssa_run.write(output_file)
示例12: pross
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import optionsString [as 别名]
where:
-boot_file IN.nc is input file in NetCDF format:
contains PISM-written model state
-Mx number of grid points in the x direction
-My number of grid points in the y direction
-riggs read RIGGS data from a file
notes:
* -boot_file is required
"""
PISM.show_usage_check_req_opts(com,"pross",["-boot_file"],usage)
config = context.config()
config.set_flag("use_ssa_velocity", True)
config.set_flag("use_ssa_when_grounded", False)
config.set_flag("use_constant_nuh_for_ssa", False)
config.set("epsilon_ssafd", 0.0)
for o in PISM.OptionsGroup(com,"","PROSS"):
Mx = PISM.optionsInt("-Mx","Number of grid points in the X-direction",default=None)
My = PISM.optionsInt("-My","Number of grid points in the X-direction",default=None)
boot_file = PISM.optionsString("-boot_file","file to bootstrap from")
riggs_file = PISM.optionsString("-riggs","file with riggs measurements")
output_file = PISM.optionsString("-o","output file",default="ross_computed.nc")
test_case = pross(Mx,My,boot_file,riggs_file)
test_case.solve()
test_case.report()
test_case.write(output_file)