def getplan(self, size="<STR_LIT>", axes=None, padding=None):
from numpy import dtype as gettype<EOL>plan = self.vshape<EOL>if axes is None:<EOL><INDENT>if isinstance(size, str):<EOL><INDENT>axes = arange(len(self.vshape))<EOL><DEDENT>else:<EOL><INDENT>axes = arange(len(size))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>axes = asarray(axes, '<STR_LIT:int>')<EOL><DEDENT>pad = array(len(self.vshape)*[<NUM_LIT:0>, ])<EOL>if padding is not None:<EOL><INDENT>pad[axes] = padding<EOL><DEDENT>if isinstance(size, tuple):<EOL><INDENT>plan[axes] = size<EOL><DEDENT>elif isinstance(size, str):<EOL><INDENT>size = <NUM_LIT> * float(size)<EOL>elsize = gettype(self.dtype).itemsize<EOL>nelements = prod(self.vshape)<EOL>dims = self.vshape[self.vmask(axes)]<EOL>if size <= elsize:<EOL><INDENT>s = ones(len(axes))<EOL><DEDENT>else:<EOL><INDENT>remsize = <NUM_LIT:1.0> * nelements * elsize<EOL>s = []<EOL>for (i, d) in enumerate(dims):<EOL><INDENT>minsize = remsize/d<EOL>if minsize >= size:<EOL><INDENT>s.append(<NUM_LIT:1>)<EOL>remsize = minsize<EOL>continue<EOL><DEDENT>else:<EOL><INDENT>s.append(min(d, floor(size/minsize)))<EOL>s[i+<NUM_LIT:1>:] = plan[i+<NUM_LIT:1>:]<EOL>break<EOL><DEDENT><DEDENT><DEDENT>plan[axes] = s<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return plan, pad<EOL>
Identify a plan for chunking values along each dimension.

Generates an ndarray with the size (in number of elements) of chunks
in each dimension. If provided, will estimate chunks for only a
subset of axes, leaving all others to the full size of the axis.

Parameters
----------
size : string or tuple
     If str, the average size (in KB) of the chunks in all value dimensions.
     If int/tuple, an explicit specification of the number chunks in
     each moving value dimension.

axes : tuple, optional, default=None
      One or more axes to estimate chunks for, if provided any
      other axes will use one chunk.

padding : tuple or int, option, default=None
    Size over overlapping padding between chunks in each dimension.
    If tuple, specifies padding along each chunked dimension; if int,
    all dimensions use same padding; if None, no padding