本文整理汇总了Python中Model.Model.make_waveform方法的典型用法代码示例。如果您正苦于以下问题:Python Model.make_waveform方法的具体用法?Python Model.make_waveform怎么用?Python Model.make_waveform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.make_waveform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MPIFitManager
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import make_waveform [as 别名]
#.........这里部分代码省略.........
wf_likes[i] = self.comm.recv(source=worker, tag=MPI.ANY_TAG)
return np.sum(wf_likes)
def wait_and_process(self):
tags = self.tags
status = MPI.Status() # get MPI status object
if self.is_master():
raise RuntimeError("Master node told to await jobs.")
while True:
# Blocking receive to wait for instructions.
task = self.comm.recv(source=0, tag=MPI.ANY_TAG, status=status)
if self.debug:
self.numCalls +=1
if self.numCalls % 1000 == 0:
meminfo = "Particle {0} (call {1}) memory: {2}\n".format(MPI.COMM_WORLD.Get_rank(), self.numCalls , memory_usage_psutil())
with open(self.debug_mem_file, "a") as f:
f.write(meminfo)
if status.tag == self.tags.CALC_LIKE:
# if self.debug:
# print( "rank %d (local rank %d) calcing like %d" % (MPI.COMM_WORLD.Get_rank(), self.rank, self.rank - 1) )
wf_idx = self.rank - 1
ln_like = self.model.calc_wf_likelihood(task, wf_idx)
self.comm.send(ln_like, dest=0, tag=status.tag)
if status.tag == self.tags.CALC_WF:
data_len = self.model.output_wf_length
model = self.model.make_waveform(data_len, task)
self.comm.send(model, dest=0, tag=status.tag)
elif status.tag == self.tags.EXIT:
break
del task
def enum(self, *sequential, **named):
"""Handy way to fake an enumerated type in Python
http://stackoverflow.com/questions/36932/how-can-i-represent-an-enum-in-python
"""
enums = dict(zip(sequential, range(len(sequential))), **named)
return type('Enum', (), enums)
def fit(self, numLevels, directory="",numPerSave=1000,numParticles=5 ):
sampler = dnest4.DNest4Sampler(self.model,
backend=dnest4.backends.CSVBackend(basedir ="./" + directory,
sep=" "))
# Set up the sampler. The first argument is max_num_levels
gen = sampler.sample(max_num_levels=numLevels, num_steps=200000, new_level_interval=10000,
num_per_step=numPerSave, thread_steps=100,
num_particles=numParticles, lam=10, beta=100, seed=1234)
# Do the sampling (one iteration here = one particle save)
for i, sample in enumerate(gen):
print("# Saved {k} particles.".format(k=(i+1)))
# Run the postprocessing
# dnest4.postprocess()