本文整理汇总了Python中setrun.setrun函数的典型用法代码示例。如果您正苦于以下问题:Python setrun函数的具体用法?Python setrun怎么用?Python setrun使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setrun函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tr
def test_tr(grids=[1800,3600,7200],frame=2):
reload(setrun)
errs = []
for i,mx in enumerate(grids):
print i,mx
rundata=setrun.setrun()
rundata.probdata.trtime=600.
rundata.probdata.t1= 10.
rundata.probdata.a1= 0.1
rundata.probdata.tw1=10.
rundata.clawdata.mx=mx
rundata.clawdata.tfinal=1200.
rundata.clawdata.nout=60
rundata.write()
runclaw(xclawcmd='xsclaw',outdir='./_output')
exact,approx,xc = timereverse(frame=frame)
Linf_err = max(abs(approx-exact))
print mx, Linf_err
errs.append(Linf_err)
return grids,errs
示例2: __init__
def __init__(self, fault, name=""):
r"""
Initialize a FaultJob object.
See :class:`FaultJob` for full documentation
"""
super(FaultJob, self).__init__()
self.type = "tsunami"
self.name = "final-tohoku-inversions"
self.prefix = "fault_%s" % name
self.executable = 'xgeoclaw'
# Data objects
import setrun
self.rundata = setrun.setrun()
# No variable friction for the time being
self.rundata.friction_data.variable_friction = False
# Replace dtopo file with our own
self.dtopo_path = 'fault_%s.tt3' % name
self.rundata.dtopo_data.dtopofiles = [[3, 4, 4, self.dtopo_path]]
self.fault = fault
示例3: __init__
def __init__(self, index, values,
source_path='clawpack/geoclaw/examples/tsunami/chile2010'):
r""""""
super(LevelsJob, self).__init__()
self.source_path = os.path.expandvars(source_path)
self.type = "Run_Data"
self.name = "AMR-Levels-%s" % \
os.path.split(os.path.splitext(self.source_path)[0])[-1]
self.prefix = "sweep_%s" % (str(index))
self.executable = 'xgeoclaw'
# Data objects
import setrun
self.rundata = setrun.setrun()
values = [int(i) for i in values]
# Geo Claw Number of Cells Data
self.rundata.clawdata.num_cells = [values[0],values[0]]
# AMR Data max levels and refinement ratios
self.rundata.amrdata.amr_levels_max = values[1]
self.rundata.amrdata.refinement_ratios_x = values[2:]
self.rundata.amrdata.refinement_ratios_y = values[2:]
self.rundata.amrdata.refinement_ratios_t = values[2:]
示例4: __init__
def __init__(self, index, values,
source_path='$SRC/tohoku2011-paper1/sources/Ammon.txydz',
contours=(numpy.infty,0.0,-200.0,-numpy.infty)):
r""""""
super(FrictionJob, self).__init__()
self.source_path = os.path.expandvars(source_path)
self.type = "tohoku"
self.name = "friction-sensitivity-%s" % \
os.path.split(os.path.splitext(self.source_path)[0])[-1]
self.prefix = "fric_%s" % (str(index))
self.executable = 'xgeoclaw'
# Data objects
import setrun
self.rundata = setrun.setrun()
# Set variable friction
self.rundata.friction_data.variable_friction = True
# Region based friction
self.rundata.friction_data.friction_regions = [[
self.rundata.clawdata.lower, self.rundata.clawdata.upper,
contours, values]]
# Set earthquake source model
dtopo_data = self.rundata.dtopo_data
dtopo_data.dtopofiles.append([1, 4, 4, self.source_path])
示例5: runTest
def runTest(self):
# Write out data files
orig_path = os.getcwd()
if sys.modules.has_key('setrun'):
del(sys.modules['setrun'])
sys.path.insert(0, self.test_path)
import setrun
rundata = setrun.setrun()
os.chdir(self.temp_path)
rundata.write()
os.chdir(orig_path)
sys.path.pop(0)
# Run code
runclaw_cmd = " ".join((
"cd %s ;" % self.temp_path,
"python",
"$CLAW/clawutil/src/python/clawutil/runclaw.py",
"xgeoclaw",
self.temp_path,
"True",
"False",
self.temp_path))
subprocess.check_call(runclaw_cmd, stdout=self.stdout,
stderr=self.stderr,
shell=True)
self.stdout.flush()
self.stderr.flush()
示例6: __init__
def __init__(self):
super(TestML1D,self).__init__()
import setrun
self.run_data = setrun.setrun()
self.ml_data = setrun.set_multilayer_data()
self.type = "ml_1d"
示例7: getent
def getent(K,rho):
rundata=setrun.setrun()
rundata.probdata.K_B=K
rundata.probdata.rho_B=rho
print K,rho
rundata.write()
runclaw(outdir='./_output')
ent=entropy(rundata.clawdata.nout)
return ent[-1]
示例8: __init__
def __init__(self, levels=3):
super(SwirlTest, self).__init__()
self.type = "AMRClaw"
self.name = "swirl"
self.setplot = "setplot"
# Data objects
import setrun
self.rundata = setrun.setrun()
self.rundata.amrdata.amr_levels_max = levels
示例9: load_rundata
def load_rundata(self):
r"""(Re)load setrun module and create *rundata* object
"""
if sys.modules.has_key("setrun"):
del (sys.modules["setrun"])
sys.path.insert(0, self.test_path)
import setrun
self.rundata = setrun.setrun()
sys.path.pop(0)
示例10: gauges2kml
def gauges2kml(rundata=None, fname='gauges.kml'):
"""
Read in the gauge locations from setrun.py and create a kml point for each.
"""
if rundata is None:
try:
import setrun
reload(setrun)
rundata = setrun.setrun()
except:
raise IOError("*** cannot execute setrun file")
elev = 0.
kml_text = kml_header()
gauges = rundata.gaugedata.gauges
if len(gauges)==0:
print "No gauges found in setrun.py"
for rnum,gauge in enumerate(gauges):
t1,t2 = gauge[3:5]
x1,y1 = gauge[1:3]
gaugeno = gauge[0]
print "Gauge %i: %10.6f %10.6f \n" % (gaugeno,x1,y1) \
+ " t1 = %10.1f, t2 = %10.1f" % (t1,t2)
mapping = {}
mapping['gaugeno'] = gaugeno
mapping['t1'] = t1
mapping['t2'] = t2
mapping['x1'] = x1
mapping['y1'] = y1
mapping['elev'] = elev
mapping['name'] = 'Gauge %i' % rnum
description = " t1 = %g, t2 = %g\n" % (t1,t2) \
+ " x1 = %g, y1 = %g\n" % (x1,y1)
mapping['desc'] = description
gauge_text = kml_gauge(mapping)
kml_text = kml_text + gauge_text
kml_text = kml_text + kml_footer()
kml_file = open(fname,'w')
kml_file.write(kml_text)
kml_file.close()
print "Created ",fname
示例11: run_sw
def run_sw(hl=3.,ul=0.,hr=1.,ur=0.):
os.system("make .exe")
import setrun
rundata = setrun.setrun() # initialize most run-time variables for clawpack
outdir = '_output'
# IC for shallow water code
rundata.probdata.hl = hl
rundata.probdata.ul = ul
rundata.probdata.hr = hr
rundata.probdata.ur = ur
rundata.write()
os.system("make output > output.txt")
os.system("make plots >> output.txt")
示例12: __init__
def __init__(self, test = "A"):
super(BenchmarkBaseTest,self).__init__()
import setrun
self.run_data = setrun.setrun()
self.name = "TestOutput"
self.test = test
if test == "A":
self.run_data.clawdata.nout = 22
elif test == "C":
self.run_data.clawdata.nout = 28
# Convert angle to degrees for the label
self.prefix = "Case%s" % test
示例13: __init__
def __init__(self, storm, storm_number):
r"""
Initialize Habanero storm surge job
See :class:`StormJob` for full documentation
"""
super(StormJob, self).__init__()
self.storm_number = storm_number
self.storm = storm
# Habanero queue settings
self.omp_num_threads = 24
self.time = "1:00:00"
self.queue = ""
# General job info
self.type = "surge"
self.name = "global_1"
self.prefix = "storm_%s" % self.storm_number
self.executable = "xgeoclaw"
# Modify run data
import setrun
self.rundata = setrun.setrun()
# Modify output times
self.rundata.clawdata.output_style = 2
recurrence = 6.0
tfinal = (storm.t[-1] - storm.t[0]).total_seconds()
N = int(tfinal / (recurrence * 60**2))
self.rundata.clawdata.output_times = [t for t in
numpy.arange(0.0, N * recurrence * 60**2, recurrence * 60**2)]
self.rundata.clawdata.output_times.append(tfinal)
# Modify storm data
surge_data = self.rundata.surge_data
base_path = os.path.expandvars(os.path.join("$DATA_PATH", "storms",
"global", "storms"))
surge_data.storm_file = os.path.join(base_path,
'storm_%s.storm'
% (str(i).zfill(5)))
self.storm.time_offset = storm.t[0]
print("Writing out GeoClaw storms...")
self.storm.write(self.rundata.surge_data.storm_file)
示例14: __init__
def __init__(self, ensemble, storm_num, base_path='./', storms_path='./'):
super(StormJob, self).__init__()
self.type = ""
self.name = ""
self.prefix = str(storm_num).zfill(5)
self.storm_num = storm_num
self.executable = "xgeoclaw"
# Create base data object
import setrun
self.rundata = setrun.setrun()
# Storm specific data
self.ensemble = ensemble
self.storm_file_path = os.path.join(storms_path
os.path.abspath("./%s.storm" % storm_num))
# Set storm file
self.rundata.storm_data.storm_type = 1
self.rundata.storm_data.storm_file = self.storm_file_path
示例15: __init__
def __init__(self, angle=0.0, bathy_angle=0.0, location=[-0.1, 0.0],
bathy_location=0.15):
super(PlaneWaveTest, self).__init__()
self.executable = 'xgeoclaw'
self.type = "multilayer"
self.name = "planewave"
# Convert angle to degrees for the label
self.prefix = "ml_2d_ia%s_ba%s" % (int(angle * 180.0 / numpy.pi),
int(bathy_angle * 180.0 / numpy.pi))
# Data objects
self.rundata = setrun.setrun()
self.rundata.qinit_data.angle = angle
self.rundata.qinit_data.init_location = location
self.bathy_location = bathy_location
self.bathy_angle = bathy_angle
# Add gauges down perpendicular
self.rundata.gaugedata.gauges = []
gauge_locations = [-0.1,0.0,0.1,0.2,0.3]
for (i,x_c) in enumerate(gauge_locations):
# y0 = (self.run_data.clawdata.yupper - self.run_data.clawdata.ylower) / 2.0
# x_p,y_p = transform_c2p(x_c,0.0,location[0],location[1],angle)
x_p = x_c * numpy.cos(angle)
y_p = x_c * numpy.sin(angle)
# print "+=====+"
# print x_c,0.0
# print x_p,y_p
if (self.rundata.clawdata.lower[0] < x_p < self.rundata.clawdata.upper[0] and
self.rundata.clawdata.lower[1] < y_p < self.rundata.clawdata.upper[1]):
self.rundata.gaugedata.gauges.append([i, x_p, y_p, 0.0, 1e10])