本文整理汇总了Python中PISM.define_time方法的典型用法代码示例。如果您正苦于以下问题:Python PISM.define_time方法的具体用法?Python PISM.define_time怎么用?Python PISM.define_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PISM
的用法示例。
在下文中一共展示了PISM.define_time方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import define_time [as 别名]
def write(self, filename):
"""Saves all of :attr:`modeldata`'s vecs (and the solution) to an
output file."""
grid = self.grid
vecs = self.modeldata.vecs
pio = PISM.PIO(grid.com, "netcdf3")
pio.open(filename, PISM.PISM_READWRITE_MOVE)
PISM.define_time(pio, grid.ctx().config().get_string("time_dimension_name"),
grid.ctx().config().get_string("calendar"),
grid.ctx().time().units_string(),
grid.ctx().unit_system())
PISM.append_time(pio, grid.ctx().config().get_string("time_dimension_name"), 0.0)
pio.close()
# Save time & command line
PISM.util.writeProvenance(filename)
vecs.writeall(filename)
vel_ssa = self.ssa.velocity()
vel_ssa.write(filename)
sys = self.grid.ctx().unit_system()
velbar_mag = model.createCBarVec(self.grid)
velbar_mag.set_to_magnitude(vel_ssa)
velbar_mag.mask_by(vecs.thk, PISM.convert(sys, -0.01, "m/year", "m/second"))
velbar_mag.write(filename)
示例2: prepare_output
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import define_time [as 别名]
def prepare_output(filename, append_time=True):
"Create an output file and prepare it for writing."
ctx = PISM.Context()
output = PISM.PIO(ctx.com, ctx.config.get_string("output.format"),
filename, PISM.PISM_READWRITE_MOVE)
PISM.define_time(output,
ctx.config.get_string("time.dimension_name"),
ctx.config.get_string("time.calendar"),
ctx.time.units_string(),
ctx.unit_system)
if append_time:
PISM.append_time(output,
ctx.config.get_string("time.dimension_name"),
ctx.time.current())
return output
示例3: grid_from_file_test
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import define_time [as 别名]
def grid_from_file_test():
"Intiialize a grid from a file"
grid = create_dummy_grid()
enthalpy = PISM.model.createEnthalpyVec(grid)
enthalpy.set(80e3)
output_file = "test_grid_from_file.nc"
pio = PISM.PIO(grid.com, "netcdf3")
pio.open(output_file, PISM.PISM_READWRITE_MOVE)
PISM.define_time(pio, grid.ctx().config().get_string("time_dimension_name"),
grid.ctx().config().get_string("calendar"),
grid.ctx().time().units_string(),
grid.ctx().unit_system())
PISM.append_time(pio,
grid.ctx().config().get_string("time_dimension_name"),
grid.ctx().time().current())
pio.close()
enthalpy.write(output_file)
grid2 = PISM.IceGrid.FromFile(grid.ctx(), output_file, "enthalpy", PISM.NOT_PERIODIC)
示例4: stream_tauc
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import define_time [as 别名]
gc.compute(bed, thickness, vecs.mask, vecs.surface_altitude)
tauc = vecs.tauc
mask = vecs.mask
tauc_free_bedrock = config.get_double('high_tauc')
with PISM.vec.Access(comm=tauc, nocomm=mask):
for (i, j) in grid.points():
tauc[i, j] = stream_tauc(grid.x(i), grid.y(j))
vecs.vel_ssa_bc.set(0.0)
no_model_mask = vecs.no_model_mask
no_model_mask.set(0)
with PISM.vec.Access(comm=[no_model_mask]):
for (i, j) in grid.points():
if (i == 0) or (i == grid.Mx() - 1) or (j == 0) or (j == grid.My() - 1):
no_model_mask[i, j] = 1
pio = PISM.PIO(grid.com, "netcdf3")
pio.open(output_filename, PISM.PISM_READWRITE_MOVE)
PISM.define_time(pio,
grid.ctx().config().get_string("time_dimension_name"),
"365_day",
"seconds since 1-1-1",
grid.ctx().unit_system())
PISM.append_time(pio,
grid.ctx().config().get_string("time_dimension_name"),
0.0)
pio.close()
vecs.writeall(output_filename)
PISM.util.writeProvenance(output_filename)
示例5: run
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import define_time [as 别名]
#.........这里部分代码省略.........
if is_regional:
sia_solver = PISM.SIAFD_Regional
vel_sia_observed = PISM.sia.computeSIASurfaceVelocities(modeldata, sia_solver)
vel_sia_observed.metadata(0).set_name('u_sia_observed')
vel_sia_observed.metadata(0).set_string('long_name', "x-component of the 'observed' SIA velocities")
vel_sia_observed.metadata(1).set_name('v_sia_observed')
vel_sia_observed.metadata(1).set_string('long_name', "y-component of the 'observed' SIA velocities")
vel_ssa_observed.copy_from(vel_surface_observed)
vel_ssa_observed.add(-1, vel_sia_observed)
vecs.add(vel_ssa_observed, writing=True)
# If the inverse data file has a variable tauc/hardav_true, this is probably
# a synthetic inversion. We'll load it now so that it will get written
# out, if needed, at the end of the computation in the output file.
if PISM.util.fileHasVariable(inv_data_filename, "%s_true" % design_var):
design_true = createDesignVec(grid, design_var, '%s_true' % design_var)
design_true.regrid(inv_data_filename, True)
design_true.read_attributes(inv_data_filename)
vecs.add(design_true, writing=saving_inv_data)
# Establish a logger which will save logging messages to the output file.
message_logger = PISM.logging.CaptureLogger(output_filename, 'pismi_log')
PISM.logging.add_logger(message_logger)
if append_mode or do_restart:
message_logger.readOldLog()
# Prep the output file from the grid so that we can save zeta to it during the runs.
if not append_mode:
pio = PISM.PIO(grid.com, "netcdf3")
pio.open(output_filename, PISM.PISM_READWRITE_MOVE)
PISM.define_time(pio,
grid.ctx().config().get_string("time_dimension_name"),
grid.ctx().config().get_string("calendar"),
grid.ctx().time().units_string(),
grid.ctx().unit_system())
PISM.append_time(pio,
grid.ctx().config().get_string("time_dimension_name"),
grid.ctx().time().current())
pio.close()
zeta.write(output_filename)
# Log the command line to the output file now so that we have a record of
# what was attempted
PISM.util.writeProvenance(output_filename)
# Attach various iteration listeners to the solver as needed for:
# Iteration report.
solver.addIterationListener(PISM.invert.ssa.printIteration)
# Misfit reporting/logging.
misfit_logger = PISM.invert.ssa.MisfitLogger()
solver.addIterationListener(misfit_logger)
if inv_method.startswith('tikhonov'):
solver.addIterationListener(PISM.invert.ssa.printTikhonovProgress)
# Saving the current iteration
solver.addDesignUpdateListener(PISM.invert.ssa.ZetaSaver(output_filename))
# Plotting
if do_plotting:
solver.addIterationListener(InvSSAPlotListener(grid, Vmax))
示例6:
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import define_time [as 别名]
vecs.no_model_mask.regrid(input_file, critical=True)
if PISM.util.fileHasVariable(input_file, 'usurfstore'):
vecs.add(PISM.model.createIceSurfaceStoreVec(grid))
vecs.usurfstore.regrid(input_file, critical=True)
else:
vecs.add(vecs.surface, 'usurfstore')
solver = PISM.SIAFD_Regional
else:
solver = PISM.SIAFD
PISM.verbPrintf(2, context.com, "* Computing SIA velocities...\n")
vel_sia = PISM.sia.computeSIASurfaceVelocities(modeldata, siasolver=solver)
PISM.verbPrintf(2, context.com, "* Saving results to %s...\n" % output_file)
pio = PISM.PIO(grid.com, "netcdf3")
pio.open(output_file, PISM.PISM_READWRITE_MOVE)
PISM.define_time(pio, grid.ctx().config().get_string("time_dimension_name"),
grid.ctx().config().get_string("calendar"),
grid.ctx().time().units_string(),
grid.ctx().unit_system())
PISM.append_time(pio,
grid.ctx().config().get_string("time_dimension_name"),
grid.ctx().time().current())
pio.close()
# Save time & command line & results
PISM.util.writeProvenance(output_file)
vel_sia.write(output_file)
示例7: modelvecs_test
# 需要导入模块: import PISM [as 别名]
# 或者: from PISM import define_time [as 别名]
def modelvecs_test():
"Test the ModelVecs class"
grid = create_dummy_grid()
mask = PISM.model.createIceMaskVec(grid)
mask.set(PISM.MASK_GROUNDED)
modeldata = PISM.model.ModelData(grid)
vecs = modeldata.vecs
vecs.add(mask, "ice_mask", writing=True)
# use the default name, no writing
vecs.add(PISM.model.createIceThicknessVec(grid))
try:
vecs.add(mask, "ice_mask")
return False
except RuntimeError:
# should fail: mask was added already
pass
# get a field:
print "get() method: ice mask: ", vecs.get("ice_mask").metadata().get_string("long_name")
print "dot notation: ice mask: ", vecs.ice_mask.metadata().get_string("long_name")
try:
vecs.invalid
return False
except AttributeError:
# should fail
pass
try:
vecs.get("invalid")
return False
except RuntimeError:
# should fail
pass
# test __repr__
print vecs
# test has()
print "Has thickness?", vecs.has("thickness")
# test markForWriting
vecs.markForWriting("ice_mask")
vecs.markForWriting(mask)
vecs.markForWriting("thk")
# test write()
output_file = "test_ModelVecs.nc"
pio = PISM.PIO(grid.com, "netcdf3")
pio.open(output_file, PISM.PISM_READWRITE_MOVE)
PISM.define_time(pio, grid.ctx().config().get_string("time_dimension_name"),
grid.ctx().config().get_string("calendar"),
grid.ctx().time().units_string(),
grid.ctx().unit_system())
PISM.append_time(pio,
grid.ctx().config().get_string("time_dimension_name"),
grid.ctx().time().current())
pio.close()
vecs.write(output_file)
# test writeall()
vecs.writeall(output_file)