本文整理汇总了Python中PISM.setVerbosityLevel方法的典型用法代码示例。如果您正苦于以下问题:Python PISM.setVerbosityLevel方法的具体用法?Python PISM.setVerbosityLevel怎么用?Python PISM.setVerbosityLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PISM
的用法示例。
在下文中一共展示了PISM.setVerbosityLevel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: logging_test
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import setVerbosityLevel [as 别名]
def logging_test():
"Test the PISM.logging module"
grid = create_dummy_grid()
pio = PISM.PIO(grid.com, "netcdf3")
import PISM.logging as L
pio.open("log.nc", PISM.PISM_READWRITE_MOVE)
pio.close()
c = L.CaptureLogger("log.nc")
L.clear_loggers()
L.add_logger(L.print_logger)
L.add_logger(c)
PISM.setVerbosityLevel(2)
L.log("log message\n", L.kError)
L.logError("error message\n")
L.logWarning("warning message\n")
L.logMessage("log message (again)\n")
L.logDebug("debug message\n")
L.logPrattle("prattle message\n")
c.write() # default arguments
c.readOldLog()
pio.open("other_log.nc", PISM.PISM_READWRITE_MOVE)
pio.close()
c.write("other_log.nc", "other_log") # non-default arguments
示例2: vel_bc
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import setVerbosityLevel [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)
示例3: run
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import setVerbosityLevel [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))
#.........这里部分代码省略.........
示例4: view
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import setVerbosityLevel [as 别名]
view(TStarR, TStarR_viewer)
view(TStarR_indirect, TStarR_indirect_viewer)
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