Skip to content

Instantly share code, notes, and snippets.

import functools
import importlib
import logging
import os
import pickle
import sys
import time
import timeit
import h5py
@lifangda01
lifangda01 / Numpy2VTK.py
Created June 4, 2019 20:51
Convert 3D numpy array to vti format
import numpy as np
import pyevtk
np_data = np.load('/Users/fangdali/Code/DEBATR/results/wFBP/freect/bag_no_5'
'/whole_bag.npz')['arr_0']
print np_data.shape
w, h, l = np_data.shape
x = np.arange(0, w + 1)
y = np.arange(0, h + 1)
z = np.arange(0, l + 1)
from pylab import *
def quick_imshow(nrows, ncols, images, titles=None, colorbar=True, vmax=None,
vmin=None, figsize=None, figtitle=None):
"""-------------------------------------------------------------------------
Desc.: convenience function that make subplots of imshow
Args.: nrows - number of rows
ncols - number of cols
images - list of images
titles - list of titles
class Buddy(object):
def __init__(self):
super(Buddy, self).__init__()
# 1024, 512, 256
self.lists = [[0],[],[]]
def get(self, req):
print "Requesting %d bytes" % (1024/2**req)
print "Lists before request:"
print self.lists
class Node(object):
def __init__(self, parent, depth, nodeID):
super(Node, self).__init__()
self.parent = parent
self.depth = depth
self.nodeID = nodeID
self.left = None
self.right = None
self.used = False