本文整理汇总了Python中cube.Cube.addData方法的典型用法代码示例。如果您正苦于以下问题:Python Cube.addData方法的具体用法?Python Cube.addData怎么用?Python Cube.addData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cube.Cube
的用法示例。
在下文中一共展示了Cube.addData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getcubedrawdata
# 需要导入模块: from cube import Cube [as 别名]
# 或者: from cube.Cube import addData [as 别名]
def getcubedrawdata(self, ci, timestep, datafield, selftask = None):
#We need to chunk the data first
#cubesize 16
cubedimension = 256
components = Datafield.objects.get(shortname=datafield).components
fullcubesize = [math.ceil(float(ci.zlen)/float(cubedimension))*cubedimension, math.ceil(float(ci.ylen)/float(cubedimension))*cubedimension, math.ceil(float(ci.xlen)/float(cubedimension))*cubedimension]
fullcubesize = [int(fullcubesize[0]), int(fullcubesize[1]), int(fullcubesize[2])]
print ("Full cube size is: ", fullcubesize)
filterwidth = ci.filter
corner = [ci.xstart, ci.ystart, ci.zstart]
step = [ci.xstep, ci.ystep, ci.zstep]
fullcube = Cube(corner, fullcubesize,step, filterwidth, components )
cubesize = [cubedimension, cubedimension, cubedimension]
cubecount = 0
args = []
for xcorner in range (ci.xstart,ci.xstart + ci.xlen, cubedimension):
for ycorner in range (ci.ystart,ci.ystart + ci.ylen, cubedimension):
for zcorner in range (ci.zstart,ci.zstart + ci.zlen, cubedimension):
print("Gettting cube: ", xcorner, ycorner, zcorner)
cubecount = cubecount + 1
corners = [xcorner, ycorner, zcorner]
args.append([corners, ci, cubesize, timestep, step, filterwidth, components, datafield])
cubesfinished = 0
for arg in args:
cube = self.getfilecube(args[cubesfinished])
fullcube.addData(cube, ci)
cubesfinished=cubesfinished+1
if (selftask != None): #Update status for progress bar when tasked
selftask.update_state(state='PROGRESS', meta={'cubes': cubesfinished, 'total': cubecount})
#Multiprocessing
#if (cubecount > 4):
# cubecount = 4 #limit to only 8 processes
#print("Multiprocessing... Cubes: ", (cubecount))
#p = Pool(cubecount)
#cubelist = p.map(self.getfilecube, args)
#self.getfilecube(args[0])
#print("Mapped")
#import pdb; pdb.set_trace();
#p.join()
#progress = 0
#for cube in cubelist:
#cubefile = open( filename , 'rb')
#cube = pickle.load(cubefile)
#print ("Cube: " % cube)
#fullcube.addData(cube, ci)
#print("Added:", cube)
#progress = progress +1
#connection.close()
#fullcube.addData(cube, ci)
#p.join()
print("Complete")
#connection.close()
#p.close() #frees the ram
fullcube.trim(ci)
print("Trimming complete, returning cube")
return fullcube.data