/* Generated by Cython 0.12.1 on Thu Jun 24 08:38:56 2010 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#else

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#endif

#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#endif

#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)

#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#endif

#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif

#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyString_Type                PyUnicode_Type
  #define PyString_CheckExact          PyUnicode_CheckExact
#else
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_CheckExact           PyString_CheckExact
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)

#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#else
  #define _USE_MATH_DEFINES
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#define __PYX_HAVE_API__yt__amr_utils
#include "stdlib.h"
#include "stdio.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#include "math.h"
#include "FixedInterpolator.h"
#include "png.h"

#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #else
    #define CYTHON_INLINE 
  #endif
#endif

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#if PY_MAJOR_VERSION < 3
#define __Pyx_PyBytes_FromString          PyString_FromString
#define __Pyx_PyBytes_FromStringAndSize   PyString_FromStringAndSize
#define __Pyx_PyBytes_AsString            PyString_AsString
#else
#define __Pyx_PyBytes_FromString          PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize   PyBytes_FromStringAndSize
#define __Pyx_PyBytes_AsString            PyBytes_AsString
#endif

#define __Pyx_PyBytes_FromUString(s)      __Pyx_PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)        ((unsigned char*) __Pyx_PyBytes_AsString(s))

#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

#if !defined(T_PYSSIZET)
#if PY_VERSION_HEX < 0x02050000
#define T_PYSSIZET T_INT
#elif !defined(T_LONGLONG)
#define T_PYSSIZET \
        ((sizeof(Py_ssize_t) == sizeof(int))  ? T_INT  : \
        ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1))
#else
#define T_PYSSIZET \
        ((sizeof(Py_ssize_t) == sizeof(int))          ? T_INT      : \
        ((sizeof(Py_ssize_t) == sizeof(long))         ? T_LONG     : \
        ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))
#endif
#endif


#if !defined(T_ULONGLONG)
#define __Pyx_T_UNSIGNED_INT(x) \
        ((sizeof(x) == sizeof(unsigned char))  ? T_UBYTE : \
        ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \
        ((sizeof(x) == sizeof(unsigned int))   ? T_UINT : \
        ((sizeof(x) == sizeof(unsigned long))  ? T_ULONG : -1))))
#else
#define __Pyx_T_UNSIGNED_INT(x) \
        ((sizeof(x) == sizeof(unsigned char))  ? T_UBYTE : \
        ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \
        ((sizeof(x) == sizeof(unsigned int))   ? T_UINT : \
        ((sizeof(x) == sizeof(unsigned long))  ? T_ULONG : \
        ((sizeof(x) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))))
#endif
#if !defined(T_LONGLONG)
#define __Pyx_T_SIGNED_INT(x) \
        ((sizeof(x) == sizeof(char))  ? T_BYTE : \
        ((sizeof(x) == sizeof(short)) ? T_SHORT : \
        ((sizeof(x) == sizeof(int))   ? T_INT : \
        ((sizeof(x) == sizeof(long))  ? T_LONG : -1))))
#else
#define __Pyx_T_SIGNED_INT(x) \
        ((sizeof(x) == sizeof(char))  ? T_BYTE : \
        ((sizeof(x) == sizeof(short)) ? T_SHORT : \
        ((sizeof(x) == sizeof(int))   ? T_INT : \
        ((sizeof(x) == sizeof(long))  ? T_LONG : \
        ((sizeof(x) == sizeof(PY_LONG_LONG))   ? T_LONGLONG : -1)))))
#endif

#define __Pyx_T_FLOATING(x) \
        ((sizeof(x) == sizeof(float)) ? T_FLOAT : \
        ((sizeof(x) == sizeof(double)) ? T_DOUBLE : -1))

#if !defined(T_SIZET)
#if !defined(T_ULONGLONG)
#define T_SIZET \
        ((sizeof(size_t) == sizeof(unsigned int))  ? T_UINT  : \
        ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1))
#else
#define T_SIZET \
        ((sizeof(size_t) == sizeof(unsigned int))          ? T_UINT      : \
        ((sizeof(size_t) == sizeof(unsigned long))         ? T_ULONG     : \
        ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))
#endif
#endif

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))


#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 ||               (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;
static const char **__pyx_f;


#if !defined(CYTHON_CCOMPLEX)
  #if defined(__cplusplus)
    #define CYTHON_CCOMPLEX 1
  #elif defined(_Complex_I)
    #define CYTHON_CCOMPLEX 1
  #else
    #define CYTHON_CCOMPLEX 0
  #endif
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #include <complex>
  #else
    #include <complex.h>
  #endif
#endif

#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  #undef _Complex_I
  #define _Complex_I 1.0fj
#endif

typedef npy_int8 __pyx_t_5numpy_int8_t;

typedef npy_int16 __pyx_t_5numpy_int16_t;

typedef npy_int32 __pyx_t_5numpy_int32_t;

typedef npy_int64 __pyx_t_5numpy_int64_t;

typedef npy_uint8 __pyx_t_5numpy_uint8_t;

typedef npy_uint16 __pyx_t_5numpy_uint16_t;

typedef npy_uint32 __pyx_t_5numpy_uint32_t;

typedef npy_uint64 __pyx_t_5numpy_uint64_t;

typedef npy_float32 __pyx_t_5numpy_float32_t;

typedef npy_float64 __pyx_t_5numpy_float64_t;

typedef npy_long __pyx_t_5numpy_int_t;

typedef npy_longlong __pyx_t_5numpy_long_t;

typedef npy_intp __pyx_t_5numpy_intp_t;

typedef npy_uintp __pyx_t_5numpy_uintp_t;

typedef npy_ulong __pyx_t_5numpy_uint_t;

typedef npy_ulonglong __pyx_t_5numpy_ulong_t;

typedef npy_double __pyx_t_5numpy_float_t;

typedef npy_double __pyx_t_5numpy_double_t;

typedef npy_longdouble __pyx_t_5numpy_longdouble_t;

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< float > __pyx_t_float_complex;
  #else
    typedef float _Complex __pyx_t_float_complex;
  #endif
#else
    typedef struct { float real, imag; } __pyx_t_float_complex;
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< double > __pyx_t_double_complex;
  #else
    typedef double _Complex __pyx_t_double_complex;
  #endif
#else
    typedef struct { double real, imag; } __pyx_t_double_complex;
#endif

/* Type declarations */

typedef npy_cfloat __pyx_t_5numpy_cfloat_t;

typedef npy_cdouble __pyx_t_5numpy_cdouble_t;

typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;

typedef npy_cdouble __pyx_t_5numpy_complex_t;

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":76
 * cdef class VectorPlane
 * 
 * cdef struct FieldInterpolationTable:             # <<<<<<<<<<<<<<
 *     # Note that we make an assumption about retaining a reference to values
 *     # externally.
 */

struct __pyx_t_2yt_9amr_utils_FieldInterpolationTable {
  __pyx_t_5numpy_float64_t *values;
  __pyx_t_5numpy_float64_t bounds[2];
  __pyx_t_5numpy_float64_t dbin;
  __pyx_t_5numpy_float64_t idbin;
  int field_id;
  int weight_field_id;
  int weight_table_id;
  int nbins;
  int pass_through;
};

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":89
 *     int pass_through
 * 
 * cdef void FIT_initialize_table(FieldInterpolationTable *fit, int nbins,             # <<<<<<<<<<<<<<
 *               np.float64_t *values, np.float64_t bounds1, np.float64_t bounds2,
 *               int field_id, int weight_field_id = -1, int weight_table_id = -1,
 */

struct __pyx_opt_args_2yt_9amr_utils_FIT_initialize_table {
  int __pyx_n;
  int weight_field_id;
  int weight_table_id;
  int pass_through;
};

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":39
 *     void *alloca(int)
 * 
 * cdef struct QuadTreeNode:             # <<<<<<<<<<<<<<
 *     np.float64_t *val
 *     np.float64_t weight_val
 */

struct __pyx_t_2yt_9amr_utils_QuadTreeNode {
  __pyx_t_5numpy_float64_t *val;
  __pyx_t_5numpy_float64_t weight_val;
  __pyx_t_5numpy_int64_t pos[2];
  int level;
  int nvals;
  struct __pyx_t_2yt_9amr_utils_QuadTreeNode *children[2][2];
};

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":118
 *     return (bv + dd*dy*fit.idbin)
 * 
 * cdef class TransferFunctionProxy:             # <<<<<<<<<<<<<<
 *     cdef int n_fields
 *     cdef int n_field_tables
 */

struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy {
  PyObject_HEAD
  struct __pyx_vtabstruct_2yt_9amr_utils_TransferFunctionProxy *__pyx_vtab;
  int n_fields;
  int n_field_tables;
  int ns;
  struct __pyx_t_2yt_9amr_utils_FieldInterpolationTable field_tables[6];
  __pyx_t_5numpy_float64_t istorage[6];
  int field_table_ids[6];
  PyObject *tf_obj;
  PyObject *my_field_tables;
};

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":36
 *         self.refined_pos = 0
 * 
 * cdef class OctreeGrid:             # <<<<<<<<<<<<<<
 *     cdef public object child_indices, fields, left_edges, dimensions, dx
 *     cdef public int level
 */

struct __pyx_obj_2yt_9amr_utils_OctreeGrid {
  PyObject_HEAD
  PyObject *child_indices;
  PyObject *fields;
  PyObject *left_edges;
  PyObject *dimensions;
  PyObject *dx;
  int level;
};

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":53
 *         self.level = level
 * 
 * cdef class OctreeGridList:             # <<<<<<<<<<<<<<
 *     cdef public object grids
 *     def __cinit__(self, grids):
 */

struct __pyx_obj_2yt_9amr_utils_OctreeGridList {
  PyObject_HEAD
  PyObject *grids;
};

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":569
 *         return 1
 * 
 * cdef class ProtoPrism:             # <<<<<<<<<<<<<<
 *     cdef np.float64_t left_edge[3]
 *     cdef np.float64_t right_edge[3]
 */

struct __pyx_obj_2yt_9amr_utils_ProtoPrism {
  PyObject_HEAD
  struct __pyx_vtabstruct_2yt_9amr_utils_ProtoPrism *__pyx_vtab;
  __pyx_t_5numpy_float64_t left_edge[3];
  __pyx_t_5numpy_float64_t right_edge[3];
  PyObject *LeftEdge;
  PyObject *RightEdge;
  PyObject *subgrid_faces;
  int parent_grid_id;
};

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":30
 * cimport cython
 * 
 * cdef class position:             # <<<<<<<<<<<<<<
 *     cdef public int output_pos, refined_pos
 *     def __cinit__(self):
 */

struct __pyx_obj_2yt_9amr_utils_position {
  PyObject_HEAD
  int output_pos;
  int refined_pos;
};

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":537
 *             tf.eval_transfer(dt, self.dvs, rgba, grad)
 * 
 * cdef class GridFace:             # <<<<<<<<<<<<<<
 *     cdef int direction
 *     cdef public np.float64_t coord
 */

struct __pyx_obj_2yt_9amr_utils_GridFace {
  PyObject_HEAD
  struct __pyx_vtabstruct_2yt_9amr_utils_GridFace *__pyx_vtab;
  int direction;
  __pyx_t_5numpy_float64_t coord;
  __pyx_t_5numpy_float64_t left_edge[3];
  __pyx_t_5numpy_float64_t right_edge[3];
};

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":99
 *     free(node)
 * 
 * cdef class QuadTree:             # <<<<<<<<<<<<<<
 *     cdef int nvals
 *     cdef np.int64_t po2[80]
 */

struct __pyx_obj_2yt_9amr_utils_QuadTree {
  PyObject_HEAD
  struct __pyx_vtabstruct_2yt_9amr_utils_QuadTree *__pyx_vtab;
  int nvals;
  __pyx_t_5numpy_int64_t po2[80];
  struct __pyx_t_2yt_9amr_utils_QuadTreeNode ***root_nodes;
  __pyx_t_5numpy_int64_t top_grid_dims[2];
};

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":74
 *                                        np.float64_t *data, np.float64_t *grad)
 * 
 * cdef class VectorPlane             # <<<<<<<<<<<<<<
 * 
 * cdef struct FieldInterpolationTable:
 */

struct __pyx_obj_2yt_9amr_utils_VectorPlane {
  PyObject_HEAD
  struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane *__pyx_vtab;
  PyObject *avp_pos;
  PyObject *avp_dir;
  PyObject *acenter;
  PyObject *aimage;
  __pyx_t_5numpy_float64_t *vp_pos;
  __pyx_t_5numpy_float64_t *vp_dir;
  __pyx_t_5numpy_float64_t *center;
  __pyx_t_5numpy_float64_t *image;
  __pyx_t_5numpy_float64_t pdx;
  __pyx_t_5numpy_float64_t pdy;
  __pyx_t_5numpy_float64_t bounds[4];
  int nv[2];
  int vp_strides[3];
  int im_strides[3];
  int vd_strides[3];
  PyObject *ax_vec;
  PyObject *ay_vec;
  __pyx_t_5numpy_float64_t *x_vec;
  __pyx_t_5numpy_float64_t *y_vec;
};

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":299
 *             tv[offset + k] = fv[k]
 * 
 * cdef class PartitionedGrid:             # <<<<<<<<<<<<<<
 *     cdef public object my_data
 *     cdef public object LeftEdge
 */

struct __pyx_obj_2yt_9amr_utils_PartitionedGrid {
  PyObject_HEAD
  struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid *__pyx_vtab;
  PyObject *my_data;
  PyObject *LeftEdge;
  PyObject *RightEdge;
  __pyx_t_5numpy_float64_t *data[6];
  __pyx_t_5numpy_float64_t dvs[6];
  __pyx_t_5numpy_float64_t left_edge[3];
  __pyx_t_5numpy_float64_t right_edge[3];
  __pyx_t_5numpy_float64_t dds[3];
  __pyx_t_5numpy_float64_t idds[3];
  int dims[3];
  int parent_grid_id;
  int n_fields;
};


/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":537
 *             tf.eval_transfer(dt, self.dvs, rgba, grad)
 * 
 * cdef class GridFace:             # <<<<<<<<<<<<<<
 *     cdef int direction
 *     cdef public np.float64_t coord
 */

struct __pyx_vtabstruct_2yt_9amr_utils_GridFace {
  int (*proj_overlap)(struct __pyx_obj_2yt_9amr_utils_GridFace *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *);
};
static struct __pyx_vtabstruct_2yt_9amr_utils_GridFace *__pyx_vtabptr_2yt_9amr_utils_GridFace;


/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":118
 *     return (bv + dd*dy*fit.idbin)
 * 
 * cdef class TransferFunctionProxy:             # <<<<<<<<<<<<<<
 *     cdef int n_fields
 *     cdef int n_field_tables
 */

struct __pyx_vtabstruct_2yt_9amr_utils_TransferFunctionProxy {
  void (*eval_transfer)(struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *);
};
static struct __pyx_vtabstruct_2yt_9amr_utils_TransferFunctionProxy *__pyx_vtabptr_2yt_9amr_utils_TransferFunctionProxy;


/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":569
 *         return 1
 * 
 * cdef class ProtoPrism:             # <<<<<<<<<<<<<<
 *     cdef np.float64_t left_edge[3]
 *     cdef np.float64_t right_edge[3]
 */

struct __pyx_vtabstruct_2yt_9amr_utils_ProtoPrism {
  PyObject *(*split)(struct __pyx_obj_2yt_9amr_utils_ProtoPrism *, __pyx_t_5numpy_float64_t *, int);
};
static struct __pyx_vtabstruct_2yt_9amr_utils_ProtoPrism *__pyx_vtabptr_2yt_9amr_utils_ProtoPrism;


/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":99
 *     free(node)
 * 
 * cdef class QuadTree:             # <<<<<<<<<<<<<<
 *     cdef int nvals
 *     cdef np.int64_t po2[80]
 */

struct __pyx_vtabstruct_2yt_9amr_utils_QuadTree {
  void (*add_to_position)(struct __pyx_obj_2yt_9amr_utils_QuadTree *, int, __pyx_t_5numpy_int64_t *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t);
  struct __pyx_t_2yt_9amr_utils_QuadTreeNode *(*find_on_root_level)(struct __pyx_obj_2yt_9amr_utils_QuadTree *, __pyx_t_5numpy_int64_t *, int);
  int (*count_at_level)(struct __pyx_obj_2yt_9amr_utils_QuadTree *, struct __pyx_t_2yt_9amr_utils_QuadTreeNode *, int);
  int (*fill_from_level)(struct __pyx_obj_2yt_9amr_utils_QuadTree *, struct __pyx_t_2yt_9amr_utils_QuadTreeNode *, int, __pyx_t_5numpy_int64_t, __pyx_t_5numpy_int64_t *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *);
};
static struct __pyx_vtabstruct_2yt_9amr_utils_QuadTree *__pyx_vtabptr_2yt_9amr_utils_QuadTree;


/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":222
 *             #rgba[i+3] += trgba[i] * (1.0 - rgba[i+3])*dt*trgba[i+3]
 * 
 * cdef class VectorPlane:             # <<<<<<<<<<<<<<
 *     cdef public object avp_pos, avp_dir, acenter, aimage
 *     cdef np.float64_t *vp_pos, *vp_dir, *center, *image,
 */

struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane {
  void (*get_start_stop)(struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *, int *);
  void (*copy_into)(struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, int, int, int, int *);
  void (*copy_back)(struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, int, int, int, int *);
};
static struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane *__pyx_vtabptr_2yt_9amr_utils_VectorPlane;


/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":299
 *             tv[offset + k] = fv[k]
 * 
 * cdef class PartitionedGrid:             # <<<<<<<<<<<<<<
 *     cdef public object my_data
 *     cdef public object LeftEdge
 */

struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid {
  void (*calculate_extent)(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *, struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *);
  int (*integrate_ray)(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *);
  void (*sample_values)(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, int *, __pyx_t_5numpy_float64_t *, struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *);
};
static struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid *__pyx_vtabptr_2yt_9amr_utils_PartitionedGrid;

#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif

#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
  end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
  }
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
#else
  #define __Pyx_RefNannySetupContext(name)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
    const char* function_name, int kw_allowed); /*proto*/

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/

/* Run-time type information about structs used with buffers */
struct __Pyx_StructField_;

typedef struct {
  const char* name; /* for error messages only */
  struct __Pyx_StructField_* fields;
  size_t size;     /* sizeof(type) */
  char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject */
} __Pyx_TypeInfo;

typedef struct __Pyx_StructField_ {
  __Pyx_TypeInfo* type;
  const char* name;
  size_t offset;
} __Pyx_StructField;

typedef struct {
  __Pyx_StructField* field;
  size_t parent_offset;
} __Pyx_BufFmt_StackElem;


static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
static int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/


static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}


#define __Pyx_GetItemInt_List(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i, size <= sizeof(long)) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
}

#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i, size <= sizeof(long)) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
}


#define __Pyx_GetItemInt(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i, size <= sizeof(long)) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
    PyObject *r;
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
        r = PySequence_GetItem(o, i);
    }
    else {
        r = __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
    }
    return r;
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
#define __Pyx_BufPtrStrided4d(type, buf, i0, s0, i1, s1, i2, s2, i3, s3) (type)((char*)buf + i0 * s0 + i1 * s1 + i2 * s2 + i3 * s3)
#define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1)

static void __Pyx_RaiseBufferFallbackError(void); /*proto*/
#define __Pyx_BufPtrStrided3d(type, buf, i0, s0, i1, s1, i2, s2) (type)((char*)buf + i0 * s0 + i1 * s1 + i2 * s2)
static void __Pyx_RaiseBufferIndexError(int axis); /*proto*/

static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (PyList_Append(L, x) < 0) return NULL;
        Py_INCREF(Py_None);
        return Py_None; /* this is just to have an accurate signature */
    }
    else {
        PyObject *r, *m;
        m = __Pyx_GetAttrString(L, "append");
        if (!m) return NULL;
        r = PyObject_CallFunctionObjArgs(m, x, NULL);
        Py_DECREF(m);
        return r;
    }
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void);

static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
static int __Pyx_EndUnpack(PyObject *); /*proto*/

#define __Pyx_SetItemInt(o, i, v, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_SetItemInt_Fast(o, i, v, size <= sizeof(long)) : \
                                                    __Pyx_SetItemInt_Generic(o, to_py_func(i), v))

static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}

static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int fits_long) {
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        Py_INCREF(v);
        Py_DECREF(PyList_GET_ITEM(o, i));
        PyList_SET_ITEM(o, i, v);
        return 1;
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && (likely(i >= 0)))
        return PySequence_SetItem(o, i, v);
    else {
        PyObject *j = fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i);
        return __Pyx_SetItemInt_Generic(o, j, v);
    }
}

#if PY_VERSION_HEX < 0x02050000
#ifndef PyAnySet_CheckExact

#define PyAnySet_CheckExact(ob) \
    ((ob)->ob_type == &PySet_Type || \
     (ob)->ob_type == &PyFrozenSet_Type)

#define PySet_New(iterable) \
    PyObject_CallFunctionObjArgs((PyObject *)&PySet_Type, (iterable), NULL)

#define Pyx_PyFrozenSet_New(iterable) \
    PyObject_CallFunctionObjArgs((PyObject *)&PyFrozenSet_Type, (iterable), NULL)

#define PySet_Size(anyset) \
    PyObject_Size((anyset))

#define PySet_Contains(anyset, key) \
    PySequence_Contains((anyset), (key))

#define PySet_Pop(set) \
    PyObject_CallMethod(set, (char *)"pop", NULL)

static CYTHON_INLINE int PySet_Clear(PyObject *set) {
    PyObject *ret = PyObject_CallMethod(set, (char *)"clear", NULL);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}

static CYTHON_INLINE int PySet_Discard(PyObject *set, PyObject *key) {
    PyObject *ret = PyObject_CallMethod(set, (char *)"discard", (char *)"O", key);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}

static CYTHON_INLINE int PySet_Add(PyObject *set, PyObject *key) {
    PyObject *ret = PyObject_CallMethod(set, (char *)"add", (char *)"O", key);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}

#endif /* PyAnySet_CheckExact (<= Py2.4) */

#if PY_VERSION_HEX < 0x02040000
#ifndef Py_SETOBJECT_H
#define Py_SETOBJECT_H

static PyTypeObject *__Pyx_PySet_Type = NULL;
static PyTypeObject *__Pyx_PyFrozenSet_Type = NULL;

#define PySet_Type (*__Pyx_PySet_Type)
#define PyFrozenSet_Type (*__Pyx_PyFrozenSet_Type)

#define PyAnySet_Check(ob) \
    (PyAnySet_CheckExact(ob) || \
     PyType_IsSubtype((ob)->ob_type, &PySet_Type) || \
     PyType_IsSubtype((ob)->ob_type, &PyFrozenSet_Type))

#define PyFrozenSet_CheckExact(ob) ((ob)->ob_type == &PyFrozenSet_Type)

static int __Pyx_Py23SetsImport(void) {
    PyObject *sets=0, *Set=0, *ImmutableSet=0;

    sets = PyImport_ImportModule((char *)"sets");
    if (!sets) goto bad;
    Set = PyObject_GetAttrString(sets, (char *)"Set");
    if (!Set) goto bad;
    ImmutableSet = PyObject_GetAttrString(sets, (char *)"ImmutableSet");
    if (!ImmutableSet) goto bad;
    Py_DECREF(sets);

    __Pyx_PySet_Type       = (PyTypeObject*) Set;
    __Pyx_PyFrozenSet_Type = (PyTypeObject*) ImmutableSet;

    return 0;

 bad:
    Py_XDECREF(sets);
    Py_XDECREF(Set);
    Py_XDECREF(ImmutableSet);
    return -1;
}

#else
static int __Pyx_Py23SetsImport(void) { return 0; }
#endif /* !Py_SETOBJECT_H */
#endif /* < Py2.4  */
#endif /* < Py2.5  */

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /*proto*/

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*proto*/
#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
#define __Pyx_GetBuffer PyObject_GetBuffer
#define __Pyx_ReleaseBuffer PyBuffer_Release
#endif

Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0};
Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1};

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_intp(npy_intp);

static CYTHON_INLINE npy_int32 __Pyx_PyInt_from_py_npy_int32(PyObject *);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_int32(npy_int32);

static int __Pyx_Print(PyObject *, int); /*proto*/
#if PY_MAJOR_VERSION >= 3
static PyObject* __pyx_print = 0;
static PyObject* __pyx_print_kwargs = 0;
#endif

static CYTHON_INLINE npy_int64 __Pyx_PyInt_from_py_npy_int64(PyObject *);

static int __Pyx_PrintOne(PyObject *o); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_int64(npy_int64);

static CYTHON_INLINE png_uint_32 __Pyx_PyInt_from_py_png_uint_32(PyObject *);

static CYTHON_INLINE long __Pyx_pow_long(long, long); /* proto */

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #define __Pyx_CREAL(z) ((z).real())
    #define __Pyx_CIMAG(z) ((z).imag())
  #else
    #define __Pyx_CREAL(z) (__real__(z))
    #define __Pyx_CIMAG(z) (__imag__(z))
  #endif
#else
    #define __Pyx_CREAL(z) ((z).real)
    #define __Pyx_CIMAG(z) ((z).imag)
#endif

#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX
    #define __Pyx_SET_CREAL(z,x) ((z).real(x))
    #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
    #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
    #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif

static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);

#if CYTHON_CCOMPLEX
    #define __Pyx_c_eqf(a, b)   ((a)==(b))
    #define __Pyx_c_sumf(a, b)  ((a)+(b))
    #define __Pyx_c_difff(a, b) ((a)-(b))
    #define __Pyx_c_prodf(a, b) ((a)*(b))
    #define __Pyx_c_quotf(a, b) ((a)/(b))
    #define __Pyx_c_negf(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zerof(z) ((z)==(float)0)
    #define __Pyx_c_conjf(z)    (::std::conj(z))
    /*#define __Pyx_c_absf(z)     (::std::abs(z))*/
  #else
    #define __Pyx_c_is_zerof(z) ((z)==0)
    #define __Pyx_c_conjf(z)    (conjf(z))
    /*#define __Pyx_c_absf(z)     (cabsf(z))*/
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex);
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex);
    /*static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex);*/
#endif

static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);

#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq(a, b)   ((a)==(b))
    #define __Pyx_c_sum(a, b)  ((a)+(b))
    #define __Pyx_c_diff(a, b) ((a)-(b))
    #define __Pyx_c_prod(a, b) ((a)*(b))
    #define __Pyx_c_quot(a, b) ((a)/(b))
    #define __Pyx_c_neg(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero(z) ((z)==(double)0)
    #define __Pyx_c_conj(z)    (::std::conj(z))
    /*#define __Pyx_c_abs(z)     (::std::abs(z))*/
  #else
    #define __Pyx_c_is_zero(z) ((z)==0)
    #define __Pyx_c_conj(z)    (conj(z))
    /*#define __Pyx_c_abs(z)     (cabs(z))*/
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex);
    /*static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex);*/
#endif

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static void __Pyx_WriteUnraisable(const char *name); /*proto*/

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

static void __Pyx_AddTraceback(const char *funcname); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from python_buffer */

/* Module declarations from python_ref */

/* Module declarations from stdlib */

/* Module declarations from stdio */

/* Module declarations from numpy */

/* Module declarations from numpy */

static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *, PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *, PyObject *, PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *, PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/
static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *, PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *); /*proto*/
/* Module declarations from cython */

/* Module declarations from yt.amr_utils */

static PyTypeObject *__pyx_ptype_2yt_9amr_utils_position = 0;
static PyTypeObject *__pyx_ptype_2yt_9amr_utils_OctreeGrid = 0;
static PyTypeObject *__pyx_ptype_2yt_9amr_utils_OctreeGridList = 0;
static PyTypeObject *__pyx_ptype_2yt_9amr_utils_VectorPlane = 0;
static PyTypeObject *__pyx_ptype_2yt_9amr_utils_TransferFunctionProxy = 0;
static PyTypeObject *__pyx_ptype_2yt_9amr_utils_PartitionedGrid = 0;
static PyTypeObject *__pyx_ptype_2yt_9amr_utils_GridFace = 0;
static PyTypeObject *__pyx_ptype_2yt_9amr_utils_ProtoPrism = 0;
static PyTypeObject *__pyx_ptype_2yt_9amr_utils_QuadTree = 0;
static CYTHON_INLINE void __pyx_f_2yt_9amr_utils_set_rotated_pos(__pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t (*)[3], __pyx_t_5numpy_float64_t *, int, int, int); /*proto*/
static void __pyx_f_2yt_9amr_utils_normalize_vector(__pyx_t_5numpy_float64_t *); /*proto*/
static void __pyx_f_2yt_9amr_utils_get_cross_product(__pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *); /*proto*/
static int __pyx_f_2yt_9amr_utils_check_projected_overlap(__pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, int, __pyx_t_5numpy_float64_t (*)[3], __pyx_t_5numpy_float64_t (*)[3]); /*proto*/
static CYTHON_INLINE int __pyx_f_2yt_9amr_utils_imax(int, int); /*proto*/
static CYTHON_INLINE __pyx_t_5numpy_float64_t __pyx_f_2yt_9amr_utils_fmax(__pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t); /*proto*/
static CYTHON_INLINE int __pyx_f_2yt_9amr_utils_imin(int, int); /*proto*/
static CYTHON_INLINE __pyx_t_5numpy_float64_t __pyx_f_2yt_9amr_utils_fmin(__pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t); /*proto*/
static CYTHON_INLINE int __pyx_f_2yt_9amr_utils_iclip(int, int, int); /*proto*/
static CYTHON_INLINE __pyx_t_5numpy_float64_t __pyx_f_2yt_9amr_utils_fclip(__pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t); /*proto*/
static void __pyx_f_2yt_9amr_utils_FIT_initialize_table(struct __pyx_t_2yt_9amr_utils_FieldInterpolationTable *, int, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, int, struct __pyx_opt_args_2yt_9amr_utils_FIT_initialize_table *__pyx_optional_args); /*proto*/
static __pyx_t_5numpy_float64_t __pyx_f_2yt_9amr_utils_FIT_get_value(struct __pyx_t_2yt_9amr_utils_FieldInterpolationTable *, __pyx_t_5numpy_float64_t *); /*proto*/
static CYTHON_INLINE __pyx_t_5numpy_int64_t __pyx_f_2yt_9amr_utils_i64max(__pyx_t_5numpy_int64_t, __pyx_t_5numpy_int64_t); /*proto*/
static CYTHON_INLINE __pyx_t_5numpy_int64_t __pyx_f_2yt_9amr_utils_i64min(__pyx_t_5numpy_int64_t, __pyx_t_5numpy_int64_t); /*proto*/
static CYTHON_INLINE int __pyx_f_2yt_9amr_utils_are_neighbors(__pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t); /*proto*/
static void __pyx_f_2yt_9amr_utils_QTN_add_value(struct __pyx_t_2yt_9amr_utils_QuadTreeNode *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t); /*proto*/
static void __pyx_f_2yt_9amr_utils_QTN_refine(struct __pyx_t_2yt_9amr_utils_QuadTreeNode *); /*proto*/
static struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_f_2yt_9amr_utils_QTN_initialize(__pyx_t_5numpy_int64_t *, int, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t, int); /*proto*/
static void __pyx_f_2yt_9amr_utils_QTN_free(struct __pyx_t_2yt_9amr_utils_QuadTreeNode *); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t = { "numpy.int32_t", NULL, sizeof(__pyx_t_5numpy_int32_t), 'I' };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "numpy.float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), 'R' };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int_t = { "numpy.int_t", NULL, sizeof(__pyx_t_5numpy_int_t), 'I' };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t = { "numpy.int8_t", NULL, sizeof(__pyx_t_5numpy_int8_t), 'I' };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float_t = { "numpy.float_t", NULL, sizeof(__pyx_t_5numpy_float_t), 'R' };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t = { "numpy.int64_t", NULL, sizeof(__pyx_t_5numpy_int64_t), 'I' };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t = { "numpy.float32_t", NULL, sizeof(__pyx_t_5numpy_float32_t), 'R' };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t = { "numpy.uint8_t", NULL, sizeof(__pyx_t_5numpy_uint8_t), 'U' };
#define __Pyx_MODULE_NAME "yt.amr_utils"
int __pyx_module_is_main_yt__amr_utils = 0;

/* Implementation of yt.amr_utils */
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_xrange;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_builtin_ValueError;
static char __pyx_k_1[] = "RecurseOctreeDepthFirst";
static char __pyx_k_2[] = "RecurseOctreeByLevels";
static char __pyx_k_3[] = "Field table";
static char __pyx_k_4[] = "corresponds to";
static char __pyx_k_5[] = "(Weighted with ";
static char __pyx_k_6[] = ")";
static char __pyx_k_7[] = "ndarray is not C contiguous";
static char __pyx_k_8[] = "ndarray is not Fortran contiguous";
static char __pyx_k_9[] = "Non-native byte order not supported";
static char __pyx_k_10[] = "unknown dtype code in numpy.pxd (%d)";
static char __pyx_k_11[] = "Format string allocated too short, see comment in numpy.pxd";
static char __pyx_k_12[] = "Format string allocated too short.";
static char __pyx_k_13[] = "\nContainer file to hold all our Cython routines.  This is to avoid problems with\nstatic linking.\n\nAuthor: Matthew Turk <matthewturk@gmail.com>\nAffiliation: KIPAC/SLAC/Stanford\nHomepage: http://yt.enzotools.org/\nLicense:\n  Copyright (C) 2008 Matthew Turk.  All Rights Reserved.\n\n  This file is part of yt.\n\n  yt is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License as published by\n  the Free Software Foundation; either version 3 of the License, or\n  (at your option) any later version.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n";
static char __pyx_k_14[] = "Transfer3D (line 36)";
static char __pyx_k_15[] = "TransferShells (line 74)";
static char __pyx_k__B[] = "B";
static char __pyx_k__F[] = "F";
static char __pyx_k__H[] = "H";
static char __pyx_k__I[] = "I";
static char __pyx_k__L[] = "L";
static char __pyx_k__O[] = "O";
static char __pyx_k__Q[] = "Q";
static char __pyx_k__a[] = "a";
static char __pyx_k__b[] = "b";
static char __pyx_k__d[] = "d";
static char __pyx_k__e[] = "e";
static char __pyx_k__f[] = "f";
static char __pyx_k__g[] = "g";
static char __pyx_k__h[] = "h";
static char __pyx_k__i[] = "i";
static char __pyx_k__l[] = "l";
static char __pyx_k__q[] = "q";
static char __pyx_k__u[] = "u";
static char __pyx_k__v[] = "v";
static char __pyx_k__x[] = "x";
static char __pyx_k__y[] = "y";
static char __pyx_k__z[] = "z";
static char __pyx_k__Zd[] = "Zd";
static char __pyx_k__Zf[] = "Zf";
static char __pyx_k__Zg[] = "Zg";
static char __pyx_k__cm[] = "cm";
static char __pyx_k__dx[] = "dx";
static char __pyx_k__dy[] = "dy";
static char __pyx_k__dz[] = "dz";
static char __pyx_k__fn[] = "fn";
static char __pyx_k__gi[] = "gi";
static char __pyx_k__np[] = "np";
static char __pyx_k__ns[] = "ns";
static char __pyx_k__nv[] = "nv";
static char __pyx_k__pv[] = "pv";
static char __pyx_k__px[] = "px";
static char __pyx_k__py[] = "py";
static char __pyx_k__rb[] = "rb";
static char __pyx_k__tf[] = "tf";
static char __pyx_k__ug[] = "ug";
static char __pyx_k__vp[] = "vp";
static char __pyx_k__wb[] = "wb";
static char __pyx_k__buf[] = "buf";
static char __pyx_k__dds[] = "dds";
static char __pyx_k__dpi[] = "dpi";
static char __pyx_k__dvs[] = "dvs";
static char __pyx_k__i_f[] = "i_f";
static char __pyx_k__i_i[] = "i_i";
static char __pyx_k__i_s[] = "i_s";
static char __pyx_k__ind[] = "ind";
static char __pyx_k__j_f[] = "j_f";
static char __pyx_k__j_i[] = "j_i";
static char __pyx_k__k_f[] = "k_f";
static char __pyx_k__k_i[] = "k_i";
static char __pyx_k__o_s[] = "o_s";
static char __pyx_k__obj[] = "obj";
static char __pyx_k__pdx[] = "pdx";
static char __pyx_k__pdy[] = "pdy";
static char __pyx_k__po2[] = "po2";
static char __pyx_k__pos[] = "pos";
static char __pyx_k__pxs[] = "pxs";
static char __pyx_k__pys[] = "pys";
static char __pyx_k__red[] = "red";
static char __pyx_k__val[] = "val";
static char __pyx_k__base[] = "base";
static char __pyx_k__blue[] = "blue";
static char __pyx_k__copy[] = "copy";
static char __pyx_k__data[] = "data";
static char __pyx_k__dbin[] = "dbin";
static char __pyx_k__dims[] = "dims";
static char __pyx_k__gray[] = "gray";
static char __pyx_k__grid[] = "grid";
static char __pyx_k__idds[] = "idds";
static char __pyx_k__imax[] = "imax";
static char __pyx_k__imin[] = "imin";
static char __pyx_k__int8[] = "int8";
static char __pyx_k__jmax[] = "jmax";
static char __pyx_k__jmin[] = "jmin";
static char __pyx_k__kmax[] = "kmax";
static char __pyx_k__kmin[] = "kmin";
static char __pyx_k__left[] = "left";
static char __pyx_k__mask[] = "mask";
static char __pyx_k__mass[] = "mass";
static char __pyx_k__ndim[] = "ndim";
static char __pyx_k__posx[] = "posx";
static char __pyx_k__posy[] = "posy";
static char __pyx_k__posz[] = "posz";
static char __pyx_k__x_is[] = "x_is";
static char __pyx_k__y_is[] = "y_is";
static char __pyx_k__z_is[] = "z_is";
static char __pyx_k__alpha[] = "alpha";
static char __pyx_k__coord[] = "coord";
static char __pyx_k__descr[] = "descr";
static char __pyx_k__dtype[] = "dtype";
static char __pyx_k__empty[] = "empty";
static char __pyx_k__field[] = "field";
static char __pyx_k__floor[] = "floor";
static char __pyx_k__green[] = "green";
static char __pyx_k__grids[] = "grids";
static char __pyx_k__idbin[] = "idbin";
static char __pyx_k__image[] = "image";
static char __pyx_k__int32[] = "int32";
static char __pyx_k__int64[] = "int64";
static char __pyx_k__joins[] = "joins";
static char __pyx_k__level[] = "level";
static char __pyx_k__names[] = "names";
static char __pyx_k__nbins[] = "nbins";
static char __pyx_k__numpy[] = "numpy";
static char __pyx_k__nvals[] = "nvals";
static char __pyx_k__order[] = "order";
static char __pyx_k__pmask[] = "pmask";
static char __pyx_k__pvals[] = "pvals";
static char __pyx_k__range[] = "range";
static char __pyx_k__shape[] = "shape";
static char __pyx_k__split[] = "split";
static char __pyx_k__stack[] = "stack";
static char __pyx_k__sweep[] = "sweep";
static char __pyx_k__table[] = "table";
static char __pyx_k__wvals[] = "wvals";
static char __pyx_k__x_vec[] = "x_vec";
static char __pyx_k__y_vec[] = "y_vec";
static char __pyx_k__zeros[] = "zeros";
static char __pyx_k__aimage[] = "aimage";
static char __pyx_k__ax_vec[] = "ax_vec";
static char __pyx_k__ay_vec[] = "ay_vec";
static char __pyx_k__bounds[] = "bounds";
static char __pyx_k__buffer[] = "buffer";
static char __pyx_k__center[] = "center";
static char __pyx_k__curpos[] = "curpos";
static char __pyx_k__fields[] = "fields";
static char __pyx_k__format[] = "format";
static char __pyx_k__grid_t[] = "grid_t";
static char __pyx_k__offset[] = "offset";
static char __pyx_k__output[] = "output";
static char __pyx_k__points[] = "points";
static char __pyx_k__shells[] = "shells";
static char __pyx_k__tables[] = "tables";
static char __pyx_k__tf_obj[] = "tf_obj";
static char __pyx_k__values[] = "values";
static char __pyx_k__vp_dir[] = "vp_dir";
static char __pyx_k__vp_pos[] = "vp_pos";
static char __pyx_k__x_bins[] = "x_bins";
static char __pyx_k__x_vals[] = "x_vals";
static char __pyx_k__xrange[] = "xrange";
static char __pyx_k__y_bins[] = "y_bins";
static char __pyx_k__y_vals[] = "y_vals";
static char __pyx_k__z_bins[] = "z_bins";
static char __pyx_k__z_vals[] = "z_vals";
static char __pyx_k__Channel[] = "Channel";
static char __pyx_k__acenter[] = "acenter";
static char __pyx_k__avp_dir[] = "avp_dir";
static char __pyx_k__avp_pos[] = "avp_pos";
static char __pyx_k__corners[] = "corners";
static char __pyx_k__float32[] = "float32";
static char __pyx_k__float64[] = "float64";
static char __pyx_k__grid_dt[] = "grid_dt";
static char __pyx_k__istride[] = "istride";
static char __pyx_k__jstride[] = "jstride";
static char __pyx_k__max_ind[] = "max_ind";
static char __pyx_k__my_data[] = "my_data";
static char __pyx_k__nshells[] = "nshells";
static char __pyx_k__refined[] = "refined";
static char __pyx_k__rot_mat[] = "rot_mat";
static char __pyx_k__strides[] = "strides";
static char __pyx_k__LeftEdge[] = "LeftEdge";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__cellSize[] = "cellSize";
static char __pyx_k__children[] = "children";
static char __pyx_k__field_id[] = "field_id";
static char __pyx_k__filename[] = "filename";
static char __pyx_k__grid_dds[] = "grid_dds";
static char __pyx_k__istorage[] = "istorage";
static char __pyx_k__itemsize[] = "itemsize";
static char __pyx_k__leftEdge[] = "leftEdge";
static char __pyx_k__n_fields[] = "n_fields";
static char __pyx_k__readonly[] = "readonly";
static char __pyx_k__type_num[] = "type_num";
static char __pyx_k__x_bounds[] = "x_bounds";
static char __pyx_k__RightEdge[] = "RightEdge";
static char __pyx_k__byteorder[] = "byteorder";
static char __pyx_k__copy_back[] = "copy_back";
static char __pyx_k__copy_into[] = "copy_into";
static char __pyx_k__direction[] = "direction";
static char __pyx_k__field_ids[] = "field_ids";
static char __pyx_k__genealogy[] = "genealogy";
static char __pyx_k__grid_mask[] = "grid_mask";
static char __pyx_k__left_edge[] = "left_edge";
static char __pyx_k__root_size[] = "root_size";
static char __pyx_k__slab_size[] = "slab_size";
static char __pyx_k__Transfer3D[] = "Transfer3D";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__box_center[] = "box_center";
static char __pyx_k__box_origin[] = "box_origin";
static char __pyx_k__child_mask[] = "child_mask";
static char __pyx_k__count_only[] = "count_only";
static char __pyx_k__dimensions[] = "dimensions";
static char __pyx_k__im_strides[] = "im_strides";
static char __pyx_k__left_edges[] = "left_edges";
static char __pyx_k__npositions[] = "npositions";
static char __pyx_k__output_pos[] = "output_pos";
static char __pyx_k__right_edge[] = "right_edge";
static char __pyx_k__root_nodes[] = "root_nodes";
static char __pyx_k__slab_start[] = "slab_start";
static char __pyx_k__suboffsets[] = "suboffsets";
static char __pyx_k__vd_strides[] = "vd_strides";
static char __pyx_k__vp_strides[] = "vp_strides";
static char __pyx_k__weight_val[] = "weight_val";
static char __pyx_k__box_lengths[] = "box_lengths";
static char __pyx_k__box_vectors[] = "box_vectors";
static char __pyx_k__break_first[] = "break_first";
static char __pyx_k__refined_pos[] = "refined_pos";
static char __pyx_k__start_index[] = "start_index";
static char __pyx_k__RuntimeError[] = "RuntimeError";
static char __pyx_k__field_tables[] = "field_tables";
static char __pyx_k__pass_through[] = "pass_through";
static char __pyx_k__proj_overlap[] = "proj_overlap";
static char __pyx_k__pweight_vals[] = "pweight_vals";
static char __pyx_k__child_indices[] = "child_indices";
static char __pyx_k__eval_transfer[] = "eval_transfer";
static char __pyx_k__gridDimension[] = "gridDimension";
static char __pyx_k__integrate_ray[] = "integrate_ray";
static char __pyx_k__sample_values[] = "sample_values";
static char __pyx_k__subgrid_faces[] = "subgrid_faces";
static char __pyx_k__top_grid_dims[] = "top_grid_dims";
static char __pyx_k__TransferShells[] = "TransferShells";
static char __pyx_k__count_at_level[] = "count_at_level";
static char __pyx_k__get_start_stop[] = "get_start_stop";
static char __pyx_k__grid_left_edge[] = "grid_left_edge";
static char __pyx_k__n_field_tables[] = "n_field_tables";
static char __pyx_k__parent_grid_id[] = "parent_grid_id";
static char __pyx_k__add_to_position[] = "add_to_position";
static char __pyx_k__field_table_ids[] = "field_table_ids";
static char __pyx_k__fill_from_level[] = "fill_from_level";
static char __pyx_k__grid_left_edges[] = "grid_left_edges";
static char __pyx_k__grid_right_edge[] = "grid_right_edge";
static char __pyx_k__my_field_tables[] = "my_field_tables";
static char __pyx_k__weight_field_id[] = "weight_field_id";
static char __pyx_k__weight_table_id[] = "weight_table_id";
static char __pyx_k__calculate_extent[] = "calculate_extent";
static char __pyx_k__grid_right_edges[] = "grid_right_edges";
static char __pyx_k__weight_field_ids[] = "weight_field_ids";
static char __pyx_k__weight_table_ids[] = "weight_table_ids";
static char __pyx_k__find_on_root_level[] = "find_on_root_level";
static PyObject *__pyx_n_s_1;
static PyObject *__pyx_kp_u_10;
static PyObject *__pyx_kp_u_11;
static PyObject *__pyx_kp_u_12;
static PyObject *__pyx_kp_u_14;
static PyObject *__pyx_kp_u_15;
static PyObject *__pyx_n_s_2;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_u_7;
static PyObject *__pyx_kp_u_8;
static PyObject *__pyx_kp_u_9;
static PyObject *__pyx_n_s__Channel;
static PyObject *__pyx_n_s__F;
static PyObject *__pyx_n_s__LeftEdge;
static PyObject *__pyx_n_s__RightEdge;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__Transfer3D;
static PyObject *__pyx_n_s__TransferShells;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s__a;
static PyObject *__pyx_n_s__acenter;
static PyObject *__pyx_n_s__add_to_position;
static PyObject *__pyx_n_s__aimage;
static PyObject *__pyx_n_s__alpha;
static PyObject *__pyx_n_s__avp_dir;
static PyObject *__pyx_n_s__avp_pos;
static PyObject *__pyx_n_s__ax_vec;
static PyObject *__pyx_n_s__ay_vec;
static PyObject *__pyx_n_s__base;
static PyObject *__pyx_n_s__blue;
static PyObject *__pyx_n_s__bounds;
static PyObject *__pyx_n_s__box_center;
static PyObject *__pyx_n_s__box_lengths;
static PyObject *__pyx_n_s__box_origin;
static PyObject *__pyx_n_s__box_vectors;
static PyObject *__pyx_n_s__break_first;
static PyObject *__pyx_n_s__buf;
static PyObject *__pyx_n_s__buffer;
static PyObject *__pyx_n_s__byteorder;
static PyObject *__pyx_n_s__calculate_extent;
static PyObject *__pyx_n_s__cellSize;
static PyObject *__pyx_n_s__center;
static PyObject *__pyx_n_s__child_indices;
static PyObject *__pyx_n_s__child_mask;
static PyObject *__pyx_n_s__children;
static PyObject *__pyx_n_s__cm;
static PyObject *__pyx_n_s__coord;
static PyObject *__pyx_n_s__copy;
static PyObject *__pyx_n_s__copy_back;
static PyObject *__pyx_n_s__copy_into;
static PyObject *__pyx_n_s__corners;
static PyObject *__pyx_n_s__count_at_level;
static PyObject *__pyx_n_s__count_only;
static PyObject *__pyx_n_s__curpos;
static PyObject *__pyx_n_s__data;
static PyObject *__pyx_n_s__dbin;
static PyObject *__pyx_n_s__dds;
static PyObject *__pyx_n_s__descr;
static PyObject *__pyx_n_s__dimensions;
static PyObject *__pyx_n_s__dims;
static PyObject *__pyx_n_s__direction;
static PyObject *__pyx_n_s__dpi;
static PyObject *__pyx_n_s__dtype;
static PyObject *__pyx_n_s__dvs;
static PyObject *__pyx_n_s__dx;
static PyObject *__pyx_n_s__dy;
static PyObject *__pyx_n_s__dz;
static PyObject *__pyx_n_s__e;
static PyObject *__pyx_n_s__empty;
static PyObject *__pyx_n_s__eval_transfer;
static PyObject *__pyx_n_s__field;
static PyObject *__pyx_n_s__field_id;
static PyObject *__pyx_n_s__field_ids;
static PyObject *__pyx_n_s__field_table_ids;
static PyObject *__pyx_n_s__field_tables;
static PyObject *__pyx_n_s__fields;
static PyObject *__pyx_n_s__filename;
static PyObject *__pyx_n_s__fill_from_level;
static PyObject *__pyx_n_s__find_on_root_level;
static PyObject *__pyx_n_s__float32;
static PyObject *__pyx_n_s__float64;
static PyObject *__pyx_n_s__floor;
static PyObject *__pyx_n_s__fn;
static PyObject *__pyx_n_s__format;
static PyObject *__pyx_n_s__genealogy;
static PyObject *__pyx_n_s__get_start_stop;
static PyObject *__pyx_n_s__gi;
static PyObject *__pyx_n_s__gray;
static PyObject *__pyx_n_s__green;
static PyObject *__pyx_n_s__grid;
static PyObject *__pyx_n_s__gridDimension;
static PyObject *__pyx_n_s__grid_dds;
static PyObject *__pyx_n_s__grid_dt;
static PyObject *__pyx_n_s__grid_left_edge;
static PyObject *__pyx_n_s__grid_left_edges;
static PyObject *__pyx_n_s__grid_mask;
static PyObject *__pyx_n_s__grid_right_edge;
static PyObject *__pyx_n_s__grid_right_edges;
static PyObject *__pyx_n_s__grid_t;
static PyObject *__pyx_n_s__grids;
static PyObject *__pyx_n_s__i_f;
static PyObject *__pyx_n_s__i_i;
static PyObject *__pyx_n_s__i_s;
static PyObject *__pyx_n_s__idbin;
static PyObject *__pyx_n_s__idds;
static PyObject *__pyx_n_s__im_strides;
static PyObject *__pyx_n_s__image;
static PyObject *__pyx_n_s__imax;
static PyObject *__pyx_n_s__imin;
static PyObject *__pyx_n_s__ind;
static PyObject *__pyx_n_s__int32;
static PyObject *__pyx_n_s__int64;
static PyObject *__pyx_n_s__int8;
static PyObject *__pyx_n_s__integrate_ray;
static PyObject *__pyx_n_s__istorage;
static PyObject *__pyx_n_s__istride;
static PyObject *__pyx_n_s__itemsize;
static PyObject *__pyx_n_s__j_f;
static PyObject *__pyx_n_s__j_i;
static PyObject *__pyx_n_s__jmax;
static PyObject *__pyx_n_s__jmin;
static PyObject *__pyx_n_s__joins;
static PyObject *__pyx_n_s__jstride;
static PyObject *__pyx_n_s__k_f;
static PyObject *__pyx_n_s__k_i;
static PyObject *__pyx_n_s__kmax;
static PyObject *__pyx_n_s__kmin;
static PyObject *__pyx_n_s__left;
static PyObject *__pyx_n_s__leftEdge;
static PyObject *__pyx_n_s__left_edge;
static PyObject *__pyx_n_s__left_edges;
static PyObject *__pyx_n_s__level;
static PyObject *__pyx_n_s__mask;
static PyObject *__pyx_n_s__mass;
static PyObject *__pyx_n_s__max_ind;
static PyObject *__pyx_n_s__my_data;
static PyObject *__pyx_n_s__my_field_tables;
static PyObject *__pyx_n_s__n_field_tables;
static PyObject *__pyx_n_s__n_fields;
static PyObject *__pyx_n_s__names;
static PyObject *__pyx_n_s__nbins;
static PyObject *__pyx_n_s__ndim;
static PyObject *__pyx_n_s__np;
static PyObject *__pyx_n_s__npositions;
static PyObject *__pyx_n_s__ns;
static PyObject *__pyx_n_s__nshells;
static PyObject *__pyx_n_s__numpy;
static PyObject *__pyx_n_s__nv;
static PyObject *__pyx_n_s__nvals;
static PyObject *__pyx_n_s__o_s;
static PyObject *__pyx_n_s__obj;
static PyObject *__pyx_n_s__offset;
static PyObject *__pyx_n_s__order;
static PyObject *__pyx_n_s__output;
static PyObject *__pyx_n_s__output_pos;
static PyObject *__pyx_n_s__parent_grid_id;
static PyObject *__pyx_n_s__pass_through;
static PyObject *__pyx_n_s__pdx;
static PyObject *__pyx_n_s__pdy;
static PyObject *__pyx_n_s__pmask;
static PyObject *__pyx_n_s__po2;
static PyObject *__pyx_n_s__points;
static PyObject *__pyx_n_s__pos;
static PyObject *__pyx_n_s__posx;
static PyObject *__pyx_n_s__posy;
static PyObject *__pyx_n_s__posz;
static PyObject *__pyx_n_s__proj_overlap;
static PyObject *__pyx_n_s__pv;
static PyObject *__pyx_n_s__pvals;
static PyObject *__pyx_n_s__pweight_vals;
static PyObject *__pyx_n_s__px;
static PyObject *__pyx_n_s__pxs;
static PyObject *__pyx_n_s__py;
static PyObject *__pyx_n_s__pys;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__readonly;
static PyObject *__pyx_n_s__red;
static PyObject *__pyx_n_s__refined;
static PyObject *__pyx_n_s__refined_pos;
static PyObject *__pyx_n_s__right_edge;
static PyObject *__pyx_n_s__root_nodes;
static PyObject *__pyx_n_s__root_size;
static PyObject *__pyx_n_s__rot_mat;
static PyObject *__pyx_n_s__sample_values;
static PyObject *__pyx_n_s__shape;
static PyObject *__pyx_n_s__shells;
static PyObject *__pyx_n_s__slab_size;
static PyObject *__pyx_n_s__slab_start;
static PyObject *__pyx_n_s__split;
static PyObject *__pyx_n_s__stack;
static PyObject *__pyx_n_s__start_index;
static PyObject *__pyx_n_s__strides;
static PyObject *__pyx_n_s__subgrid_faces;
static PyObject *__pyx_n_s__suboffsets;
static PyObject *__pyx_n_s__sweep;
static PyObject *__pyx_n_s__table;
static PyObject *__pyx_n_s__tables;
static PyObject *__pyx_n_s__tf;
static PyObject *__pyx_n_s__tf_obj;
static PyObject *__pyx_n_s__top_grid_dims;
static PyObject *__pyx_n_s__type_num;
static PyObject *__pyx_n_s__u;
static PyObject *__pyx_n_s__ug;
static PyObject *__pyx_n_s__v;
static PyObject *__pyx_n_s__val;
static PyObject *__pyx_n_s__values;
static PyObject *__pyx_n_s__vd_strides;
static PyObject *__pyx_n_s__vp;
static PyObject *__pyx_n_s__vp_dir;
static PyObject *__pyx_n_s__vp_pos;
static PyObject *__pyx_n_s__vp_strides;
static PyObject *__pyx_n_s__weight_field_id;
static PyObject *__pyx_n_s__weight_field_ids;
static PyObject *__pyx_n_s__weight_table_id;
static PyObject *__pyx_n_s__weight_table_ids;
static PyObject *__pyx_n_s__weight_val;
static PyObject *__pyx_n_s__wvals;
static PyObject *__pyx_n_s__x;
static PyObject *__pyx_n_s__x_bins;
static PyObject *__pyx_n_s__x_bounds;
static PyObject *__pyx_n_s__x_is;
static PyObject *__pyx_n_s__x_vals;
static PyObject *__pyx_n_s__x_vec;
static PyObject *__pyx_n_s__xrange;
static PyObject *__pyx_n_s__y;
static PyObject *__pyx_n_s__y_bins;
static PyObject *__pyx_n_s__y_is;
static PyObject *__pyx_n_s__y_vals;
static PyObject *__pyx_n_s__y_vec;
static PyObject *__pyx_n_s__z;
static PyObject *__pyx_n_s__z_bins;
static PyObject *__pyx_n_s__z_is;
static PyObject *__pyx_n_s__z_vals;
static PyObject *__pyx_n_s__zeros;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_int_15;

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":32
 * cdef class position:
 *     cdef public int output_pos, refined_pos
 *     def __cinit__(self):             # <<<<<<<<<<<<<<
 *         self.output_pos = 0
 *         self.refined_pos = 0
 */

static int __pyx_pf_2yt_9amr_utils_8position___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_2yt_9amr_utils_8position___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":33
 *     cdef public int output_pos, refined_pos
 *     def __cinit__(self):
 *         self.output_pos = 0             # <<<<<<<<<<<<<<
 *         self.refined_pos = 0
 * 
 */
  ((struct __pyx_obj_2yt_9amr_utils_position *)__pyx_v_self)->output_pos = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":34
 *     def __cinit__(self):
 *         self.output_pos = 0
 *         self.refined_pos = 0             # <<<<<<<<<<<<<<
 * 
 * cdef class OctreeGrid:
 */
  ((struct __pyx_obj_2yt_9amr_utils_position *)__pyx_v_self)->refined_pos = 0;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":39
 *     cdef public object child_indices, fields, left_edges, dimensions, dx
 *     cdef public int level
 *     def __cinit__(self,             # <<<<<<<<<<<<<<
 *                   np.ndarray[np.int32_t, ndim=3] child_indices,
 *                   np.ndarray[np.float64_t, ndim=4] fields,
 */

static int __pyx_pf_2yt_9amr_utils_10OctreeGrid___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_2yt_9amr_utils_10OctreeGrid___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_child_indices = 0;
  PyArrayObject *__pyx_v_fields = 0;
  PyArrayObject *__pyx_v_left_edges = 0;
  PyArrayObject *__pyx_v_dimensions = 0;
  PyArrayObject *__pyx_v_dx = 0;
  int __pyx_v_level;
  Py_buffer __pyx_bstruct_child_indices;
  Py_ssize_t __pyx_bstride_0_child_indices = 0;
  Py_ssize_t __pyx_bstride_1_child_indices = 0;
  Py_ssize_t __pyx_bstride_2_child_indices = 0;
  Py_ssize_t __pyx_bshape_0_child_indices = 0;
  Py_ssize_t __pyx_bshape_1_child_indices = 0;
  Py_ssize_t __pyx_bshape_2_child_indices = 0;
  Py_buffer __pyx_bstruct_fields;
  Py_ssize_t __pyx_bstride_0_fields = 0;
  Py_ssize_t __pyx_bstride_1_fields = 0;
  Py_ssize_t __pyx_bstride_2_fields = 0;
  Py_ssize_t __pyx_bstride_3_fields = 0;
  Py_ssize_t __pyx_bshape_0_fields = 0;
  Py_ssize_t __pyx_bshape_1_fields = 0;
  Py_ssize_t __pyx_bshape_2_fields = 0;
  Py_ssize_t __pyx_bshape_3_fields = 0;
  Py_buffer __pyx_bstruct_dx;
  Py_ssize_t __pyx_bstride_0_dx = 0;
  Py_ssize_t __pyx_bshape_0_dx = 0;
  Py_buffer __pyx_bstruct_left_edges;
  Py_ssize_t __pyx_bstride_0_left_edges = 0;
  Py_ssize_t __pyx_bshape_0_left_edges = 0;
  Py_buffer __pyx_bstruct_dimensions;
  Py_ssize_t __pyx_bstride_0_dimensions = 0;
  Py_ssize_t __pyx_bshape_0_dimensions = 0;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__child_indices,&__pyx_n_s__fields,&__pyx_n_s__left_edges,&__pyx_n_s__dimensions,&__pyx_n_s__dx,&__pyx_n_s__level,0};
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[6] = {0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__child_indices);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fields);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__left_edges);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dimensions);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dx);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__level);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_child_indices = ((PyArrayObject *)values[0]);
    __pyx_v_fields = ((PyArrayObject *)values[1]);
    __pyx_v_left_edges = ((PyArrayObject *)values[2]);
    __pyx_v_dimensions = ((PyArrayObject *)values[3]);
    __pyx_v_dx = ((PyArrayObject *)values[4]);
    __pyx_v_level = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_level == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_child_indices = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_fields = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_left_edges = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_dimensions = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_dx = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_level = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_level == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.OctreeGrid.__cinit__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_bstruct_child_indices.buf = NULL;
  __pyx_bstruct_fields.buf = NULL;
  __pyx_bstruct_left_edges.buf = NULL;
  __pyx_bstruct_dimensions.buf = NULL;
  __pyx_bstruct_dx.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child_indices), __pyx_ptype_5numpy_ndarray, 1, "child_indices", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fields), __pyx_ptype_5numpy_ndarray, 1, "fields", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_left_edges), __pyx_ptype_5numpy_ndarray, 1, "left_edges", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dimensions), __pyx_ptype_5numpy_ndarray, 1, "dimensions", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dx), __pyx_ptype_5numpy_ndarray, 1, "dx", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_child_indices, (PyObject*)__pyx_v_child_indices, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_child_indices = __pyx_bstruct_child_indices.strides[0]; __pyx_bstride_1_child_indices = __pyx_bstruct_child_indices.strides[1]; __pyx_bstride_2_child_indices = __pyx_bstruct_child_indices.strides[2];
  __pyx_bshape_0_child_indices = __pyx_bstruct_child_indices.shape[0]; __pyx_bshape_1_child_indices = __pyx_bstruct_child_indices.shape[1]; __pyx_bshape_2_child_indices = __pyx_bstruct_child_indices.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_fields, (PyObject*)__pyx_v_fields, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 4, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_fields = __pyx_bstruct_fields.strides[0]; __pyx_bstride_1_fields = __pyx_bstruct_fields.strides[1]; __pyx_bstride_2_fields = __pyx_bstruct_fields.strides[2]; __pyx_bstride_3_fields = __pyx_bstruct_fields.strides[3];
  __pyx_bshape_0_fields = __pyx_bstruct_fields.shape[0]; __pyx_bshape_1_fields = __pyx_bstruct_fields.shape[1]; __pyx_bshape_2_fields = __pyx_bstruct_fields.shape[2]; __pyx_bshape_3_fields = __pyx_bstruct_fields.shape[3];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_left_edges, (PyObject*)__pyx_v_left_edges, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_left_edges = __pyx_bstruct_left_edges.strides[0];
  __pyx_bshape_0_left_edges = __pyx_bstruct_left_edges.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dimensions, (PyObject*)__pyx_v_dimensions, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_dimensions = __pyx_bstruct_dimensions.strides[0];
  __pyx_bshape_0_dimensions = __pyx_bstruct_dimensions.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dx, (PyObject*)__pyx_v_dx, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_dx = __pyx_bstruct_dx.strides[0];
  __pyx_bshape_0_dx = __pyx_bstruct_dx.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":46
 *                   np.ndarray[np.float64_t, ndim=1] dx,
 *                   int level):
 *         self.child_indices = child_indices             # <<<<<<<<<<<<<<
 *         self.fields = fields
 *         self.left_edges = left_edges
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_child_indices));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_child_indices));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->child_indices);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->child_indices);
  ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->child_indices = ((PyObject *)__pyx_v_child_indices);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":47
 *                   int level):
 *         self.child_indices = child_indices
 *         self.fields = fields             # <<<<<<<<<<<<<<
 *         self.left_edges = left_edges
 *         self.dimensions = dimensions
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_fields));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_fields));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->fields);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->fields);
  ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->fields = ((PyObject *)__pyx_v_fields);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":48
 *         self.child_indices = child_indices
 *         self.fields = fields
 *         self.left_edges = left_edges             # <<<<<<<<<<<<<<
 *         self.dimensions = dimensions
 *         self.dx = dx
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_left_edges));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_left_edges));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->left_edges);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->left_edges);
  ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->left_edges = ((PyObject *)__pyx_v_left_edges);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":49
 *         self.fields = fields
 *         self.left_edges = left_edges
 *         self.dimensions = dimensions             # <<<<<<<<<<<<<<
 *         self.dx = dx
 *         self.level = level
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_dimensions));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dimensions));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->dimensions);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->dimensions);
  ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->dimensions = ((PyObject *)__pyx_v_dimensions);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":50
 *         self.left_edges = left_edges
 *         self.dimensions = dimensions
 *         self.dx = dx             # <<<<<<<<<<<<<<
 *         self.level = level
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_dx));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dx));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->dx);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->dx);
  ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->dx = ((PyObject *)__pyx_v_dx);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":51
 *         self.dimensions = dimensions
 *         self.dx = dx
 *         self.level = level             # <<<<<<<<<<<<<<
 * 
 * cdef class OctreeGridList:
 */
  ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_v_self)->level = __pyx_v_level;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_indices);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_fields);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edges);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dimensions);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.OctreeGrid.__cinit__");
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_indices);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_fields);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edges);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dimensions);
  __pyx_L2:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":55
 * cdef class OctreeGridList:
 *     cdef public object grids
 *     def __cinit__(self, grids):             # <<<<<<<<<<<<<<
 *         self.grids = grids
 * 
 */

static int __pyx_pf_2yt_9amr_utils_14OctreeGridList___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_2yt_9amr_utils_14OctreeGridList___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_grids = 0;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__grids,0};
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grids);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_grids = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_grids = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.OctreeGridList.__cinit__");
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":56
 *     cdef public object grids
 *     def __cinit__(self, grids):
 *         self.grids = grids             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, int item):
 */
  __Pyx_INCREF(__pyx_v_grids);
  __Pyx_GIVEREF(__pyx_v_grids);
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)__pyx_v_self)->grids);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)__pyx_v_self)->grids);
  ((struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)__pyx_v_self)->grids = __pyx_v_grids;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":58
 *         self.grids = grids
 * 
 *     def __getitem__(self, int item):             # <<<<<<<<<<<<<<
 *         return self.grids[item]
 * 
 */

static PyObject *__pyx_pf_2yt_9amr_utils_14OctreeGridList___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_item); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_14OctreeGridList___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_item) {
  int __pyx_v_item;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__getitem__");
  assert(__pyx_arg_item); {
    __pyx_v_item = __Pyx_PyInt_AsInt(__pyx_arg_item); if (unlikely((__pyx_v_item == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.OctreeGridList.__getitem__");
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":59
 * 
 *     def __getitem__(self, int item):
 *         return self.grids[item]             # <<<<<<<<<<<<<<
 * 
 * @cython.boundscheck(False)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(((struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)__pyx_v_self)->grids, __pyx_v_item, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("yt.amr_utils.OctreeGridList.__getitem__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":62
 * 
 * @cython.boundscheck(False)
 * def RecurseOctreeDepthFirst(int i_i, int j_i, int k_i,             # <<<<<<<<<<<<<<
 *                             int i_f, int j_f, int k_f,
 *                             position curpos, int gi,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_RecurseOctreeDepthFirst(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_RecurseOctreeDepthFirst(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_i_i;
  int __pyx_v_j_i;
  int __pyx_v_k_i;
  int __pyx_v_i_f;
  int __pyx_v_j_f;
  int __pyx_v_k_f;
  struct __pyx_obj_2yt_9amr_utils_position *__pyx_v_curpos = 0;
  int __pyx_v_gi;
  PyArrayObject *__pyx_v_output = 0;
  PyArrayObject *__pyx_v_refined = 0;
  struct __pyx_obj_2yt_9amr_utils_OctreeGridList *__pyx_v_grids = 0;
  int __pyx_v_i;
  int __pyx_v_i_off;
  int __pyx_v_j;
  int __pyx_v_j_off;
  int __pyx_v_k;
  int __pyx_v_k_off;
  int __pyx_v_ci;
  int __pyx_v_fi;
  int __pyx_v_child_i;
  int __pyx_v_child_j;
  int __pyx_v_child_k;
  struct __pyx_obj_2yt_9amr_utils_OctreeGrid *__pyx_v_child_grid;
  struct __pyx_obj_2yt_9amr_utils_OctreeGrid *__pyx_v_grid = 0;
  PyArrayObject *__pyx_v_child_indices = 0;
  PyArrayObject *__pyx_v_dimensions = 0;
  PyArrayObject *__pyx_v_fields = 0;
  PyArrayObject *__pyx_v_leftedges = 0;
  __pyx_t_5numpy_float64_t __pyx_v_dx;
  __pyx_t_5numpy_float64_t __pyx_v_child_dx;
  PyArrayObject *__pyx_v_child_leftedges;
  __pyx_t_5numpy_float64_t __pyx_v_cx;
  __pyx_t_5numpy_float64_t __pyx_v_cy;
  __pyx_t_5numpy_float64_t __pyx_v_cz;
  PyObject *__pyx_v_s;
  Py_buffer __pyx_bstruct_leftedges;
  Py_ssize_t __pyx_bstride_0_leftedges = 0;
  Py_ssize_t __pyx_bshape_0_leftedges = 0;
  Py_buffer __pyx_bstruct_refined;
  Py_ssize_t __pyx_bstride_0_refined = 0;
  Py_ssize_t __pyx_bshape_0_refined = 0;
  Py_buffer __pyx_bstruct_child_leftedges;
  Py_ssize_t __pyx_bstride_0_child_leftedges = 0;
  Py_ssize_t __pyx_bshape_0_child_leftedges = 0;
  Py_buffer __pyx_bstruct_dimensions;
  Py_ssize_t __pyx_bstride_0_dimensions = 0;
  Py_ssize_t __pyx_bshape_0_dimensions = 0;
  Py_buffer __pyx_bstruct_child_indices;
  Py_ssize_t __pyx_bstride_0_child_indices = 0;
  Py_ssize_t __pyx_bstride_1_child_indices = 0;
  Py_ssize_t __pyx_bstride_2_child_indices = 0;
  Py_ssize_t __pyx_bshape_0_child_indices = 0;
  Py_ssize_t __pyx_bshape_1_child_indices = 0;
  Py_ssize_t __pyx_bshape_2_child_indices = 0;
  Py_buffer __pyx_bstruct_fields;
  Py_ssize_t __pyx_bstride_0_fields = 0;
  Py_ssize_t __pyx_bstride_1_fields = 0;
  Py_ssize_t __pyx_bstride_2_fields = 0;
  Py_ssize_t __pyx_bstride_3_fields = 0;
  Py_ssize_t __pyx_bshape_0_fields = 0;
  Py_ssize_t __pyx_bshape_1_fields = 0;
  Py_ssize_t __pyx_bshape_2_fields = 0;
  Py_ssize_t __pyx_bshape_3_fields = 0;
  Py_buffer __pyx_bstruct_output;
  Py_ssize_t __pyx_bstride_0_output = 0;
  Py_ssize_t __pyx_bstride_1_output = 0;
  Py_ssize_t __pyx_bshape_0_output = 0;
  Py_ssize_t __pyx_bshape_1_output = 0;
  PyObject *__pyx_r = NULL;
  long __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyArrayObject *__pyx_t_3 = NULL;
  PyArrayObject *__pyx_t_4 = NULL;
  PyArrayObject *__pyx_t_5 = NULL;
  PyArrayObject *__pyx_t_6 = NULL;
  __pyx_t_5numpy_float64_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  long __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  long __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  int __pyx_t_19;
  int __pyx_t_20;
  npy_intp __pyx_t_21;
  int __pyx_t_22;
  int __pyx_t_23;
  int __pyx_t_24;
  int __pyx_t_25;
  int __pyx_t_26;
  int __pyx_t_27;
  int __pyx_t_28;
  long __pyx_t_29;
  PyArrayObject *__pyx_t_30 = NULL;
  int __pyx_t_31;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  PyObject *__pyx_t_34 = NULL;
  long __pyx_t_35;
  long __pyx_t_36;
  PyObject *__pyx_t_37 = NULL;
  PyObject *__pyx_t_38 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__i_i,&__pyx_n_s__j_i,&__pyx_n_s__k_i,&__pyx_n_s__i_f,&__pyx_n_s__j_f,&__pyx_n_s__k_f,&__pyx_n_s__curpos,&__pyx_n_s__gi,&__pyx_n_s__output,&__pyx_n_s__refined,&__pyx_n_s__grids,0};
  __Pyx_RefNannySetupContext("RecurseOctreeDepthFirst");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_i);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__j_i);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeDepthFirst", 1, 11, 11, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k_i);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeDepthFirst", 1, 11, 11, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_f);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeDepthFirst", 1, 11, 11, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__j_f);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeDepthFirst", 1, 11, 11, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k_f);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeDepthFirst", 1, 11, 11, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__curpos);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeDepthFirst", 1, 11, 11, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  7:
      values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__gi);
      if (likely(values[7])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeDepthFirst", 1, 11, 11, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  8:
      values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__output);
      if (likely(values[8])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeDepthFirst", 1, 11, 11, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  9:
      values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__refined);
      if (likely(values[9])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeDepthFirst", 1, 11, 11, 9); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case 10:
      values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grids);
      if (likely(values[10])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeDepthFirst", 1, 11, 11, 10); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "RecurseOctreeDepthFirst") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_i_i = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_i_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_j_i = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_j_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k_i = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_k_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_i_f = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_i_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_j_f = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_j_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k_f = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_k_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_curpos = ((struct __pyx_obj_2yt_9amr_utils_position *)values[6]);
    __pyx_v_gi = __Pyx_PyInt_AsInt(values[7]); if (unlikely((__pyx_v_gi == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_output = ((PyArrayObject *)values[8]);
    __pyx_v_refined = ((PyArrayObject *)values[9]);
    __pyx_v_grids = ((struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)values[10]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 11) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_i_i = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_i_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_j_i = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_j_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k_i = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_k_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_i_f = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_i_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_j_f = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_j_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k_f = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_k_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_curpos = ((struct __pyx_obj_2yt_9amr_utils_position *)PyTuple_GET_ITEM(__pyx_args, 6));
    __pyx_v_gi = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 7)); if (unlikely((__pyx_v_gi == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_output = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 8));
    __pyx_v_refined = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 9));
    __pyx_v_grids = ((struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)PyTuple_GET_ITEM(__pyx_args, 10));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("RecurseOctreeDepthFirst", 1, 11, 11, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.RecurseOctreeDepthFirst");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_curpos);
  __Pyx_INCREF((PyObject *)__pyx_v_output);
  __Pyx_INCREF((PyObject *)__pyx_v_refined);
  __Pyx_INCREF((PyObject *)__pyx_v_grids);
  __pyx_v_child_grid = ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_child_leftedges = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
  __pyx_bstruct_child_indices.buf = NULL;
  __pyx_bstruct_dimensions.buf = NULL;
  __pyx_bstruct_fields.buf = NULL;
  __pyx_bstruct_leftedges.buf = NULL;
  __pyx_bstruct_child_leftedges.buf = NULL;
  __pyx_bstruct_output.buf = NULL;
  __pyx_bstruct_refined.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_curpos), __pyx_ptype_2yt_9amr_utils_position, 1, "curpos", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output), __pyx_ptype_5numpy_ndarray, 1, "output", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_refined), __pyx_ptype_5numpy_ndarray, 1, "refined", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grids), __pyx_ptype_2yt_9amr_utils_OctreeGridList, 1, "grids", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_output, (PyObject*)__pyx_v_output, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_output = __pyx_bstruct_output.strides[0]; __pyx_bstride_1_output = __pyx_bstruct_output.strides[1];
  __pyx_bshape_0_output = __pyx_bstruct_output.shape[0]; __pyx_bshape_1_output = __pyx_bstruct_output.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_refined, (PyObject*)__pyx_v_refined, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_refined = __pyx_bstruct_refined.strides[0];
  __pyx_bshape_0_refined = __pyx_bstruct_refined.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":71
 *     cdef int child_i, child_j, child_k
 *     cdef OctreeGrid child_grid
 *     cdef OctreeGrid grid = grids[gi-1]             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.int32_t, ndim=3] child_indices = grid.child_indices
 *     cdef np.ndarray[np.int32_t, ndim=1] dimensions = grid.dimensions
 */
  __pyx_t_1 = (__pyx_v_gi - 1);
  __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_grids), __pyx_t_1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_2yt_9amr_utils_OctreeGrid))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_grid = ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":72
 *     cdef OctreeGrid child_grid
 *     cdef OctreeGrid grid = grids[gi-1]
 *     cdef np.ndarray[np.int32_t, ndim=3] child_indices = grid.child_indices             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.int32_t, ndim=1] dimensions = grid.dimensions
 *     cdef np.ndarray[np.float64_t, ndim=4] fields = grid.fields
 */
  if (!(likely(((__pyx_v_grid->child_indices) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_grid->child_indices, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((PyArrayObject *)__pyx_v_grid->child_indices);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_child_indices, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_child_indices = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_child_indices.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_child_indices = __pyx_bstruct_child_indices.strides[0]; __pyx_bstride_1_child_indices = __pyx_bstruct_child_indices.strides[1]; __pyx_bstride_2_child_indices = __pyx_bstruct_child_indices.strides[2];
      __pyx_bshape_0_child_indices = __pyx_bstruct_child_indices.shape[0]; __pyx_bshape_1_child_indices = __pyx_bstruct_child_indices.shape[1]; __pyx_bshape_2_child_indices = __pyx_bstruct_child_indices.shape[2];
    }
  }
  __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_grid->child_indices);
  __pyx_v_child_indices = ((PyArrayObject *)__pyx_v_grid->child_indices);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":73
 *     cdef OctreeGrid grid = grids[gi-1]
 *     cdef np.ndarray[np.int32_t, ndim=3] child_indices = grid.child_indices
 *     cdef np.ndarray[np.int32_t, ndim=1] dimensions = grid.dimensions             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.float64_t, ndim=4] fields = grid.fields
 *     cdef np.ndarray[np.float64_t, ndim=1] leftedges = grid.left_edges
 */
  if (!(likely(((__pyx_v_grid->dimensions) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_grid->dimensions, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = ((PyArrayObject *)__pyx_v_grid->dimensions);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dimensions, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_dimensions = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_dimensions.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_dimensions = __pyx_bstruct_dimensions.strides[0];
      __pyx_bshape_0_dimensions = __pyx_bstruct_dimensions.shape[0];
    }
  }
  __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_grid->dimensions);
  __pyx_v_dimensions = ((PyArrayObject *)__pyx_v_grid->dimensions);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":74
 *     cdef np.ndarray[np.int32_t, ndim=3] child_indices = grid.child_indices
 *     cdef np.ndarray[np.int32_t, ndim=1] dimensions = grid.dimensions
 *     cdef np.ndarray[np.float64_t, ndim=4] fields = grid.fields             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.float64_t, ndim=1] leftedges = grid.left_edges
 *     cdef np.float64_t dx = grid.dx[0]
 */
  if (!(likely(((__pyx_v_grid->fields) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_grid->fields, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_v_grid->fields);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_fields, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 4, 0, __pyx_stack) == -1)) {
      __pyx_v_fields = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_fields.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_fields = __pyx_bstruct_fields.strides[0]; __pyx_bstride_1_fields = __pyx_bstruct_fields.strides[1]; __pyx_bstride_2_fields = __pyx_bstruct_fields.strides[2]; __pyx_bstride_3_fields = __pyx_bstruct_fields.strides[3];
      __pyx_bshape_0_fields = __pyx_bstruct_fields.shape[0]; __pyx_bshape_1_fields = __pyx_bstruct_fields.shape[1]; __pyx_bshape_2_fields = __pyx_bstruct_fields.shape[2]; __pyx_bshape_3_fields = __pyx_bstruct_fields.shape[3];
    }
  }
  __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_grid->fields);
  __pyx_v_fields = ((PyArrayObject *)__pyx_v_grid->fields);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":75
 *     cdef np.ndarray[np.int32_t, ndim=1] dimensions = grid.dimensions
 *     cdef np.ndarray[np.float64_t, ndim=4] fields = grid.fields
 *     cdef np.ndarray[np.float64_t, ndim=1] leftedges = grid.left_edges             # <<<<<<<<<<<<<<
 *     cdef np.float64_t dx = grid.dx[0]
 *     cdef np.float64_t child_dx
 */
  if (!(likely(((__pyx_v_grid->left_edges) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_grid->left_edges, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_v_grid->left_edges);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_leftedges, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_leftedges = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_leftedges.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_leftedges = __pyx_bstruct_leftedges.strides[0];
      __pyx_bshape_0_leftedges = __pyx_bstruct_leftedges.shape[0];
    }
  }
  __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_grid->left_edges);
  __pyx_v_leftedges = ((PyArrayObject *)__pyx_v_grid->left_edges);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":76
 *     cdef np.ndarray[np.float64_t, ndim=4] fields = grid.fields
 *     cdef np.ndarray[np.float64_t, ndim=1] leftedges = grid.left_edges
 *     cdef np.float64_t dx = grid.dx[0]             # <<<<<<<<<<<<<<
 *     cdef np.float64_t child_dx
 *     cdef np.ndarray[np.float64_t, ndim=1] child_leftedges
 */
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_grid->dx, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_7 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_dx = __pyx_t_7;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":80
 *     cdef np.ndarray[np.float64_t, ndim=1] child_leftedges
 *     cdef np.float64_t cx, cy, cz
 *     for k_off in range(k_f):             # <<<<<<<<<<<<<<
 *         k = k_off + k_i
 *         cz = (leftedges[2] + k*dx)
 */
  __pyx_t_8 = __pyx_v_k_f;
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
    __pyx_v_k_off = __pyx_t_9;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":81
 *     cdef np.float64_t cx, cy, cz
 *     for k_off in range(k_f):
 *         k = k_off + k_i             # <<<<<<<<<<<<<<
 *         cz = (leftedges[2] + k*dx)
 *         for j_off in range(j_f):
 */
    __pyx_v_k = (__pyx_v_k_off + __pyx_v_k_i);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":82
 *     for k_off in range(k_f):
 *         k = k_off + k_i
 *         cz = (leftedges[2] + k*dx)             # <<<<<<<<<<<<<<
 *         for j_off in range(j_f):
 *             j = j_off + j_i
 */
    __pyx_t_1 = 2;
    if (__pyx_t_1 < 0) __pyx_t_1 += __pyx_bshape_0_leftedges;
    __pyx_v_cz = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_leftedges.buf, __pyx_t_1, __pyx_bstride_0_leftedges)) + (__pyx_v_k * __pyx_v_dx));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":83
 *         k = k_off + k_i
 *         cz = (leftedges[2] + k*dx)
 *         for j_off in range(j_f):             # <<<<<<<<<<<<<<
 *             j = j_off + j_i
 *             cy = (leftedges[1] + j*dx)
 */
    __pyx_t_10 = __pyx_v_j_f;
    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
      __pyx_v_j_off = __pyx_t_11;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":84
 *         cz = (leftedges[2] + k*dx)
 *         for j_off in range(j_f):
 *             j = j_off + j_i             # <<<<<<<<<<<<<<
 *             cy = (leftedges[1] + j*dx)
 *             for i_off in range(i_f):
 */
      __pyx_v_j = (__pyx_v_j_off + __pyx_v_j_i);

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":85
 *         for j_off in range(j_f):
 *             j = j_off + j_i
 *             cy = (leftedges[1] + j*dx)             # <<<<<<<<<<<<<<
 *             for i_off in range(i_f):
 *                 i = i_off + i_i
 */
      __pyx_t_12 = 1;
      if (__pyx_t_12 < 0) __pyx_t_12 += __pyx_bshape_0_leftedges;
      __pyx_v_cy = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_leftedges.buf, __pyx_t_12, __pyx_bstride_0_leftedges)) + (__pyx_v_j * __pyx_v_dx));

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":86
 *             j = j_off + j_i
 *             cy = (leftedges[1] + j*dx)
 *             for i_off in range(i_f):             # <<<<<<<<<<<<<<
 *                 i = i_off + i_i
 *                 cx = (leftedges[0] + i*dx)
 */
      __pyx_t_13 = __pyx_v_i_f;
      for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
        __pyx_v_i_off = __pyx_t_14;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":87
 *             cy = (leftedges[1] + j*dx)
 *             for i_off in range(i_f):
 *                 i = i_off + i_i             # <<<<<<<<<<<<<<
 *                 cx = (leftedges[0] + i*dx)
 *                 ci = grid.child_indices[i,j,k]
 */
        __pyx_v_i = (__pyx_v_i_off + __pyx_v_i_i);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":88
 *             for i_off in range(i_f):
 *                 i = i_off + i_i
 *                 cx = (leftedges[0] + i*dx)             # <<<<<<<<<<<<<<
 *                 ci = grid.child_indices[i,j,k]
 *                 if ci == -1:
 */
        __pyx_t_15 = 0;
        if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_bshape_0_leftedges;
        __pyx_v_cx = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_leftedges.buf, __pyx_t_15, __pyx_bstride_0_leftedges)) + (__pyx_v_i * __pyx_v_dx));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":89
 *                 i = i_off + i_i
 *                 cx = (leftedges[0] + i*dx)
 *                 ci = grid.child_indices[i,j,k]             # <<<<<<<<<<<<<<
 *                 if ci == -1:
 *                     for fi in range(fields.shape[0]):
 */
        __pyx_t_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_16 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_16);
        __pyx_t_17 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_18 = PyTuple_New(3); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_18);
        PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_16);
        __Pyx_GIVEREF(__pyx_t_16);
        PyTuple_SET_ITEM(__pyx_t_18, 2, __pyx_t_17);
        __Pyx_GIVEREF(__pyx_t_17);
        __pyx_t_2 = 0;
        __pyx_t_16 = 0;
        __pyx_t_17 = 0;
        __pyx_t_17 = PyObject_GetItem(__pyx_v_grid->child_indices, __pyx_t_18); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_19 = __Pyx_PyInt_AsInt(__pyx_t_17); if (unlikely((__pyx_t_19 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_v_ci = __pyx_t_19;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":90
 *                 cx = (leftedges[0] + i*dx)
 *                 ci = grid.child_indices[i,j,k]
 *                 if ci == -1:             # <<<<<<<<<<<<<<
 *                     for fi in range(fields.shape[0]):
 *                         output[curpos.output_pos,fi] = fields[fi,i,j,k]
 */
        __pyx_t_20 = (__pyx_v_ci == -1);
        if (__pyx_t_20) {

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":91
 *                 ci = grid.child_indices[i,j,k]
 *                 if ci == -1:
 *                     for fi in range(fields.shape[0]):             # <<<<<<<<<<<<<<
 *                         output[curpos.output_pos,fi] = fields[fi,i,j,k]
 *                     refined[curpos.refined_pos] = 0
 */
          __pyx_t_21 = (__pyx_v_fields->dimensions[0]);
          for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_21; __pyx_t_19+=1) {
            __pyx_v_fi = __pyx_t_19;

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":92
 *                 if ci == -1:
 *                     for fi in range(fields.shape[0]):
 *                         output[curpos.output_pos,fi] = fields[fi,i,j,k]             # <<<<<<<<<<<<<<
 *                     refined[curpos.refined_pos] = 0
 *                     curpos.output_pos += 1
 */
            __pyx_t_22 = __pyx_v_fi;
            __pyx_t_23 = __pyx_v_i;
            __pyx_t_24 = __pyx_v_j;
            __pyx_t_25 = __pyx_v_k;
            if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_bshape_0_fields;
            if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_bshape_1_fields;
            if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_bshape_2_fields;
            if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_bshape_3_fields;
            __pyx_t_26 = __pyx_v_curpos->output_pos;
            __pyx_t_27 = __pyx_v_fi;
            if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_bshape_0_output;
            if (__pyx_t_27 < 0) __pyx_t_27 += __pyx_bshape_1_output;
            *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_output.buf, __pyx_t_26, __pyx_bstride_0_output, __pyx_t_27, __pyx_bstride_1_output) = (*__Pyx_BufPtrStrided4d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_fields.buf, __pyx_t_22, __pyx_bstride_0_fields, __pyx_t_23, __pyx_bstride_1_fields, __pyx_t_24, __pyx_bstride_2_fields, __pyx_t_25, __pyx_bstride_3_fields));
          }

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":93
 *                     for fi in range(fields.shape[0]):
 *                         output[curpos.output_pos,fi] = fields[fi,i,j,k]
 *                     refined[curpos.refined_pos] = 0             # <<<<<<<<<<<<<<
 *                     curpos.output_pos += 1
 *                     curpos.refined_pos += 1
 */
          __pyx_t_19 = __pyx_v_curpos->refined_pos;
          if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_bshape_0_refined;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_refined.buf, __pyx_t_19, __pyx_bstride_0_refined) = 0;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":94
 *                         output[curpos.output_pos,fi] = fields[fi,i,j,k]
 *                     refined[curpos.refined_pos] = 0
 *                     curpos.output_pos += 1             # <<<<<<<<<<<<<<
 *                     curpos.refined_pos += 1
 *                 else:
 */
          __pyx_v_curpos->output_pos += 1;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":95
 *                     refined[curpos.refined_pos] = 0
 *                     curpos.output_pos += 1
 *                     curpos.refined_pos += 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     refined[curpos.refined_pos] = 1
 */
          __pyx_v_curpos->refined_pos += 1;
          goto __pyx_L12;
        }
        /*else*/ {

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":97
 *                     curpos.refined_pos += 1
 *                 else:
 *                     refined[curpos.refined_pos] = 1             # <<<<<<<<<<<<<<
 *                     curpos.refined_pos += 1
 *                     child_grid = grids[ci-1]
 */
          __pyx_t_28 = __pyx_v_curpos->refined_pos;
          if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_bshape_0_refined;
          *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_refined.buf, __pyx_t_28, __pyx_bstride_0_refined) = 1;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":98
 *                 else:
 *                     refined[curpos.refined_pos] = 1
 *                     curpos.refined_pos += 1             # <<<<<<<<<<<<<<
 *                     child_grid = grids[ci-1]
 *                     child_dx = child_grid.dx[0]
 */
          __pyx_v_curpos->refined_pos += 1;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":99
 *                     refined[curpos.refined_pos] = 1
 *                     curpos.refined_pos += 1
 *                     child_grid = grids[ci-1]             # <<<<<<<<<<<<<<
 *                     child_dx = child_grid.dx[0]
 *                     child_leftedges = child_grid.left_edges
 */
          __pyx_t_29 = (__pyx_v_ci - 1);
          __pyx_t_17 = __Pyx_GetItemInt(((PyObject *)__pyx_v_grids), __pyx_t_29, sizeof(long), PyInt_FromLong); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_17);
          if (!(likely(((__pyx_t_17) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_17, __pyx_ptype_2yt_9amr_utils_OctreeGrid))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(((PyObject *)__pyx_v_child_grid));
          __pyx_v_child_grid = ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_t_17);
          __pyx_t_17 = 0;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":100
 *                     curpos.refined_pos += 1
 *                     child_grid = grids[ci-1]
 *                     child_dx = child_grid.dx[0]             # <<<<<<<<<<<<<<
 *                     child_leftedges = child_grid.left_edges
 *                     child_i = int((cx - child_leftedges[0])/child_dx)
 */
          __pyx_t_17 = __Pyx_GetItemInt(__pyx_v_child_grid->dx, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_17) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_17); if (unlikely((__pyx_t_7 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_v_child_dx = __pyx_t_7;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":101
 *                     child_grid = grids[ci-1]
 *                     child_dx = child_grid.dx[0]
 *                     child_leftedges = child_grid.left_edges             # <<<<<<<<<<<<<<
 *                     child_i = int((cx - child_leftedges[0])/child_dx)
 *                     child_j = int((cy - child_leftedges[1])/child_dx)
 */
          if (!(likely(((__pyx_v_child_grid->left_edges) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_child_grid->left_edges, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_30 = ((PyArrayObject *)__pyx_v_child_grid->left_edges);
          {
            __Pyx_BufFmt_StackElem __pyx_stack[1];
            __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_leftedges);
            __pyx_t_31 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_child_leftedges, (PyObject*)__pyx_t_30, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
            if (unlikely(__pyx_t_31 < 0)) {
              PyErr_Fetch(&__pyx_t_32, &__pyx_t_33, &__pyx_t_34);
              if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_child_leftedges, (PyObject*)__pyx_v_child_leftedges, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
                Py_XDECREF(__pyx_t_32); Py_XDECREF(__pyx_t_33); Py_XDECREF(__pyx_t_34);
                __Pyx_RaiseBufferFallbackError();
              } else {
                PyErr_Restore(__pyx_t_32, __pyx_t_33, __pyx_t_34);
              }
            }
            __pyx_bstride_0_child_leftedges = __pyx_bstruct_child_leftedges.strides[0];
            __pyx_bshape_0_child_leftedges = __pyx_bstruct_child_leftedges.shape[0];
            if (unlikely(__pyx_t_31 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_30 = 0;
          __Pyx_INCREF(__pyx_v_child_grid->left_edges);
          __Pyx_DECREF(((PyObject *)__pyx_v_child_leftedges));
          __pyx_v_child_leftedges = ((PyArrayObject *)__pyx_v_child_grid->left_edges);

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":102
 *                     child_dx = child_grid.dx[0]
 *                     child_leftedges = child_grid.left_edges
 *                     child_i = int((cx - child_leftedges[0])/child_dx)             # <<<<<<<<<<<<<<
 *                     child_j = int((cy - child_leftedges[1])/child_dx)
 *                     child_k = int((cz - child_leftedges[2])/child_dx)
 */
          __pyx_t_29 = 0;
          if (__pyx_t_29 < 0) __pyx_t_29 += __pyx_bshape_0_child_leftedges;
          __pyx_v_child_i = ((int)((__pyx_v_cx - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_child_leftedges.buf, __pyx_t_29, __pyx_bstride_0_child_leftedges))) / __pyx_v_child_dx));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":103
 *                     child_leftedges = child_grid.left_edges
 *                     child_i = int((cx - child_leftedges[0])/child_dx)
 *                     child_j = int((cy - child_leftedges[1])/child_dx)             # <<<<<<<<<<<<<<
 *                     child_k = int((cz - child_leftedges[2])/child_dx)
 *                     s = RecurseOctreeDepthFirst(child_i, child_j, child_k, 2, 2, 2,
 */
          __pyx_t_35 = 1;
          if (__pyx_t_35 < 0) __pyx_t_35 += __pyx_bshape_0_child_leftedges;
          __pyx_v_child_j = ((int)((__pyx_v_cy - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_child_leftedges.buf, __pyx_t_35, __pyx_bstride_0_child_leftedges))) / __pyx_v_child_dx));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":104
 *                     child_i = int((cx - child_leftedges[0])/child_dx)
 *                     child_j = int((cy - child_leftedges[1])/child_dx)
 *                     child_k = int((cz - child_leftedges[2])/child_dx)             # <<<<<<<<<<<<<<
 *                     s = RecurseOctreeDepthFirst(child_i, child_j, child_k, 2, 2, 2,
 *                                         curpos, ci, output, refined, grids)
 */
          __pyx_t_36 = 2;
          if (__pyx_t_36 < 0) __pyx_t_36 += __pyx_bshape_0_child_leftedges;
          __pyx_v_child_k = ((int)((__pyx_v_cz - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_child_leftedges.buf, __pyx_t_36, __pyx_bstride_0_child_leftedges))) / __pyx_v_child_dx));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":105
 *                     child_j = int((cy - child_leftedges[1])/child_dx)
 *                     child_k = int((cz - child_leftedges[2])/child_dx)
 *                     s = RecurseOctreeDepthFirst(child_i, child_j, child_k, 2, 2, 2,             # <<<<<<<<<<<<<<
 *                                         curpos, ci, output, refined, grids)
 *     return s
 */
          __pyx_t_17 = __Pyx_GetName(__pyx_m, __pyx_n_s_1); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_18 = PyInt_FromLong(__pyx_v_child_i); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_16 = PyInt_FromLong(__pyx_v_child_j); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_16);
          __pyx_t_2 = PyInt_FromLong(__pyx_v_child_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":106
 *                     child_k = int((cz - child_leftedges[2])/child_dx)
 *                     s = RecurseOctreeDepthFirst(child_i, child_j, child_k, 2, 2, 2,
 *                                         curpos, ci, output, refined, grids)             # <<<<<<<<<<<<<<
 *     return s
 * 
 */
          __pyx_t_37 = PyInt_FromLong(__pyx_v_ci); if (unlikely(!__pyx_t_37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_37);
          __pyx_t_38 = PyTuple_New(11); if (unlikely(!__pyx_t_38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_38);
          PyTuple_SET_ITEM(__pyx_t_38, 0, __pyx_t_18);
          __Pyx_GIVEREF(__pyx_t_18);
          PyTuple_SET_ITEM(__pyx_t_38, 1, __pyx_t_16);
          __Pyx_GIVEREF(__pyx_t_16);
          PyTuple_SET_ITEM(__pyx_t_38, 2, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __Pyx_INCREF(__pyx_int_2);
          PyTuple_SET_ITEM(__pyx_t_38, 3, __pyx_int_2);
          __Pyx_GIVEREF(__pyx_int_2);
          __Pyx_INCREF(__pyx_int_2);
          PyTuple_SET_ITEM(__pyx_t_38, 4, __pyx_int_2);
          __Pyx_GIVEREF(__pyx_int_2);
          __Pyx_INCREF(__pyx_int_2);
          PyTuple_SET_ITEM(__pyx_t_38, 5, __pyx_int_2);
          __Pyx_GIVEREF(__pyx_int_2);
          __Pyx_INCREF(((PyObject *)__pyx_v_curpos));
          PyTuple_SET_ITEM(__pyx_t_38, 6, ((PyObject *)__pyx_v_curpos));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_curpos));
          PyTuple_SET_ITEM(__pyx_t_38, 7, __pyx_t_37);
          __Pyx_GIVEREF(__pyx_t_37);
          __Pyx_INCREF(((PyObject *)__pyx_v_output));
          PyTuple_SET_ITEM(__pyx_t_38, 8, ((PyObject *)__pyx_v_output));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_output));
          __Pyx_INCREF(((PyObject *)__pyx_v_refined));
          PyTuple_SET_ITEM(__pyx_t_38, 9, ((PyObject *)__pyx_v_refined));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_refined));
          __Pyx_INCREF(((PyObject *)__pyx_v_grids));
          PyTuple_SET_ITEM(__pyx_t_38, 10, ((PyObject *)__pyx_v_grids));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_grids));
          __pyx_t_18 = 0;
          __pyx_t_16 = 0;
          __pyx_t_2 = 0;
          __pyx_t_37 = 0;
          __pyx_t_37 = PyObject_Call(__pyx_t_17, __pyx_t_38, NULL); if (unlikely(!__pyx_t_37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_37);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
          __Pyx_DECREF(__pyx_v_s);
          __pyx_v_s = __pyx_t_37;
          __pyx_t_37 = 0;
        }
        __pyx_L12:;
      }
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":107
 *                     s = RecurseOctreeDepthFirst(child_i, child_j, child_k, 2, 2, 2,
 *                                         curpos, ci, output, refined, grids)
 *     return s             # <<<<<<<<<<<<<<
 * 
 * @cython.boundscheck(False)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_s);
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_37);
  __Pyx_XDECREF(__pyx_t_38);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_leftedges);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_refined);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_leftedges);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dimensions);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_indices);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_fields);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_output);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.RecurseOctreeDepthFirst");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_leftedges);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_refined);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_leftedges);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dimensions);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_indices);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_fields);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_output);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_child_grid);
  __Pyx_XDECREF((PyObject *)__pyx_v_grid);
  __Pyx_XDECREF((PyObject *)__pyx_v_child_indices);
  __Pyx_XDECREF((PyObject *)__pyx_v_dimensions);
  __Pyx_XDECREF((PyObject *)__pyx_v_fields);
  __Pyx_XDECREF((PyObject *)__pyx_v_leftedges);
  __Pyx_DECREF((PyObject *)__pyx_v_child_leftedges);
  __Pyx_DECREF(__pyx_v_s);
  __Pyx_DECREF((PyObject *)__pyx_v_curpos);
  __Pyx_DECREF((PyObject *)__pyx_v_output);
  __Pyx_DECREF((PyObject *)__pyx_v_refined);
  __Pyx_DECREF((PyObject *)__pyx_v_grids);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":110
 * 
 * @cython.boundscheck(False)
 * def RecurseOctreeByLevels(int i_i, int j_i, int k_i,             # <<<<<<<<<<<<<<
 *                           int i_f, int j_f, int k_f,
 *                           np.ndarray[np.int32_t, ndim=1] curpos,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_RecurseOctreeByLevels(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_RecurseOctreeByLevels(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_i_i;
  int __pyx_v_j_i;
  int __pyx_v_k_i;
  int __pyx_v_i_f;
  int __pyx_v_j_f;
  int __pyx_v_k_f;
  PyArrayObject *__pyx_v_curpos = 0;
  int __pyx_v_gi;
  PyArrayObject *__pyx_v_output = 0;
  PyArrayObject *__pyx_v_genealogy = 0;
  PyArrayObject *__pyx_v_corners = 0;
  struct __pyx_obj_2yt_9amr_utils_OctreeGridList *__pyx_v_grids = 0;
  __pyx_t_5numpy_int32_t __pyx_v_i;
  __pyx_t_5numpy_int32_t __pyx_v_i_off;
  __pyx_t_5numpy_int32_t __pyx_v_j;
  __pyx_t_5numpy_int32_t __pyx_v_j_off;
  __pyx_t_5numpy_int32_t __pyx_v_k;
  __pyx_t_5numpy_int32_t __pyx_v_k_off;
  __pyx_t_5numpy_int32_t __pyx_v_ci;
  __pyx_t_5numpy_int32_t __pyx_v_fi;
  int __pyx_v_child_i;
  int __pyx_v_child_j;
  int __pyx_v_child_k;
  struct __pyx_obj_2yt_9amr_utils_OctreeGrid *__pyx_v_child_grid;
  struct __pyx_obj_2yt_9amr_utils_OctreeGrid *__pyx_v_grid = 0;
  int __pyx_v_level;
  PyArrayObject *__pyx_v_child_indices = 0;
  PyArrayObject *__pyx_v_dimensions = 0;
  PyArrayObject *__pyx_v_fields = 0;
  PyArrayObject *__pyx_v_leftedges = 0;
  __pyx_t_5numpy_float64_t __pyx_v_dx;
  __pyx_t_5numpy_float64_t __pyx_v_child_dx;
  PyArrayObject *__pyx_v_child_leftedges;
  __pyx_t_5numpy_float64_t __pyx_v_cx;
  __pyx_t_5numpy_float64_t __pyx_v_cy;
  __pyx_t_5numpy_float64_t __pyx_v_cz;
  int __pyx_v_cp;
  PyObject *__pyx_v_s;
  Py_buffer __pyx_bstruct_leftedges;
  Py_ssize_t __pyx_bstride_0_leftedges = 0;
  Py_ssize_t __pyx_bshape_0_leftedges = 0;
  Py_buffer __pyx_bstruct_curpos;
  Py_ssize_t __pyx_bstride_0_curpos = 0;
  Py_ssize_t __pyx_bshape_0_curpos = 0;
  Py_buffer __pyx_bstruct_child_leftedges;
  Py_ssize_t __pyx_bstride_0_child_leftedges = 0;
  Py_ssize_t __pyx_bshape_0_child_leftedges = 0;
  Py_buffer __pyx_bstruct_dimensions;
  Py_ssize_t __pyx_bstride_0_dimensions = 0;
  Py_ssize_t __pyx_bshape_0_dimensions = 0;
  Py_buffer __pyx_bstruct_child_indices;
  Py_ssize_t __pyx_bstride_0_child_indices = 0;
  Py_ssize_t __pyx_bstride_1_child_indices = 0;
  Py_ssize_t __pyx_bstride_2_child_indices = 0;
  Py_ssize_t __pyx_bshape_0_child_indices = 0;
  Py_ssize_t __pyx_bshape_1_child_indices = 0;
  Py_ssize_t __pyx_bshape_2_child_indices = 0;
  Py_buffer __pyx_bstruct_genealogy;
  Py_ssize_t __pyx_bstride_0_genealogy = 0;
  Py_ssize_t __pyx_bstride_1_genealogy = 0;
  Py_ssize_t __pyx_bshape_0_genealogy = 0;
  Py_ssize_t __pyx_bshape_1_genealogy = 0;
  Py_buffer __pyx_bstruct_corners;
  Py_ssize_t __pyx_bstride_0_corners = 0;
  Py_ssize_t __pyx_bstride_1_corners = 0;
  Py_ssize_t __pyx_bshape_0_corners = 0;
  Py_ssize_t __pyx_bshape_1_corners = 0;
  Py_buffer __pyx_bstruct_fields;
  Py_ssize_t __pyx_bstride_0_fields = 0;
  Py_ssize_t __pyx_bstride_1_fields = 0;
  Py_ssize_t __pyx_bstride_2_fields = 0;
  Py_ssize_t __pyx_bstride_3_fields = 0;
  Py_ssize_t __pyx_bshape_0_fields = 0;
  Py_ssize_t __pyx_bshape_1_fields = 0;
  Py_ssize_t __pyx_bshape_2_fields = 0;
  Py_ssize_t __pyx_bshape_3_fields = 0;
  Py_buffer __pyx_bstruct_output;
  Py_ssize_t __pyx_bstride_0_output = 0;
  Py_ssize_t __pyx_bstride_1_output = 0;
  Py_ssize_t __pyx_bshape_0_output = 0;
  Py_ssize_t __pyx_bshape_1_output = 0;
  PyObject *__pyx_r = NULL;
  long __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyArrayObject *__pyx_t_3 = NULL;
  PyArrayObject *__pyx_t_4 = NULL;
  PyArrayObject *__pyx_t_5 = NULL;
  PyArrayObject *__pyx_t_6 = NULL;
  __pyx_t_5numpy_float64_t __pyx_t_7;
  int __pyx_t_8;
  __pyx_t_5numpy_int32_t __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  __pyx_t_5numpy_int32_t __pyx_t_14;
  long __pyx_t_15;
  int __pyx_t_16;
  __pyx_t_5numpy_int32_t __pyx_t_17;
  long __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  long __pyx_t_21;
  int __pyx_t_22;
  long __pyx_t_23;
  int __pyx_t_24;
  long __pyx_t_25;
  int __pyx_t_26;
  __pyx_t_5numpy_int32_t __pyx_t_27;
  long __pyx_t_28;
  npy_intp __pyx_t_29;
  __pyx_t_5numpy_int32_t __pyx_t_30;
  __pyx_t_5numpy_int32_t __pyx_t_31;
  __pyx_t_5numpy_int32_t __pyx_t_32;
  __pyx_t_5numpy_int32_t __pyx_t_33;
  __pyx_t_5numpy_int32_t __pyx_t_34;
  int __pyx_t_35;
  __pyx_t_5numpy_int32_t __pyx_t_36;
  __pyx_t_5numpy_int32_t __pyx_t_37;
  __pyx_t_5numpy_int32_t __pyx_t_38;
  long __pyx_t_39;
  PyArrayObject *__pyx_t_40 = NULL;
  int __pyx_t_41;
  PyObject *__pyx_t_42 = NULL;
  PyObject *__pyx_t_43 = NULL;
  PyObject *__pyx_t_44 = NULL;
  long __pyx_t_45;
  long __pyx_t_46;
  long __pyx_t_47;
  long __pyx_t_48;
  long __pyx_t_49;
  long __pyx_t_50;
  PyObject *__pyx_t_51 = NULL;
  PyObject *__pyx_t_52 = NULL;
  PyObject *__pyx_t_53 = NULL;
  int __pyx_t_54;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__i_i,&__pyx_n_s__j_i,&__pyx_n_s__k_i,&__pyx_n_s__i_f,&__pyx_n_s__j_f,&__pyx_n_s__k_f,&__pyx_n_s__curpos,&__pyx_n_s__gi,&__pyx_n_s__output,&__pyx_n_s__genealogy,&__pyx_n_s__corners,&__pyx_n_s__grids,0};
  __Pyx_RefNannySetupContext("RecurseOctreeByLevels");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
      case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_i);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__j_i);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k_i);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_f);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__j_f);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__k_f);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__curpos);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, 6); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  7:
      values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__gi);
      if (likely(values[7])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, 7); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  8:
      values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__output);
      if (likely(values[8])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, 8); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  9:
      values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__genealogy);
      if (likely(values[9])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, 9); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case 10:
      values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__corners);
      if (likely(values[10])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, 10); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case 11:
      values[11] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grids);
      if (likely(values[11])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, 11); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "RecurseOctreeByLevels") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_i_i = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_i_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_j_i = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_j_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k_i = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_k_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_i_f = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_i_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_j_f = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_j_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k_f = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_k_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_curpos = ((PyArrayObject *)values[6]);
    __pyx_v_gi = __Pyx_PyInt_AsInt(values[7]); if (unlikely((__pyx_v_gi == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_output = ((PyArrayObject *)values[8]);
    __pyx_v_genealogy = ((PyArrayObject *)values[9]);
    __pyx_v_corners = ((PyArrayObject *)values[10]);
    __pyx_v_grids = ((struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)values[11]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 12) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_i_i = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_i_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_j_i = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_j_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k_i = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_k_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_i_f = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_i_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_j_f = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_j_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_k_f = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_k_f == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_curpos = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 6));
    __pyx_v_gi = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 7)); if (unlikely((__pyx_v_gi == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_output = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 8));
    __pyx_v_genealogy = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 9));
    __pyx_v_corners = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 10));
    __pyx_v_grids = ((struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)PyTuple_GET_ITEM(__pyx_args, 11));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("RecurseOctreeByLevels", 1, 12, 12, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.RecurseOctreeByLevels");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_curpos);
  __Pyx_INCREF((PyObject *)__pyx_v_output);
  __Pyx_INCREF((PyObject *)__pyx_v_genealogy);
  __Pyx_INCREF((PyObject *)__pyx_v_corners);
  __Pyx_INCREF((PyObject *)__pyx_v_grids);
  __pyx_v_child_grid = ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_child_leftedges = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
  __pyx_bstruct_child_indices.buf = NULL;
  __pyx_bstruct_dimensions.buf = NULL;
  __pyx_bstruct_fields.buf = NULL;
  __pyx_bstruct_leftedges.buf = NULL;
  __pyx_bstruct_child_leftedges.buf = NULL;
  __pyx_bstruct_curpos.buf = NULL;
  __pyx_bstruct_output.buf = NULL;
  __pyx_bstruct_genealogy.buf = NULL;
  __pyx_bstruct_corners.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_curpos), __pyx_ptype_5numpy_ndarray, 1, "curpos", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output), __pyx_ptype_5numpy_ndarray, 1, "output", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_genealogy), __pyx_ptype_5numpy_ndarray, 1, "genealogy", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_corners), __pyx_ptype_5numpy_ndarray, 1, "corners", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grids), __pyx_ptype_2yt_9amr_utils_OctreeGridList, 1, "grids", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_curpos, (PyObject*)__pyx_v_curpos, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_curpos = __pyx_bstruct_curpos.strides[0];
  __pyx_bshape_0_curpos = __pyx_bstruct_curpos.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_output, (PyObject*)__pyx_v_output, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_output = __pyx_bstruct_output.strides[0]; __pyx_bstride_1_output = __pyx_bstruct_output.strides[1];
  __pyx_bshape_0_output = __pyx_bstruct_output.shape[0]; __pyx_bshape_1_output = __pyx_bstruct_output.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_genealogy, (PyObject*)__pyx_v_genealogy, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_genealogy = __pyx_bstruct_genealogy.strides[0]; __pyx_bstride_1_genealogy = __pyx_bstruct_genealogy.strides[1];
  __pyx_bshape_0_genealogy = __pyx_bstruct_genealogy.shape[0]; __pyx_bshape_1_genealogy = __pyx_bstruct_genealogy.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_corners, (PyObject*)__pyx_v_corners, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_corners = __pyx_bstruct_corners.strides[0]; __pyx_bstride_1_corners = __pyx_bstruct_corners.strides[1];
  __pyx_bshape_0_corners = __pyx_bstruct_corners.shape[0]; __pyx_bshape_1_corners = __pyx_bstruct_corners.shape[1];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":121
 *     cdef int child_i, child_j, child_k
 *     cdef OctreeGrid child_grid
 *     cdef OctreeGrid grid = grids[gi-1]             # <<<<<<<<<<<<<<
 *     cdef int level = grid.level
 *     cdef np.ndarray[np.int32_t, ndim=3] child_indices = grid.child_indices
 */
  __pyx_t_1 = (__pyx_v_gi - 1);
  __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_grids), __pyx_t_1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_2yt_9amr_utils_OctreeGrid))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_grid = ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":122
 *     cdef OctreeGrid child_grid
 *     cdef OctreeGrid grid = grids[gi-1]
 *     cdef int level = grid.level             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.int32_t, ndim=3] child_indices = grid.child_indices
 *     cdef np.ndarray[np.int32_t, ndim=1] dimensions = grid.dimensions
 */
  __pyx_v_level = __pyx_v_grid->level;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":123
 *     cdef OctreeGrid grid = grids[gi-1]
 *     cdef int level = grid.level
 *     cdef np.ndarray[np.int32_t, ndim=3] child_indices = grid.child_indices             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.int32_t, ndim=1] dimensions = grid.dimensions
 *     cdef np.ndarray[np.float64_t, ndim=4] fields = grid.fields
 */
  if (!(likely(((__pyx_v_grid->child_indices) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_grid->child_indices, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = ((PyArrayObject *)__pyx_v_grid->child_indices);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_child_indices, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
      __pyx_v_child_indices = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_child_indices.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_child_indices = __pyx_bstruct_child_indices.strides[0]; __pyx_bstride_1_child_indices = __pyx_bstruct_child_indices.strides[1]; __pyx_bstride_2_child_indices = __pyx_bstruct_child_indices.strides[2];
      __pyx_bshape_0_child_indices = __pyx_bstruct_child_indices.shape[0]; __pyx_bshape_1_child_indices = __pyx_bstruct_child_indices.shape[1]; __pyx_bshape_2_child_indices = __pyx_bstruct_child_indices.shape[2];
    }
  }
  __pyx_t_3 = 0;
  __Pyx_INCREF(__pyx_v_grid->child_indices);
  __pyx_v_child_indices = ((PyArrayObject *)__pyx_v_grid->child_indices);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":124
 *     cdef int level = grid.level
 *     cdef np.ndarray[np.int32_t, ndim=3] child_indices = grid.child_indices
 *     cdef np.ndarray[np.int32_t, ndim=1] dimensions = grid.dimensions             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.float64_t, ndim=4] fields = grid.fields
 *     cdef np.ndarray[np.float64_t, ndim=1] leftedges = grid.left_edges
 */
  if (!(likely(((__pyx_v_grid->dimensions) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_grid->dimensions, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = ((PyArrayObject *)__pyx_v_grid->dimensions);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dimensions, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_dimensions = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_dimensions.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_dimensions = __pyx_bstruct_dimensions.strides[0];
      __pyx_bshape_0_dimensions = __pyx_bstruct_dimensions.shape[0];
    }
  }
  __pyx_t_4 = 0;
  __Pyx_INCREF(__pyx_v_grid->dimensions);
  __pyx_v_dimensions = ((PyArrayObject *)__pyx_v_grid->dimensions);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":125
 *     cdef np.ndarray[np.int32_t, ndim=3] child_indices = grid.child_indices
 *     cdef np.ndarray[np.int32_t, ndim=1] dimensions = grid.dimensions
 *     cdef np.ndarray[np.float64_t, ndim=4] fields = grid.fields             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.float64_t, ndim=1] leftedges = grid.left_edges
 *     cdef np.float64_t dx = grid.dx[0]
 */
  if (!(likely(((__pyx_v_grid->fields) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_grid->fields, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_v_grid->fields);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_fields, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 4, 0, __pyx_stack) == -1)) {
      __pyx_v_fields = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_fields.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_fields = __pyx_bstruct_fields.strides[0]; __pyx_bstride_1_fields = __pyx_bstruct_fields.strides[1]; __pyx_bstride_2_fields = __pyx_bstruct_fields.strides[2]; __pyx_bstride_3_fields = __pyx_bstruct_fields.strides[3];
      __pyx_bshape_0_fields = __pyx_bstruct_fields.shape[0]; __pyx_bshape_1_fields = __pyx_bstruct_fields.shape[1]; __pyx_bshape_2_fields = __pyx_bstruct_fields.shape[2]; __pyx_bshape_3_fields = __pyx_bstruct_fields.shape[3];
    }
  }
  __pyx_t_5 = 0;
  __Pyx_INCREF(__pyx_v_grid->fields);
  __pyx_v_fields = ((PyArrayObject *)__pyx_v_grid->fields);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":126
 *     cdef np.ndarray[np.int32_t, ndim=1] dimensions = grid.dimensions
 *     cdef np.ndarray[np.float64_t, ndim=4] fields = grid.fields
 *     cdef np.ndarray[np.float64_t, ndim=1] leftedges = grid.left_edges             # <<<<<<<<<<<<<<
 *     cdef np.float64_t dx = grid.dx[0]
 *     cdef np.float64_t child_dx
 */
  if (!(likely(((__pyx_v_grid->left_edges) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_grid->left_edges, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_v_grid->left_edges);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_leftedges, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_leftedges = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_leftedges.buf = NULL;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_leftedges = __pyx_bstruct_leftedges.strides[0];
      __pyx_bshape_0_leftedges = __pyx_bstruct_leftedges.shape[0];
    }
  }
  __pyx_t_6 = 0;
  __Pyx_INCREF(__pyx_v_grid->left_edges);
  __pyx_v_leftedges = ((PyArrayObject *)__pyx_v_grid->left_edges);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":127
 *     cdef np.ndarray[np.float64_t, ndim=4] fields = grid.fields
 *     cdef np.ndarray[np.float64_t, ndim=1] leftedges = grid.left_edges
 *     cdef np.float64_t dx = grid.dx[0]             # <<<<<<<<<<<<<<
 *     cdef np.float64_t child_dx
 *     cdef np.ndarray[np.float64_t, ndim=1] child_leftedges
 */
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_grid->dx, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_7 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_dx = __pyx_t_7;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":132
 *     cdef np.float64_t cx, cy, cz
 *     cdef int cp
 *     for i_off in range(i_f):             # <<<<<<<<<<<<<<
 *         i = i_off + i_i
 *         cx = (leftedges[0] + i*dx)
 */
  __pyx_t_8 = __pyx_v_i_f;
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
    __pyx_v_i_off = __pyx_t_9;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":133
 *     cdef int cp
 *     for i_off in range(i_f):
 *         i = i_off + i_i             # <<<<<<<<<<<<<<
 *         cx = (leftedges[0] + i*dx)
 *         if i_f > 2: print k, cz
 */
    __pyx_v_i = (__pyx_v_i_off + __pyx_v_i_i);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":134
 *     for i_off in range(i_f):
 *         i = i_off + i_i
 *         cx = (leftedges[0] + i*dx)             # <<<<<<<<<<<<<<
 *         if i_f > 2: print k, cz
 *         for j_off in range(j_f):
 */
    __pyx_t_1 = 0;
    if (__pyx_t_1 < 0) __pyx_t_1 += __pyx_bshape_0_leftedges;
    __pyx_v_cx = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_leftedges.buf, __pyx_t_1, __pyx_bstride_0_leftedges)) + (__pyx_v_i * __pyx_v_dx));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":135
 *         i = i_off + i_i
 *         cx = (leftedges[0] + i*dx)
 *         if i_f > 2: print k, cz             # <<<<<<<<<<<<<<
 *         for j_off in range(j_f):
 *             j = j_off + j_i
 */
    __pyx_t_10 = (__pyx_v_i_f > 2);
    if (__pyx_t_10) {
      __pyx_t_2 = __Pyx_PyInt_to_py_npy_int32(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_11 = PyFloat_FromDouble(__pyx_v_cz); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_11);
      __pyx_t_2 = 0;
      __pyx_t_11 = 0;
      if (__Pyx_Print(__pyx_t_12, 1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":136
 *         cx = (leftedges[0] + i*dx)
 *         if i_f > 2: print k, cz
 *         for j_off in range(j_f):             # <<<<<<<<<<<<<<
 *             j = j_off + j_i
 *             cy = (leftedges[1] + j*dx)
 */
    __pyx_t_13 = __pyx_v_j_f;
    for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
      __pyx_v_j_off = __pyx_t_14;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":137
 *         if i_f > 2: print k, cz
 *         for j_off in range(j_f):
 *             j = j_off + j_i             # <<<<<<<<<<<<<<
 *             cy = (leftedges[1] + j*dx)
 *             for k_off in range(k_f):
 */
      __pyx_v_j = (__pyx_v_j_off + __pyx_v_j_i);

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":138
 *         for j_off in range(j_f):
 *             j = j_off + j_i
 *             cy = (leftedges[1] + j*dx)             # <<<<<<<<<<<<<<
 *             for k_off in range(k_f):
 *                 k = k_off + k_i
 */
      __pyx_t_15 = 1;
      if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_bshape_0_leftedges;
      __pyx_v_cy = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_leftedges.buf, __pyx_t_15, __pyx_bstride_0_leftedges)) + (__pyx_v_j * __pyx_v_dx));

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":139
 *             j = j_off + j_i
 *             cy = (leftedges[1] + j*dx)
 *             for k_off in range(k_f):             # <<<<<<<<<<<<<<
 *                 k = k_off + k_i
 *                 cz = (leftedges[2] + k*dx)
 */
      __pyx_t_16 = __pyx_v_k_f;
      for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_16; __pyx_t_17+=1) {
        __pyx_v_k_off = __pyx_t_17;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":140
 *             cy = (leftedges[1] + j*dx)
 *             for k_off in range(k_f):
 *                 k = k_off + k_i             # <<<<<<<<<<<<<<
 *                 cz = (leftedges[2] + k*dx)
 *                 cp = curpos[level]
 */
        __pyx_v_k = (__pyx_v_k_off + __pyx_v_k_i);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":141
 *             for k_off in range(k_f):
 *                 k = k_off + k_i
 *                 cz = (leftedges[2] + k*dx)             # <<<<<<<<<<<<<<
 *                 cp = curpos[level]
 *                 corners[cp, 0] = cx
 */
        __pyx_t_18 = 2;
        if (__pyx_t_18 < 0) __pyx_t_18 += __pyx_bshape_0_leftedges;
        __pyx_v_cz = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_leftedges.buf, __pyx_t_18, __pyx_bstride_0_leftedges)) + (__pyx_v_k * __pyx_v_dx));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":142
 *                 k = k_off + k_i
 *                 cz = (leftedges[2] + k*dx)
 *                 cp = curpos[level]             # <<<<<<<<<<<<<<
 *                 corners[cp, 0] = cx
 *                 corners[cp, 1] = cy
 */
        __pyx_t_19 = __pyx_v_level;
        if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_bshape_0_curpos;
        __pyx_v_cp = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_curpos.buf, __pyx_t_19, __pyx_bstride_0_curpos));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":143
 *                 cz = (leftedges[2] + k*dx)
 *                 cp = curpos[level]
 *                 corners[cp, 0] = cx             # <<<<<<<<<<<<<<
 *                 corners[cp, 1] = cy
 *                 corners[cp, 2] = cz
 */
        __pyx_t_20 = __pyx_v_cp;
        __pyx_t_21 = 0;
        if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_bshape_0_corners;
        if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_bshape_1_corners;
        *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_corners.buf, __pyx_t_20, __pyx_bstride_0_corners, __pyx_t_21, __pyx_bstride_1_corners) = __pyx_v_cx;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":144
 *                 cp = curpos[level]
 *                 corners[cp, 0] = cx
 *                 corners[cp, 1] = cy             # <<<<<<<<<<<<<<
 *                 corners[cp, 2] = cz
 *                 genealogy[curpos[level], 2] = level
 */
        __pyx_t_22 = __pyx_v_cp;
        __pyx_t_23 = 1;
        if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_bshape_0_corners;
        if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_bshape_1_corners;
        *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_corners.buf, __pyx_t_22, __pyx_bstride_0_corners, __pyx_t_23, __pyx_bstride_1_corners) = __pyx_v_cy;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":145
 *                 corners[cp, 0] = cx
 *                 corners[cp, 1] = cy
 *                 corners[cp, 2] = cz             # <<<<<<<<<<<<<<
 *                 genealogy[curpos[level], 2] = level
 *                 # always output data
 */
        __pyx_t_24 = __pyx_v_cp;
        __pyx_t_25 = 2;
        if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_bshape_0_corners;
        if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_bshape_1_corners;
        *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_corners.buf, __pyx_t_24, __pyx_bstride_0_corners, __pyx_t_25, __pyx_bstride_1_corners) = __pyx_v_cz;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":146
 *                 corners[cp, 1] = cy
 *                 corners[cp, 2] = cz
 *                 genealogy[curpos[level], 2] = level             # <<<<<<<<<<<<<<
 *                 # always output data
 *                 for fi in range(fields.shape[0]):
 */
        __pyx_t_26 = __pyx_v_level;
        if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_bshape_0_curpos;
        __pyx_t_27 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_curpos.buf, __pyx_t_26, __pyx_bstride_0_curpos));
        __pyx_t_28 = 2;
        if (__pyx_t_27 < 0) __pyx_t_27 += __pyx_bshape_0_genealogy;
        if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_bshape_1_genealogy;
        *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_genealogy.buf, __pyx_t_27, __pyx_bstride_0_genealogy, __pyx_t_28, __pyx_bstride_1_genealogy) = __pyx_v_level;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":148
 *                 genealogy[curpos[level], 2] = level
 *                 # always output data
 *                 for fi in range(fields.shape[0]):             # <<<<<<<<<<<<<<
 *                     output[cp,fi] = fields[fi,i,j,k]
 *                 ci = child_indices[i,j,k]
 */
        __pyx_t_29 = (__pyx_v_fields->dimensions[0]);
        for (__pyx_t_30 = 0; __pyx_t_30 < __pyx_t_29; __pyx_t_30+=1) {
          __pyx_v_fi = __pyx_t_30;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":149
 *                 # always output data
 *                 for fi in range(fields.shape[0]):
 *                     output[cp,fi] = fields[fi,i,j,k]             # <<<<<<<<<<<<<<
 *                 ci = child_indices[i,j,k]
 *                 if ci > -1:
 */
          __pyx_t_31 = __pyx_v_fi;
          __pyx_t_32 = __pyx_v_i;
          __pyx_t_33 = __pyx_v_j;
          __pyx_t_34 = __pyx_v_k;
          if (__pyx_t_31 < 0) __pyx_t_31 += __pyx_bshape_0_fields;
          if (__pyx_t_32 < 0) __pyx_t_32 += __pyx_bshape_1_fields;
          if (__pyx_t_33 < 0) __pyx_t_33 += __pyx_bshape_2_fields;
          if (__pyx_t_34 < 0) __pyx_t_34 += __pyx_bshape_3_fields;
          __pyx_t_35 = __pyx_v_cp;
          __pyx_t_36 = __pyx_v_fi;
          if (__pyx_t_35 < 0) __pyx_t_35 += __pyx_bshape_0_output;
          if (__pyx_t_36 < 0) __pyx_t_36 += __pyx_bshape_1_output;
          *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_output.buf, __pyx_t_35, __pyx_bstride_0_output, __pyx_t_36, __pyx_bstride_1_output) = (*__Pyx_BufPtrStrided4d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_fields.buf, __pyx_t_31, __pyx_bstride_0_fields, __pyx_t_32, __pyx_bstride_1_fields, __pyx_t_33, __pyx_bstride_2_fields, __pyx_t_34, __pyx_bstride_3_fields));
        }

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":150
 *                 for fi in range(fields.shape[0]):
 *                     output[cp,fi] = fields[fi,i,j,k]
 *                 ci = child_indices[i,j,k]             # <<<<<<<<<<<<<<
 *                 if ci > -1:
 *                     child_grid = grids[ci-1]
 */
        __pyx_t_30 = __pyx_v_i;
        __pyx_t_37 = __pyx_v_j;
        __pyx_t_38 = __pyx_v_k;
        if (__pyx_t_30 < 0) __pyx_t_30 += __pyx_bshape_0_child_indices;
        if (__pyx_t_37 < 0) __pyx_t_37 += __pyx_bshape_1_child_indices;
        if (__pyx_t_38 < 0) __pyx_t_38 += __pyx_bshape_2_child_indices;
        __pyx_v_ci = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_child_indices.buf, __pyx_t_30, __pyx_bstride_0_child_indices, __pyx_t_37, __pyx_bstride_1_child_indices, __pyx_t_38, __pyx_bstride_2_child_indices));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":151
 *                     output[cp,fi] = fields[fi,i,j,k]
 *                 ci = child_indices[i,j,k]
 *                 if ci > -1:             # <<<<<<<<<<<<<<
 *                     child_grid = grids[ci-1]
 *                     child_dx = child_grid.dx[0]
 */
        __pyx_t_10 = (__pyx_v_ci > -1);
        if (__pyx_t_10) {

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":152
 *                 ci = child_indices[i,j,k]
 *                 if ci > -1:
 *                     child_grid = grids[ci-1]             # <<<<<<<<<<<<<<
 *                     child_dx = child_grid.dx[0]
 *                     child_leftedges = child_grid.left_edges
 */
          __pyx_t_39 = (__pyx_v_ci - 1);
          __pyx_t_12 = __Pyx_GetItemInt(((PyObject *)__pyx_v_grids), __pyx_t_39, sizeof(long), PyInt_FromLong); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_2yt_9amr_utils_OctreeGrid))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(((PyObject *)__pyx_v_child_grid));
          __pyx_v_child_grid = ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)__pyx_t_12);
          __pyx_t_12 = 0;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":153
 *                 if ci > -1:
 *                     child_grid = grids[ci-1]
 *                     child_dx = child_grid.dx[0]             # <<<<<<<<<<<<<<
 *                     child_leftedges = child_grid.left_edges
 *                     child_i = int((cx-child_leftedges[0])/child_dx)
 */
          __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_child_grid->dx, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_12) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_12); if (unlikely((__pyx_t_7 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_v_child_dx = __pyx_t_7;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":154
 *                     child_grid = grids[ci-1]
 *                     child_dx = child_grid.dx[0]
 *                     child_leftedges = child_grid.left_edges             # <<<<<<<<<<<<<<
 *                     child_i = int((cx-child_leftedges[0])/child_dx)
 *                     child_j = int((cy-child_leftedges[1])/child_dx)
 */
          if (!(likely(((__pyx_v_child_grid->left_edges) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_child_grid->left_edges, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_40 = ((PyArrayObject *)__pyx_v_child_grid->left_edges);
          {
            __Pyx_BufFmt_StackElem __pyx_stack[1];
            __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_leftedges);
            __pyx_t_41 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_child_leftedges, (PyObject*)__pyx_t_40, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
            if (unlikely(__pyx_t_41 < 0)) {
              PyErr_Fetch(&__pyx_t_42, &__pyx_t_43, &__pyx_t_44);
              if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_child_leftedges, (PyObject*)__pyx_v_child_leftedges, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
                Py_XDECREF(__pyx_t_42); Py_XDECREF(__pyx_t_43); Py_XDECREF(__pyx_t_44);
                __Pyx_RaiseBufferFallbackError();
              } else {
                PyErr_Restore(__pyx_t_42, __pyx_t_43, __pyx_t_44);
              }
            }
            __pyx_bstride_0_child_leftedges = __pyx_bstruct_child_leftedges.strides[0];
            __pyx_bshape_0_child_leftedges = __pyx_bstruct_child_leftedges.shape[0];
            if (unlikely(__pyx_t_41 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_40 = 0;
          __Pyx_INCREF(__pyx_v_child_grid->left_edges);
          __Pyx_DECREF(((PyObject *)__pyx_v_child_leftedges));
          __pyx_v_child_leftedges = ((PyArrayObject *)__pyx_v_child_grid->left_edges);

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":155
 *                     child_dx = child_grid.dx[0]
 *                     child_leftedges = child_grid.left_edges
 *                     child_i = int((cx-child_leftedges[0])/child_dx)             # <<<<<<<<<<<<<<
 *                     child_j = int((cy-child_leftedges[1])/child_dx)
 *                     child_k = int((cz-child_leftedges[2])/child_dx)
 */
          __pyx_t_39 = 0;
          if (__pyx_t_39 < 0) __pyx_t_39 += __pyx_bshape_0_child_leftedges;
          __pyx_v_child_i = ((int)((__pyx_v_cx - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_child_leftedges.buf, __pyx_t_39, __pyx_bstride_0_child_leftedges))) / __pyx_v_child_dx));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":156
 *                     child_leftedges = child_grid.left_edges
 *                     child_i = int((cx-child_leftedges[0])/child_dx)
 *                     child_j = int((cy-child_leftedges[1])/child_dx)             # <<<<<<<<<<<<<<
 *                     child_k = int((cz-child_leftedges[2])/child_dx)
 *                     # set current child id to id of next cell to examine
 */
          __pyx_t_45 = 1;
          if (__pyx_t_45 < 0) __pyx_t_45 += __pyx_bshape_0_child_leftedges;
          __pyx_v_child_j = ((int)((__pyx_v_cy - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_child_leftedges.buf, __pyx_t_45, __pyx_bstride_0_child_leftedges))) / __pyx_v_child_dx));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":157
 *                     child_i = int((cx-child_leftedges[0])/child_dx)
 *                     child_j = int((cy-child_leftedges[1])/child_dx)
 *                     child_k = int((cz-child_leftedges[2])/child_dx)             # <<<<<<<<<<<<<<
 *                     # set current child id to id of next cell to examine
 *                     genealogy[cp, 0] = curpos[level+1]
 */
          __pyx_t_46 = 2;
          if (__pyx_t_46 < 0) __pyx_t_46 += __pyx_bshape_0_child_leftedges;
          __pyx_v_child_k = ((int)((__pyx_v_cz - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_child_leftedges.buf, __pyx_t_46, __pyx_bstride_0_child_leftedges))) / __pyx_v_child_dx));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":159
 *                     child_k = int((cz-child_leftedges[2])/child_dx)
 *                     # set current child id to id of next cell to examine
 *                     genealogy[cp, 0] = curpos[level+1]             # <<<<<<<<<<<<<<
 *                     # set next parent id to id of current cell
 *                     genealogy[curpos[level+1]:curpos[level+1]+8, 1] = cp
 */
          __pyx_t_47 = (__pyx_v_level + 1);
          if (__pyx_t_47 < 0) __pyx_t_47 += __pyx_bshape_0_curpos;
          __pyx_t_41 = __pyx_v_cp;
          __pyx_t_48 = 0;
          if (__pyx_t_41 < 0) __pyx_t_41 += __pyx_bshape_0_genealogy;
          if (__pyx_t_48 < 0) __pyx_t_48 += __pyx_bshape_1_genealogy;
          *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_genealogy.buf, __pyx_t_41, __pyx_bstride_0_genealogy, __pyx_t_48, __pyx_bstride_1_genealogy) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_curpos.buf, __pyx_t_47, __pyx_bstride_0_curpos));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":161
 *                     genealogy[cp, 0] = curpos[level+1]
 *                     # set next parent id to id of current cell
 *                     genealogy[curpos[level+1]:curpos[level+1]+8, 1] = cp             # <<<<<<<<<<<<<<
 *                     s = RecurseOctreeByLevels(child_i, child_j, child_k, 2, 2, 2,
 *                                               curpos, ci, output, genealogy,
 */
          __pyx_t_12 = PyInt_FromLong(__pyx_v_cp); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_49 = (__pyx_v_level + 1);
          if (__pyx_t_49 < 0) __pyx_t_49 += __pyx_bshape_0_curpos;
          __pyx_t_11 = __Pyx_PyInt_to_py_npy_int32((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_curpos.buf, __pyx_t_49, __pyx_bstride_0_curpos))); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_50 = (__pyx_v_level + 1);
          if (__pyx_t_50 < 0) __pyx_t_50 += __pyx_bshape_0_curpos;
          __pyx_t_2 = PyInt_FromLong(((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_curpos.buf, __pyx_t_50, __pyx_bstride_0_curpos)) + 8)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_51 = PySlice_New(__pyx_t_11, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_51);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_51);
          __Pyx_GIVEREF(__pyx_t_51);
          __Pyx_INCREF(__pyx_int_1);
          PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_1);
          __Pyx_GIVEREF(__pyx_int_1);
          __pyx_t_51 = 0;
          if (PyObject_SetItem(((PyObject *)__pyx_v_genealogy), __pyx_t_2, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":162
 *                     # set next parent id to id of current cell
 *                     genealogy[curpos[level+1]:curpos[level+1]+8, 1] = cp
 *                     s = RecurseOctreeByLevels(child_i, child_j, child_k, 2, 2, 2,             # <<<<<<<<<<<<<<
 *                                               curpos, ci, output, genealogy,
 *                                               corners, grids)
 */
          __pyx_t_12 = __Pyx_GetName(__pyx_m, __pyx_n_s_2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_2 = PyInt_FromLong(__pyx_v_child_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_51 = PyInt_FromLong(__pyx_v_child_j); if (unlikely(!__pyx_t_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_51);
          __pyx_t_11 = PyInt_FromLong(__pyx_v_child_k); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_11);

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":163
 *                     genealogy[curpos[level+1]:curpos[level+1]+8, 1] = cp
 *                     s = RecurseOctreeByLevels(child_i, child_j, child_k, 2, 2, 2,
 *                                               curpos, ci, output, genealogy,             # <<<<<<<<<<<<<<
 *                                               corners, grids)
 *                 curpos[level] += 1
 */
          __pyx_t_52 = __Pyx_PyInt_to_py_npy_int32(__pyx_v_ci); if (unlikely(!__pyx_t_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_52);

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":164
 *                     s = RecurseOctreeByLevels(child_i, child_j, child_k, 2, 2, 2,
 *                                               curpos, ci, output, genealogy,
 *                                               corners, grids)             # <<<<<<<<<<<<<<
 *                 curpos[level] += 1
 *     return s
 */
          __pyx_t_53 = PyTuple_New(12); if (unlikely(!__pyx_t_53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_53);
          PyTuple_SET_ITEM(__pyx_t_53, 0, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_53, 1, __pyx_t_51);
          __Pyx_GIVEREF(__pyx_t_51);
          PyTuple_SET_ITEM(__pyx_t_53, 2, __pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_11);
          __Pyx_INCREF(__pyx_int_2);
          PyTuple_SET_ITEM(__pyx_t_53, 3, __pyx_int_2);
          __Pyx_GIVEREF(__pyx_int_2);
          __Pyx_INCREF(__pyx_int_2);
          PyTuple_SET_ITEM(__pyx_t_53, 4, __pyx_int_2);
          __Pyx_GIVEREF(__pyx_int_2);
          __Pyx_INCREF(__pyx_int_2);
          PyTuple_SET_ITEM(__pyx_t_53, 5, __pyx_int_2);
          __Pyx_GIVEREF(__pyx_int_2);
          __Pyx_INCREF(((PyObject *)__pyx_v_curpos));
          PyTuple_SET_ITEM(__pyx_t_53, 6, ((PyObject *)__pyx_v_curpos));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_curpos));
          PyTuple_SET_ITEM(__pyx_t_53, 7, __pyx_t_52);
          __Pyx_GIVEREF(__pyx_t_52);
          __Pyx_INCREF(((PyObject *)__pyx_v_output));
          PyTuple_SET_ITEM(__pyx_t_53, 8, ((PyObject *)__pyx_v_output));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_output));
          __Pyx_INCREF(((PyObject *)__pyx_v_genealogy));
          PyTuple_SET_ITEM(__pyx_t_53, 9, ((PyObject *)__pyx_v_genealogy));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_genealogy));
          __Pyx_INCREF(((PyObject *)__pyx_v_corners));
          PyTuple_SET_ITEM(__pyx_t_53, 10, ((PyObject *)__pyx_v_corners));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_corners));
          __Pyx_INCREF(((PyObject *)__pyx_v_grids));
          PyTuple_SET_ITEM(__pyx_t_53, 11, ((PyObject *)__pyx_v_grids));
          __Pyx_GIVEREF(((PyObject *)__pyx_v_grids));
          __pyx_t_2 = 0;
          __pyx_t_51 = 0;
          __pyx_t_11 = 0;
          __pyx_t_52 = 0;
          __pyx_t_52 = PyObject_Call(__pyx_t_12, __pyx_t_53, NULL); if (unlikely(!__pyx_t_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_52);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_53); __pyx_t_53 = 0;
          __Pyx_DECREF(__pyx_v_s);
          __pyx_v_s = __pyx_t_52;
          __pyx_t_52 = 0;
          goto __pyx_L15;
        }
        __pyx_L15:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":165
 *                                               curpos, ci, output, genealogy,
 *                                               corners, grids)
 *                 curpos[level] += 1             # <<<<<<<<<<<<<<
 *     return s
 * 
 */
        __pyx_t_54 = __pyx_v_level;
        if (__pyx_t_54 < 0) __pyx_t_54 += __pyx_bshape_0_curpos;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_curpos.buf, __pyx_t_54, __pyx_bstride_0_curpos) += 1;
      }
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":166
 *                                               corners, grids)
 *                 curpos[level] += 1
 *     return s             # <<<<<<<<<<<<<<
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_s);
  __pyx_r = __pyx_v_s;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_51);
  __Pyx_XDECREF(__pyx_t_52);
  __Pyx_XDECREF(__pyx_t_53);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_leftedges);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_curpos);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_leftedges);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dimensions);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_indices);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_genealogy);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_corners);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_fields);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_output);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.RecurseOctreeByLevels");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_leftedges);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_curpos);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_leftedges);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dimensions);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_child_indices);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_genealogy);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_corners);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_fields);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_output);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_child_grid);
  __Pyx_XDECREF((PyObject *)__pyx_v_grid);
  __Pyx_XDECREF((PyObject *)__pyx_v_child_indices);
  __Pyx_XDECREF((PyObject *)__pyx_v_dimensions);
  __Pyx_XDECREF((PyObject *)__pyx_v_fields);
  __Pyx_XDECREF((PyObject *)__pyx_v_leftedges);
  __Pyx_DECREF((PyObject *)__pyx_v_child_leftedges);
  __Pyx_DECREF(__pyx_v_s);
  __Pyx_DECREF((PyObject *)__pyx_v_curpos);
  __Pyx_DECREF((PyObject *)__pyx_v_output);
  __Pyx_DECREF((PyObject *)__pyx_v_genealogy);
  __Pyx_DECREF((PyObject *)__pyx_v_corners);
  __Pyx_DECREF((PyObject *)__pyx_v_grids);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":31
 * 
 * @cython.boundscheck(False)
 * def UnilinearlyInterpolate(np.ndarray[np.float64_t, ndim=1] table,             # <<<<<<<<<<<<<<
 *                            np.ndarray[np.float64_t, ndim=1] x_vals,
 *                            np.ndarray[np.float64_t, ndim=1] x_bins,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_UnilinearlyInterpolate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_UnilinearlyInterpolate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_table = 0;
  PyArrayObject *__pyx_v_x_vals = 0;
  PyArrayObject *__pyx_v_x_bins = 0;
  PyArrayObject *__pyx_v_x_is = 0;
  PyArrayObject *__pyx_v_output = 0;
  double __pyx_v_x;
  double __pyx_v_xp;
  double __pyx_v_xm;
  int __pyx_v_i;
  int __pyx_v_x_i;
  PyObject *__pyx_v_dx_inv;
  Py_buffer __pyx_bstruct_x_is;
  Py_ssize_t __pyx_bstride_0_x_is = 0;
  Py_ssize_t __pyx_bshape_0_x_is = 0;
  Py_buffer __pyx_bstruct_output;
  Py_ssize_t __pyx_bstride_0_output = 0;
  Py_ssize_t __pyx_bshape_0_output = 0;
  Py_buffer __pyx_bstruct_x_vals;
  Py_ssize_t __pyx_bstride_0_x_vals = 0;
  Py_ssize_t __pyx_bshape_0_x_vals = 0;
  Py_buffer __pyx_bstruct_table;
  Py_ssize_t __pyx_bstride_0_table = 0;
  Py_ssize_t __pyx_bshape_0_table = 0;
  Py_buffer __pyx_bstruct_x_bins;
  Py_ssize_t __pyx_bstride_0_x_bins = 0;
  Py_ssize_t __pyx_bshape_0_x_bins = 0;
  PyObject *__pyx_r = NULL;
  npy_intp __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  long __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  double __pyx_t_10;
  long __pyx_t_11;
  int __pyx_t_12;
  long __pyx_t_13;
  int __pyx_t_14;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__table,&__pyx_n_s__x_vals,&__pyx_n_s__x_bins,&__pyx_n_s__x_is,&__pyx_n_s__output,0};
  __Pyx_RefNannySetupContext("UnilinearlyInterpolate");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__table);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_vals);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("UnilinearlyInterpolate", 1, 5, 5, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_bins);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("UnilinearlyInterpolate", 1, 5, 5, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_is);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("UnilinearlyInterpolate", 1, 5, 5, 3); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__output);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("UnilinearlyInterpolate", 1, 5, 5, 4); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "UnilinearlyInterpolate") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_table = ((PyArrayObject *)values[0]);
    __pyx_v_x_vals = ((PyArrayObject *)values[1]);
    __pyx_v_x_bins = ((PyArrayObject *)values[2]);
    __pyx_v_x_is = ((PyArrayObject *)values[3]);
    __pyx_v_output = ((PyArrayObject *)values[4]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_table = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_x_vals = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_x_bins = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_x_is = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_output = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("UnilinearlyInterpolate", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.UnilinearlyInterpolate");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_table);
  __Pyx_INCREF((PyObject *)__pyx_v_x_vals);
  __Pyx_INCREF((PyObject *)__pyx_v_x_bins);
  __Pyx_INCREF((PyObject *)__pyx_v_x_is);
  __Pyx_INCREF((PyObject *)__pyx_v_output);
  __pyx_v_dx_inv = Py_None; __Pyx_INCREF(Py_None);
  __pyx_bstruct_table.buf = NULL;
  __pyx_bstruct_x_vals.buf = NULL;
  __pyx_bstruct_x_bins.buf = NULL;
  __pyx_bstruct_x_is.buf = NULL;
  __pyx_bstruct_output.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_table), __pyx_ptype_5numpy_ndarray, 1, "table", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x_vals), __pyx_ptype_5numpy_ndarray, 1, "x_vals", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x_bins), __pyx_ptype_5numpy_ndarray, 1, "x_bins", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x_is), __pyx_ptype_5numpy_ndarray, 1, "x_is", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output), __pyx_ptype_5numpy_ndarray, 1, "output", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_table, (PyObject*)__pyx_v_table, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_table = __pyx_bstruct_table.strides[0];
  __pyx_bshape_0_table = __pyx_bstruct_table.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x_vals, (PyObject*)__pyx_v_x_vals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_x_vals = __pyx_bstruct_x_vals.strides[0];
  __pyx_bshape_0_x_vals = __pyx_bstruct_x_vals.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x_bins, (PyObject*)__pyx_v_x_bins, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_x_bins = __pyx_bstruct_x_bins.strides[0];
  __pyx_bshape_0_x_bins = __pyx_bstruct_x_bins.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x_is, (PyObject*)__pyx_v_x_is, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_x_is = __pyx_bstruct_x_is.strides[0];
  __pyx_bshape_0_x_is = __pyx_bstruct_x_is.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_output, (PyObject*)__pyx_v_output, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_output = __pyx_bstruct_output.strides[0];
  __pyx_bshape_0_output = __pyx_bstruct_output.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":38
 *     cdef double x, xp, xm
 *     cdef int i, x_i, y_i
 *     for i in range(x_vals.shape[0]):             # <<<<<<<<<<<<<<
 *         x_i = x_is[i]
 *         x = x_vals[i]
 */
  __pyx_t_1 = (__pyx_v_x_vals->dimensions[0]);
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":39
 *     cdef int i, x_i, y_i
 *     for i in range(x_vals.shape[0]):
 *         x_i = x_is[i]             # <<<<<<<<<<<<<<
 *         x = x_vals[i]
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 */
    __pyx_t_3 = __pyx_v_i;
    if (__pyx_t_3 < 0) __pyx_t_3 += __pyx_bshape_0_x_is;
    __pyx_v_x_i = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_x_is.buf, __pyx_t_3, __pyx_bstride_0_x_is));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":40
 *     for i in range(x_vals.shape[0]):
 *         x_i = x_is[i]
 *         x = x_vals[i]             # <<<<<<<<<<<<<<
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 *         xp = (x - x_bins[x_i]) * dx_inv
 */
    __pyx_t_4 = __pyx_v_i;
    if (__pyx_t_4 < 0) __pyx_t_4 += __pyx_bshape_0_x_vals;
    __pyx_v_x = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_vals.buf, __pyx_t_4, __pyx_bstride_0_x_vals));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":41
 *         x_i = x_is[i]
 *         x = x_vals[i]
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])             # <<<<<<<<<<<<<<
 *         xp = (x - x_bins[x_i]) * dx_inv
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 */
    __pyx_t_5 = (__pyx_v_x_i + 1);
    if (__pyx_t_5 < 0) __pyx_t_5 += __pyx_bshape_0_x_bins;
    __pyx_t_6 = __pyx_v_x_i;
    if (__pyx_t_6 < 0) __pyx_t_6 += __pyx_bshape_0_x_bins;
    __pyx_t_7 = PyFloat_FromDouble((1.0 / ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_5, __pyx_bstride_0_x_bins)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_6, __pyx_bstride_0_x_bins))))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_v_dx_inv);
    __pyx_v_dx_inv = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":42
 *         x = x_vals[i]
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 *         xp = (x - x_bins[x_i]) * dx_inv             # <<<<<<<<<<<<<<
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 *         output[i]  = table[x_i  ] * (xm) \
 */
    __pyx_t_8 = __pyx_v_x_i;
    if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_bshape_0_x_bins;
    __pyx_t_7 = PyFloat_FromDouble((__pyx_v_x - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_8, __pyx_bstride_0_x_bins)))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_9 = PyNumber_Multiply(__pyx_t_7, __pyx_v_dx_inv); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_xp = __pyx_t_10;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":43
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 *         xp = (x - x_bins[x_i]) * dx_inv
 *         xm = (x_bins[x_i+1] - x) * dx_inv             # <<<<<<<<<<<<<<
 *         output[i]  = table[x_i  ] * (xm) \
 *                    + table[x_i+1] * (xp)
 */
    __pyx_t_11 = (__pyx_v_x_i + 1);
    if (__pyx_t_11 < 0) __pyx_t_11 += __pyx_bshape_0_x_bins;
    __pyx_t_9 = PyFloat_FromDouble(((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_11, __pyx_bstride_0_x_bins)) - __pyx_v_x)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_7 = PyNumber_Multiply(__pyx_t_9, __pyx_v_dx_inv); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_xm = __pyx_t_10;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":44
 *         xp = (x - x_bins[x_i]) * dx_inv
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 *         output[i]  = table[x_i  ] * (xm) \             # <<<<<<<<<<<<<<
 *                    + table[x_i+1] * (xp)
 * 
 */
    __pyx_t_12 = __pyx_v_x_i;
    if (__pyx_t_12 < 0) __pyx_t_12 += __pyx_bshape_0_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":45
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 *         output[i]  = table[x_i  ] * (xm) \
 *                    + table[x_i+1] * (xp)             # <<<<<<<<<<<<<<
 * 
 * @cython.boundscheck(False)
 */
    __pyx_t_13 = (__pyx_v_x_i + 1);
    if (__pyx_t_13 < 0) __pyx_t_13 += __pyx_bshape_0_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":44
 *         xp = (x - x_bins[x_i]) * dx_inv
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 *         output[i]  = table[x_i  ] * (xm) \             # <<<<<<<<<<<<<<
 *                    + table[x_i+1] * (xp)
 * 
 */
    __pyx_t_14 = __pyx_v_i;
    if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_bshape_0_output;
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_output.buf, __pyx_t_14, __pyx_bstride_0_output) = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_12, __pyx_bstride_0_table)) * __pyx_v_xm) + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_13, __pyx_bstride_0_table)) * __pyx_v_xp));
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_is);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_output);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_vals);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_table);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_bins);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.UnilinearlyInterpolate");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_is);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_output);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_vals);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_table);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_bins);
  __pyx_L2:;
  __Pyx_DECREF(__pyx_v_dx_inv);
  __Pyx_DECREF((PyObject *)__pyx_v_table);
  __Pyx_DECREF((PyObject *)__pyx_v_x_vals);
  __Pyx_DECREF((PyObject *)__pyx_v_x_bins);
  __Pyx_DECREF((PyObject *)__pyx_v_x_is);
  __Pyx_DECREF((PyObject *)__pyx_v_output);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":48
 * 
 * @cython.boundscheck(False)
 * def BilinearlyInterpolate(np.ndarray[np.float64_t, ndim=2] table,             # <<<<<<<<<<<<<<
 *                           np.ndarray[np.float64_t, ndim=1] x_vals,
 *                           np.ndarray[np.float64_t, ndim=1] y_vals,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_BilinearlyInterpolate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_BilinearlyInterpolate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_table = 0;
  PyArrayObject *__pyx_v_x_vals = 0;
  PyArrayObject *__pyx_v_y_vals = 0;
  PyArrayObject *__pyx_v_x_bins = 0;
  PyArrayObject *__pyx_v_y_bins = 0;
  PyArrayObject *__pyx_v_x_is = 0;
  PyArrayObject *__pyx_v_y_is = 0;
  PyArrayObject *__pyx_v_output = 0;
  double __pyx_v_x;
  double __pyx_v_xp;
  double __pyx_v_xm;
  double __pyx_v_y;
  double __pyx_v_yp;
  double __pyx_v_ym;
  double __pyx_v_dx_inv;
  double __pyx_v_dy_inv;
  int __pyx_v_i;
  int __pyx_v_x_i;
  int __pyx_v_y_i;
  Py_buffer __pyx_bstruct_y_vals;
  Py_ssize_t __pyx_bstride_0_y_vals = 0;
  Py_ssize_t __pyx_bshape_0_y_vals = 0;
  Py_buffer __pyx_bstruct_output;
  Py_ssize_t __pyx_bstride_0_output = 0;
  Py_ssize_t __pyx_bshape_0_output = 0;
  Py_buffer __pyx_bstruct_y_is;
  Py_ssize_t __pyx_bstride_0_y_is = 0;
  Py_ssize_t __pyx_bshape_0_y_is = 0;
  Py_buffer __pyx_bstruct_y_bins;
  Py_ssize_t __pyx_bstride_0_y_bins = 0;
  Py_ssize_t __pyx_bshape_0_y_bins = 0;
  Py_buffer __pyx_bstruct_x_is;
  Py_ssize_t __pyx_bstride_0_x_is = 0;
  Py_ssize_t __pyx_bshape_0_x_is = 0;
  Py_buffer __pyx_bstruct_x_vals;
  Py_ssize_t __pyx_bstride_0_x_vals = 0;
  Py_ssize_t __pyx_bshape_0_x_vals = 0;
  Py_buffer __pyx_bstruct_table;
  Py_ssize_t __pyx_bstride_0_table = 0;
  Py_ssize_t __pyx_bstride_1_table = 0;
  Py_ssize_t __pyx_bshape_0_table = 0;
  Py_ssize_t __pyx_bshape_1_table = 0;
  Py_buffer __pyx_bstruct_x_bins;
  Py_ssize_t __pyx_bstride_0_x_bins = 0;
  Py_ssize_t __pyx_bshape_0_x_bins = 0;
  PyObject *__pyx_r = NULL;
  npy_intp __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  long __pyx_t_7;
  int __pyx_t_8;
  long __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  long __pyx_t_13;
  long __pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  long __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  long __pyx_t_20;
  long __pyx_t_21;
  long __pyx_t_22;
  int __pyx_t_23;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__table,&__pyx_n_s__x_vals,&__pyx_n_s__y_vals,&__pyx_n_s__x_bins,&__pyx_n_s__y_bins,&__pyx_n_s__x_is,&__pyx_n_s__y_is,&__pyx_n_s__output,0};
  __Pyx_RefNannySetupContext("BilinearlyInterpolate");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__table);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_vals);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("BilinearlyInterpolate", 1, 8, 8, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y_vals);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("BilinearlyInterpolate", 1, 8, 8, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_bins);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("BilinearlyInterpolate", 1, 8, 8, 3); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y_bins);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("BilinearlyInterpolate", 1, 8, 8, 4); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_is);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("BilinearlyInterpolate", 1, 8, 8, 5); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y_is);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("BilinearlyInterpolate", 1, 8, 8, 6); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  7:
      values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__output);
      if (likely(values[7])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("BilinearlyInterpolate", 1, 8, 8, 7); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "BilinearlyInterpolate") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_table = ((PyArrayObject *)values[0]);
    __pyx_v_x_vals = ((PyArrayObject *)values[1]);
    __pyx_v_y_vals = ((PyArrayObject *)values[2]);
    __pyx_v_x_bins = ((PyArrayObject *)values[3]);
    __pyx_v_y_bins = ((PyArrayObject *)values[4]);
    __pyx_v_x_is = ((PyArrayObject *)values[5]);
    __pyx_v_y_is = ((PyArrayObject *)values[6]);
    __pyx_v_output = ((PyArrayObject *)values[7]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_table = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_x_vals = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_y_vals = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_x_bins = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_y_bins = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_x_is = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 5));
    __pyx_v_y_is = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 6));
    __pyx_v_output = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 7));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("BilinearlyInterpolate", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.BilinearlyInterpolate");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_table);
  __Pyx_INCREF((PyObject *)__pyx_v_x_vals);
  __Pyx_INCREF((PyObject *)__pyx_v_y_vals);
  __Pyx_INCREF((PyObject *)__pyx_v_x_bins);
  __Pyx_INCREF((PyObject *)__pyx_v_y_bins);
  __Pyx_INCREF((PyObject *)__pyx_v_x_is);
  __Pyx_INCREF((PyObject *)__pyx_v_y_is);
  __Pyx_INCREF((PyObject *)__pyx_v_output);
  __pyx_bstruct_table.buf = NULL;
  __pyx_bstruct_x_vals.buf = NULL;
  __pyx_bstruct_y_vals.buf = NULL;
  __pyx_bstruct_x_bins.buf = NULL;
  __pyx_bstruct_y_bins.buf = NULL;
  __pyx_bstruct_x_is.buf = NULL;
  __pyx_bstruct_y_is.buf = NULL;
  __pyx_bstruct_output.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_table), __pyx_ptype_5numpy_ndarray, 1, "table", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x_vals), __pyx_ptype_5numpy_ndarray, 1, "x_vals", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y_vals), __pyx_ptype_5numpy_ndarray, 1, "y_vals", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x_bins), __pyx_ptype_5numpy_ndarray, 1, "x_bins", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y_bins), __pyx_ptype_5numpy_ndarray, 1, "y_bins", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x_is), __pyx_ptype_5numpy_ndarray, 1, "x_is", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y_is), __pyx_ptype_5numpy_ndarray, 1, "y_is", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output), __pyx_ptype_5numpy_ndarray, 1, "output", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_table, (PyObject*)__pyx_v_table, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_table = __pyx_bstruct_table.strides[0]; __pyx_bstride_1_table = __pyx_bstruct_table.strides[1];
  __pyx_bshape_0_table = __pyx_bstruct_table.shape[0]; __pyx_bshape_1_table = __pyx_bstruct_table.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x_vals, (PyObject*)__pyx_v_x_vals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_x_vals = __pyx_bstruct_x_vals.strides[0];
  __pyx_bshape_0_x_vals = __pyx_bstruct_x_vals.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y_vals, (PyObject*)__pyx_v_y_vals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_y_vals = __pyx_bstruct_y_vals.strides[0];
  __pyx_bshape_0_y_vals = __pyx_bstruct_y_vals.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x_bins, (PyObject*)__pyx_v_x_bins, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_x_bins = __pyx_bstruct_x_bins.strides[0];
  __pyx_bshape_0_x_bins = __pyx_bstruct_x_bins.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y_bins, (PyObject*)__pyx_v_y_bins, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_y_bins = __pyx_bstruct_y_bins.strides[0];
  __pyx_bshape_0_y_bins = __pyx_bstruct_y_bins.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x_is, (PyObject*)__pyx_v_x_is, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_x_is = __pyx_bstruct_x_is.strides[0];
  __pyx_bshape_0_x_is = __pyx_bstruct_x_is.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y_is, (PyObject*)__pyx_v_y_is, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_y_is = __pyx_bstruct_y_is.strides[0];
  __pyx_bshape_0_y_is = __pyx_bstruct_y_is.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_output, (PyObject*)__pyx_v_output, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_output = __pyx_bstruct_output.strides[0];
  __pyx_bshape_0_output = __pyx_bstruct_output.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":60
 *     cdef double dx_inv, dy_inv
 *     cdef int i, x_i, y_i
 *     for i in range(x_vals.shape[0]):             # <<<<<<<<<<<<<<
 *         x_i = x_is[i]
 *         y_i = y_is[i]
 */
  __pyx_t_1 = (__pyx_v_x_vals->dimensions[0]);
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":61
 *     cdef int i, x_i, y_i
 *     for i in range(x_vals.shape[0]):
 *         x_i = x_is[i]             # <<<<<<<<<<<<<<
 *         y_i = y_is[i]
 *         x = x_vals[i]
 */
    __pyx_t_3 = __pyx_v_i;
    if (__pyx_t_3 < 0) __pyx_t_3 += __pyx_bshape_0_x_is;
    __pyx_v_x_i = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_x_is.buf, __pyx_t_3, __pyx_bstride_0_x_is));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":62
 *     for i in range(x_vals.shape[0]):
 *         x_i = x_is[i]
 *         y_i = y_is[i]             # <<<<<<<<<<<<<<
 *         x = x_vals[i]
 *         y = y_vals[i]
 */
    __pyx_t_4 = __pyx_v_i;
    if (__pyx_t_4 < 0) __pyx_t_4 += __pyx_bshape_0_y_is;
    __pyx_v_y_i = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_y_is.buf, __pyx_t_4, __pyx_bstride_0_y_is));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":63
 *         x_i = x_is[i]
 *         y_i = y_is[i]
 *         x = x_vals[i]             # <<<<<<<<<<<<<<
 *         y = y_vals[i]
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 */
    __pyx_t_5 = __pyx_v_i;
    if (__pyx_t_5 < 0) __pyx_t_5 += __pyx_bshape_0_x_vals;
    __pyx_v_x = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_vals.buf, __pyx_t_5, __pyx_bstride_0_x_vals));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":64
 *         y_i = y_is[i]
 *         x = x_vals[i]
 *         y = y_vals[i]             # <<<<<<<<<<<<<<
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 *         dy_inv = 1.0 / (y_bins[y_i+1] - y_bins[y_i])
 */
    __pyx_t_6 = __pyx_v_i;
    if (__pyx_t_6 < 0) __pyx_t_6 += __pyx_bshape_0_y_vals;
    __pyx_v_y = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y_vals.buf, __pyx_t_6, __pyx_bstride_0_y_vals));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":65
 *         x = x_vals[i]
 *         y = y_vals[i]
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])             # <<<<<<<<<<<<<<
 *         dy_inv = 1.0 / (y_bins[y_i+1] - y_bins[y_i])
 *         xp = (x - x_bins[x_i]) * dx_inv
 */
    __pyx_t_7 = (__pyx_v_x_i + 1);
    if (__pyx_t_7 < 0) __pyx_t_7 += __pyx_bshape_0_x_bins;
    __pyx_t_8 = __pyx_v_x_i;
    if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_bshape_0_x_bins;
    __pyx_v_dx_inv = (1.0 / ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_7, __pyx_bstride_0_x_bins)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_8, __pyx_bstride_0_x_bins))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":66
 *         y = y_vals[i]
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 *         dy_inv = 1.0 / (y_bins[y_i+1] - y_bins[y_i])             # <<<<<<<<<<<<<<
 *         xp = (x - x_bins[x_i]) * dx_inv
 *         yp = (y - y_bins[y_i]) * dy_inv
 */
    __pyx_t_9 = (__pyx_v_y_i + 1);
    if (__pyx_t_9 < 0) __pyx_t_9 += __pyx_bshape_0_y_bins;
    __pyx_t_10 = __pyx_v_y_i;
    if (__pyx_t_10 < 0) __pyx_t_10 += __pyx_bshape_0_y_bins;
    __pyx_v_dy_inv = (1.0 / ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y_bins.buf, __pyx_t_9, __pyx_bstride_0_y_bins)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y_bins.buf, __pyx_t_10, __pyx_bstride_0_y_bins))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":67
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 *         dy_inv = 1.0 / (y_bins[y_i+1] - y_bins[y_i])
 *         xp = (x - x_bins[x_i]) * dx_inv             # <<<<<<<<<<<<<<
 *         yp = (y - y_bins[y_i]) * dy_inv
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 */
    __pyx_t_11 = __pyx_v_x_i;
    if (__pyx_t_11 < 0) __pyx_t_11 += __pyx_bshape_0_x_bins;
    __pyx_v_xp = ((__pyx_v_x - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_11, __pyx_bstride_0_x_bins))) * __pyx_v_dx_inv);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":68
 *         dy_inv = 1.0 / (y_bins[y_i+1] - y_bins[y_i])
 *         xp = (x - x_bins[x_i]) * dx_inv
 *         yp = (y - y_bins[y_i]) * dy_inv             # <<<<<<<<<<<<<<
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 *         ym = (y_bins[y_i+1] - y) * dy_inv
 */
    __pyx_t_12 = __pyx_v_y_i;
    if (__pyx_t_12 < 0) __pyx_t_12 += __pyx_bshape_0_y_bins;
    __pyx_v_yp = ((__pyx_v_y - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y_bins.buf, __pyx_t_12, __pyx_bstride_0_y_bins))) * __pyx_v_dy_inv);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":69
 *         xp = (x - x_bins[x_i]) * dx_inv
 *         yp = (y - y_bins[y_i]) * dy_inv
 *         xm = (x_bins[x_i+1] - x) * dx_inv             # <<<<<<<<<<<<<<
 *         ym = (y_bins[y_i+1] - y) * dy_inv
 *         output[i]  = table[x_i  , y_i  ] * (xm*ym) \
 */
    __pyx_t_13 = (__pyx_v_x_i + 1);
    if (__pyx_t_13 < 0) __pyx_t_13 += __pyx_bshape_0_x_bins;
    __pyx_v_xm = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_13, __pyx_bstride_0_x_bins)) - __pyx_v_x) * __pyx_v_dx_inv);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":70
 *         yp = (y - y_bins[y_i]) * dy_inv
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 *         ym = (y_bins[y_i+1] - y) * dy_inv             # <<<<<<<<<<<<<<
 *         output[i]  = table[x_i  , y_i  ] * (xm*ym) \
 *                    + table[x_i+1, y_i  ] * (xp*ym) \
 */
    __pyx_t_14 = (__pyx_v_y_i + 1);
    if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_bshape_0_y_bins;
    __pyx_v_ym = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y_bins.buf, __pyx_t_14, __pyx_bstride_0_y_bins)) - __pyx_v_y) * __pyx_v_dy_inv);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":71
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 *         ym = (y_bins[y_i+1] - y) * dy_inv
 *         output[i]  = table[x_i  , y_i  ] * (xm*ym) \             # <<<<<<<<<<<<<<
 *                    + table[x_i+1, y_i  ] * (xp*ym) \
 *                    + table[x_i  , y_i+1] * (xm*yp) \
 */
    __pyx_t_15 = __pyx_v_x_i;
    __pyx_t_16 = __pyx_v_y_i;
    if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_bshape_0_table;
    if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_bshape_1_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":72
 *         ym = (y_bins[y_i+1] - y) * dy_inv
 *         output[i]  = table[x_i  , y_i  ] * (xm*ym) \
 *                    + table[x_i+1, y_i  ] * (xp*ym) \             # <<<<<<<<<<<<<<
 *                    + table[x_i  , y_i+1] * (xm*yp) \
 *                    + table[x_i+1, y_i+1] * (xp*yp)
 */
    __pyx_t_17 = (__pyx_v_x_i + 1);
    __pyx_t_18 = __pyx_v_y_i;
    if (__pyx_t_17 < 0) __pyx_t_17 += __pyx_bshape_0_table;
    if (__pyx_t_18 < 0) __pyx_t_18 += __pyx_bshape_1_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":73
 *         output[i]  = table[x_i  , y_i  ] * (xm*ym) \
 *                    + table[x_i+1, y_i  ] * (xp*ym) \
 *                    + table[x_i  , y_i+1] * (xm*yp) \             # <<<<<<<<<<<<<<
 *                    + table[x_i+1, y_i+1] * (xp*yp)
 * 
 */
    __pyx_t_19 = __pyx_v_x_i;
    __pyx_t_20 = (__pyx_v_y_i + 1);
    if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_bshape_0_table;
    if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_bshape_1_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":74
 *                    + table[x_i+1, y_i  ] * (xp*ym) \
 *                    + table[x_i  , y_i+1] * (xm*yp) \
 *                    + table[x_i+1, y_i+1] * (xp*yp)             # <<<<<<<<<<<<<<
 * 
 * @cython.boundscheck(False)
 */
    __pyx_t_21 = (__pyx_v_x_i + 1);
    __pyx_t_22 = (__pyx_v_y_i + 1);
    if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_bshape_0_table;
    if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_bshape_1_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":71
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 *         ym = (y_bins[y_i+1] - y) * dy_inv
 *         output[i]  = table[x_i  , y_i  ] * (xm*ym) \             # <<<<<<<<<<<<<<
 *                    + table[x_i+1, y_i  ] * (xp*ym) \
 *                    + table[x_i  , y_i+1] * (xm*yp) \
 */
    __pyx_t_23 = __pyx_v_i;
    if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_bshape_0_output;
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_output.buf, __pyx_t_23, __pyx_bstride_0_output) = (((((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_15, __pyx_bstride_0_table, __pyx_t_16, __pyx_bstride_1_table)) * (__pyx_v_xm * __pyx_v_ym)) + ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_17, __pyx_bstride_0_table, __pyx_t_18, __pyx_bstride_1_table)) * (__pyx_v_xp * __pyx_v_ym))) + ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_19, __pyx_bstride_0_table, __pyx_t_20, __pyx_bstride_1_table)) * (__pyx_v_xm * __pyx_v_yp))) + ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_21, __pyx_bstride_0_table, __pyx_t_22, __pyx_bstride_1_table)) * (__pyx_v_xp * __pyx_v_yp)));
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_vals);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_output);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_is);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_bins);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_is);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_vals);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_table);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_bins);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.BilinearlyInterpolate");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_vals);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_output);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_is);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_bins);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_is);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_vals);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_table);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_bins);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_table);
  __Pyx_DECREF((PyObject *)__pyx_v_x_vals);
  __Pyx_DECREF((PyObject *)__pyx_v_y_vals);
  __Pyx_DECREF((PyObject *)__pyx_v_x_bins);
  __Pyx_DECREF((PyObject *)__pyx_v_y_bins);
  __Pyx_DECREF((PyObject *)__pyx_v_x_is);
  __Pyx_DECREF((PyObject *)__pyx_v_y_is);
  __Pyx_DECREF((PyObject *)__pyx_v_output);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":77
 * 
 * @cython.boundscheck(False)
 * def TrilinearlyInterpolate(np.ndarray[np.float64_t, ndim=3] table,             # <<<<<<<<<<<<<<
 *                            np.ndarray[np.float64_t, ndim=1] x_vals,
 *                            np.ndarray[np.float64_t, ndim=1] y_vals,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_TrilinearlyInterpolate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_TrilinearlyInterpolate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_table = 0;
  PyArrayObject *__pyx_v_x_vals = 0;
  PyArrayObject *__pyx_v_y_vals = 0;
  PyArrayObject *__pyx_v_z_vals = 0;
  PyArrayObject *__pyx_v_x_bins = 0;
  PyArrayObject *__pyx_v_y_bins = 0;
  PyArrayObject *__pyx_v_z_bins = 0;
  PyArrayObject *__pyx_v_x_is = 0;
  PyArrayObject *__pyx_v_y_is = 0;
  PyArrayObject *__pyx_v_z_is = 0;
  PyArrayObject *__pyx_v_output = 0;
  double __pyx_v_x;
  double __pyx_v_xp;
  double __pyx_v_xm;
  double __pyx_v_y;
  double __pyx_v_yp;
  double __pyx_v_ym;
  double __pyx_v_z;
  double __pyx_v_zp;
  double __pyx_v_zm;
  double __pyx_v_dx_inv;
  double __pyx_v_dy_inv;
  double __pyx_v_dz_inv;
  int __pyx_v_i;
  int __pyx_v_x_i;
  int __pyx_v_y_i;
  int __pyx_v_z_i;
  Py_buffer __pyx_bstruct_z_is;
  Py_ssize_t __pyx_bstride_0_z_is = 0;
  Py_ssize_t __pyx_bshape_0_z_is = 0;
  Py_buffer __pyx_bstruct_x_vals;
  Py_ssize_t __pyx_bstride_0_x_vals = 0;
  Py_ssize_t __pyx_bshape_0_x_vals = 0;
  Py_buffer __pyx_bstruct_y_is;
  Py_ssize_t __pyx_bstride_0_y_is = 0;
  Py_ssize_t __pyx_bshape_0_y_is = 0;
  Py_buffer __pyx_bstruct_y_bins;
  Py_ssize_t __pyx_bstride_0_y_bins = 0;
  Py_ssize_t __pyx_bshape_0_y_bins = 0;
  Py_buffer __pyx_bstruct_z_bins;
  Py_ssize_t __pyx_bstride_0_z_bins = 0;
  Py_ssize_t __pyx_bshape_0_z_bins = 0;
  Py_buffer __pyx_bstruct_x_is;
  Py_ssize_t __pyx_bstride_0_x_is = 0;
  Py_ssize_t __pyx_bshape_0_x_is = 0;
  Py_buffer __pyx_bstruct_output;
  Py_ssize_t __pyx_bstride_0_output = 0;
  Py_ssize_t __pyx_bshape_0_output = 0;
  Py_buffer __pyx_bstruct_table;
  Py_ssize_t __pyx_bstride_0_table = 0;
  Py_ssize_t __pyx_bstride_1_table = 0;
  Py_ssize_t __pyx_bstride_2_table = 0;
  Py_ssize_t __pyx_bshape_0_table = 0;
  Py_ssize_t __pyx_bshape_1_table = 0;
  Py_ssize_t __pyx_bshape_2_table = 0;
  Py_buffer __pyx_bstruct_x_bins;
  Py_ssize_t __pyx_bstride_0_x_bins = 0;
  Py_ssize_t __pyx_bshape_0_x_bins = 0;
  Py_buffer __pyx_bstruct_y_vals;
  Py_ssize_t __pyx_bstride_0_y_vals = 0;
  Py_ssize_t __pyx_bshape_0_y_vals = 0;
  Py_buffer __pyx_bstruct_z_vals;
  Py_ssize_t __pyx_bstride_0_z_vals = 0;
  Py_ssize_t __pyx_bshape_0_z_vals = 0;
  PyObject *__pyx_r = NULL;
  npy_intp __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  long __pyx_t_9;
  int __pyx_t_10;
  long __pyx_t_11;
  int __pyx_t_12;
  long __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  long __pyx_t_18;
  long __pyx_t_19;
  long __pyx_t_20;
  int __pyx_t_21;
  int __pyx_t_22;
  int __pyx_t_23;
  long __pyx_t_24;
  int __pyx_t_25;
  int __pyx_t_26;
  int __pyx_t_27;
  long __pyx_t_28;
  int __pyx_t_29;
  int __pyx_t_30;
  int __pyx_t_31;
  long __pyx_t_32;
  long __pyx_t_33;
  int __pyx_t_34;
  long __pyx_t_35;
  int __pyx_t_36;
  long __pyx_t_37;
  long __pyx_t_38;
  long __pyx_t_39;
  long __pyx_t_40;
  int __pyx_t_41;
  long __pyx_t_42;
  long __pyx_t_43;
  long __pyx_t_44;
  int __pyx_t_45;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__table,&__pyx_n_s__x_vals,&__pyx_n_s__y_vals,&__pyx_n_s__z_vals,&__pyx_n_s__x_bins,&__pyx_n_s__y_bins,&__pyx_n_s__z_bins,&__pyx_n_s__x_is,&__pyx_n_s__y_is,&__pyx_n_s__z_is,&__pyx_n_s__output,0};
  __Pyx_RefNannySetupContext("TrilinearlyInterpolate");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__table);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_vals);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TrilinearlyInterpolate", 1, 11, 11, 1); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y_vals);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TrilinearlyInterpolate", 1, 11, 11, 2); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__z_vals);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TrilinearlyInterpolate", 1, 11, 11, 3); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_bins);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TrilinearlyInterpolate", 1, 11, 11, 4); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y_bins);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TrilinearlyInterpolate", 1, 11, 11, 5); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__z_bins);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TrilinearlyInterpolate", 1, 11, 11, 6); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  7:
      values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_is);
      if (likely(values[7])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TrilinearlyInterpolate", 1, 11, 11, 7); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  8:
      values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y_is);
      if (likely(values[8])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TrilinearlyInterpolate", 1, 11, 11, 8); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  9:
      values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__z_is);
      if (likely(values[9])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TrilinearlyInterpolate", 1, 11, 11, 9); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case 10:
      values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__output);
      if (likely(values[10])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TrilinearlyInterpolate", 1, 11, 11, 10); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "TrilinearlyInterpolate") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_table = ((PyArrayObject *)values[0]);
    __pyx_v_x_vals = ((PyArrayObject *)values[1]);
    __pyx_v_y_vals = ((PyArrayObject *)values[2]);
    __pyx_v_z_vals = ((PyArrayObject *)values[3]);
    __pyx_v_x_bins = ((PyArrayObject *)values[4]);
    __pyx_v_y_bins = ((PyArrayObject *)values[5]);
    __pyx_v_z_bins = ((PyArrayObject *)values[6]);
    __pyx_v_x_is = ((PyArrayObject *)values[7]);
    __pyx_v_y_is = ((PyArrayObject *)values[8]);
    __pyx_v_z_is = ((PyArrayObject *)values[9]);
    __pyx_v_output = ((PyArrayObject *)values[10]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 11) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_table = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_x_vals = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_y_vals = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_z_vals = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_x_bins = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_y_bins = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 5));
    __pyx_v_z_bins = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 6));
    __pyx_v_x_is = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 7));
    __pyx_v_y_is = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 8));
    __pyx_v_z_is = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 9));
    __pyx_v_output = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 10));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("TrilinearlyInterpolate", 1, 11, 11, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.TrilinearlyInterpolate");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_table);
  __Pyx_INCREF((PyObject *)__pyx_v_x_vals);
  __Pyx_INCREF((PyObject *)__pyx_v_y_vals);
  __Pyx_INCREF((PyObject *)__pyx_v_z_vals);
  __Pyx_INCREF((PyObject *)__pyx_v_x_bins);
  __Pyx_INCREF((PyObject *)__pyx_v_y_bins);
  __Pyx_INCREF((PyObject *)__pyx_v_z_bins);
  __Pyx_INCREF((PyObject *)__pyx_v_x_is);
  __Pyx_INCREF((PyObject *)__pyx_v_y_is);
  __Pyx_INCREF((PyObject *)__pyx_v_z_is);
  __Pyx_INCREF((PyObject *)__pyx_v_output);
  __pyx_bstruct_table.buf = NULL;
  __pyx_bstruct_x_vals.buf = NULL;
  __pyx_bstruct_y_vals.buf = NULL;
  __pyx_bstruct_z_vals.buf = NULL;
  __pyx_bstruct_x_bins.buf = NULL;
  __pyx_bstruct_y_bins.buf = NULL;
  __pyx_bstruct_z_bins.buf = NULL;
  __pyx_bstruct_x_is.buf = NULL;
  __pyx_bstruct_y_is.buf = NULL;
  __pyx_bstruct_z_is.buf = NULL;
  __pyx_bstruct_output.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_table), __pyx_ptype_5numpy_ndarray, 1, "table", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x_vals), __pyx_ptype_5numpy_ndarray, 1, "x_vals", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y_vals), __pyx_ptype_5numpy_ndarray, 1, "y_vals", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_z_vals), __pyx_ptype_5numpy_ndarray, 1, "z_vals", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x_bins), __pyx_ptype_5numpy_ndarray, 1, "x_bins", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y_bins), __pyx_ptype_5numpy_ndarray, 1, "y_bins", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_z_bins), __pyx_ptype_5numpy_ndarray, 1, "z_bins", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x_is), __pyx_ptype_5numpy_ndarray, 1, "x_is", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y_is), __pyx_ptype_5numpy_ndarray, 1, "y_is", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_z_is), __pyx_ptype_5numpy_ndarray, 1, "z_is", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output), __pyx_ptype_5numpy_ndarray, 1, "output", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_table, (PyObject*)__pyx_v_table, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_table = __pyx_bstruct_table.strides[0]; __pyx_bstride_1_table = __pyx_bstruct_table.strides[1]; __pyx_bstride_2_table = __pyx_bstruct_table.strides[2];
  __pyx_bshape_0_table = __pyx_bstruct_table.shape[0]; __pyx_bshape_1_table = __pyx_bstruct_table.shape[1]; __pyx_bshape_2_table = __pyx_bstruct_table.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x_vals, (PyObject*)__pyx_v_x_vals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_x_vals = __pyx_bstruct_x_vals.strides[0];
  __pyx_bshape_0_x_vals = __pyx_bstruct_x_vals.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y_vals, (PyObject*)__pyx_v_y_vals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_y_vals = __pyx_bstruct_y_vals.strides[0];
  __pyx_bshape_0_y_vals = __pyx_bstruct_y_vals.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_z_vals, (PyObject*)__pyx_v_z_vals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_z_vals = __pyx_bstruct_z_vals.strides[0];
  __pyx_bshape_0_z_vals = __pyx_bstruct_z_vals.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x_bins, (PyObject*)__pyx_v_x_bins, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_x_bins = __pyx_bstruct_x_bins.strides[0];
  __pyx_bshape_0_x_bins = __pyx_bstruct_x_bins.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y_bins, (PyObject*)__pyx_v_y_bins, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_y_bins = __pyx_bstruct_y_bins.strides[0];
  __pyx_bshape_0_y_bins = __pyx_bstruct_y_bins.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_z_bins, (PyObject*)__pyx_v_z_bins, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_z_bins = __pyx_bstruct_z_bins.strides[0];
  __pyx_bshape_0_z_bins = __pyx_bstruct_z_bins.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x_is, (PyObject*)__pyx_v_x_is, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_x_is = __pyx_bstruct_x_is.strides[0];
  __pyx_bshape_0_x_is = __pyx_bstruct_x_is.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y_is, (PyObject*)__pyx_v_y_is, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_y_is = __pyx_bstruct_y_is.strides[0];
  __pyx_bshape_0_y_is = __pyx_bstruct_y_is.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_z_is, (PyObject*)__pyx_v_z_is, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_z_is = __pyx_bstruct_z_is.strides[0];
  __pyx_bshape_0_z_is = __pyx_bstruct_z_is.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_output, (PyObject*)__pyx_v_output, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_output = __pyx_bstruct_output.strides[0];
  __pyx_bshape_0_output = __pyx_bstruct_output.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":93
 *     cdef double dx_inv, dy_inv, dz_inv
 *     cdef int i, x_i, y_i, z_i
 *     for i in range(x_vals.shape[0]):             # <<<<<<<<<<<<<<
 *         x_i = x_is[i]
 *         y_i = y_is[i]
 */
  __pyx_t_1 = (__pyx_v_x_vals->dimensions[0]);
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":94
 *     cdef int i, x_i, y_i, z_i
 *     for i in range(x_vals.shape[0]):
 *         x_i = x_is[i]             # <<<<<<<<<<<<<<
 *         y_i = y_is[i]
 *         z_i = z_is[i]
 */
    __pyx_t_3 = __pyx_v_i;
    if (__pyx_t_3 < 0) __pyx_t_3 += __pyx_bshape_0_x_is;
    __pyx_v_x_i = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_bstruct_x_is.buf, __pyx_t_3, __pyx_bstride_0_x_is));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":95
 *     for i in range(x_vals.shape[0]):
 *         x_i = x_is[i]
 *         y_i = y_is[i]             # <<<<<<<<<<<<<<
 *         z_i = z_is[i]
 *         x = x_vals[i]
 */
    __pyx_t_4 = __pyx_v_i;
    if (__pyx_t_4 < 0) __pyx_t_4 += __pyx_bshape_0_y_is;
    __pyx_v_y_i = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_bstruct_y_is.buf, __pyx_t_4, __pyx_bstride_0_y_is));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":96
 *         x_i = x_is[i]
 *         y_i = y_is[i]
 *         z_i = z_is[i]             # <<<<<<<<<<<<<<
 *         x = x_vals[i]
 *         y = y_vals[i]
 */
    __pyx_t_5 = __pyx_v_i;
    if (__pyx_t_5 < 0) __pyx_t_5 += __pyx_bshape_0_z_is;
    __pyx_v_z_i = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int_t *, __pyx_bstruct_z_is.buf, __pyx_t_5, __pyx_bstride_0_z_is));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":97
 *         y_i = y_is[i]
 *         z_i = z_is[i]
 *         x = x_vals[i]             # <<<<<<<<<<<<<<
 *         y = y_vals[i]
 *         z = z_vals[i]
 */
    __pyx_t_6 = __pyx_v_i;
    if (__pyx_t_6 < 0) __pyx_t_6 += __pyx_bshape_0_x_vals;
    __pyx_v_x = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_vals.buf, __pyx_t_6, __pyx_bstride_0_x_vals));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":98
 *         z_i = z_is[i]
 *         x = x_vals[i]
 *         y = y_vals[i]             # <<<<<<<<<<<<<<
 *         z = z_vals[i]
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 */
    __pyx_t_7 = __pyx_v_i;
    if (__pyx_t_7 < 0) __pyx_t_7 += __pyx_bshape_0_y_vals;
    __pyx_v_y = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y_vals.buf, __pyx_t_7, __pyx_bstride_0_y_vals));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":99
 *         x = x_vals[i]
 *         y = y_vals[i]
 *         z = z_vals[i]             # <<<<<<<<<<<<<<
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 *         dy_inv = 1.0 / (y_bins[y_i+1] - y_bins[y_i])
 */
    __pyx_t_8 = __pyx_v_i;
    if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_bshape_0_z_vals;
    __pyx_v_z = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_z_vals.buf, __pyx_t_8, __pyx_bstride_0_z_vals));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":100
 *         y = y_vals[i]
 *         z = z_vals[i]
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])             # <<<<<<<<<<<<<<
 *         dy_inv = 1.0 / (y_bins[y_i+1] - y_bins[y_i])
 *         dz_inv = 1.0 / (z_bins[z_i+1] - z_bins[z_i])
 */
    __pyx_t_9 = (__pyx_v_x_i + 1);
    if (__pyx_t_9 < 0) __pyx_t_9 += __pyx_bshape_0_x_bins;
    __pyx_t_10 = __pyx_v_x_i;
    if (__pyx_t_10 < 0) __pyx_t_10 += __pyx_bshape_0_x_bins;
    __pyx_v_dx_inv = (1.0 / ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_9, __pyx_bstride_0_x_bins)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_10, __pyx_bstride_0_x_bins))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":101
 *         z = z_vals[i]
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 *         dy_inv = 1.0 / (y_bins[y_i+1] - y_bins[y_i])             # <<<<<<<<<<<<<<
 *         dz_inv = 1.0 / (z_bins[z_i+1] - z_bins[z_i])
 *         xp = (x - x_bins[x_i]) * dx_inv
 */
    __pyx_t_11 = (__pyx_v_y_i + 1);
    if (__pyx_t_11 < 0) __pyx_t_11 += __pyx_bshape_0_y_bins;
    __pyx_t_12 = __pyx_v_y_i;
    if (__pyx_t_12 < 0) __pyx_t_12 += __pyx_bshape_0_y_bins;
    __pyx_v_dy_inv = (1.0 / ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y_bins.buf, __pyx_t_11, __pyx_bstride_0_y_bins)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y_bins.buf, __pyx_t_12, __pyx_bstride_0_y_bins))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":102
 *         dx_inv = 1.0 / (x_bins[x_i+1] - x_bins[x_i])
 *         dy_inv = 1.0 / (y_bins[y_i+1] - y_bins[y_i])
 *         dz_inv = 1.0 / (z_bins[z_i+1] - z_bins[z_i])             # <<<<<<<<<<<<<<
 *         xp = (x - x_bins[x_i]) * dx_inv
 *         yp = (y - y_bins[y_i]) * dy_inv
 */
    __pyx_t_13 = (__pyx_v_z_i + 1);
    if (__pyx_t_13 < 0) __pyx_t_13 += __pyx_bshape_0_z_bins;
    __pyx_t_14 = __pyx_v_z_i;
    if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_bshape_0_z_bins;
    __pyx_v_dz_inv = (1.0 / ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_z_bins.buf, __pyx_t_13, __pyx_bstride_0_z_bins)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_z_bins.buf, __pyx_t_14, __pyx_bstride_0_z_bins))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":103
 *         dy_inv = 1.0 / (y_bins[y_i+1] - y_bins[y_i])
 *         dz_inv = 1.0 / (z_bins[z_i+1] - z_bins[z_i])
 *         xp = (x - x_bins[x_i]) * dx_inv             # <<<<<<<<<<<<<<
 *         yp = (y - y_bins[y_i]) * dy_inv
 *         zp = (z - z_bins[z_i]) * dz_inv
 */
    __pyx_t_15 = __pyx_v_x_i;
    if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_bshape_0_x_bins;
    __pyx_v_xp = ((__pyx_v_x - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_15, __pyx_bstride_0_x_bins))) * __pyx_v_dx_inv);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":104
 *         dz_inv = 1.0 / (z_bins[z_i+1] - z_bins[z_i])
 *         xp = (x - x_bins[x_i]) * dx_inv
 *         yp = (y - y_bins[y_i]) * dy_inv             # <<<<<<<<<<<<<<
 *         zp = (z - z_bins[z_i]) * dz_inv
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 */
    __pyx_t_16 = __pyx_v_y_i;
    if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_bshape_0_y_bins;
    __pyx_v_yp = ((__pyx_v_y - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y_bins.buf, __pyx_t_16, __pyx_bstride_0_y_bins))) * __pyx_v_dy_inv);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":105
 *         xp = (x - x_bins[x_i]) * dx_inv
 *         yp = (y - y_bins[y_i]) * dy_inv
 *         zp = (z - z_bins[z_i]) * dz_inv             # <<<<<<<<<<<<<<
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 *         ym = (y_bins[y_i+1] - y) * dy_inv
 */
    __pyx_t_17 = __pyx_v_z_i;
    if (__pyx_t_17 < 0) __pyx_t_17 += __pyx_bshape_0_z_bins;
    __pyx_v_zp = ((__pyx_v_z - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_z_bins.buf, __pyx_t_17, __pyx_bstride_0_z_bins))) * __pyx_v_dz_inv);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":106
 *         yp = (y - y_bins[y_i]) * dy_inv
 *         zp = (z - z_bins[z_i]) * dz_inv
 *         xm = (x_bins[x_i+1] - x) * dx_inv             # <<<<<<<<<<<<<<
 *         ym = (y_bins[y_i+1] - y) * dy_inv
 *         zm = (z_bins[z_i+1] - z) * dz_inv
 */
    __pyx_t_18 = (__pyx_v_x_i + 1);
    if (__pyx_t_18 < 0) __pyx_t_18 += __pyx_bshape_0_x_bins;
    __pyx_v_xm = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x_bins.buf, __pyx_t_18, __pyx_bstride_0_x_bins)) - __pyx_v_x) * __pyx_v_dx_inv);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":107
 *         zp = (z - z_bins[z_i]) * dz_inv
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 *         ym = (y_bins[y_i+1] - y) * dy_inv             # <<<<<<<<<<<<<<
 *         zm = (z_bins[z_i+1] - z) * dz_inv
 *         output[i]  = table[x_i  ,y_i  ,z_i  ] * (xm*ym*zm) \
 */
    __pyx_t_19 = (__pyx_v_y_i + 1);
    if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_bshape_0_y_bins;
    __pyx_v_ym = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y_bins.buf, __pyx_t_19, __pyx_bstride_0_y_bins)) - __pyx_v_y) * __pyx_v_dy_inv);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":108
 *         xm = (x_bins[x_i+1] - x) * dx_inv
 *         ym = (y_bins[y_i+1] - y) * dy_inv
 *         zm = (z_bins[z_i+1] - z) * dz_inv             # <<<<<<<<<<<<<<
 *         output[i]  = table[x_i  ,y_i  ,z_i  ] * (xm*ym*zm) \
 *                    + table[x_i+1,y_i  ,z_i  ] * (xp*ym*zm) \
 */
    __pyx_t_20 = (__pyx_v_z_i + 1);
    if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_bshape_0_z_bins;
    __pyx_v_zm = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_z_bins.buf, __pyx_t_20, __pyx_bstride_0_z_bins)) - __pyx_v_z) * __pyx_v_dz_inv);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":109
 *         ym = (y_bins[y_i+1] - y) * dy_inv
 *         zm = (z_bins[z_i+1] - z) * dz_inv
 *         output[i]  = table[x_i  ,y_i  ,z_i  ] * (xm*ym*zm) \             # <<<<<<<<<<<<<<
 *                    + table[x_i+1,y_i  ,z_i  ] * (xp*ym*zm) \
 *                    + table[x_i  ,y_i+1,z_i  ] * (xm*yp*zm) \
 */
    __pyx_t_21 = __pyx_v_x_i;
    __pyx_t_22 = __pyx_v_y_i;
    __pyx_t_23 = __pyx_v_z_i;
    if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_bshape_0_table;
    if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_bshape_1_table;
    if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_bshape_2_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":110
 *         zm = (z_bins[z_i+1] - z) * dz_inv
 *         output[i]  = table[x_i  ,y_i  ,z_i  ] * (xm*ym*zm) \
 *                    + table[x_i+1,y_i  ,z_i  ] * (xp*ym*zm) \             # <<<<<<<<<<<<<<
 *                    + table[x_i  ,y_i+1,z_i  ] * (xm*yp*zm) \
 *                    + table[x_i  ,y_i  ,z_i+1] * (xm*ym*zp) \
 */
    __pyx_t_24 = (__pyx_v_x_i + 1);
    __pyx_t_25 = __pyx_v_y_i;
    __pyx_t_26 = __pyx_v_z_i;
    if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_bshape_0_table;
    if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_bshape_1_table;
    if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_bshape_2_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":111
 *         output[i]  = table[x_i  ,y_i  ,z_i  ] * (xm*ym*zm) \
 *                    + table[x_i+1,y_i  ,z_i  ] * (xp*ym*zm) \
 *                    + table[x_i  ,y_i+1,z_i  ] * (xm*yp*zm) \             # <<<<<<<<<<<<<<
 *                    + table[x_i  ,y_i  ,z_i+1] * (xm*ym*zp) \
 *                    + table[x_i+1,y_i  ,z_i+1] * (xp*ym*zp) \
 */
    __pyx_t_27 = __pyx_v_x_i;
    __pyx_t_28 = (__pyx_v_y_i + 1);
    __pyx_t_29 = __pyx_v_z_i;
    if (__pyx_t_27 < 0) __pyx_t_27 += __pyx_bshape_0_table;
    if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_bshape_1_table;
    if (__pyx_t_29 < 0) __pyx_t_29 += __pyx_bshape_2_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":112
 *                    + table[x_i+1,y_i  ,z_i  ] * (xp*ym*zm) \
 *                    + table[x_i  ,y_i+1,z_i  ] * (xm*yp*zm) \
 *                    + table[x_i  ,y_i  ,z_i+1] * (xm*ym*zp) \             # <<<<<<<<<<<<<<
 *                    + table[x_i+1,y_i  ,z_i+1] * (xp*ym*zp) \
 *                    + table[x_i  ,y_i+1,z_i+1] * (xm*yp*zp) \
 */
    __pyx_t_30 = __pyx_v_x_i;
    __pyx_t_31 = __pyx_v_y_i;
    __pyx_t_32 = (__pyx_v_z_i + 1);
    if (__pyx_t_30 < 0) __pyx_t_30 += __pyx_bshape_0_table;
    if (__pyx_t_31 < 0) __pyx_t_31 += __pyx_bshape_1_table;
    if (__pyx_t_32 < 0) __pyx_t_32 += __pyx_bshape_2_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":113
 *                    + table[x_i  ,y_i+1,z_i  ] * (xm*yp*zm) \
 *                    + table[x_i  ,y_i  ,z_i+1] * (xm*ym*zp) \
 *                    + table[x_i+1,y_i  ,z_i+1] * (xp*ym*zp) \             # <<<<<<<<<<<<<<
 *                    + table[x_i  ,y_i+1,z_i+1] * (xm*yp*zp) \
 *                    + table[x_i+1,y_i+1,z_i  ] * (xp*yp*zm) \
 */
    __pyx_t_33 = (__pyx_v_x_i + 1);
    __pyx_t_34 = __pyx_v_y_i;
    __pyx_t_35 = (__pyx_v_z_i + 1);
    if (__pyx_t_33 < 0) __pyx_t_33 += __pyx_bshape_0_table;
    if (__pyx_t_34 < 0) __pyx_t_34 += __pyx_bshape_1_table;
    if (__pyx_t_35 < 0) __pyx_t_35 += __pyx_bshape_2_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":114
 *                    + table[x_i  ,y_i  ,z_i+1] * (xm*ym*zp) \
 *                    + table[x_i+1,y_i  ,z_i+1] * (xp*ym*zp) \
 *                    + table[x_i  ,y_i+1,z_i+1] * (xm*yp*zp) \             # <<<<<<<<<<<<<<
 *                    + table[x_i+1,y_i+1,z_i  ] * (xp*yp*zm) \
 *                    + table[x_i+1,y_i+1,z_i+1] * (xp*yp*zp)
 */
    __pyx_t_36 = __pyx_v_x_i;
    __pyx_t_37 = (__pyx_v_y_i + 1);
    __pyx_t_38 = (__pyx_v_z_i + 1);
    if (__pyx_t_36 < 0) __pyx_t_36 += __pyx_bshape_0_table;
    if (__pyx_t_37 < 0) __pyx_t_37 += __pyx_bshape_1_table;
    if (__pyx_t_38 < 0) __pyx_t_38 += __pyx_bshape_2_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":115
 *                    + table[x_i+1,y_i  ,z_i+1] * (xp*ym*zp) \
 *                    + table[x_i  ,y_i+1,z_i+1] * (xm*yp*zp) \
 *                    + table[x_i+1,y_i+1,z_i  ] * (xp*yp*zm) \             # <<<<<<<<<<<<<<
 *                    + table[x_i+1,y_i+1,z_i+1] * (xp*yp*zp)
 */
    __pyx_t_39 = (__pyx_v_x_i + 1);
    __pyx_t_40 = (__pyx_v_y_i + 1);
    __pyx_t_41 = __pyx_v_z_i;
    if (__pyx_t_39 < 0) __pyx_t_39 += __pyx_bshape_0_table;
    if (__pyx_t_40 < 0) __pyx_t_40 += __pyx_bshape_1_table;
    if (__pyx_t_41 < 0) __pyx_t_41 += __pyx_bshape_2_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":116
 *                    + table[x_i  ,y_i+1,z_i+1] * (xm*yp*zp) \
 *                    + table[x_i+1,y_i+1,z_i  ] * (xp*yp*zm) \
 *                    + table[x_i+1,y_i+1,z_i+1] * (xp*yp*zp)             # <<<<<<<<<<<<<<
 */
    __pyx_t_42 = (__pyx_v_x_i + 1);
    __pyx_t_43 = (__pyx_v_y_i + 1);
    __pyx_t_44 = (__pyx_v_z_i + 1);
    if (__pyx_t_42 < 0) __pyx_t_42 += __pyx_bshape_0_table;
    if (__pyx_t_43 < 0) __pyx_t_43 += __pyx_bshape_1_table;
    if (__pyx_t_44 < 0) __pyx_t_44 += __pyx_bshape_2_table;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":109
 *         ym = (y_bins[y_i+1] - y) * dy_inv
 *         zm = (z_bins[z_i+1] - z) * dz_inv
 *         output[i]  = table[x_i  ,y_i  ,z_i  ] * (xm*ym*zm) \             # <<<<<<<<<<<<<<
 *                    + table[x_i+1,y_i  ,z_i  ] * (xp*ym*zm) \
 *                    + table[x_i  ,y_i+1,z_i  ] * (xm*yp*zm) \
 */
    __pyx_t_45 = __pyx_v_i;
    if (__pyx_t_45 < 0) __pyx_t_45 += __pyx_bshape_0_output;
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_output.buf, __pyx_t_45, __pyx_bstride_0_output) = (((((((((*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_21, __pyx_bstride_0_table, __pyx_t_22, __pyx_bstride_1_table, __pyx_t_23, __pyx_bstride_2_table)) * ((__pyx_v_xm * __pyx_v_ym) * __pyx_v_zm)) + ((*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_24, __pyx_bstride_0_table, __pyx_t_25, __pyx_bstride_1_table, __pyx_t_26, __pyx_bstride_2_table)) * ((__pyx_v_xp * __pyx_v_ym) * __pyx_v_zm))) + ((*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_27, __pyx_bstride_0_table, __pyx_t_28, __pyx_bstride_1_table, __pyx_t_29, __pyx_bstride_2_table)) * ((__pyx_v_xm * __pyx_v_yp) * __pyx_v_zm))) + ((*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_30, __pyx_bstride_0_table, __pyx_t_31, __pyx_bstride_1_table, __pyx_t_32, __pyx_bstride_2_table)) * ((__pyx_v_xm * __pyx_v_ym) * __pyx_v_zp))) + ((*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_33, __pyx_bstride_0_table, __pyx_t_34, __pyx_bstride_1_table, __pyx_t_35, __pyx_bstride_2_table)) * ((__pyx_v_xp * __pyx_v_ym) * __pyx_v_zp))) + ((*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_36, __pyx_bstride_0_table, __pyx_t_37, __pyx_bstride_1_table, __pyx_t_38, __pyx_bstride_2_table)) * ((__pyx_v_xm * __pyx_v_yp) * __pyx_v_zp))) + ((*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_39, __pyx_bstride_0_table, __pyx_t_40, __pyx_bstride_1_table, __pyx_t_41, __pyx_bstride_2_table)) * ((__pyx_v_xp * __pyx_v_yp) * __pyx_v_zm))) + ((*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_table.buf, __pyx_t_42, __pyx_bstride_0_table, __pyx_t_43, __pyx_bstride_1_table, __pyx_t_44, __pyx_bstride_2_table)) * ((__pyx_v_xp * __pyx_v_yp) * __pyx_v_zp)));
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_z_is);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_vals);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_is);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_bins);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_z_bins);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_is);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_output);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_table);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_bins);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_vals);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_z_vals);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.TrilinearlyInterpolate");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_z_is);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_vals);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_is);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_bins);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_z_bins);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_is);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_output);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_table);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_bins);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_vals);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_z_vals);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_table);
  __Pyx_DECREF((PyObject *)__pyx_v_x_vals);
  __Pyx_DECREF((PyObject *)__pyx_v_y_vals);
  __Pyx_DECREF((PyObject *)__pyx_v_z_vals);
  __Pyx_DECREF((PyObject *)__pyx_v_x_bins);
  __Pyx_DECREF((PyObject *)__pyx_v_y_bins);
  __Pyx_DECREF((PyObject *)__pyx_v_z_bins);
  __Pyx_DECREF((PyObject *)__pyx_v_x_is);
  __Pyx_DECREF((PyObject *)__pyx_v_y_is);
  __Pyx_DECREF((PyObject *)__pyx_v_z_is);
  __Pyx_DECREF((PyObject *)__pyx_v_output);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":36
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def planar_points_in_volume(             # <<<<<<<<<<<<<<
 *                    np.ndarray[np.float64_t, ndim=2] points,
 *                    np.ndarray[np.int8_t, ndim=1] pmask,  # pixel mask
 */

static PyObject *__pyx_pf_2yt_9amr_utils_planar_points_in_volume(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_planar_points_in_volume(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_points = 0;
  PyArrayObject *__pyx_v_pmask = 0;
  PyArrayObject *__pyx_v_left_edge = 0;
  PyArrayObject *__pyx_v_right_edge = 0;
  PyArrayObject *__pyx_v_mask = 0;
  float __pyx_v_dx;
  PyArrayObject *__pyx_v_valid = 0;
  int __pyx_v_i;
  int __pyx_v_dim;
  int __pyx_v_count;
  int __pyx_v_ex;
  double __pyx_v_dx_inv;
  unsigned int __pyx_v_idx[3];
  PyArrayObject *__pyx_v_result = 0;
  Py_buffer __pyx_bstruct_valid;
  Py_ssize_t __pyx_bstride_0_valid = 0;
  Py_ssize_t __pyx_bshape_0_valid = 0;
  Py_buffer __pyx_bstruct_right_edge;
  Py_ssize_t __pyx_bstride_0_right_edge = 0;
  Py_ssize_t __pyx_bshape_0_right_edge = 0;
  Py_buffer __pyx_bstruct_mask;
  Py_ssize_t __pyx_bstride_0_mask = 0;
  Py_ssize_t __pyx_bstride_1_mask = 0;
  Py_ssize_t __pyx_bstride_2_mask = 0;
  Py_ssize_t __pyx_bshape_0_mask = 0;
  Py_ssize_t __pyx_bshape_1_mask = 0;
  Py_ssize_t __pyx_bshape_2_mask = 0;
  Py_buffer __pyx_bstruct_points;
  Py_ssize_t __pyx_bstride_0_points = 0;
  Py_ssize_t __pyx_bstride_1_points = 0;
  Py_ssize_t __pyx_bshape_0_points = 0;
  Py_ssize_t __pyx_bshape_1_points = 0;
  Py_buffer __pyx_bstruct_left_edge;
  Py_ssize_t __pyx_bstride_0_left_edge = 0;
  Py_ssize_t __pyx_bshape_0_left_edge = 0;
  Py_buffer __pyx_bstruct_pmask;
  Py_ssize_t __pyx_bstride_0_pmask = 0;
  Py_ssize_t __pyx_bshape_0_pmask = 0;
  Py_buffer __pyx_bstruct_result;
  Py_ssize_t __pyx_bstride_0_result = 0;
  Py_ssize_t __pyx_bshape_0_result = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyArrayObject *__pyx_t_5 = NULL;
  npy_intp __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  int __pyx_t_21;
  int __pyx_t_22;
  unsigned int __pyx_t_23;
  unsigned int __pyx_t_24;
  unsigned int __pyx_t_25;
  PyArrayObject *__pyx_t_26 = NULL;
  int __pyx_t_27;
  int __pyx_t_28;
  int __pyx_t_29;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__points,&__pyx_n_s__pmask,&__pyx_n_s__left_edge,&__pyx_n_s__right_edge,&__pyx_n_s__mask,&__pyx_n_s__dx,0};
  __Pyx_RefNannySetupContext("planar_points_in_volume");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[6] = {0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__points);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pmask);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("planar_points_in_volume", 1, 6, 6, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__left_edge);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("planar_points_in_volume", 1, 6, 6, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__right_edge);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("planar_points_in_volume", 1, 6, 6, 3); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mask);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("planar_points_in_volume", 1, 6, 6, 4); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dx);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("planar_points_in_volume", 1, 6, 6, 5); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "planar_points_in_volume") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_points = ((PyArrayObject *)values[0]);
    __pyx_v_pmask = ((PyArrayObject *)values[1]);
    __pyx_v_left_edge = ((PyArrayObject *)values[2]);
    __pyx_v_right_edge = ((PyArrayObject *)values[3]);
    __pyx_v_mask = ((PyArrayObject *)values[4]);
    __pyx_v_dx = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_dx == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_points = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_pmask = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_left_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_right_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_mask = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_dx = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_dx == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("planar_points_in_volume", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.planar_points_in_volume");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_points);
  __Pyx_INCREF((PyObject *)__pyx_v_pmask);
  __Pyx_INCREF((PyObject *)__pyx_v_left_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_right_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_mask);
  __pyx_bstruct_valid.buf = NULL;
  __pyx_bstruct_result.buf = NULL;
  __pyx_bstruct_points.buf = NULL;
  __pyx_bstruct_pmask.buf = NULL;
  __pyx_bstruct_left_edge.buf = NULL;
  __pyx_bstruct_right_edge.buf = NULL;
  __pyx_bstruct_mask.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_points), __pyx_ptype_5numpy_ndarray, 1, "points", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pmask), __pyx_ptype_5numpy_ndarray, 1, "pmask", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_left_edge), __pyx_ptype_5numpy_ndarray, 1, "left_edge", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_right_edge), __pyx_ptype_5numpy_ndarray, 1, "right_edge", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_5numpy_ndarray, 1, "mask", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_points, (PyObject*)__pyx_v_points, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_points = __pyx_bstruct_points.strides[0]; __pyx_bstride_1_points = __pyx_bstruct_points.strides[1];
  __pyx_bshape_0_points = __pyx_bstruct_points.shape[0]; __pyx_bshape_1_points = __pyx_bstruct_points.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_pmask, (PyObject*)__pyx_v_pmask, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_pmask = __pyx_bstruct_pmask.strides[0];
  __pyx_bshape_0_pmask = __pyx_bstruct_pmask.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_left_edge, (PyObject*)__pyx_v_left_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_left_edge = __pyx_bstruct_left_edge.strides[0];
  __pyx_bshape_0_left_edge = __pyx_bstruct_left_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_right_edge, (PyObject*)__pyx_v_right_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_right_edge = __pyx_bstruct_right_edge.strides[0];
  __pyx_bshape_0_right_edge = __pyx_bstruct_right_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_mask, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_mask = __pyx_bstruct_mask.strides[0]; __pyx_bstride_1_mask = __pyx_bstruct_mask.strides[1]; __pyx_bstride_2_mask = __pyx_bstruct_mask.strides[2];
  __pyx_bshape_0_mask = __pyx_bstruct_mask.shape[0]; __pyx_bshape_1_mask = __pyx_bstruct_mask.shape[1]; __pyx_bshape_2_mask = __pyx_bstruct_mask.shape[2];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":44
 *                    float dx):
 *     cdef np.ndarray[np.int8_t, ndim=1] \
 *          valid = np.zeros(points.shape[0], dtype='int8')             # <<<<<<<<<<<<<<
 *     cdef int i, dim, count
 *     cdef int ex
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_to_py_npy_intp((__pyx_v_points->dimensions[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)__pyx_n_s__int8)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_valid, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int8_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_valid = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_valid.buf = NULL;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_valid = __pyx_bstruct_valid.strides[0];
      __pyx_bshape_0_valid = __pyx_bstruct_valid.shape[0];
    }
  }
  __pyx_t_5 = 0;
  __pyx_v_valid = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":49
 *     cdef double dx_inv
 *     cdef unsigned int idx[3]
 *     count = 0             # <<<<<<<<<<<<<<
 *     dx_inv = 1.0 / dx
 *     for i in xrange(points.shape[0]):
 */
  __pyx_v_count = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":50
 *     cdef unsigned int idx[3]
 *     count = 0
 *     dx_inv = 1.0 / dx             # <<<<<<<<<<<<<<
 *     for i in xrange(points.shape[0]):
 *         if pmask[i] == 0:
 */
  __pyx_v_dx_inv = (1.0 / __pyx_v_dx);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":51
 *     count = 0
 *     dx_inv = 1.0 / dx
 *     for i in xrange(points.shape[0]):             # <<<<<<<<<<<<<<
 *         if pmask[i] == 0:
 *             continue
 */
  __pyx_t_6 = (__pyx_v_points->dimensions[0]);
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":52
 *     dx_inv = 1.0 / dx
 *     for i in xrange(points.shape[0]):
 *         if pmask[i] == 0:             # <<<<<<<<<<<<<<
 *             continue
 *         ex = 1
 */
    __pyx_t_8 = __pyx_v_i;
    __pyx_t_9 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_bstruct_pmask.buf, __pyx_t_8, __pyx_bstride_0_pmask)) == 0);
    if (__pyx_t_9) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":53
 *     for i in xrange(points.shape[0]):
 *         if pmask[i] == 0:
 *             continue             # <<<<<<<<<<<<<<
 *         ex = 1
 *         for dim in xrange(3):
 */
      goto __pyx_L6_continue;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":54
 *         if pmask[i] == 0:
 *             continue
 *         ex = 1             # <<<<<<<<<<<<<<
 *         for dim in xrange(3):
 *             if points[i,dim] < left_edge[dim] or points[i,dim] > right_edge[dim]:
 */
    __pyx_v_ex = 1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":55
 *             continue
 *         ex = 1
 *         for dim in xrange(3):             # <<<<<<<<<<<<<<
 *             if points[i,dim] < left_edge[dim] or points[i,dim] > right_edge[dim]:
 *                 valid[i] = ex = 0
 */
    for (__pyx_t_10 = 0; __pyx_t_10 < 3; __pyx_t_10+=1) {
      __pyx_v_dim = __pyx_t_10;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":56
 *         ex = 1
 *         for dim in xrange(3):
 *             if points[i,dim] < left_edge[dim] or points[i,dim] > right_edge[dim]:             # <<<<<<<<<<<<<<
 *                 valid[i] = ex = 0
 *                 break
 */
      __pyx_t_11 = __pyx_v_i;
      __pyx_t_12 = __pyx_v_dim;
      __pyx_t_13 = __pyx_v_dim;
      __pyx_t_9 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_points.buf, __pyx_t_11, __pyx_bstride_0_points, __pyx_t_12, __pyx_bstride_1_points)) < (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_13, __pyx_bstride_0_left_edge)));
      if (!__pyx_t_9) {
        __pyx_t_14 = __pyx_v_i;
        __pyx_t_15 = __pyx_v_dim;
        __pyx_t_16 = __pyx_v_dim;
        __pyx_t_17 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_points.buf, __pyx_t_14, __pyx_bstride_0_points, __pyx_t_15, __pyx_bstride_1_points)) > (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_16, __pyx_bstride_0_right_edge)));
        __pyx_t_18 = __pyx_t_17;
      } else {
        __pyx_t_18 = __pyx_t_9;
      }
      if (__pyx_t_18) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":57
 *         for dim in xrange(3):
 *             if points[i,dim] < left_edge[dim] or points[i,dim] > right_edge[dim]:
 *                 valid[i] = ex = 0             # <<<<<<<<<<<<<<
 *                 break
 *         if ex == 1:
 */
        __pyx_t_19 = __pyx_v_i;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_bstruct_valid.buf, __pyx_t_19, __pyx_bstride_0_valid) = 0;
        __pyx_v_ex = 0;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":58
 *             if points[i,dim] < left_edge[dim] or points[i,dim] > right_edge[dim]:
 *                 valid[i] = ex = 0
 *                 break             # <<<<<<<<<<<<<<
 *         if ex == 1:
 *             for dim in xrange(3):
 */
        goto __pyx_L10_break;
        goto __pyx_L11;
      }
      __pyx_L11:;
    }
    __pyx_L10_break:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":59
 *                 valid[i] = ex = 0
 *                 break
 *         if ex == 1:             # <<<<<<<<<<<<<<
 *             for dim in xrange(3):
 *                 idx[dim] = <unsigned int> \
 */
    __pyx_t_18 = (__pyx_v_ex == 1);
    if (__pyx_t_18) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":60
 *                 break
 *         if ex == 1:
 *             for dim in xrange(3):             # <<<<<<<<<<<<<<
 *                 idx[dim] = <unsigned int> \
 *                            ((points[i,dim] - left_edge[dim]) * dx_inv)
 */
      for (__pyx_t_10 = 0; __pyx_t_10 < 3; __pyx_t_10+=1) {
        __pyx_v_dim = __pyx_t_10;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":62
 *             for dim in xrange(3):
 *                 idx[dim] = <unsigned int> \
 *                            ((points[i,dim] - left_edge[dim]) * dx_inv)             # <<<<<<<<<<<<<<
 *             if mask[idx[0], idx[1], idx[2]] == 1:
 *                 valid[i] = 1
 */
        __pyx_t_20 = __pyx_v_i;
        __pyx_t_21 = __pyx_v_dim;
        __pyx_t_22 = __pyx_v_dim;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":61
 *         if ex == 1:
 *             for dim in xrange(3):
 *                 idx[dim] = <unsigned int> \             # <<<<<<<<<<<<<<
 *                            ((points[i,dim] - left_edge[dim]) * dx_inv)
 *             if mask[idx[0], idx[1], idx[2]] == 1:
 */
        (__pyx_v_idx[__pyx_v_dim]) = ((unsigned int)(((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_points.buf, __pyx_t_20, __pyx_bstride_0_points, __pyx_t_21, __pyx_bstride_1_points)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_22, __pyx_bstride_0_left_edge))) * __pyx_v_dx_inv));
      }

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":63
 *                 idx[dim] = <unsigned int> \
 *                            ((points[i,dim] - left_edge[dim]) * dx_inv)
 *             if mask[idx[0], idx[1], idx[2]] == 1:             # <<<<<<<<<<<<<<
 *                 valid[i] = 1
 *                 count += 1
 */
      __pyx_t_23 = (__pyx_v_idx[0]);
      __pyx_t_24 = (__pyx_v_idx[1]);
      __pyx_t_25 = (__pyx_v_idx[2]);
      __pyx_t_18 = ((*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_mask.buf, __pyx_t_23, __pyx_bstride_0_mask, __pyx_t_24, __pyx_bstride_1_mask, __pyx_t_25, __pyx_bstride_2_mask)) == 1);
      if (__pyx_t_18) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":64
 *                            ((points[i,dim] - left_edge[dim]) * dx_inv)
 *             if mask[idx[0], idx[1], idx[2]] == 1:
 *                 valid[i] = 1             # <<<<<<<<<<<<<<
 *                 count += 1
 * 
 */
        __pyx_t_10 = __pyx_v_i;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_bstruct_valid.buf, __pyx_t_10, __pyx_bstride_0_valid) = 1;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":65
 *             if mask[idx[0], idx[1], idx[2]] == 1:
 *                 valid[i] = 1
 *                 count += 1             # <<<<<<<<<<<<<<
 * 
 *     cdef np.ndarray[np.int32_t, ndim=1] result = np.empty(count, dtype='int32')
 */
        __pyx_v_count += 1;
        goto __pyx_L15;
      }
      __pyx_L15:;
      goto __pyx_L12;
    }
    __pyx_L12:;
    __pyx_L6_continue:;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":67
 *                 count += 1
 * 
 *     cdef np.ndarray[np.int32_t, ndim=1] result = np.empty(count, dtype='int32')             # <<<<<<<<<<<<<<
 *     count = 0
 *     for i in xrange(points.shape[0]):
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__empty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromLong(__pyx_v_count); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)__pyx_n_s__int32)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyEval_CallObjectWithKeywords(__pyx_t_1, __pyx_t_3, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_26 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_result, (PyObject*)__pyx_t_26, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_result = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_result.buf = NULL;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_result = __pyx_bstruct_result.strides[0];
      __pyx_bshape_0_result = __pyx_bstruct_result.shape[0];
    }
  }
  __pyx_t_26 = 0;
  __pyx_v_result = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":68
 * 
 *     cdef np.ndarray[np.int32_t, ndim=1] result = np.empty(count, dtype='int32')
 *     count = 0             # <<<<<<<<<<<<<<
 *     for i in xrange(points.shape[0]):
 *         if valid[i] == 1 and pmask[i] == 1:
 */
  __pyx_v_count = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":69
 *     cdef np.ndarray[np.int32_t, ndim=1] result = np.empty(count, dtype='int32')
 *     count = 0
 *     for i in xrange(points.shape[0]):             # <<<<<<<<<<<<<<
 *         if valid[i] == 1 and pmask[i] == 1:
 *             result[count] = i
 */
  __pyx_t_6 = (__pyx_v_points->dimensions[0]);
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_i = __pyx_t_7;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":70
 *     count = 0
 *     for i in xrange(points.shape[0]):
 *         if valid[i] == 1 and pmask[i] == 1:             # <<<<<<<<<<<<<<
 *             result[count] = i
 *             count += 1
 */
    __pyx_t_27 = __pyx_v_i;
    __pyx_t_18 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_bstruct_valid.buf, __pyx_t_27, __pyx_bstride_0_valid)) == 1);
    if (__pyx_t_18) {
      __pyx_t_28 = __pyx_v_i;
      __pyx_t_9 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int8_t *, __pyx_bstruct_pmask.buf, __pyx_t_28, __pyx_bstride_0_pmask)) == 1);
      __pyx_t_17 = __pyx_t_9;
    } else {
      __pyx_t_17 = __pyx_t_18;
    }
    if (__pyx_t_17) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":71
 *     for i in xrange(points.shape[0]):
 *         if valid[i] == 1 and pmask[i] == 1:
 *             result[count] = i             # <<<<<<<<<<<<<<
 *             count += 1
 * 
 */
      __pyx_t_29 = __pyx_v_count;
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_result.buf, __pyx_t_29, __pyx_bstride_0_result) = __pyx_v_i;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":72
 *         if valid[i] == 1 and pmask[i] == 1:
 *             result[count] = i
 *             count += 1             # <<<<<<<<<<<<<<
 * 
 *     return result
 */
      __pyx_v_count += 1;
      goto __pyx_L18;
    }
    __pyx_L18:;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":74
 *             count += 1
 * 
 *     return result             # <<<<<<<<<<<<<<
 * 
 * cdef inline void set_rotated_pos(
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_result));
  __pyx_r = ((PyObject *)__pyx_v_result);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_valid);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_mask);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_points);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pmask);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_result);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.planar_points_in_volume");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_valid);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_mask);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_points);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pmask);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_result);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_valid);
  __Pyx_XDECREF((PyObject *)__pyx_v_result);
  __Pyx_DECREF((PyObject *)__pyx_v_points);
  __Pyx_DECREF((PyObject *)__pyx_v_pmask);
  __Pyx_DECREF((PyObject *)__pyx_v_left_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_right_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_mask);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":76
 *     return result
 * 
 * cdef inline void set_rotated_pos(             # <<<<<<<<<<<<<<
 *             np.float64_t cp[3], np.float64_t rdds[3][3],
 *             np.float64_t rorigin[3], int i, int j, int k):
 */

static CYTHON_INLINE void __pyx_f_2yt_9amr_utils_set_rotated_pos(__pyx_t_5numpy_float64_t *__pyx_v_cp, __pyx_t_5numpy_float64_t (*__pyx_v_rdds)[3], __pyx_t_5numpy_float64_t *__pyx_v_rorigin, int __pyx_v_i, int __pyx_v_j, int __pyx_v_k) {
  int __pyx_v_oi;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("set_rotated_pos");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":80
 *             np.float64_t rorigin[3], int i, int j, int k):
 *     cdef int oi
 *     for oi in range(3):             # <<<<<<<<<<<<<<
 *         cp[oi] = rdds[0][oi] * (0.5 + i) \
 *                + rdds[1][oi] * (0.5 + j) \
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_oi = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":81
 *     cdef int oi
 *     for oi in range(3):
 *         cp[oi] = rdds[0][oi] * (0.5 + i) \             # <<<<<<<<<<<<<<
 *                + rdds[1][oi] * (0.5 + j) \
 *                + rdds[2][oi] * (0.5 + k) \
 */
    (__pyx_v_cp[__pyx_v_oi]) = ((((((__pyx_v_rdds[0])[__pyx_v_oi]) * (0.5 + __pyx_v_i)) + (((__pyx_v_rdds[1])[__pyx_v_oi]) * (0.5 + __pyx_v_j))) + (((__pyx_v_rdds[2])[__pyx_v_oi]) * (0.5 + __pyx_v_k))) + (__pyx_v_rorigin[__pyx_v_oi]));
  }

  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":88
 * #@cython.wraparound(False)
 * #@cython.boundscheck(False)
 * def grid_points_in_volume(             # <<<<<<<<<<<<<<
 *                    np.ndarray[np.float64_t, ndim=1] box_lengths,
 *                    np.ndarray[np.float64_t, ndim=1] box_origin,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_grid_points_in_volume(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_grid_points_in_volume(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_box_lengths = 0;
  PyArrayObject *__pyx_v_box_origin = 0;
  PyArrayObject *__pyx_v_rot_mat = 0;
  PyArrayObject *__pyx_v_grid_left_edge = 0;
  PyArrayObject *__pyx_v_grid_right_edge = 0;
  PyArrayObject *__pyx_v_dds = 0;
  PyArrayObject *__pyx_v_mask = 0;
  int __pyx_v_break_first;
  int __pyx_v_n[3];
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  __pyx_t_5numpy_float64_t __pyx_v_rds[3][3];
  __pyx_t_5numpy_float64_t __pyx_v_cur_pos[3];
  __pyx_t_5numpy_float64_t __pyx_v_rorigin[3];
  Py_buffer __pyx_bstruct_dds;
  Py_ssize_t __pyx_bstride_0_dds = 0;
  Py_ssize_t __pyx_bshape_0_dds = 0;
  Py_buffer __pyx_bstruct_grid_right_edge;
  Py_ssize_t __pyx_bstride_0_grid_right_edge = 0;
  Py_ssize_t __pyx_bshape_0_grid_right_edge = 0;
  Py_buffer __pyx_bstruct_mask;
  Py_ssize_t __pyx_bstride_0_mask = 0;
  Py_ssize_t __pyx_bstride_1_mask = 0;
  Py_ssize_t __pyx_bstride_2_mask = 0;
  Py_ssize_t __pyx_bshape_0_mask = 0;
  Py_ssize_t __pyx_bshape_1_mask = 0;
  Py_ssize_t __pyx_bshape_2_mask = 0;
  Py_buffer __pyx_bstruct_box_lengths;
  Py_ssize_t __pyx_bstride_0_box_lengths = 0;
  Py_ssize_t __pyx_bshape_0_box_lengths = 0;
  Py_buffer __pyx_bstruct_rot_mat;
  Py_ssize_t __pyx_bstride_0_rot_mat = 0;
  Py_ssize_t __pyx_bstride_1_rot_mat = 0;
  Py_ssize_t __pyx_bshape_0_rot_mat = 0;
  Py_ssize_t __pyx_bshape_1_rot_mat = 0;
  Py_buffer __pyx_bstruct_box_origin;
  Py_ssize_t __pyx_bstride_0_box_origin = 0;
  Py_ssize_t __pyx_bshape_0_box_origin = 0;
  Py_buffer __pyx_bstruct_grid_left_edge;
  Py_ssize_t __pyx_bstride_0_grid_left_edge = 0;
  Py_ssize_t __pyx_bshape_0_grid_left_edge = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  long __pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  long __pyx_t_17;
  long __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  int __pyx_t_21;
  __pyx_t_5numpy_int32_t __pyx_t_22;
  int __pyx_t_23;
  int __pyx_t_24;
  int __pyx_t_25;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__box_lengths,&__pyx_n_s__box_origin,&__pyx_n_s__rot_mat,&__pyx_n_s__grid_left_edge,&__pyx_n_s__grid_right_edge,&__pyx_n_s__dds,&__pyx_n_s__mask,&__pyx_n_s__break_first,0};
  __Pyx_RefNannySetupContext("grid_points_in_volume");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__box_lengths);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__box_origin);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("grid_points_in_volume", 1, 8, 8, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__rot_mat);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("grid_points_in_volume", 1, 8, 8, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grid_left_edge);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("grid_points_in_volume", 1, 8, 8, 3); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grid_right_edge);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("grid_points_in_volume", 1, 8, 8, 4); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dds);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("grid_points_in_volume", 1, 8, 8, 5); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mask);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("grid_points_in_volume", 1, 8, 8, 6); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  7:
      values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__break_first);
      if (likely(values[7])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("grid_points_in_volume", 1, 8, 8, 7); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "grid_points_in_volume") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_box_lengths = ((PyArrayObject *)values[0]);
    __pyx_v_box_origin = ((PyArrayObject *)values[1]);
    __pyx_v_rot_mat = ((PyArrayObject *)values[2]);
    __pyx_v_grid_left_edge = ((PyArrayObject *)values[3]);
    __pyx_v_grid_right_edge = ((PyArrayObject *)values[4]);
    __pyx_v_dds = ((PyArrayObject *)values[5]);
    __pyx_v_mask = ((PyArrayObject *)values[6]);
    __pyx_v_break_first = __Pyx_PyInt_AsInt(values[7]); if (unlikely((__pyx_v_break_first == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_box_lengths = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_box_origin = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_rot_mat = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_grid_left_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_grid_right_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_dds = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 5));
    __pyx_v_mask = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 6));
    __pyx_v_break_first = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 7)); if (unlikely((__pyx_v_break_first == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("grid_points_in_volume", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.grid_points_in_volume");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_box_lengths);
  __Pyx_INCREF((PyObject *)__pyx_v_box_origin);
  __Pyx_INCREF((PyObject *)__pyx_v_rot_mat);
  __Pyx_INCREF((PyObject *)__pyx_v_grid_left_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_grid_right_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_dds);
  __Pyx_INCREF((PyObject *)__pyx_v_mask);
  __pyx_bstruct_box_lengths.buf = NULL;
  __pyx_bstruct_box_origin.buf = NULL;
  __pyx_bstruct_rot_mat.buf = NULL;
  __pyx_bstruct_grid_left_edge.buf = NULL;
  __pyx_bstruct_grid_right_edge.buf = NULL;
  __pyx_bstruct_dds.buf = NULL;
  __pyx_bstruct_mask.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_box_lengths), __pyx_ptype_5numpy_ndarray, 1, "box_lengths", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_box_origin), __pyx_ptype_5numpy_ndarray, 1, "box_origin", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_rot_mat), __pyx_ptype_5numpy_ndarray, 1, "rot_mat", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grid_left_edge), __pyx_ptype_5numpy_ndarray, 1, "grid_left_edge", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grid_right_edge), __pyx_ptype_5numpy_ndarray, 1, "grid_right_edge", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dds), __pyx_ptype_5numpy_ndarray, 1, "dds", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mask), __pyx_ptype_5numpy_ndarray, 1, "mask", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_box_lengths, (PyObject*)__pyx_v_box_lengths, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_box_lengths = __pyx_bstruct_box_lengths.strides[0];
  __pyx_bshape_0_box_lengths = __pyx_bstruct_box_lengths.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_box_origin, (PyObject*)__pyx_v_box_origin, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_box_origin = __pyx_bstruct_box_origin.strides[0];
  __pyx_bshape_0_box_origin = __pyx_bstruct_box_origin.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_rot_mat, (PyObject*)__pyx_v_rot_mat, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_rot_mat = __pyx_bstruct_rot_mat.strides[0]; __pyx_bstride_1_rot_mat = __pyx_bstruct_rot_mat.strides[1];
  __pyx_bshape_0_rot_mat = __pyx_bstruct_rot_mat.shape[0]; __pyx_bshape_1_rot_mat = __pyx_bstruct_rot_mat.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_grid_left_edge, (PyObject*)__pyx_v_grid_left_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_grid_left_edge = __pyx_bstruct_grid_left_edge.strides[0];
  __pyx_bshape_0_grid_left_edge = __pyx_bstruct_grid_left_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_grid_right_edge, (PyObject*)__pyx_v_grid_right_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_grid_right_edge = __pyx_bstruct_grid_right_edge.strides[0];
  __pyx_bshape_0_grid_right_edge = __pyx_bstruct_grid_right_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dds, (PyObject*)__pyx_v_dds, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_dds = __pyx_bstruct_dds.strides[0];
  __pyx_bshape_0_dds = __pyx_bstruct_dds.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_mask, (PyObject*)__pyx_v_mask, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_mask = __pyx_bstruct_mask.strides[0]; __pyx_bstride_1_mask = __pyx_bstruct_mask.strides[1]; __pyx_bstride_2_mask = __pyx_bstruct_mask.strides[2];
  __pyx_bshape_0_mask = __pyx_bstruct_mask.shape[0]; __pyx_bshape_1_mask = __pyx_bstruct_mask.shape[1]; __pyx_bshape_2_mask = __pyx_bstruct_mask.shape[2];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":99
 *     cdef int n[3], i, j, k, ax
 *     cdef np.float64_t rds[3][3], cur_pos[3], rorigin[3]
 *     for i in range(3):             # <<<<<<<<<<<<<<
 *         rorigin[i] = 0.0
 *     for i in range(3):
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":100
 *     cdef np.float64_t rds[3][3], cur_pos[3], rorigin[3]
 *     for i in range(3):
 *         rorigin[i] = 0.0             # <<<<<<<<<<<<<<
 *     for i in range(3):
 *         n[i] = mask.shape[i]
 */
    (__pyx_v_rorigin[__pyx_v_i]) = 0.0;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":101
 *     for i in range(3):
 *         rorigin[i] = 0.0
 *     for i in range(3):             # <<<<<<<<<<<<<<
 *         n[i] = mask.shape[i]
 *         for j in range(3):
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":102
 *         rorigin[i] = 0.0
 *     for i in range(3):
 *         n[i] = mask.shape[i]             # <<<<<<<<<<<<<<
 *         for j in range(3):
 *             # Set up our transposed dx, which has a component in every
 */
    (__pyx_v_n[__pyx_v_i]) = (__pyx_v_mask->dimensions[__pyx_v_i]);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":103
 *     for i in range(3):
 *         n[i] = mask.shape[i]
 *         for j in range(3):             # <<<<<<<<<<<<<<
 *             # Set up our transposed dx, which has a component in every
 *             # direction
 */
    for (__pyx_t_2 = 0; __pyx_t_2 < 3; __pyx_t_2+=1) {
      __pyx_v_j = __pyx_t_2;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":106
 *             # Set up our transposed dx, which has a component in every
 *             # direction
 *             rds[i][j] = dds[i] * rot_mat[j,i]             # <<<<<<<<<<<<<<
 *             # In our rotated coordinate system, the box origin is 0,0,0
 *             # so we subtract the box_origin from the grid_origin and rotate
 */
      __pyx_t_3 = __pyx_v_i;
      __pyx_t_4 = -1;
      if (__pyx_t_3 < 0) {
        __pyx_t_3 += __pyx_bshape_0_dds;
        if (unlikely(__pyx_t_3 < 0)) __pyx_t_4 = 0;
      } else if (unlikely(__pyx_t_3 >= __pyx_bshape_0_dds)) __pyx_t_4 = 0;
      if (unlikely(__pyx_t_4 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_4);
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_4 = __pyx_v_j;
      __pyx_t_5 = __pyx_v_i;
      __pyx_t_6 = -1;
      if (__pyx_t_4 < 0) {
        __pyx_t_4 += __pyx_bshape_0_rot_mat;
        if (unlikely(__pyx_t_4 < 0)) __pyx_t_6 = 0;
      } else if (unlikely(__pyx_t_4 >= __pyx_bshape_0_rot_mat)) __pyx_t_6 = 0;
      if (__pyx_t_5 < 0) {
        __pyx_t_5 += __pyx_bshape_1_rot_mat;
        if (unlikely(__pyx_t_5 < 0)) __pyx_t_6 = 1;
      } else if (unlikely(__pyx_t_5 >= __pyx_bshape_1_rot_mat)) __pyx_t_6 = 1;
      if (unlikely(__pyx_t_6 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_6);
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      ((__pyx_v_rds[__pyx_v_i])[__pyx_v_j]) = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dds.buf, __pyx_t_3, __pyx_bstride_0_dds)) * (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_rot_mat.buf, __pyx_t_4, __pyx_bstride_0_rot_mat, __pyx_t_5, __pyx_bstride_1_rot_mat)));

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":110
 *             # so we subtract the box_origin from the grid_origin and rotate
 *             # that
 *             rorigin[j] += (grid_left_edge[i] - box_origin[i]) * rot_mat[j,i]             # <<<<<<<<<<<<<<
 * 
 *     for i in range(n[0]):
 */
      __pyx_t_6 = __pyx_v_i;
      __pyx_t_7 = -1;
      if (__pyx_t_6 < 0) {
        __pyx_t_6 += __pyx_bshape_0_grid_left_edge;
        if (unlikely(__pyx_t_6 < 0)) __pyx_t_7 = 0;
      } else if (unlikely(__pyx_t_6 >= __pyx_bshape_0_grid_left_edge)) __pyx_t_7 = 0;
      if (unlikely(__pyx_t_7 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_7);
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_7 = __pyx_v_i;
      __pyx_t_8 = -1;
      if (__pyx_t_7 < 0) {
        __pyx_t_7 += __pyx_bshape_0_box_origin;
        if (unlikely(__pyx_t_7 < 0)) __pyx_t_8 = 0;
      } else if (unlikely(__pyx_t_7 >= __pyx_bshape_0_box_origin)) __pyx_t_8 = 0;
      if (unlikely(__pyx_t_8 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_8);
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_t_8 = __pyx_v_j;
      __pyx_t_9 = __pyx_v_i;
      __pyx_t_10 = -1;
      if (__pyx_t_8 < 0) {
        __pyx_t_8 += __pyx_bshape_0_rot_mat;
        if (unlikely(__pyx_t_8 < 0)) __pyx_t_10 = 0;
      } else if (unlikely(__pyx_t_8 >= __pyx_bshape_0_rot_mat)) __pyx_t_10 = 0;
      if (__pyx_t_9 < 0) {
        __pyx_t_9 += __pyx_bshape_1_rot_mat;
        if (unlikely(__pyx_t_9 < 0)) __pyx_t_10 = 1;
      } else if (unlikely(__pyx_t_9 >= __pyx_bshape_1_rot_mat)) __pyx_t_10 = 1;
      if (unlikely(__pyx_t_10 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_10);
        {__pyx_filename = __pyx_f[1]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      (__pyx_v_rorigin[__pyx_v_j]) += (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_left_edge.buf, __pyx_t_6, __pyx_bstride_0_grid_left_edge)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_box_origin.buf, __pyx_t_7, __pyx_bstride_0_box_origin))) * (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_rot_mat.buf, __pyx_t_8, __pyx_bstride_0_rot_mat, __pyx_t_9, __pyx_bstride_1_rot_mat)));
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":112
 *             rorigin[j] += (grid_left_edge[i] - box_origin[i]) * rot_mat[j,i]
 * 
 *     for i in range(n[0]):             # <<<<<<<<<<<<<<
 *         for j in range(n[1]):
 *             for k in range(n[2]):
 */
  __pyx_t_1 = (__pyx_v_n[0]);
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":113
 * 
 *     for i in range(n[0]):
 *         for j in range(n[1]):             # <<<<<<<<<<<<<<
 *             for k in range(n[2]):
 *                 set_rotated_pos(cur_pos, rds, rorigin, i, j, k)
 */
    __pyx_t_10 = (__pyx_v_n[1]);
    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
      __pyx_v_j = __pyx_t_11;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":114
 *     for i in range(n[0]):
 *         for j in range(n[1]):
 *             for k in range(n[2]):             # <<<<<<<<<<<<<<
 *                 set_rotated_pos(cur_pos, rds, rorigin, i, j, k)
 *                 if (cur_pos[0] > box_lengths[0]): continue
 */
      __pyx_t_12 = (__pyx_v_n[2]);
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
        __pyx_v_k = __pyx_t_13;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":115
 *         for j in range(n[1]):
 *             for k in range(n[2]):
 *                 set_rotated_pos(cur_pos, rds, rorigin, i, j, k)             # <<<<<<<<<<<<<<
 *                 if (cur_pos[0] > box_lengths[0]): continue
 *                 if (cur_pos[1] > box_lengths[1]): continue
 */
        __pyx_f_2yt_9amr_utils_set_rotated_pos(__pyx_v_cur_pos, __pyx_v_rds, __pyx_v_rorigin, __pyx_v_i, __pyx_v_j, __pyx_v_k);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":116
 *             for k in range(n[2]):
 *                 set_rotated_pos(cur_pos, rds, rorigin, i, j, k)
 *                 if (cur_pos[0] > box_lengths[0]): continue             # <<<<<<<<<<<<<<
 *                 if (cur_pos[1] > box_lengths[1]): continue
 *                 if (cur_pos[2] > box_lengths[2]): continue
 */
        __pyx_t_14 = 0;
        __pyx_t_15 = -1;
        if (__pyx_t_14 < 0) {
          __pyx_t_14 += __pyx_bshape_0_box_lengths;
          if (unlikely(__pyx_t_14 < 0)) __pyx_t_15 = 0;
        } else if (unlikely(__pyx_t_14 >= __pyx_bshape_0_box_lengths)) __pyx_t_15 = 0;
        if (unlikely(__pyx_t_15 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_15);
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_16 = ((__pyx_v_cur_pos[0]) > (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_box_lengths.buf, __pyx_t_14, __pyx_bstride_0_box_lengths)));
        if (__pyx_t_16) {
          goto __pyx_L16_continue;
          goto __pyx_L18;
        }
        __pyx_L18:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":117
 *                 set_rotated_pos(cur_pos, rds, rorigin, i, j, k)
 *                 if (cur_pos[0] > box_lengths[0]): continue
 *                 if (cur_pos[1] > box_lengths[1]): continue             # <<<<<<<<<<<<<<
 *                 if (cur_pos[2] > box_lengths[2]): continue
 *                 if (cur_pos[0] < 0.0): continue
 */
        __pyx_t_17 = 1;
        __pyx_t_15 = -1;
        if (__pyx_t_17 < 0) {
          __pyx_t_17 += __pyx_bshape_0_box_lengths;
          if (unlikely(__pyx_t_17 < 0)) __pyx_t_15 = 0;
        } else if (unlikely(__pyx_t_17 >= __pyx_bshape_0_box_lengths)) __pyx_t_15 = 0;
        if (unlikely(__pyx_t_15 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_15);
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_16 = ((__pyx_v_cur_pos[1]) > (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_box_lengths.buf, __pyx_t_17, __pyx_bstride_0_box_lengths)));
        if (__pyx_t_16) {
          goto __pyx_L16_continue;
          goto __pyx_L19;
        }
        __pyx_L19:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":118
 *                 if (cur_pos[0] > box_lengths[0]): continue
 *                 if (cur_pos[1] > box_lengths[1]): continue
 *                 if (cur_pos[2] > box_lengths[2]): continue             # <<<<<<<<<<<<<<
 *                 if (cur_pos[0] < 0.0): continue
 *                 if (cur_pos[1] < 0.0): continue
 */
        __pyx_t_18 = 2;
        __pyx_t_15 = -1;
        if (__pyx_t_18 < 0) {
          __pyx_t_18 += __pyx_bshape_0_box_lengths;
          if (unlikely(__pyx_t_18 < 0)) __pyx_t_15 = 0;
        } else if (unlikely(__pyx_t_18 >= __pyx_bshape_0_box_lengths)) __pyx_t_15 = 0;
        if (unlikely(__pyx_t_15 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_15);
          {__pyx_filename = __pyx_f[1]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_t_16 = ((__pyx_v_cur_pos[2]) > (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_box_lengths.buf, __pyx_t_18, __pyx_bstride_0_box_lengths)));
        if (__pyx_t_16) {
          goto __pyx_L16_continue;
          goto __pyx_L20;
        }
        __pyx_L20:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":119
 *                 if (cur_pos[1] > box_lengths[1]): continue
 *                 if (cur_pos[2] > box_lengths[2]): continue
 *                 if (cur_pos[0] < 0.0): continue             # <<<<<<<<<<<<<<
 *                 if (cur_pos[1] < 0.0): continue
 *                 if (cur_pos[2] < 0.0): continue
 */
        __pyx_t_16 = ((__pyx_v_cur_pos[0]) < 0.0);
        if (__pyx_t_16) {
          goto __pyx_L16_continue;
          goto __pyx_L21;
        }
        __pyx_L21:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":120
 *                 if (cur_pos[2] > box_lengths[2]): continue
 *                 if (cur_pos[0] < 0.0): continue
 *                 if (cur_pos[1] < 0.0): continue             # <<<<<<<<<<<<<<
 *                 if (cur_pos[2] < 0.0): continue
 *                 if break_first:
 */
        __pyx_t_16 = ((__pyx_v_cur_pos[1]) < 0.0);
        if (__pyx_t_16) {
          goto __pyx_L16_continue;
          goto __pyx_L22;
        }
        __pyx_L22:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":121
 *                 if (cur_pos[0] < 0.0): continue
 *                 if (cur_pos[1] < 0.0): continue
 *                 if (cur_pos[2] < 0.0): continue             # <<<<<<<<<<<<<<
 *                 if break_first:
 *                     if mask[i,j,k]: return 1
 */
        __pyx_t_16 = ((__pyx_v_cur_pos[2]) < 0.0);
        if (__pyx_t_16) {
          goto __pyx_L16_continue;
          goto __pyx_L23;
        }
        __pyx_L23:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":122
 *                 if (cur_pos[1] < 0.0): continue
 *                 if (cur_pos[2] < 0.0): continue
 *                 if break_first:             # <<<<<<<<<<<<<<
 *                     if mask[i,j,k]: return 1
 *                 else:
 */
        __pyx_t_15 = __pyx_v_break_first;
        if (__pyx_t_15) {

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":123
 *                 if (cur_pos[2] < 0.0): continue
 *                 if break_first:
 *                     if mask[i,j,k]: return 1             # <<<<<<<<<<<<<<
 *                 else:
 *                     mask[i,j,k] = 1
 */
          __pyx_t_15 = __pyx_v_i;
          __pyx_t_19 = __pyx_v_j;
          __pyx_t_20 = __pyx_v_k;
          __pyx_t_21 = -1;
          if (__pyx_t_15 < 0) {
            __pyx_t_15 += __pyx_bshape_0_mask;
            if (unlikely(__pyx_t_15 < 0)) __pyx_t_21 = 0;
          } else if (unlikely(__pyx_t_15 >= __pyx_bshape_0_mask)) __pyx_t_21 = 0;
          if (__pyx_t_19 < 0) {
            __pyx_t_19 += __pyx_bshape_1_mask;
            if (unlikely(__pyx_t_19 < 0)) __pyx_t_21 = 1;
          } else if (unlikely(__pyx_t_19 >= __pyx_bshape_1_mask)) __pyx_t_21 = 1;
          if (__pyx_t_20 < 0) {
            __pyx_t_20 += __pyx_bshape_2_mask;
            if (unlikely(__pyx_t_20 < 0)) __pyx_t_21 = 2;
          } else if (unlikely(__pyx_t_20 >= __pyx_bshape_2_mask)) __pyx_t_21 = 2;
          if (unlikely(__pyx_t_21 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_21);
            {__pyx_filename = __pyx_f[1]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          __pyx_t_22 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_mask.buf, __pyx_t_15, __pyx_bstride_0_mask, __pyx_t_19, __pyx_bstride_1_mask, __pyx_t_20, __pyx_bstride_2_mask));
          if (__pyx_t_22) {
            __Pyx_XDECREF(__pyx_r);
            __Pyx_INCREF(__pyx_int_1);
            __pyx_r = __pyx_int_1;
            goto __pyx_L0;
            goto __pyx_L25;
          }
          __pyx_L25:;
          goto __pyx_L24;
        }
        /*else*/ {

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":125
 *                     if mask[i,j,k]: return 1
 *                 else:
 *                     mask[i,j,k] = 1             # <<<<<<<<<<<<<<
 *     return 0
 * 
 */
          __pyx_t_21 = __pyx_v_i;
          __pyx_t_23 = __pyx_v_j;
          __pyx_t_24 = __pyx_v_k;
          __pyx_t_25 = -1;
          if (__pyx_t_21 < 0) {
            __pyx_t_21 += __pyx_bshape_0_mask;
            if (unlikely(__pyx_t_21 < 0)) __pyx_t_25 = 0;
          } else if (unlikely(__pyx_t_21 >= __pyx_bshape_0_mask)) __pyx_t_25 = 0;
          if (__pyx_t_23 < 0) {
            __pyx_t_23 += __pyx_bshape_1_mask;
            if (unlikely(__pyx_t_23 < 0)) __pyx_t_25 = 1;
          } else if (unlikely(__pyx_t_23 >= __pyx_bshape_1_mask)) __pyx_t_25 = 1;
          if (__pyx_t_24 < 0) {
            __pyx_t_24 += __pyx_bshape_2_mask;
            if (unlikely(__pyx_t_24 < 0)) __pyx_t_25 = 2;
          } else if (unlikely(__pyx_t_24 >= __pyx_bshape_2_mask)) __pyx_t_25 = 2;
          if (unlikely(__pyx_t_25 != -1)) {
            __Pyx_RaiseBufferIndexError(__pyx_t_25);
            {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_mask.buf, __pyx_t_21, __pyx_bstride_0_mask, __pyx_t_23, __pyx_bstride_1_mask, __pyx_t_24, __pyx_bstride_2_mask) = 1;
        }
        __pyx_L24:;
        __pyx_L16_continue:;
      }
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":126
 *                 else:
 *                     mask[i,j,k] = 1
 *     return 0             # <<<<<<<<<<<<<<
 * 
 * cdef void normalize_vector(np.float64_t vec[3]):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_int_0);
  __pyx_r = __pyx_int_0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dds);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_right_edge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_mask);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_box_lengths);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_rot_mat);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_box_origin);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_left_edge);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.grid_points_in_volume");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dds);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_right_edge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_mask);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_box_lengths);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_rot_mat);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_box_origin);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_left_edge);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_box_lengths);
  __Pyx_DECREF((PyObject *)__pyx_v_box_origin);
  __Pyx_DECREF((PyObject *)__pyx_v_rot_mat);
  __Pyx_DECREF((PyObject *)__pyx_v_grid_left_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_grid_right_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_dds);
  __Pyx_DECREF((PyObject *)__pyx_v_mask);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":128
 *     return 0
 * 
 * cdef void normalize_vector(np.float64_t vec[3]):             # <<<<<<<<<<<<<<
 *     cdef int i
 *     cdef np.float64_t norm = 0.0
 */

static  void __pyx_f_2yt_9amr_utils_normalize_vector(__pyx_t_5numpy_float64_t *__pyx_v_vec) {
  int __pyx_v_i;
  __pyx_t_5numpy_float64_t __pyx_v_norm;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("normalize_vector");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":130
 * cdef void normalize_vector(np.float64_t vec[3]):
 *     cdef int i
 *     cdef np.float64_t norm = 0.0             # <<<<<<<<<<<<<<
 *     for i in range(3):
 *         norm += vec[i]*vec[i]
 */
  __pyx_v_norm = 0.0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":131
 *     cdef int i
 *     cdef np.float64_t norm = 0.0
 *     for i in range(3):             # <<<<<<<<<<<<<<
 *         norm += vec[i]*vec[i]
 *     norm = norm**0.5
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":132
 *     cdef np.float64_t norm = 0.0
 *     for i in range(3):
 *         norm += vec[i]*vec[i]             # <<<<<<<<<<<<<<
 *     norm = norm**0.5
 *     for i in range(3):
 */
    __pyx_v_norm += ((__pyx_v_vec[__pyx_v_i]) * (__pyx_v_vec[__pyx_v_i]));
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":133
 *     for i in range(3):
 *         norm += vec[i]*vec[i]
 *     norm = norm**0.5             # <<<<<<<<<<<<<<
 *     for i in range(3):
 *         vec[i] /= norm
 */
  __pyx_v_norm = pow(__pyx_v_norm, 0.5);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":134
 *         norm += vec[i]*vec[i]
 *     norm = norm**0.5
 *     for i in range(3):             # <<<<<<<<<<<<<<
 *         vec[i] /= norm
 * 
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":135
 *     norm = norm**0.5
 *     for i in range(3):
 *         vec[i] /= norm             # <<<<<<<<<<<<<<
 * 
 * cdef void get_cross_product(np.float64_t v1[3],
 */
    (__pyx_v_vec[__pyx_v_i]) /= __pyx_v_norm;
  }

  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":137
 *         vec[i] /= norm
 * 
 * cdef void get_cross_product(np.float64_t v1[3],             # <<<<<<<<<<<<<<
 *                             np.float64_t v2[3],
 *                             np.float64_t cp[3]):
 */

static  void __pyx_f_2yt_9amr_utils_get_cross_product(__pyx_t_5numpy_float64_t *__pyx_v_v1, __pyx_t_5numpy_float64_t *__pyx_v_v2, __pyx_t_5numpy_float64_t *__pyx_v_cp) {
  __Pyx_RefNannySetupContext("get_cross_product");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":140
 *                             np.float64_t v2[3],
 *                             np.float64_t cp[3]):
 *     cp[0] = v1[1]*v2[2] - v1[2]*v2[1]             # <<<<<<<<<<<<<<
 *     cp[1] = v1[3]*v2[0] - v1[0]*v2[3]
 *     cp[2] = v1[0]*v2[1] - v1[1]*v2[0]
 */
  (__pyx_v_cp[0]) = (((__pyx_v_v1[1]) * (__pyx_v_v2[2])) - ((__pyx_v_v1[2]) * (__pyx_v_v2[1])));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":141
 *                             np.float64_t cp[3]):
 *     cp[0] = v1[1]*v2[2] - v1[2]*v2[1]
 *     cp[1] = v1[3]*v2[0] - v1[0]*v2[3]             # <<<<<<<<<<<<<<
 *     cp[2] = v1[0]*v2[1] - v1[1]*v2[0]
 *     #print cp[0], cp[1], cp[2]
 */
  (__pyx_v_cp[1]) = (((__pyx_v_v1[3]) * (__pyx_v_v2[0])) - ((__pyx_v_v1[0]) * (__pyx_v_v2[3])));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":142
 *     cp[0] = v1[1]*v2[2] - v1[2]*v2[1]
 *     cp[1] = v1[3]*v2[0] - v1[0]*v2[3]
 *     cp[2] = v1[0]*v2[1] - v1[1]*v2[0]             # <<<<<<<<<<<<<<
 *     #print cp[0], cp[1], cp[2]
 * 
 */
  (__pyx_v_cp[2]) = (((__pyx_v_v1[0]) * (__pyx_v_v2[1])) - ((__pyx_v_v1[1]) * (__pyx_v_v2[0])));

  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":145
 *     #print cp[0], cp[1], cp[2]
 * 
 * cdef int check_projected_overlap(             # <<<<<<<<<<<<<<
 *         np.float64_t sep_ax[3], np.float64_t sep_vec[3], int gi,
 *         np.float64_t b_vec[3][3], np.float64_t g_vec[3][3]):
 */

static  int __pyx_f_2yt_9amr_utils_check_projected_overlap(__pyx_t_5numpy_float64_t *__pyx_v_sep_ax, __pyx_t_5numpy_float64_t *__pyx_v_sep_vec, int __pyx_v_gi, __pyx_t_5numpy_float64_t (*__pyx_v_b_vec)[3], __pyx_t_5numpy_float64_t (*__pyx_v_g_vec)[3]) {
  int __pyx_v_g_ax;
  int __pyx_v_b_ax;
  __pyx_t_5numpy_float64_t __pyx_v_tba;
  __pyx_t_5numpy_float64_t __pyx_v_tga;
  __pyx_t_5numpy_float64_t __pyx_v_ba;
  __pyx_t_5numpy_float64_t __pyx_v_ga;
  __pyx_t_5numpy_float64_t __pyx_v_sep_dot;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("check_projected_overlap");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":150
 *     cdef int g_ax, b_ax
 *     cdef np.float64_t tba, tga, ba, ga, sep_dot
 *     ba = ga = sep_dot = 0.0             # <<<<<<<<<<<<<<
 *     for g_ax in range(3):
 *         # We need the grid vectors, which we'll precompute here
 */
  __pyx_v_ba = 0.0;
  __pyx_v_ga = 0.0;
  __pyx_v_sep_dot = 0.0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":151
 *     cdef np.float64_t tba, tga, ba, ga, sep_dot
 *     ba = ga = sep_dot = 0.0
 *     for g_ax in range(3):             # <<<<<<<<<<<<<<
 *         # We need the grid vectors, which we'll precompute here
 *         tba = tga = 0.0
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_g_ax = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":153
 *     for g_ax in range(3):
 *         # We need the grid vectors, which we'll precompute here
 *         tba = tga = 0.0             # <<<<<<<<<<<<<<
 *         for b_ax in range(3):
 *             tba += b_vec[g_ax][b_ax] * sep_vec[b_ax]
 */
    __pyx_v_tba = 0.0;
    __pyx_v_tga = 0.0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":154
 *         # We need the grid vectors, which we'll precompute here
 *         tba = tga = 0.0
 *         for b_ax in range(3):             # <<<<<<<<<<<<<<
 *             tba += b_vec[g_ax][b_ax] * sep_vec[b_ax]
 *             tga += g_vec[g_ax][b_ax] * sep_vec[b_ax]
 */
    for (__pyx_t_2 = 0; __pyx_t_2 < 3; __pyx_t_2+=1) {
      __pyx_v_b_ax = __pyx_t_2;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":155
 *         tba = tga = 0.0
 *         for b_ax in range(3):
 *             tba += b_vec[g_ax][b_ax] * sep_vec[b_ax]             # <<<<<<<<<<<<<<
 *             tga += g_vec[g_ax][b_ax] * sep_vec[b_ax]
 *         ba += fabs(tba)
 */
      __pyx_v_tba += (((__pyx_v_b_vec[__pyx_v_g_ax])[__pyx_v_b_ax]) * (__pyx_v_sep_vec[__pyx_v_b_ax]));

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":156
 *         for b_ax in range(3):
 *             tba += b_vec[g_ax][b_ax] * sep_vec[b_ax]
 *             tga += g_vec[g_ax][b_ax] * sep_vec[b_ax]             # <<<<<<<<<<<<<<
 *         ba += fabs(tba)
 *         ga += fabs(tga)
 */
      __pyx_v_tga += (((__pyx_v_g_vec[__pyx_v_g_ax])[__pyx_v_b_ax]) * (__pyx_v_sep_vec[__pyx_v_b_ax]));
    }

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":157
 *             tba += b_vec[g_ax][b_ax] * sep_vec[b_ax]
 *             tga += g_vec[g_ax][b_ax] * sep_vec[b_ax]
 *         ba += fabs(tba)             # <<<<<<<<<<<<<<
 *         ga += fabs(tga)
 *         sep_dot += sep_vec[g_ax] * sep_ax[g_ax]
 */
    __pyx_v_ba += fabs(__pyx_v_tba);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":158
 *             tga += g_vec[g_ax][b_ax] * sep_vec[b_ax]
 *         ba += fabs(tba)
 *         ga += fabs(tga)             # <<<<<<<<<<<<<<
 *         sep_dot += sep_vec[g_ax] * sep_ax[g_ax]
 *     #print sep_vec[0], sep_vec[1], sep_vec[2],
 */
    __pyx_v_ga += fabs(__pyx_v_tga);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":159
 *         ba += fabs(tba)
 *         ga += fabs(tga)
 *         sep_dot += sep_vec[g_ax] * sep_ax[g_ax]             # <<<<<<<<<<<<<<
 *     #print sep_vec[0], sep_vec[1], sep_vec[2],
 *     #print sep_ax[0], sep_ax[1], sep_ax[2]
 */
    __pyx_v_sep_dot += ((__pyx_v_sep_vec[__pyx_v_g_ax]) * (__pyx_v_sep_ax[__pyx_v_g_ax]));
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":162
 *     #print sep_vec[0], sep_vec[1], sep_vec[2],
 *     #print sep_ax[0], sep_ax[1], sep_ax[2]
 *     return (fabs(sep_dot) > ba+ga)             # <<<<<<<<<<<<<<
 *     # Now we do
 * 
 */
  __pyx_r = (fabs(__pyx_v_sep_dot) > (__pyx_v_ba + __pyx_v_ga));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":167
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def find_grids_in_inclined_box(             # <<<<<<<<<<<<<<
 *         np.ndarray[np.float64_t, ndim=2] box_vectors,
 *         np.ndarray[np.float64_t, ndim=1] box_center,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_find_grids_in_inclined_box(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_find_grids_in_inclined_box(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_box_vectors = 0;
  PyArrayObject *__pyx_v_box_center = 0;
  PyArrayObject *__pyx_v_grid_left_edges = 0;
  PyArrayObject *__pyx_v_grid_right_edges = 0;
  int __pyx_v_n;
  int __pyx_v_g_ax;
  int __pyx_v_b_ax;
  int __pyx_v_gi;
  __pyx_t_5numpy_float64_t __pyx_v_b_vec[3][3];
  __pyx_t_5numpy_float64_t __pyx_v_g_vec[3][3];
  __pyx_t_5numpy_float64_t __pyx_v_a_vec[3][3];
  __pyx_t_5numpy_float64_t __pyx_v_sep_ax[15][3];
  __pyx_t_5numpy_float64_t __pyx_v_sep_vec[3];
  PyArrayObject *__pyx_v_good = 0;
  PyArrayObject *__pyx_v_grid_centers;
  Py_buffer __pyx_bstruct_grid_left_edges;
  Py_ssize_t __pyx_bstride_0_grid_left_edges = 0;
  Py_ssize_t __pyx_bstride_1_grid_left_edges = 0;
  Py_ssize_t __pyx_bshape_0_grid_left_edges = 0;
  Py_ssize_t __pyx_bshape_1_grid_left_edges = 0;
  Py_buffer __pyx_bstruct_box_vectors;
  Py_ssize_t __pyx_bstride_0_box_vectors = 0;
  Py_ssize_t __pyx_bstride_1_box_vectors = 0;
  Py_ssize_t __pyx_bshape_0_box_vectors = 0;
  Py_ssize_t __pyx_bshape_1_box_vectors = 0;
  Py_buffer __pyx_bstruct_good;
  Py_ssize_t __pyx_bstride_0_good = 0;
  Py_ssize_t __pyx_bshape_0_good = 0;
  Py_buffer __pyx_bstruct_grid_right_edges;
  Py_ssize_t __pyx_bstride_0_grid_right_edges = 0;
  Py_ssize_t __pyx_bstride_1_grid_right_edges = 0;
  Py_ssize_t __pyx_bshape_0_grid_right_edges = 0;
  Py_ssize_t __pyx_bshape_1_grid_right_edges = 0;
  Py_buffer __pyx_bstruct_grid_centers;
  Py_ssize_t __pyx_bstride_0_grid_centers = 0;
  Py_ssize_t __pyx_bstride_1_grid_centers = 0;
  Py_ssize_t __pyx_bshape_0_grid_centers = 0;
  Py_ssize_t __pyx_bshape_1_grid_centers = 0;
  Py_buffer __pyx_bstruct_box_center;
  Py_ssize_t __pyx_bstride_0_box_center = 0;
  Py_ssize_t __pyx_bshape_0_box_center = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyArrayObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  PyArrayObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  int __pyx_t_21;
  int __pyx_t_22;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__box_vectors,&__pyx_n_s__box_center,&__pyx_n_s__grid_left_edges,&__pyx_n_s__grid_right_edges,0};
  __Pyx_RefNannySetupContext("find_grids_in_inclined_box");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__box_vectors);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__box_center);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("find_grids_in_inclined_box", 1, 4, 4, 1); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grid_left_edges);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("find_grids_in_inclined_box", 1, 4, 4, 2); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grid_right_edges);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("find_grids_in_inclined_box", 1, 4, 4, 3); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "find_grids_in_inclined_box") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_box_vectors = ((PyArrayObject *)values[0]);
    __pyx_v_box_center = ((PyArrayObject *)values[1]);
    __pyx_v_grid_left_edges = ((PyArrayObject *)values[2]);
    __pyx_v_grid_right_edges = ((PyArrayObject *)values[3]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_box_vectors = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_box_center = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_grid_left_edges = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_grid_right_edges = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("find_grids_in_inclined_box", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.find_grids_in_inclined_box");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_box_vectors);
  __Pyx_INCREF((PyObject *)__pyx_v_box_center);
  __Pyx_INCREF((PyObject *)__pyx_v_grid_left_edges);
  __Pyx_INCREF((PyObject *)__pyx_v_grid_right_edges);
  __pyx_v_grid_centers = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_bstruct_good.buf = NULL;
  __pyx_bstruct_grid_centers.buf = NULL;
  __pyx_bstruct_box_vectors.buf = NULL;
  __pyx_bstruct_box_center.buf = NULL;
  __pyx_bstruct_grid_left_edges.buf = NULL;
  __pyx_bstruct_grid_right_edges.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_box_vectors), __pyx_ptype_5numpy_ndarray, 1, "box_vectors", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_box_center), __pyx_ptype_5numpy_ndarray, 1, "box_center", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grid_left_edges), __pyx_ptype_5numpy_ndarray, 1, "grid_left_edges", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grid_right_edges), __pyx_ptype_5numpy_ndarray, 1, "grid_right_edges", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_box_vectors, (PyObject*)__pyx_v_box_vectors, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_box_vectors = __pyx_bstruct_box_vectors.strides[0]; __pyx_bstride_1_box_vectors = __pyx_bstruct_box_vectors.strides[1];
  __pyx_bshape_0_box_vectors = __pyx_bstruct_box_vectors.shape[0]; __pyx_bshape_1_box_vectors = __pyx_bstruct_box_vectors.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_box_center, (PyObject*)__pyx_v_box_center, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_box_center = __pyx_bstruct_box_center.strides[0];
  __pyx_bshape_0_box_center = __pyx_bstruct_box_center.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_grid_left_edges, (PyObject*)__pyx_v_grid_left_edges, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_grid_left_edges = __pyx_bstruct_grid_left_edges.strides[0]; __pyx_bstride_1_grid_left_edges = __pyx_bstruct_grid_left_edges.strides[1];
  __pyx_bshape_0_grid_left_edges = __pyx_bstruct_grid_left_edges.shape[0]; __pyx_bshape_1_grid_left_edges = __pyx_bstruct_grid_left_edges.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_grid_right_edges, (PyObject*)__pyx_v_grid_right_edges, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_grid_right_edges = __pyx_bstruct_grid_right_edges.strides[0]; __pyx_bstride_1_grid_right_edges = __pyx_bstruct_grid_right_edges.strides[1];
  __pyx_bshape_0_grid_right_edges = __pyx_bstruct_grid_right_edges.shape[0]; __pyx_bshape_1_grid_right_edges = __pyx_bstruct_grid_right_edges.shape[1];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":174
 * 
 *     # http://www.gamasutra.com/view/feature/3383/simple_intersection_tests_for_games.php?page=5
 *     cdef int n = grid_right_edges.shape[0]             # <<<<<<<<<<<<<<
 *     cdef int g_ax, b_ax, gi
 *     cdef np.float64_t b_vec[3][3], g_vec[3][3], a_vec[3][3], sep_ax[15][3]
 */
  __pyx_v_n = (__pyx_v_grid_right_edges->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":178
 *     cdef np.float64_t b_vec[3][3], g_vec[3][3], a_vec[3][3], sep_ax[15][3]
 *     cdef np.float64_t sep_vec[3], norm
 *     cdef np.ndarray[np.int32_t, ndim=1] good = np.zeros(n, dtype='int32')             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.float64_t, ndim=2] grid_centers
 *     # Fill in our axis unit vectors
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)__pyx_n_s__int32)) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_good, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_good = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_good.buf = NULL;
      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_good = __pyx_bstruct_good.strides[0];
      __pyx_bshape_0_good = __pyx_bstruct_good.shape[0];
    }
  }
  __pyx_t_5 = 0;
  __pyx_v_good = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":181
 *     cdef np.ndarray[np.float64_t, ndim=2] grid_centers
 *     # Fill in our axis unit vectors
 *     for b_ax in range(3):             # <<<<<<<<<<<<<<
 *         for g_ax in range(3):
 *             a_vec[b_ax][g_ax] = <np.float64_t> (b_ax == g_ax)
 */
  for (__pyx_t_6 = 0; __pyx_t_6 < 3; __pyx_t_6+=1) {
    __pyx_v_b_ax = __pyx_t_6;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":182
 *     # Fill in our axis unit vectors
 *     for b_ax in range(3):
 *         for g_ax in range(3):             # <<<<<<<<<<<<<<
 *             a_vec[b_ax][g_ax] = <np.float64_t> (b_ax == g_ax)
 *     grid_centers = (grid_right_edges + grid_left_edges)/2.0
 */
    for (__pyx_t_7 = 0; __pyx_t_7 < 3; __pyx_t_7+=1) {
      __pyx_v_g_ax = __pyx_t_7;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":183
 *     for b_ax in range(3):
 *         for g_ax in range(3):
 *             a_vec[b_ax][g_ax] = <np.float64_t> (b_ax == g_ax)             # <<<<<<<<<<<<<<
 *     grid_centers = (grid_right_edges + grid_left_edges)/2.0
 * 
 */
      ((__pyx_v_a_vec[__pyx_v_b_ax])[__pyx_v_g_ax]) = ((__pyx_t_5numpy_float64_t)(__pyx_v_b_ax == __pyx_v_g_ax));
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":184
 *         for g_ax in range(3):
 *             a_vec[b_ax][g_ax] = <np.float64_t> (b_ax == g_ax)
 *     grid_centers = (grid_right_edges + grid_left_edges)/2.0             # <<<<<<<<<<<<<<
 * 
 *     # Now we pre-compute our candidate separating axes, because the unit
 */
  __pyx_t_4 = PyNumber_Add(((PyObject *)__pyx_v_grid_right_edges), ((PyObject *)__pyx_v_grid_left_edges)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyFloat_FromDouble(2.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_centers);
    __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_grid_centers, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_6 < 0)) {
      PyErr_Fetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_grid_centers, (PyObject*)__pyx_v_grid_centers, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      }
    }
    __pyx_bstride_0_grid_centers = __pyx_bstruct_grid_centers.strides[0]; __pyx_bstride_1_grid_centers = __pyx_bstruct_grid_centers.strides[1];
    __pyx_bshape_0_grid_centers = __pyx_bstruct_grid_centers.shape[0]; __pyx_bshape_1_grid_centers = __pyx_bstruct_grid_centers.shape[1];
    if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_8 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_v_grid_centers));
  __pyx_v_grid_centers = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":188
 *     # Now we pre-compute our candidate separating axes, because the unit
 *     # vectors for all the grids are identical
 *     for b_ax in range(3):             # <<<<<<<<<<<<<<
 *         # We have 6 principal axes we already know, which are the grid (domain)
 *         # principal axes and the box axes
 */
  for (__pyx_t_6 = 0; __pyx_t_6 < 3; __pyx_t_6+=1) {
    __pyx_v_b_ax = __pyx_t_6;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":191
 *         # We have 6 principal axes we already know, which are the grid (domain)
 *         # principal axes and the box axes
 *         sep_ax[b_ax][0] = sep_ax[b_ax][1] = sep_ax[b_ax][2] = 0.0             # <<<<<<<<<<<<<<
 *         sep_ax[b_ax][b_ax] = 1.0 # delta_ijk, for grid axes
 *         for g_ax in range(3):
 */
    ((__pyx_v_sep_ax[__pyx_v_b_ax])[0]) = 0.0;
    ((__pyx_v_sep_ax[__pyx_v_b_ax])[1]) = 0.0;
    ((__pyx_v_sep_ax[__pyx_v_b_ax])[2]) = 0.0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":192
 *         # principal axes and the box axes
 *         sep_ax[b_ax][0] = sep_ax[b_ax][1] = sep_ax[b_ax][2] = 0.0
 *         sep_ax[b_ax][b_ax] = 1.0 # delta_ijk, for grid axes             # <<<<<<<<<<<<<<
 *         for g_ax in range(3):
 *             b_vec[b_ax][g_ax] = 0.5*box_vectors[b_ax,g_ax]
 */
    ((__pyx_v_sep_ax[__pyx_v_b_ax])[__pyx_v_b_ax]) = 1.0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":193
 *         sep_ax[b_ax][0] = sep_ax[b_ax][1] = sep_ax[b_ax][2] = 0.0
 *         sep_ax[b_ax][b_ax] = 1.0 # delta_ijk, for grid axes
 *         for g_ax in range(3):             # <<<<<<<<<<<<<<
 *             b_vec[b_ax][g_ax] = 0.5*box_vectors[b_ax,g_ax]
 *             sep_ax[b_ax + 3][g_ax] = b_vec[b_ax][g_ax] # box axes
 */
    for (__pyx_t_7 = 0; __pyx_t_7 < 3; __pyx_t_7+=1) {
      __pyx_v_g_ax = __pyx_t_7;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":194
 *         sep_ax[b_ax][b_ax] = 1.0 # delta_ijk, for grid axes
 *         for g_ax in range(3):
 *             b_vec[b_ax][g_ax] = 0.5*box_vectors[b_ax,g_ax]             # <<<<<<<<<<<<<<
 *             sep_ax[b_ax + 3][g_ax] = b_vec[b_ax][g_ax] # box axes
 *         normalize_vector(sep_ax[b_ax + 3])
 */
      __pyx_t_12 = __pyx_v_b_ax;
      __pyx_t_13 = __pyx_v_g_ax;
      ((__pyx_v_b_vec[__pyx_v_b_ax])[__pyx_v_g_ax]) = (0.5 * (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_box_vectors.buf, __pyx_t_12, __pyx_bstride_0_box_vectors, __pyx_t_13, __pyx_bstride_1_box_vectors)));

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":195
 *         for g_ax in range(3):
 *             b_vec[b_ax][g_ax] = 0.5*box_vectors[b_ax,g_ax]
 *             sep_ax[b_ax + 3][g_ax] = b_vec[b_ax][g_ax] # box axes             # <<<<<<<<<<<<<<
 *         normalize_vector(sep_ax[b_ax + 3])
 *         for g_ax in range(3):
 */
      ((__pyx_v_sep_ax[(__pyx_v_b_ax + 3)])[__pyx_v_g_ax]) = ((__pyx_v_b_vec[__pyx_v_b_ax])[__pyx_v_g_ax]);
    }

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":196
 *             b_vec[b_ax][g_ax] = 0.5*box_vectors[b_ax,g_ax]
 *             sep_ax[b_ax + 3][g_ax] = b_vec[b_ax][g_ax] # box axes
 *         normalize_vector(sep_ax[b_ax + 3])             # <<<<<<<<<<<<<<
 *         for g_ax in range(3):
 *             get_cross_product(b_vec[b_ax], a_vec[g_ax], sep_ax[b_ax*3 + g_ax + 6])
 */
    __pyx_f_2yt_9amr_utils_normalize_vector((__pyx_v_sep_ax[(__pyx_v_b_ax + 3)]));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":197
 *             sep_ax[b_ax + 3][g_ax] = b_vec[b_ax][g_ax] # box axes
 *         normalize_vector(sep_ax[b_ax + 3])
 *         for g_ax in range(3):             # <<<<<<<<<<<<<<
 *             get_cross_product(b_vec[b_ax], a_vec[g_ax], sep_ax[b_ax*3 + g_ax + 6])
 *             normalize_vector(sep_ax[b_ax*3 + g_ax + 6])
 */
    for (__pyx_t_7 = 0; __pyx_t_7 < 3; __pyx_t_7+=1) {
      __pyx_v_g_ax = __pyx_t_7;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":198
 *         normalize_vector(sep_ax[b_ax + 3])
 *         for g_ax in range(3):
 *             get_cross_product(b_vec[b_ax], a_vec[g_ax], sep_ax[b_ax*3 + g_ax + 6])             # <<<<<<<<<<<<<<
 *             normalize_vector(sep_ax[b_ax*3 + g_ax + 6])
 * 
 */
      __pyx_f_2yt_9amr_utils_get_cross_product((__pyx_v_b_vec[__pyx_v_b_ax]), (__pyx_v_a_vec[__pyx_v_g_ax]), (__pyx_v_sep_ax[(((__pyx_v_b_ax * 3) + __pyx_v_g_ax) + 6)]));

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":199
 *         for g_ax in range(3):
 *             get_cross_product(b_vec[b_ax], a_vec[g_ax], sep_ax[b_ax*3 + g_ax + 6])
 *             normalize_vector(sep_ax[b_ax*3 + g_ax + 6])             # <<<<<<<<<<<<<<
 * 
 *     for gi in range(n):
 */
      __pyx_f_2yt_9amr_utils_normalize_vector((__pyx_v_sep_ax[(((__pyx_v_b_ax * 3) + __pyx_v_g_ax) + 6)]));
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":201
 *             normalize_vector(sep_ax[b_ax*3 + g_ax + 6])
 * 
 *     for gi in range(n):             # <<<<<<<<<<<<<<
 *         for g_ax in range(3):
 *             # Calculate the separation vector
 */
  __pyx_t_6 = __pyx_v_n;
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_v_gi = __pyx_t_7;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":202
 * 
 *     for gi in range(n):
 *         for g_ax in range(3):             # <<<<<<<<<<<<<<
 *             # Calculate the separation vector
 *             sep_vec[g_ax] = grid_centers[gi, g_ax] - box_center[g_ax]
 */
    for (__pyx_t_14 = 0; __pyx_t_14 < 3; __pyx_t_14+=1) {
      __pyx_v_g_ax = __pyx_t_14;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":204
 *         for g_ax in range(3):
 *             # Calculate the separation vector
 *             sep_vec[g_ax] = grid_centers[gi, g_ax] - box_center[g_ax]             # <<<<<<<<<<<<<<
 *             # Calculate the grid axis lengths
 *             g_vec[g_ax][0] = g_vec[g_ax][1] = g_vec[g_ax][2] = 0.0
 */
      __pyx_t_15 = __pyx_v_gi;
      __pyx_t_16 = __pyx_v_g_ax;
      __pyx_t_17 = __pyx_v_g_ax;
      (__pyx_v_sep_vec[__pyx_v_g_ax]) = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_centers.buf, __pyx_t_15, __pyx_bstride_0_grid_centers, __pyx_t_16, __pyx_bstride_1_grid_centers)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_box_center.buf, __pyx_t_17, __pyx_bstride_0_box_center)));

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":206
 *             sep_vec[g_ax] = grid_centers[gi, g_ax] - box_center[g_ax]
 *             # Calculate the grid axis lengths
 *             g_vec[g_ax][0] = g_vec[g_ax][1] = g_vec[g_ax][2] = 0.0             # <<<<<<<<<<<<<<
 *             g_vec[g_ax][g_ax] = 0.5 * (grid_right_edges[gi, g_ax]
 *                                      - grid_left_edges[gi, g_ax])
 */
      ((__pyx_v_g_vec[__pyx_v_g_ax])[0]) = 0.0;
      ((__pyx_v_g_vec[__pyx_v_g_ax])[1]) = 0.0;
      ((__pyx_v_g_vec[__pyx_v_g_ax])[2]) = 0.0;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":207
 *             # Calculate the grid axis lengths
 *             g_vec[g_ax][0] = g_vec[g_ax][1] = g_vec[g_ax][2] = 0.0
 *             g_vec[g_ax][g_ax] = 0.5 * (grid_right_edges[gi, g_ax]             # <<<<<<<<<<<<<<
 *                                      - grid_left_edges[gi, g_ax])
 *         for b_ax in range(15):
 */
      __pyx_t_18 = __pyx_v_gi;
      __pyx_t_19 = __pyx_v_g_ax;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":208
 *             g_vec[g_ax][0] = g_vec[g_ax][1] = g_vec[g_ax][2] = 0.0
 *             g_vec[g_ax][g_ax] = 0.5 * (grid_right_edges[gi, g_ax]
 *                                      - grid_left_edges[gi, g_ax])             # <<<<<<<<<<<<<<
 *         for b_ax in range(15):
 *             #print b_ax,
 */
      __pyx_t_20 = __pyx_v_gi;
      __pyx_t_21 = __pyx_v_g_ax;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":207
 *             # Calculate the grid axis lengths
 *             g_vec[g_ax][0] = g_vec[g_ax][1] = g_vec[g_ax][2] = 0.0
 *             g_vec[g_ax][g_ax] = 0.5 * (grid_right_edges[gi, g_ax]             # <<<<<<<<<<<<<<
 *                                      - grid_left_edges[gi, g_ax])
 *         for b_ax in range(15):
 */
      ((__pyx_v_g_vec[__pyx_v_g_ax])[__pyx_v_g_ax]) = (0.5 * ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_right_edges.buf, __pyx_t_18, __pyx_bstride_0_grid_right_edges, __pyx_t_19, __pyx_bstride_1_grid_right_edges)) - (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_left_edges.buf, __pyx_t_20, __pyx_bstride_0_grid_left_edges, __pyx_t_21, __pyx_bstride_1_grid_left_edges))));
    }

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":209
 *             g_vec[g_ax][g_ax] = 0.5 * (grid_right_edges[gi, g_ax]
 *                                      - grid_left_edges[gi, g_ax])
 *         for b_ax in range(15):             # <<<<<<<<<<<<<<
 *             #print b_ax,
 *             if check_projected_overlap(
 */
    for (__pyx_t_14 = 0; __pyx_t_14 < 15; __pyx_t_14+=1) {
      __pyx_v_b_ax = __pyx_t_14;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":213
 *             if check_projected_overlap(
 *                         sep_ax[b_ax], sep_vec, gi,
 *                         b_vec,  g_vec):             # <<<<<<<<<<<<<<
 *                 good[gi] = 1
 *                 break
 */
      __pyx_t_22 = __pyx_f_2yt_9amr_utils_check_projected_overlap((__pyx_v_sep_ax[__pyx_v_b_ax]), __pyx_v_sep_vec, __pyx_v_gi, __pyx_v_b_vec, __pyx_v_g_vec);
      if (__pyx_t_22) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":214
 *                         sep_ax[b_ax], sep_vec, gi,
 *                         b_vec,  g_vec):
 *                 good[gi] = 1             # <<<<<<<<<<<<<<
 *                 break
 *     return good
 */
        __pyx_t_22 = __pyx_v_gi;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_good.buf, __pyx_t_22, __pyx_bstride_0_good) = 1;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":215
 *                         b_vec,  g_vec):
 *                 good[gi] = 1
 *                 break             # <<<<<<<<<<<<<<
 *     return good
 * 
 */
        goto __pyx_L21_break;
        goto __pyx_L22;
      }
      __pyx_L22:;
    }
    __pyx_L21_break:;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":216
 *                 good[gi] = 1
 *                 break
 *     return good             # <<<<<<<<<<<<<<
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_good));
  __pyx_r = ((PyObject *)__pyx_v_good);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_left_edges);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_box_vectors);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_good);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_right_edges);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_centers);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_box_center);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.find_grids_in_inclined_box");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_left_edges);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_box_vectors);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_good);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_right_edges);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_centers);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_box_center);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_good);
  __Pyx_DECREF((PyObject *)__pyx_v_grid_centers);
  __Pyx_DECREF((PyObject *)__pyx_v_box_vectors);
  __Pyx_DECREF((PyObject *)__pyx_v_box_center);
  __Pyx_DECREF((PyObject *)__pyx_v_grid_left_edges);
  __Pyx_DECREF((PyObject *)__pyx_v_grid_right_edges);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":36
 * 
 * @cython.boundscheck(False)
 * def Transfer3D(np.ndarray[np.float64_t, ndim=3] i_s,             # <<<<<<<<<<<<<<
 *                np.ndarray[np.float64_t, ndim=4] o_s,
 *                np.ndarray[np.float64_t, ndim=4] e,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_Transfer3D(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_2yt_9amr_utils_Transfer3D[] = "\n    This function accepts an incoming slab (*i_s*), a buffer\n    for an outgoing set of values at every point in the grid (*o_s*),\n    an emission array (*e*), an absorption array (*a*), and dimensions of\n    the grid (*imin*, *imax*, *jmin*, *jmax*, *kmin*, *kmax*) as well\n    as strides in the *i* and *j* directions, and a *dx* of the grid being\n    integrated.\n    ";
static PyObject *__pyx_pf_2yt_9amr_utils_Transfer3D(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_i_s = 0;
  PyArrayObject *__pyx_v_o_s = 0;
  PyArrayObject *__pyx_v_e = 0;
  PyArrayObject *__pyx_v_a = 0;
  int __pyx_v_imin;
  int __pyx_v_imax;
  int __pyx_v_jmin;
  int __pyx_v_jmax;
  int __pyx_v_kmin;
  int __pyx_v_kmax;
  int __pyx_v_istride;
  int __pyx_v_jstride;
  __pyx_t_5numpy_float64_t __pyx_v_dx;
  int __pyx_v_i;
  int __pyx_v_ii;
  int __pyx_v_j;
  int __pyx_v_jj;
  int __pyx_v_k;
  int __pyx_v_kk;
  int __pyx_v_n;
  int __pyx_v_nn;
  __pyx_t_5numpy_float64_t *__pyx_v_temp;
  Py_buffer __pyx_bstruct_o_s;
  Py_ssize_t __pyx_bstride_0_o_s = 0;
  Py_ssize_t __pyx_bstride_1_o_s = 0;
  Py_ssize_t __pyx_bstride_2_o_s = 0;
  Py_ssize_t __pyx_bstride_3_o_s = 0;
  Py_ssize_t __pyx_bshape_0_o_s = 0;
  Py_ssize_t __pyx_bshape_1_o_s = 0;
  Py_ssize_t __pyx_bshape_2_o_s = 0;
  Py_ssize_t __pyx_bshape_3_o_s = 0;
  Py_buffer __pyx_bstruct_i_s;
  Py_ssize_t __pyx_bstride_0_i_s = 0;
  Py_ssize_t __pyx_bstride_1_i_s = 0;
  Py_ssize_t __pyx_bstride_2_i_s = 0;
  Py_ssize_t __pyx_bshape_0_i_s = 0;
  Py_ssize_t __pyx_bshape_1_i_s = 0;
  Py_ssize_t __pyx_bshape_2_i_s = 0;
  Py_buffer __pyx_bstruct_a;
  Py_ssize_t __pyx_bstride_0_a = 0;
  Py_ssize_t __pyx_bstride_1_a = 0;
  Py_ssize_t __pyx_bstride_2_a = 0;
  Py_ssize_t __pyx_bstride_3_a = 0;
  Py_ssize_t __pyx_bshape_0_a = 0;
  Py_ssize_t __pyx_bshape_1_a = 0;
  Py_ssize_t __pyx_bshape_2_a = 0;
  Py_ssize_t __pyx_bshape_3_a = 0;
  Py_buffer __pyx_bstruct_e;
  Py_ssize_t __pyx_bstride_0_e = 0;
  Py_ssize_t __pyx_bstride_1_e = 0;
  Py_ssize_t __pyx_bstride_2_e = 0;
  Py_ssize_t __pyx_bstride_3_e = 0;
  Py_ssize_t __pyx_bshape_0_e = 0;
  Py_ssize_t __pyx_bshape_1_e = 0;
  Py_ssize_t __pyx_bshape_2_e = 0;
  Py_ssize_t __pyx_bshape_3_e = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  int __pyx_t_21;
  int __pyx_t_22;
  int __pyx_t_23;
  int __pyx_t_24;
  int __pyx_t_25;
  int __pyx_t_26;
  int __pyx_t_27;
  int __pyx_t_28;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__i_s,&__pyx_n_s__o_s,&__pyx_n_s__e,&__pyx_n_s__a,&__pyx_n_s__imin,&__pyx_n_s__imax,&__pyx_n_s__jmin,&__pyx_n_s__jmax,&__pyx_n_s__kmin,&__pyx_n_s__kmax,&__pyx_n_s__istride,&__pyx_n_s__jstride,&__pyx_n_s__dx,0};
  __Pyx_RefNannySetupContext("Transfer3D");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12);
      case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11);
      case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
      case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_s);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__o_s);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 1); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__e);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 2); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 3); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__imin);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 4); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__imax);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 5); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__jmin);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 6); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  7:
      values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__jmax);
      if (likely(values[7])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 7); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  8:
      values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__kmin);
      if (likely(values[8])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 8); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  9:
      values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__kmax);
      if (likely(values[9])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 9); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case 10:
      values[10] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__istride);
      if (likely(values[10])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 10); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case 11:
      values[11] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__jstride);
      if (likely(values[11])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 11); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case 12:
      values[12] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dx);
      if (likely(values[12])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, 12); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "Transfer3D") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_i_s = ((PyArrayObject *)values[0]);
    __pyx_v_o_s = ((PyArrayObject *)values[1]);
    __pyx_v_e = ((PyArrayObject *)values[2]);
    __pyx_v_a = ((PyArrayObject *)values[3]);
    __pyx_v_imin = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_imin == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_imax = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_imax == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_jmin = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_jmin == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_jmax = __Pyx_PyInt_AsInt(values[7]); if (unlikely((__pyx_v_jmax == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_kmin = __Pyx_PyInt_AsInt(values[8]); if (unlikely((__pyx_v_kmin == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_kmax = __Pyx_PyInt_AsInt(values[9]); if (unlikely((__pyx_v_kmax == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_istride = __Pyx_PyInt_AsInt(values[10]); if (unlikely((__pyx_v_istride == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_jstride = __Pyx_PyInt_AsInt(values[11]); if (unlikely((__pyx_v_jstride == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_dx = __pyx_PyFloat_AsDouble(values[12]); if (unlikely((__pyx_v_dx == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 13) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_i_s = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_o_s = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_e = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_a = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_imin = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_imin == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_imax = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_imax == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_jmin = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 6)); if (unlikely((__pyx_v_jmin == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_jmax = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 7)); if (unlikely((__pyx_v_jmax == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_kmin = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 8)); if (unlikely((__pyx_v_kmin == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_kmax = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 9)); if (unlikely((__pyx_v_kmax == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_istride = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 10)); if (unlikely((__pyx_v_istride == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_jstride = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 11)); if (unlikely((__pyx_v_jstride == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_dx = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 12)); if (unlikely((__pyx_v_dx == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("Transfer3D", 1, 13, 13, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.Transfer3D");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_i_s);
  __Pyx_INCREF((PyObject *)__pyx_v_o_s);
  __Pyx_INCREF((PyObject *)__pyx_v_e);
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __pyx_bstruct_i_s.buf = NULL;
  __pyx_bstruct_o_s.buf = NULL;
  __pyx_bstruct_e.buf = NULL;
  __pyx_bstruct_a.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_i_s), __pyx_ptype_5numpy_ndarray, 1, "i_s", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_o_s), __pyx_ptype_5numpy_ndarray, 1, "o_s", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_e), __pyx_ptype_5numpy_ndarray, 1, "e", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_5numpy_ndarray, 1, "a", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_i_s, (PyObject*)__pyx_v_i_s, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_i_s = __pyx_bstruct_i_s.strides[0]; __pyx_bstride_1_i_s = __pyx_bstruct_i_s.strides[1]; __pyx_bstride_2_i_s = __pyx_bstruct_i_s.strides[2];
  __pyx_bshape_0_i_s = __pyx_bstruct_i_s.shape[0]; __pyx_bshape_1_i_s = __pyx_bstruct_i_s.shape[1]; __pyx_bshape_2_i_s = __pyx_bstruct_i_s.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_o_s, (PyObject*)__pyx_v_o_s, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 4, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_o_s = __pyx_bstruct_o_s.strides[0]; __pyx_bstride_1_o_s = __pyx_bstruct_o_s.strides[1]; __pyx_bstride_2_o_s = __pyx_bstruct_o_s.strides[2]; __pyx_bstride_3_o_s = __pyx_bstruct_o_s.strides[3];
  __pyx_bshape_0_o_s = __pyx_bstruct_o_s.shape[0]; __pyx_bshape_1_o_s = __pyx_bstruct_o_s.shape[1]; __pyx_bshape_2_o_s = __pyx_bstruct_o_s.shape[2]; __pyx_bshape_3_o_s = __pyx_bstruct_o_s.shape[3];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_e, (PyObject*)__pyx_v_e, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 4, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_e = __pyx_bstruct_e.strides[0]; __pyx_bstride_1_e = __pyx_bstruct_e.strides[1]; __pyx_bstride_2_e = __pyx_bstruct_e.strides[2]; __pyx_bstride_3_e = __pyx_bstruct_e.strides[3];
  __pyx_bshape_0_e = __pyx_bstruct_e.shape[0]; __pyx_bshape_1_e = __pyx_bstruct_e.shape[1]; __pyx_bshape_2_e = __pyx_bstruct_e.shape[2]; __pyx_bshape_3_e = __pyx_bstruct_e.shape[3];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_a, (PyObject*)__pyx_v_a, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 4, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_a = __pyx_bstruct_a.strides[0]; __pyx_bstride_1_a = __pyx_bstruct_a.strides[1]; __pyx_bstride_2_a = __pyx_bstruct_a.strides[2]; __pyx_bstride_3_a = __pyx_bstruct_a.strides[3];
  __pyx_bshape_0_a = __pyx_bstruct_a.shape[0]; __pyx_bshape_1_a = __pyx_bstruct_a.shape[1]; __pyx_bshape_2_a = __pyx_bstruct_a.shape[2]; __pyx_bshape_3_a = __pyx_bstruct_a.shape[3];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":55
 *     cdef int k, kk
 *     cdef int n, nn
 *     nn = o_s.shape[3] # This might be slow             # <<<<<<<<<<<<<<
 *     cdef np.float64_t *temp = <np.float64_t *>malloc(sizeof(np.float64_t) * nn)
 *     for i in range((imax-imin)*istride):
 */
  __pyx_v_nn = (__pyx_v_o_s->dimensions[3]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":56
 *     cdef int n, nn
 *     nn = o_s.shape[3] # This might be slow
 *     cdef np.float64_t *temp = <np.float64_t *>malloc(sizeof(np.float64_t) * nn)             # <<<<<<<<<<<<<<
 *     for i in range((imax-imin)*istride):
 *         ii = i + imin*istride
 */
  __pyx_v_temp = ((__pyx_t_5numpy_float64_t *)malloc(((sizeof(__pyx_t_5numpy_float64_t)) * __pyx_v_nn)));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":57
 *     nn = o_s.shape[3] # This might be slow
 *     cdef np.float64_t *temp = <np.float64_t *>malloc(sizeof(np.float64_t) * nn)
 *     for i in range((imax-imin)*istride):             # <<<<<<<<<<<<<<
 *         ii = i + imin*istride
 *         for j in range((jmax-jmin)*jstride):
 */
  __pyx_t_1 = ((__pyx_v_imax - __pyx_v_imin) * __pyx_v_istride);
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":58
 *     cdef np.float64_t *temp = <np.float64_t *>malloc(sizeof(np.float64_t) * nn)
 *     for i in range((imax-imin)*istride):
 *         ii = i + imin*istride             # <<<<<<<<<<<<<<
 *         for j in range((jmax-jmin)*jstride):
 *             jj = j + jmin*jstride
 */
    __pyx_v_ii = (__pyx_v_i + (__pyx_v_imin * __pyx_v_istride));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":59
 *     for i in range((imax-imin)*istride):
 *         ii = i + imin*istride
 *         for j in range((jmax-jmin)*jstride):             # <<<<<<<<<<<<<<
 *             jj = j + jmin*jstride
 *             # Not sure about the ordering of the loops here
 */
    __pyx_t_3 = ((__pyx_v_jmax - __pyx_v_jmin) * __pyx_v_jstride);
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_j = __pyx_t_4;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":60
 *         ii = i + imin*istride
 *         for j in range((jmax-jmin)*jstride):
 *             jj = j + jmin*jstride             # <<<<<<<<<<<<<<
 *             # Not sure about the ordering of the loops here
 *             for n in range(nn):
 */
      __pyx_v_jj = (__pyx_v_j + (__pyx_v_jmin * __pyx_v_jstride));

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":62
 *             jj = j + jmin*jstride
 *             # Not sure about the ordering of the loops here
 *             for n in range(nn):             # <<<<<<<<<<<<<<
 *                 temp[n] = i_s[ii,jj,n]
 *             for k in range(kmax-kmin):
 */
      __pyx_t_5 = __pyx_v_nn;
      for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
        __pyx_v_n = __pyx_t_6;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":63
 *             # Not sure about the ordering of the loops here
 *             for n in range(nn):
 *                 temp[n] = i_s[ii,jj,n]             # <<<<<<<<<<<<<<
 *             for k in range(kmax-kmin):
 *                 kk = k + kmin#*kstride, which doesn't make any sense
 */
        __pyx_t_7 = __pyx_v_ii;
        __pyx_t_8 = __pyx_v_jj;
        __pyx_t_9 = __pyx_v_n;
        if (__pyx_t_7 < 0) __pyx_t_7 += __pyx_bshape_0_i_s;
        if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_bshape_1_i_s;
        if (__pyx_t_9 < 0) __pyx_t_9 += __pyx_bshape_2_i_s;
        (__pyx_v_temp[__pyx_v_n]) = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_i_s.buf, __pyx_t_7, __pyx_bstride_0_i_s, __pyx_t_8, __pyx_bstride_1_i_s, __pyx_t_9, __pyx_bstride_2_i_s));
      }

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":64
 *             for n in range(nn):
 *                 temp[n] = i_s[ii,jj,n]
 *             for k in range(kmax-kmin):             # <<<<<<<<<<<<<<
 *                 kk = k + kmin#*kstride, which doesn't make any sense
 *                 for n in range(nn):
 */
      __pyx_t_5 = (__pyx_v_kmax - __pyx_v_kmin);
      for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
        __pyx_v_k = __pyx_t_6;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":65
 *                 temp[n] = i_s[ii,jj,n]
 *             for k in range(kmax-kmin):
 *                 kk = k + kmin#*kstride, which doesn't make any sense             # <<<<<<<<<<<<<<
 *                 for n in range(nn):
 *                     o_s[i,j,k,n] = temp[n] + dx*(e[i,j,k,n] - temp[n]*a[i,j,k,n])
 */
        __pyx_v_kk = (__pyx_v_k + __pyx_v_kmin);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":66
 *             for k in range(kmax-kmin):
 *                 kk = k + kmin#*kstride, which doesn't make any sense
 *                 for n in range(nn):             # <<<<<<<<<<<<<<
 *                     o_s[i,j,k,n] = temp[n] + dx*(e[i,j,k,n] - temp[n]*a[i,j,k,n])
 *                     temp[n] = o_s[i,j,k,n]
 */
        __pyx_t_10 = __pyx_v_nn;
        for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
          __pyx_v_n = __pyx_t_11;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":67
 *                 kk = k + kmin#*kstride, which doesn't make any sense
 *                 for n in range(nn):
 *                     o_s[i,j,k,n] = temp[n] + dx*(e[i,j,k,n] - temp[n]*a[i,j,k,n])             # <<<<<<<<<<<<<<
 *                     temp[n] = o_s[i,j,k,n]
 *             for n in range(nn):
 */
          __pyx_t_12 = __pyx_v_i;
          __pyx_t_13 = __pyx_v_j;
          __pyx_t_14 = __pyx_v_k;
          __pyx_t_15 = __pyx_v_n;
          if (__pyx_t_12 < 0) __pyx_t_12 += __pyx_bshape_0_e;
          if (__pyx_t_13 < 0) __pyx_t_13 += __pyx_bshape_1_e;
          if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_bshape_2_e;
          if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_bshape_3_e;
          __pyx_t_16 = __pyx_v_i;
          __pyx_t_17 = __pyx_v_j;
          __pyx_t_18 = __pyx_v_k;
          __pyx_t_19 = __pyx_v_n;
          if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_bshape_0_a;
          if (__pyx_t_17 < 0) __pyx_t_17 += __pyx_bshape_1_a;
          if (__pyx_t_18 < 0) __pyx_t_18 += __pyx_bshape_2_a;
          if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_bshape_3_a;
          __pyx_t_20 = __pyx_v_i;
          __pyx_t_21 = __pyx_v_j;
          __pyx_t_22 = __pyx_v_k;
          __pyx_t_23 = __pyx_v_n;
          if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_bshape_0_o_s;
          if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_bshape_1_o_s;
          if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_bshape_2_o_s;
          if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_bshape_3_o_s;
          *__Pyx_BufPtrStrided4d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_o_s.buf, __pyx_t_20, __pyx_bstride_0_o_s, __pyx_t_21, __pyx_bstride_1_o_s, __pyx_t_22, __pyx_bstride_2_o_s, __pyx_t_23, __pyx_bstride_3_o_s) = ((__pyx_v_temp[__pyx_v_n]) + (__pyx_v_dx * ((*__Pyx_BufPtrStrided4d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_e.buf, __pyx_t_12, __pyx_bstride_0_e, __pyx_t_13, __pyx_bstride_1_e, __pyx_t_14, __pyx_bstride_2_e, __pyx_t_15, __pyx_bstride_3_e)) - ((__pyx_v_temp[__pyx_v_n]) * (*__Pyx_BufPtrStrided4d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_a.buf, __pyx_t_16, __pyx_bstride_0_a, __pyx_t_17, __pyx_bstride_1_a, __pyx_t_18, __pyx_bstride_2_a, __pyx_t_19, __pyx_bstride_3_a))))));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":68
 *                 for n in range(nn):
 *                     o_s[i,j,k,n] = temp[n] + dx*(e[i,j,k,n] - temp[n]*a[i,j,k,n])
 *                     temp[n] = o_s[i,j,k,n]             # <<<<<<<<<<<<<<
 *             for n in range(nn):
 *                 i_s[ii,jj,n] = temp[n]
 */
          __pyx_t_24 = __pyx_v_i;
          __pyx_t_25 = __pyx_v_j;
          __pyx_t_26 = __pyx_v_k;
          __pyx_t_27 = __pyx_v_n;
          if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_bshape_0_o_s;
          if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_bshape_1_o_s;
          if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_bshape_2_o_s;
          if (__pyx_t_27 < 0) __pyx_t_27 += __pyx_bshape_3_o_s;
          (__pyx_v_temp[__pyx_v_n]) = (*__Pyx_BufPtrStrided4d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_o_s.buf, __pyx_t_24, __pyx_bstride_0_o_s, __pyx_t_25, __pyx_bstride_1_o_s, __pyx_t_26, __pyx_bstride_2_o_s, __pyx_t_27, __pyx_bstride_3_o_s));
        }
      }

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":69
 *                     o_s[i,j,k,n] = temp[n] + dx*(e[i,j,k,n] - temp[n]*a[i,j,k,n])
 *                     temp[n] = o_s[i,j,k,n]
 *             for n in range(nn):             # <<<<<<<<<<<<<<
 *                 i_s[ii,jj,n] = temp[n]
 *     free(temp)
 */
      __pyx_t_5 = __pyx_v_nn;
      for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
        __pyx_v_n = __pyx_t_6;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":70
 *                     temp[n] = o_s[i,j,k,n]
 *             for n in range(nn):
 *                 i_s[ii,jj,n] = temp[n]             # <<<<<<<<<<<<<<
 *     free(temp)
 * 
 */
        __pyx_t_10 = __pyx_v_ii;
        __pyx_t_11 = __pyx_v_jj;
        __pyx_t_28 = __pyx_v_n;
        if (__pyx_t_10 < 0) __pyx_t_10 += __pyx_bshape_0_i_s;
        if (__pyx_t_11 < 0) __pyx_t_11 += __pyx_bshape_1_i_s;
        if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_bshape_2_i_s;
        *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_i_s.buf, __pyx_t_10, __pyx_bstride_0_i_s, __pyx_t_11, __pyx_bstride_1_i_s, __pyx_t_28, __pyx_bstride_2_i_s) = (__pyx_v_temp[__pyx_v_n]);
      }
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":71
 *             for n in range(nn):
 *                 i_s[ii,jj,n] = temp[n]
 *     free(temp)             # <<<<<<<<<<<<<<
 * 
 * @cython.boundscheck(False)
 */
  free(__pyx_v_temp);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_o_s);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_i_s);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_a);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_e);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.Transfer3D");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_o_s);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_i_s);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_a);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_e);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_i_s);
  __Pyx_DECREF((PyObject *)__pyx_v_o_s);
  __Pyx_DECREF((PyObject *)__pyx_v_e);
  __Pyx_DECREF((PyObject *)__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":74
 * 
 * @cython.boundscheck(False)
 * def TransferShells(np.ndarray[np.float64_t, ndim=3] i_s,             # <<<<<<<<<<<<<<
 *                    np.ndarray[np.float64_t, ndim=3] data,
 *                    np.ndarray[np.float64_t, ndim=2] shells):
 */

static PyObject *__pyx_pf_2yt_9amr_utils_TransferShells(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_2yt_9amr_utils_TransferShells[] = "\n    This function accepts an incoming slab (*i_s*), a buffer of *data*,\n    and a list of shells specified as [ (value, tolerance, r, g, b), ... ].\n    ";
static PyObject *__pyx_pf_2yt_9amr_utils_TransferShells(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_i_s = 0;
  PyArrayObject *__pyx_v_data = 0;
  PyArrayObject *__pyx_v_shells = 0;
  int __pyx_v_i;
  int __pyx_v_ii;
  int __pyx_v_j;
  int __pyx_v_jj;
  int __pyx_v_k;
  int __pyx_v_kk;
  int __pyx_v_n;
  int __pyx_v_nn;
  __pyx_t_5numpy_float64_t __pyx_v_dist;
  float __pyx_v_rgba[4];
  float __pyx_v_alpha;
  Py_buffer __pyx_bstruct_shells;
  Py_ssize_t __pyx_bstride_0_shells = 0;
  Py_ssize_t __pyx_bstride_1_shells = 0;
  Py_ssize_t __pyx_bshape_0_shells = 0;
  Py_ssize_t __pyx_bshape_1_shells = 0;
  Py_buffer __pyx_bstruct_i_s;
  Py_ssize_t __pyx_bstride_0_i_s = 0;
  Py_ssize_t __pyx_bstride_1_i_s = 0;
  Py_ssize_t __pyx_bstride_2_i_s = 0;
  Py_ssize_t __pyx_bshape_0_i_s = 0;
  Py_ssize_t __pyx_bshape_1_i_s = 0;
  Py_ssize_t __pyx_bshape_2_i_s = 0;
  Py_buffer __pyx_bstruct_data;
  Py_ssize_t __pyx_bstride_0_data = 0;
  Py_ssize_t __pyx_bstride_1_data = 0;
  Py_ssize_t __pyx_bstride_2_data = 0;
  Py_ssize_t __pyx_bshape_0_data = 0;
  Py_ssize_t __pyx_bshape_1_data = 0;
  Py_ssize_t __pyx_bshape_2_data = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  long __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  long __pyx_t_16;
  int __pyx_t_17;
  long __pyx_t_18;
  int __pyx_t_19;
  long __pyx_t_20;
  int __pyx_t_21;
  long __pyx_t_22;
  int __pyx_t_23;
  long __pyx_t_24;
  int __pyx_t_25;
  int __pyx_t_26;
  long __pyx_t_27;
  int __pyx_t_28;
  int __pyx_t_29;
  long __pyx_t_30;
  int __pyx_t_31;
  int __pyx_t_32;
  long __pyx_t_33;
  int __pyx_t_34;
  int __pyx_t_35;
  long __pyx_t_36;
  int __pyx_t_37;
  int __pyx_t_38;
  long __pyx_t_39;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__i_s,&__pyx_n_s__data,&__pyx_n_s__shells,0};
  __Pyx_RefNannySetupContext("TransferShells");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_s);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TransferShells", 1, 3, 3, 1); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__shells);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("TransferShells", 1, 3, 3, 2); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "TransferShells") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_i_s = ((PyArrayObject *)values[0]);
    __pyx_v_data = ((PyArrayObject *)values[1]);
    __pyx_v_shells = ((PyArrayObject *)values[2]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_i_s = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_data = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_shells = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("TransferShells", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.TransferShells");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_i_s);
  __Pyx_INCREF((PyObject *)__pyx_v_data);
  __Pyx_INCREF((PyObject *)__pyx_v_shells);
  __pyx_bstruct_i_s.buf = NULL;
  __pyx_bstruct_data.buf = NULL;
  __pyx_bstruct_shells.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_i_s), __pyx_ptype_5numpy_ndarray, 1, "i_s", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), __pyx_ptype_5numpy_ndarray, 1, "data", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shells), __pyx_ptype_5numpy_ndarray, 1, "shells", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_i_s, (PyObject*)__pyx_v_i_s, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_i_s = __pyx_bstruct_i_s.strides[0]; __pyx_bstride_1_i_s = __pyx_bstruct_i_s.strides[1]; __pyx_bstride_2_i_s = __pyx_bstruct_i_s.strides[2];
  __pyx_bshape_0_i_s = __pyx_bstruct_i_s.shape[0]; __pyx_bshape_1_i_s = __pyx_bstruct_i_s.shape[1]; __pyx_bshape_2_i_s = __pyx_bstruct_i_s.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_data, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_data = __pyx_bstruct_data.strides[0]; __pyx_bstride_1_data = __pyx_bstruct_data.strides[1]; __pyx_bstride_2_data = __pyx_bstruct_data.strides[2];
  __pyx_bshape_0_data = __pyx_bstruct_data.shape[0]; __pyx_bshape_1_data = __pyx_bstruct_data.shape[1]; __pyx_bshape_2_data = __pyx_bstruct_data.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_shells, (PyObject*)__pyx_v_shells, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_shells = __pyx_bstruct_shells.strides[0]; __pyx_bstride_1_shells = __pyx_bstruct_shells.strides[1];
  __pyx_bshape_0_shells = __pyx_bstruct_shells.shape[0]; __pyx_bshape_1_shells = __pyx_bstruct_shells.shape[1];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":86
 *     cdef int n, nn
 *     cdef np.float64_t dist
 *     ii = data.shape[0]             # <<<<<<<<<<<<<<
 *     jj = data.shape[1]
 *     kk = data.shape[2]
 */
  __pyx_v_ii = (__pyx_v_data->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":87
 *     cdef np.float64_t dist
 *     ii = data.shape[0]
 *     jj = data.shape[1]             # <<<<<<<<<<<<<<
 *     kk = data.shape[2]
 *     nn = shells.shape[0]
 */
  __pyx_v_jj = (__pyx_v_data->dimensions[1]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":88
 *     ii = data.shape[0]
 *     jj = data.shape[1]
 *     kk = data.shape[2]             # <<<<<<<<<<<<<<
 *     nn = shells.shape[0]
 *     cdef float rgba[4]
 */
  __pyx_v_kk = (__pyx_v_data->dimensions[2]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":89
 *     jj = data.shape[1]
 *     kk = data.shape[2]
 *     nn = shells.shape[0]             # <<<<<<<<<<<<<<
 *     cdef float rgba[4]
 *     cdef float alpha
 */
  __pyx_v_nn = (__pyx_v_shells->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":92
 *     cdef float rgba[4]
 *     cdef float alpha
 *     for i in range(ii):             # <<<<<<<<<<<<<<
 *         for j in range(jj):
 *             # Not sure about the ordering of the loops here
 */
  __pyx_t_1 = __pyx_v_ii;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":93
 *     cdef float alpha
 *     for i in range(ii):
 *         for j in range(jj):             # <<<<<<<<<<<<<<
 *             # Not sure about the ordering of the loops here
 *             for k in range(kk):
 */
    __pyx_t_3 = __pyx_v_jj;
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_j = __pyx_t_4;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":95
 *         for j in range(jj):
 *             # Not sure about the ordering of the loops here
 *             for k in range(kk):             # <<<<<<<<<<<<<<
 *                 for n in range(nn):
 *                     dist = shells[n, 0] - data[i,j,k]
 */
      __pyx_t_5 = __pyx_v_kk;
      for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
        __pyx_v_k = __pyx_t_6;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":96
 *             # Not sure about the ordering of the loops here
 *             for k in range(kk):
 *                 for n in range(nn):             # <<<<<<<<<<<<<<
 *                     dist = shells[n, 0] - data[i,j,k]
 *                     if dist < 0: dist *= -1.0
 */
        __pyx_t_7 = __pyx_v_nn;
        for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
          __pyx_v_n = __pyx_t_8;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":97
 *             for k in range(kk):
 *                 for n in range(nn):
 *                     dist = shells[n, 0] - data[i,j,k]             # <<<<<<<<<<<<<<
 *                     if dist < 0: dist *= -1.0
 *                     if dist < shells[n,1]:
 */
          __pyx_t_9 = __pyx_v_n;
          __pyx_t_10 = 0;
          if (__pyx_t_9 < 0) __pyx_t_9 += __pyx_bshape_0_shells;
          if (__pyx_t_10 < 0) __pyx_t_10 += __pyx_bshape_1_shells;
          __pyx_t_11 = __pyx_v_i;
          __pyx_t_12 = __pyx_v_j;
          __pyx_t_13 = __pyx_v_k;
          if (__pyx_t_11 < 0) __pyx_t_11 += __pyx_bshape_0_data;
          if (__pyx_t_12 < 0) __pyx_t_12 += __pyx_bshape_1_data;
          if (__pyx_t_13 < 0) __pyx_t_13 += __pyx_bshape_2_data;
          __pyx_v_dist = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_9, __pyx_bstride_0_shells, __pyx_t_10, __pyx_bstride_1_shells)) - (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_data.buf, __pyx_t_11, __pyx_bstride_0_data, __pyx_t_12, __pyx_bstride_1_data, __pyx_t_13, __pyx_bstride_2_data)));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":98
 *                 for n in range(nn):
 *                     dist = shells[n, 0] - data[i,j,k]
 *                     if dist < 0: dist *= -1.0             # <<<<<<<<<<<<<<
 *                     if dist < shells[n,1]:
 *                         dist = exp(-dist/8.0)
 */
          __pyx_t_14 = (__pyx_v_dist < 0);
          if (__pyx_t_14) {
            __pyx_v_dist *= (-1.0);
            goto __pyx_L14;
          }
          __pyx_L14:;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":99
 *                     dist = shells[n, 0] - data[i,j,k]
 *                     if dist < 0: dist *= -1.0
 *                     if dist < shells[n,1]:             # <<<<<<<<<<<<<<
 *                         dist = exp(-dist/8.0)
 *                         rgba[0] = shells[n,2]
 */
          __pyx_t_15 = __pyx_v_n;
          __pyx_t_16 = 1;
          if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_bshape_0_shells;
          if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_bshape_1_shells;
          __pyx_t_14 = (__pyx_v_dist < (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_15, __pyx_bstride_0_shells, __pyx_t_16, __pyx_bstride_1_shells)));
          if (__pyx_t_14) {

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":100
 *                     if dist < 0: dist *= -1.0
 *                     if dist < shells[n,1]:
 *                         dist = exp(-dist/8.0)             # <<<<<<<<<<<<<<
 *                         rgba[0] = shells[n,2]
 *                         rgba[1] = shells[n,3]
 */
            __pyx_v_dist = exp(((-__pyx_v_dist) / 8.0));

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":101
 *                     if dist < shells[n,1]:
 *                         dist = exp(-dist/8.0)
 *                         rgba[0] = shells[n,2]             # <<<<<<<<<<<<<<
 *                         rgba[1] = shells[n,3]
 *                         rgba[2] = shells[n,4]
 */
            __pyx_t_17 = __pyx_v_n;
            __pyx_t_18 = 2;
            if (__pyx_t_17 < 0) __pyx_t_17 += __pyx_bshape_0_shells;
            if (__pyx_t_18 < 0) __pyx_t_18 += __pyx_bshape_1_shells;
            (__pyx_v_rgba[0]) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_17, __pyx_bstride_0_shells, __pyx_t_18, __pyx_bstride_1_shells));

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":102
 *                         dist = exp(-dist/8.0)
 *                         rgba[0] = shells[n,2]
 *                         rgba[1] = shells[n,3]             # <<<<<<<<<<<<<<
 *                         rgba[2] = shells[n,4]
 *                         rgba[3] = shells[n,5]
 */
            __pyx_t_19 = __pyx_v_n;
            __pyx_t_20 = 3;
            if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_bshape_0_shells;
            if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_bshape_1_shells;
            (__pyx_v_rgba[1]) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_19, __pyx_bstride_0_shells, __pyx_t_20, __pyx_bstride_1_shells));

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":103
 *                         rgba[0] = shells[n,2]
 *                         rgba[1] = shells[n,3]
 *                         rgba[2] = shells[n,4]             # <<<<<<<<<<<<<<
 *                         rgba[3] = shells[n,5]
 *                         alpha = i_s[i,j,3]
 */
            __pyx_t_21 = __pyx_v_n;
            __pyx_t_22 = 4;
            if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_bshape_0_shells;
            if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_bshape_1_shells;
            (__pyx_v_rgba[2]) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_21, __pyx_bstride_0_shells, __pyx_t_22, __pyx_bstride_1_shells));

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":104
 *                         rgba[1] = shells[n,3]
 *                         rgba[2] = shells[n,4]
 *                         rgba[3] = shells[n,5]             # <<<<<<<<<<<<<<
 *                         alpha = i_s[i,j,3]
 *                         dist *= dist # This might improve appearance
 */
            __pyx_t_23 = __pyx_v_n;
            __pyx_t_24 = 5;
            if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_bshape_0_shells;
            if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_bshape_1_shells;
            (__pyx_v_rgba[3]) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_23, __pyx_bstride_0_shells, __pyx_t_24, __pyx_bstride_1_shells));

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":105
 *                         rgba[2] = shells[n,4]
 *                         rgba[3] = shells[n,5]
 *                         alpha = i_s[i,j,3]             # <<<<<<<<<<<<<<
 *                         dist *= dist # This might improve appearance
 *                         i_s[i,j,0] += (1.0 - alpha)*rgba[0]*dist*rgba[3]
 */
            __pyx_t_25 = __pyx_v_i;
            __pyx_t_26 = __pyx_v_j;
            __pyx_t_27 = 3;
            if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_bshape_0_i_s;
            if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_bshape_1_i_s;
            if (__pyx_t_27 < 0) __pyx_t_27 += __pyx_bshape_2_i_s;
            __pyx_v_alpha = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_i_s.buf, __pyx_t_25, __pyx_bstride_0_i_s, __pyx_t_26, __pyx_bstride_1_i_s, __pyx_t_27, __pyx_bstride_2_i_s));

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":106
 *                         rgba[3] = shells[n,5]
 *                         alpha = i_s[i,j,3]
 *                         dist *= dist # This might improve appearance             # <<<<<<<<<<<<<<
 *                         i_s[i,j,0] += (1.0 - alpha)*rgba[0]*dist*rgba[3]
 *                         i_s[i,j,1] += (1.0 - alpha)*rgba[1]*dist*rgba[3]
 */
            __pyx_v_dist *= __pyx_v_dist;

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":107
 *                         alpha = i_s[i,j,3]
 *                         dist *= dist # This might improve appearance
 *                         i_s[i,j,0] += (1.0 - alpha)*rgba[0]*dist*rgba[3]             # <<<<<<<<<<<<<<
 *                         i_s[i,j,1] += (1.0 - alpha)*rgba[1]*dist*rgba[3]
 *                         i_s[i,j,2] += (1.0 - alpha)*rgba[2]*dist*rgba[3]
 */
            __pyx_t_28 = __pyx_v_i;
            __pyx_t_29 = __pyx_v_j;
            __pyx_t_30 = 0;
            if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_bshape_0_i_s;
            if (__pyx_t_29 < 0) __pyx_t_29 += __pyx_bshape_1_i_s;
            if (__pyx_t_30 < 0) __pyx_t_30 += __pyx_bshape_2_i_s;
            *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_i_s.buf, __pyx_t_28, __pyx_bstride_0_i_s, __pyx_t_29, __pyx_bstride_1_i_s, __pyx_t_30, __pyx_bstride_2_i_s) += ((((1.0 - __pyx_v_alpha) * (__pyx_v_rgba[0])) * __pyx_v_dist) * (__pyx_v_rgba[3]));

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":108
 *                         dist *= dist # This might improve appearance
 *                         i_s[i,j,0] += (1.0 - alpha)*rgba[0]*dist*rgba[3]
 *                         i_s[i,j,1] += (1.0 - alpha)*rgba[1]*dist*rgba[3]             # <<<<<<<<<<<<<<
 *                         i_s[i,j,2] += (1.0 - alpha)*rgba[2]*dist*rgba[3]
 *                         i_s[i,j,3] += (1.0 - alpha)*rgba[3]*dist*rgba[3]
 */
            __pyx_t_31 = __pyx_v_i;
            __pyx_t_32 = __pyx_v_j;
            __pyx_t_33 = 1;
            if (__pyx_t_31 < 0) __pyx_t_31 += __pyx_bshape_0_i_s;
            if (__pyx_t_32 < 0) __pyx_t_32 += __pyx_bshape_1_i_s;
            if (__pyx_t_33 < 0) __pyx_t_33 += __pyx_bshape_2_i_s;
            *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_i_s.buf, __pyx_t_31, __pyx_bstride_0_i_s, __pyx_t_32, __pyx_bstride_1_i_s, __pyx_t_33, __pyx_bstride_2_i_s) += ((((1.0 - __pyx_v_alpha) * (__pyx_v_rgba[1])) * __pyx_v_dist) * (__pyx_v_rgba[3]));

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":109
 *                         i_s[i,j,0] += (1.0 - alpha)*rgba[0]*dist*rgba[3]
 *                         i_s[i,j,1] += (1.0 - alpha)*rgba[1]*dist*rgba[3]
 *                         i_s[i,j,2] += (1.0 - alpha)*rgba[2]*dist*rgba[3]             # <<<<<<<<<<<<<<
 *                         i_s[i,j,3] += (1.0 - alpha)*rgba[3]*dist*rgba[3]
 *                         break
 */
            __pyx_t_34 = __pyx_v_i;
            __pyx_t_35 = __pyx_v_j;
            __pyx_t_36 = 2;
            if (__pyx_t_34 < 0) __pyx_t_34 += __pyx_bshape_0_i_s;
            if (__pyx_t_35 < 0) __pyx_t_35 += __pyx_bshape_1_i_s;
            if (__pyx_t_36 < 0) __pyx_t_36 += __pyx_bshape_2_i_s;
            *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_i_s.buf, __pyx_t_34, __pyx_bstride_0_i_s, __pyx_t_35, __pyx_bstride_1_i_s, __pyx_t_36, __pyx_bstride_2_i_s) += ((((1.0 - __pyx_v_alpha) * (__pyx_v_rgba[2])) * __pyx_v_dist) * (__pyx_v_rgba[3]));

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":110
 *                         i_s[i,j,1] += (1.0 - alpha)*rgba[1]*dist*rgba[3]
 *                         i_s[i,j,2] += (1.0 - alpha)*rgba[2]*dist*rgba[3]
 *                         i_s[i,j,3] += (1.0 - alpha)*rgba[3]*dist*rgba[3]             # <<<<<<<<<<<<<<
 *                         break
 * 
 */
            __pyx_t_37 = __pyx_v_i;
            __pyx_t_38 = __pyx_v_j;
            __pyx_t_39 = 3;
            if (__pyx_t_37 < 0) __pyx_t_37 += __pyx_bshape_0_i_s;
            if (__pyx_t_38 < 0) __pyx_t_38 += __pyx_bshape_1_i_s;
            if (__pyx_t_39 < 0) __pyx_t_39 += __pyx_bshape_2_i_s;
            *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_i_s.buf, __pyx_t_37, __pyx_bstride_0_i_s, __pyx_t_38, __pyx_bstride_1_i_s, __pyx_t_39, __pyx_bstride_2_i_s) += ((((1.0 - __pyx_v_alpha) * (__pyx_v_rgba[3])) * __pyx_v_dist) * (__pyx_v_rgba[3]));

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":111
 *                         i_s[i,j,2] += (1.0 - alpha)*rgba[2]*dist*rgba[3]
 *                         i_s[i,j,3] += (1.0 - alpha)*rgba[3]*dist*rgba[3]
 *                         break             # <<<<<<<<<<<<<<
 * 
 * @cython.boundscheck(False)
 */
            goto __pyx_L13_break;
            goto __pyx_L15;
          }
          __pyx_L15:;
        }
        __pyx_L13_break:;
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_shells);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_i_s);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_data);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.TransferShells");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_shells);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_i_s);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_data);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_i_s);
  __Pyx_DECREF((PyObject *)__pyx_v_data);
  __Pyx_DECREF((PyObject *)__pyx_v_shells);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":114
 * 
 * @cython.boundscheck(False)
 * def Transfer1D(float i_s,             # <<<<<<<<<<<<<<
 *                np.ndarray[np.float_t, ndim=1] o_s,
 *                np.ndarray[np.float_t, ndim=1] e,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_Transfer1D(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_Transfer1D(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  float __pyx_v_i_s;
  PyArrayObject *__pyx_v_o_s = 0;
  PyArrayObject *__pyx_v_e = 0;
  PyArrayObject *__pyx_v_a = 0;
  PyArrayObject *__pyx_v_dx = 0;
  int __pyx_v_imin;
  int __pyx_v_imax;
  int __pyx_v_i;
  Py_buffer __pyx_bstruct_a;
  Py_ssize_t __pyx_bstride_0_a = 0;
  Py_ssize_t __pyx_bshape_0_a = 0;
  Py_buffer __pyx_bstruct_e;
  Py_ssize_t __pyx_bstride_0_e = 0;
  Py_ssize_t __pyx_bshape_0_e = 0;
  Py_buffer __pyx_bstruct_o_s;
  Py_ssize_t __pyx_bstride_0_o_s = 0;
  Py_ssize_t __pyx_bshape_0_o_s = 0;
  Py_buffer __pyx_bstruct_dx;
  Py_ssize_t __pyx_bstride_0_dx = 0;
  Py_ssize_t __pyx_bshape_0_dx = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__i_s,&__pyx_n_s__o_s,&__pyx_n_s__e,&__pyx_n_s__a,&__pyx_n_s__dx,&__pyx_n_s__imin,&__pyx_n_s__imax,0};
  __Pyx_RefNannySetupContext("Transfer1D");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[7] = {0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_s);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__o_s);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer1D", 1, 7, 7, 1); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__e);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer1D", 1, 7, 7, 2); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer1D", 1, 7, 7, 3); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dx);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer1D", 1, 7, 7, 4); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__imin);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer1D", 1, 7, 7, 5); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__imax);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("Transfer1D", 1, 7, 7, 6); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "Transfer1D") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_i_s = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_i_s == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_o_s = ((PyArrayObject *)values[1]);
    __pyx_v_e = ((PyArrayObject *)values[2]);
    __pyx_v_a = ((PyArrayObject *)values[3]);
    __pyx_v_dx = ((PyArrayObject *)values[4]);
    __pyx_v_imin = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_imin == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_imax = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_imax == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_i_s = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_i_s == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_o_s = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_e = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_a = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_dx = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_imin = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_imin == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_imax = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 6)); if (unlikely((__pyx_v_imax == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("Transfer1D", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.Transfer1D");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_o_s);
  __Pyx_INCREF((PyObject *)__pyx_v_e);
  __Pyx_INCREF((PyObject *)__pyx_v_a);
  __Pyx_INCREF((PyObject *)__pyx_v_dx);
  __pyx_bstruct_o_s.buf = NULL;
  __pyx_bstruct_e.buf = NULL;
  __pyx_bstruct_a.buf = NULL;
  __pyx_bstruct_dx.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_o_s), __pyx_ptype_5numpy_ndarray, 1, "o_s", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_e), __pyx_ptype_5numpy_ndarray, 1, "e", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_a), __pyx_ptype_5numpy_ndarray, 1, "a", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dx), __pyx_ptype_5numpy_ndarray, 1, "dx", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_o_s, (PyObject*)__pyx_v_o_s, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_o_s = __pyx_bstruct_o_s.strides[0];
  __pyx_bshape_0_o_s = __pyx_bstruct_o_s.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_e, (PyObject*)__pyx_v_e, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_e = __pyx_bstruct_e.strides[0];
  __pyx_bshape_0_e = __pyx_bstruct_e.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_a, (PyObject*)__pyx_v_a, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_a = __pyx_bstruct_a.strides[0];
  __pyx_bshape_0_a = __pyx_bstruct_a.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dx, (PyObject*)__pyx_v_dx, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_dx = __pyx_bstruct_dx.strides[0];
  __pyx_bshape_0_dx = __pyx_bstruct_dx.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":121
 *                int imin, int imax):
 *     cdef int i
 *     for i in range(imin, imax):             # <<<<<<<<<<<<<<
 *         o_s[i] = i_s + dx[i]*(e[i] - i_s*a[i])
 *         i_s = o_s[i]
 */
  __pyx_t_1 = __pyx_v_imax;
  for (__pyx_t_2 = __pyx_v_imin; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":122
 *     cdef int i
 *     for i in range(imin, imax):
 *         o_s[i] = i_s + dx[i]*(e[i] - i_s*a[i])             # <<<<<<<<<<<<<<
 *         i_s = o_s[i]
 *     return i_s
 */
    __pyx_t_3 = __pyx_v_i;
    if (__pyx_t_3 < 0) __pyx_t_3 += __pyx_bshape_0_dx;
    __pyx_t_4 = __pyx_v_i;
    if (__pyx_t_4 < 0) __pyx_t_4 += __pyx_bshape_0_e;
    __pyx_t_5 = __pyx_v_i;
    if (__pyx_t_5 < 0) __pyx_t_5 += __pyx_bshape_0_a;
    __pyx_t_6 = __pyx_v_i;
    if (__pyx_t_6 < 0) __pyx_t_6 += __pyx_bshape_0_o_s;
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float_t *, __pyx_bstruct_o_s.buf, __pyx_t_6, __pyx_bstride_0_o_s) = (__pyx_v_i_s + ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float_t *, __pyx_bstruct_dx.buf, __pyx_t_3, __pyx_bstride_0_dx)) * ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float_t *, __pyx_bstruct_e.buf, __pyx_t_4, __pyx_bstride_0_e)) - (__pyx_v_i_s * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float_t *, __pyx_bstruct_a.buf, __pyx_t_5, __pyx_bstride_0_a))))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":123
 *     for i in range(imin, imax):
 *         o_s[i] = i_s + dx[i]*(e[i] - i_s*a[i])
 *         i_s = o_s[i]             # <<<<<<<<<<<<<<
 *     return i_s
 * 
 */
    __pyx_t_7 = __pyx_v_i;
    if (__pyx_t_7 < 0) __pyx_t_7 += __pyx_bshape_0_o_s;
    __pyx_v_i_s = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float_t *, __pyx_bstruct_o_s.buf, __pyx_t_7, __pyx_bstride_0_o_s));
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":124
 *         o_s[i] = i_s + dx[i]*(e[i] - i_s*a[i])
 *         i_s = o_s[i]
 *     return i_s             # <<<<<<<<<<<<<<
 * 
 * @cython.wraparound(False)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = PyFloat_FromDouble(__pyx_v_i_s); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_r = __pyx_t_8;
  __pyx_t_8 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_8);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_a);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_e);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_o_s);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.Transfer1D");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_a);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_e);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_o_s);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_o_s);
  __Pyx_DECREF((PyObject *)__pyx_v_e);
  __Pyx_DECREF((PyObject *)__pyx_v_a);
  __Pyx_DECREF((PyObject *)__pyx_v_dx);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":128
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def VoxelTraversal(np.ndarray[np.int_t, ndim=3] grid_mask,             # <<<<<<<<<<<<<<
 *                    np.ndarray[np.float64_t, ndim=3] grid_t,
 *                    np.ndarray[np.float64_t, ndim=3] grid_dt,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_VoxelTraversal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_VoxelTraversal(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_grid_mask = 0;
  PyArrayObject *__pyx_v_grid_t = 0;
  PyArrayObject *__pyx_v_grid_dt = 0;
  PyArrayObject *__pyx_v_left_edge = 0;
  PyArrayObject *__pyx_v_right_edge = 0;
  PyArrayObject *__pyx_v_dx = 0;
  PyArrayObject *__pyx_v_u = 0;
  PyArrayObject *__pyx_v_v = 0;
  int __pyx_v_i;
  int __pyx_v_x;
  int __pyx_v_y;
  __pyx_t_5numpy_float64_t __pyx_v_tl;
  __pyx_t_5numpy_float64_t __pyx_v_tr;
  __pyx_t_5numpy_float64_t __pyx_v_intersect_t;
  __pyx_t_5numpy_float64_t __pyx_v_enter_t;
  __pyx_t_5numpy_float64_t __pyx_v_dt_tolerance;
  PyArrayObject *__pyx_v_step = 0;
  PyArrayObject *__pyx_v_cur_ind = 0;
  PyArrayObject *__pyx_v_tdelta = 0;
  PyArrayObject *__pyx_v_tmax = 0;
  PyArrayObject *__pyx_v_intersect = 0;
  Py_buffer __pyx_bstruct_right_edge;
  Py_ssize_t __pyx_bstride_0_right_edge = 0;
  Py_ssize_t __pyx_bshape_0_right_edge = 0;
  Py_buffer __pyx_bstruct_intersect;
  Py_ssize_t __pyx_bstride_0_intersect = 0;
  Py_ssize_t __pyx_bshape_0_intersect = 0;
  Py_buffer __pyx_bstruct_grid_t;
  Py_ssize_t __pyx_bstride_0_grid_t = 0;
  Py_ssize_t __pyx_bstride_1_grid_t = 0;
  Py_ssize_t __pyx_bstride_2_grid_t = 0;
  Py_ssize_t __pyx_bshape_0_grid_t = 0;
  Py_ssize_t __pyx_bshape_1_grid_t = 0;
  Py_ssize_t __pyx_bshape_2_grid_t = 0;
  Py_buffer __pyx_bstruct_grid_dt;
  Py_ssize_t __pyx_bstride_0_grid_dt = 0;
  Py_ssize_t __pyx_bstride_1_grid_dt = 0;
  Py_ssize_t __pyx_bstride_2_grid_dt = 0;
  Py_ssize_t __pyx_bshape_0_grid_dt = 0;
  Py_ssize_t __pyx_bshape_1_grid_dt = 0;
  Py_ssize_t __pyx_bshape_2_grid_dt = 0;
  Py_buffer __pyx_bstruct_cur_ind;
  Py_ssize_t __pyx_bstride_0_cur_ind = 0;
  Py_ssize_t __pyx_bshape_0_cur_ind = 0;
  Py_buffer __pyx_bstruct_left_edge;
  Py_ssize_t __pyx_bstride_0_left_edge = 0;
  Py_ssize_t __pyx_bshape_0_left_edge = 0;
  Py_buffer __pyx_bstruct_step;
  Py_ssize_t __pyx_bstride_0_step = 0;
  Py_ssize_t __pyx_bshape_0_step = 0;
  Py_buffer __pyx_bstruct_dx;
  Py_ssize_t __pyx_bstride_0_dx = 0;
  Py_ssize_t __pyx_bshape_0_dx = 0;
  Py_buffer __pyx_bstruct_tdelta;
  Py_ssize_t __pyx_bstride_0_tdelta = 0;
  Py_ssize_t __pyx_bshape_0_tdelta = 0;
  Py_buffer __pyx_bstruct_tmax;
  Py_ssize_t __pyx_bstride_0_tmax = 0;
  Py_ssize_t __pyx_bshape_0_tmax = 0;
  Py_buffer __pyx_bstruct_grid_mask;
  Py_ssize_t __pyx_bstride_0_grid_mask = 0;
  Py_ssize_t __pyx_bstride_1_grid_mask = 0;
  Py_ssize_t __pyx_bstride_2_grid_mask = 0;
  Py_ssize_t __pyx_bshape_0_grid_mask = 0;
  Py_ssize_t __pyx_bshape_1_grid_mask = 0;
  Py_ssize_t __pyx_bshape_2_grid_mask = 0;
  Py_buffer __pyx_bstruct_u;
  Py_ssize_t __pyx_bstride_0_u = 0;
  Py_ssize_t __pyx_bshape_0_u = 0;
  Py_buffer __pyx_bstruct_v;
  Py_ssize_t __pyx_bstride_0_v = 0;
  Py_ssize_t __pyx_bshape_0_v = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyArrayObject *__pyx_t_6 = NULL;
  PyArrayObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  PyArrayObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  int __pyx_t_21;
  int __pyx_t_22;
  int __pyx_t_23;
  int __pyx_t_24;
  __pyx_t_5numpy_float64_t __pyx_t_25;
  int __pyx_t_26;
  int __pyx_t_27;
  int __pyx_t_28;
  int __pyx_t_29;
  int __pyx_t_30;
  int __pyx_t_31;
  int __pyx_t_32;
  int __pyx_t_33;
  int __pyx_t_34;
  int __pyx_t_35;
  int __pyx_t_36;
  int __pyx_t_37;
  int __pyx_t_38;
  int __pyx_t_39;
  int __pyx_t_40;
  int __pyx_t_41;
  long __pyx_t_42;
  long __pyx_t_43;
  long __pyx_t_44;
  long __pyx_t_45;
  long __pyx_t_46;
  long __pyx_t_47;
  long __pyx_t_48;
  long __pyx_t_49;
  long __pyx_t_50;
  PyObject *__pyx_t_51 = NULL;
  PyObject *__pyx_t_52 = NULL;
  PyObject *__pyx_t_53 = NULL;
  int __pyx_t_54;
  int __pyx_t_55;
  int __pyx_t_56;
  int __pyx_t_57;
  __pyx_t_5numpy_int64_t __pyx_t_58;
  int __pyx_t_59;
  int __pyx_t_60;
  int __pyx_t_61;
  int __pyx_t_62;
  int __pyx_t_63;
  int __pyx_t_64;
  int __pyx_t_65;
  int __pyx_t_66;
  int __pyx_t_67;
  int __pyx_t_68;
  int __pyx_t_69;
  int __pyx_t_70;
  int __pyx_t_71;
  int __pyx_t_72;
  int __pyx_t_73;
  int __pyx_t_74;
  int __pyx_t_75;
  int __pyx_t_76;
  int __pyx_t_77;
  int __pyx_t_78;
  int __pyx_t_79;
  int __pyx_t_80;
  int __pyx_t_81;
  int __pyx_t_82;
  int __pyx_t_83;
  int __pyx_t_84;
  int __pyx_t_85;
  int __pyx_t_86;
  int __pyx_t_87;
  int __pyx_t_88;
  long __pyx_t_89;
  long __pyx_t_90;
  long __pyx_t_91;
  long __pyx_t_92;
  long __pyx_t_93;
  long __pyx_t_94;
  __pyx_t_5numpy_int64_t __pyx_t_95;
  __pyx_t_5numpy_int64_t __pyx_t_96;
  long __pyx_t_97;
  long __pyx_t_98;
  long __pyx_t_99;
  long __pyx_t_100;
  long __pyx_t_101;
  long __pyx_t_102;
  __pyx_t_5numpy_int64_t __pyx_t_103;
  __pyx_t_5numpy_int64_t __pyx_t_104;
  __pyx_t_5numpy_int64_t __pyx_t_105;
  long __pyx_t_106;
  long __pyx_t_107;
  long __pyx_t_108;
  long __pyx_t_109;
  long __pyx_t_110;
  long __pyx_t_111;
  long __pyx_t_112;
  __pyx_t_5numpy_int64_t __pyx_t_113;
  __pyx_t_5numpy_int64_t __pyx_t_114;
  __pyx_t_5numpy_int64_t __pyx_t_115;
  long __pyx_t_116;
  long __pyx_t_117;
  long __pyx_t_118;
  long __pyx_t_119;
  __pyx_t_5numpy_int64_t __pyx_t_120;
  __pyx_t_5numpy_int64_t __pyx_t_121;
  __pyx_t_5numpy_int64_t __pyx_t_122;
  long __pyx_t_123;
  long __pyx_t_124;
  long __pyx_t_125;
  long __pyx_t_126;
  long __pyx_t_127;
  long __pyx_t_128;
  long __pyx_t_129;
  long __pyx_t_130;
  __pyx_t_5numpy_int64_t __pyx_t_131;
  __pyx_t_5numpy_int64_t __pyx_t_132;
  __pyx_t_5numpy_int64_t __pyx_t_133;
  long __pyx_t_134;
  long __pyx_t_135;
  long __pyx_t_136;
  long __pyx_t_137;
  __pyx_t_5numpy_int64_t __pyx_t_138;
  __pyx_t_5numpy_int64_t __pyx_t_139;
  __pyx_t_5numpy_int64_t __pyx_t_140;
  long __pyx_t_141;
  long __pyx_t_142;
  long __pyx_t_143;
  long __pyx_t_144;
  long __pyx_t_145;
  long __pyx_t_146;
  long __pyx_t_147;
  long __pyx_t_148;
  long __pyx_t_149;
  long __pyx_t_150;
  __pyx_t_5numpy_int64_t __pyx_t_151;
  __pyx_t_5numpy_int64_t __pyx_t_152;
  __pyx_t_5numpy_int64_t __pyx_t_153;
  long __pyx_t_154;
  long __pyx_t_155;
  long __pyx_t_156;
  long __pyx_t_157;
  __pyx_t_5numpy_int64_t __pyx_t_158;
  __pyx_t_5numpy_int64_t __pyx_t_159;
  __pyx_t_5numpy_int64_t __pyx_t_160;
  long __pyx_t_161;
  long __pyx_t_162;
  long __pyx_t_163;
  long __pyx_t_164;
  long __pyx_t_165;
  long __pyx_t_166;
  long __pyx_t_167;
  long __pyx_t_168;
  __pyx_t_5numpy_int64_t __pyx_t_169;
  __pyx_t_5numpy_int64_t __pyx_t_170;
  __pyx_t_5numpy_int64_t __pyx_t_171;
  long __pyx_t_172;
  long __pyx_t_173;
  long __pyx_t_174;
  long __pyx_t_175;
  __pyx_t_5numpy_int64_t __pyx_t_176;
  __pyx_t_5numpy_int64_t __pyx_t_177;
  __pyx_t_5numpy_int64_t __pyx_t_178;
  long __pyx_t_179;
  long __pyx_t_180;
  long __pyx_t_181;
  long __pyx_t_182;
  long __pyx_t_183;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__grid_mask,&__pyx_n_s__grid_t,&__pyx_n_s__grid_dt,&__pyx_n_s__left_edge,&__pyx_n_s__right_edge,&__pyx_n_s__dx,&__pyx_n_s__u,&__pyx_n_s__v,0};
  __Pyx_RefNannySetupContext("VoxelTraversal");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grid_mask);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grid_t);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("VoxelTraversal", 1, 8, 8, 1); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grid_dt);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("VoxelTraversal", 1, 8, 8, 2); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__left_edge);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("VoxelTraversal", 1, 8, 8, 3); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__right_edge);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("VoxelTraversal", 1, 8, 8, 4); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dx);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("VoxelTraversal", 1, 8, 8, 5); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__u);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("VoxelTraversal", 1, 8, 8, 6); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  7:
      values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__v);
      if (likely(values[7])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("VoxelTraversal", 1, 8, 8, 7); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "VoxelTraversal") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_grid_mask = ((PyArrayObject *)values[0]);
    __pyx_v_grid_t = ((PyArrayObject *)values[1]);
    __pyx_v_grid_dt = ((PyArrayObject *)values[2]);
    __pyx_v_left_edge = ((PyArrayObject *)values[3]);
    __pyx_v_right_edge = ((PyArrayObject *)values[4]);
    __pyx_v_dx = ((PyArrayObject *)values[5]);
    __pyx_v_u = ((PyArrayObject *)values[6]);
    __pyx_v_v = ((PyArrayObject *)values[7]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_grid_mask = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_grid_t = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_grid_dt = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_left_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_right_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_dx = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 5));
    __pyx_v_u = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 6));
    __pyx_v_v = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 7));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("VoxelTraversal", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.VoxelTraversal");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_grid_mask);
  __Pyx_INCREF((PyObject *)__pyx_v_grid_t);
  __Pyx_INCREF((PyObject *)__pyx_v_grid_dt);
  __Pyx_INCREF((PyObject *)__pyx_v_left_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_right_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_dx);
  __Pyx_INCREF((PyObject *)__pyx_v_u);
  __Pyx_INCREF((PyObject *)__pyx_v_v);
  __pyx_bstruct_step.buf = NULL;
  __pyx_bstruct_cur_ind.buf = NULL;
  __pyx_bstruct_tdelta.buf = NULL;
  __pyx_bstruct_tmax.buf = NULL;
  __pyx_bstruct_intersect.buf = NULL;
  __pyx_bstruct_grid_mask.buf = NULL;
  __pyx_bstruct_grid_t.buf = NULL;
  __pyx_bstruct_grid_dt.buf = NULL;
  __pyx_bstruct_left_edge.buf = NULL;
  __pyx_bstruct_right_edge.buf = NULL;
  __pyx_bstruct_dx.buf = NULL;
  __pyx_bstruct_u.buf = NULL;
  __pyx_bstruct_v.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grid_mask), __pyx_ptype_5numpy_ndarray, 1, "grid_mask", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grid_t), __pyx_ptype_5numpy_ndarray, 1, "grid_t", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grid_dt), __pyx_ptype_5numpy_ndarray, 1, "grid_dt", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_left_edge), __pyx_ptype_5numpy_ndarray, 1, "left_edge", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_right_edge), __pyx_ptype_5numpy_ndarray, 1, "right_edge", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dx), __pyx_ptype_5numpy_ndarray, 1, "dx", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_u), __pyx_ptype_5numpy_ndarray, 1, "u", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_v), __pyx_ptype_5numpy_ndarray, 1, "v", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_grid_mask, (PyObject*)__pyx_v_grid_mask, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_grid_mask = __pyx_bstruct_grid_mask.strides[0]; __pyx_bstride_1_grid_mask = __pyx_bstruct_grid_mask.strides[1]; __pyx_bstride_2_grid_mask = __pyx_bstruct_grid_mask.strides[2];
  __pyx_bshape_0_grid_mask = __pyx_bstruct_grid_mask.shape[0]; __pyx_bshape_1_grid_mask = __pyx_bstruct_grid_mask.shape[1]; __pyx_bshape_2_grid_mask = __pyx_bstruct_grid_mask.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_grid_t, (PyObject*)__pyx_v_grid_t, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_grid_t = __pyx_bstruct_grid_t.strides[0]; __pyx_bstride_1_grid_t = __pyx_bstruct_grid_t.strides[1]; __pyx_bstride_2_grid_t = __pyx_bstruct_grid_t.strides[2];
  __pyx_bshape_0_grid_t = __pyx_bstruct_grid_t.shape[0]; __pyx_bshape_1_grid_t = __pyx_bstruct_grid_t.shape[1]; __pyx_bshape_2_grid_t = __pyx_bstruct_grid_t.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_grid_dt, (PyObject*)__pyx_v_grid_dt, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_grid_dt = __pyx_bstruct_grid_dt.strides[0]; __pyx_bstride_1_grid_dt = __pyx_bstruct_grid_dt.strides[1]; __pyx_bstride_2_grid_dt = __pyx_bstruct_grid_dt.strides[2];
  __pyx_bshape_0_grid_dt = __pyx_bstruct_grid_dt.shape[0]; __pyx_bshape_1_grid_dt = __pyx_bstruct_grid_dt.shape[1]; __pyx_bshape_2_grid_dt = __pyx_bstruct_grid_dt.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_left_edge, (PyObject*)__pyx_v_left_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_left_edge = __pyx_bstruct_left_edge.strides[0];
  __pyx_bshape_0_left_edge = __pyx_bstruct_left_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_right_edge, (PyObject*)__pyx_v_right_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_right_edge = __pyx_bstruct_right_edge.strides[0];
  __pyx_bshape_0_right_edge = __pyx_bstruct_right_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dx, (PyObject*)__pyx_v_dx, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_dx = __pyx_bstruct_dx.strides[0];
  __pyx_bshape_0_dx = __pyx_bstruct_dx.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_u, (PyObject*)__pyx_v_u, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_u = __pyx_bstruct_u.strides[0];
  __pyx_bshape_0_u = __pyx_bstruct_u.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_v, (PyObject*)__pyx_v_v, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_v = __pyx_bstruct_v.strides[0];
  __pyx_bshape_0_v = __pyx_bstruct_v.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":141
 *     cdef int i, x, y
 *     cdef np.float64_t tl, tr, intersect_t, enter_t, exit_t, dt_tolerance
 *     cdef np.ndarray[np.int64_t,   ndim=1] step = np.empty((3,), dtype=np.int64)             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.int64_t,   ndim=1] cur_ind = np.empty((3,), dtype=np.int64)
 *     cdef np.ndarray[np.float64_t, ndim=1] tdelta = np.empty((3,), dtype=np.float64)
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__int64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_step, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_step = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_step.buf = NULL;
      {__pyx_filename = __pyx_f[4]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_step = __pyx_bstruct_step.strides[0];
      __pyx_bshape_0_step = __pyx_bstruct_step.shape[0];
    }
  }
  __pyx_t_6 = 0;
  __pyx_v_step = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":142
 *     cdef np.float64_t tl, tr, intersect_t, enter_t, exit_t, dt_tolerance
 *     cdef np.ndarray[np.int64_t,   ndim=1] step = np.empty((3,), dtype=np.int64)
 *     cdef np.ndarray[np.int64_t,   ndim=1] cur_ind = np.empty((3,), dtype=np.int64)             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.float64_t, ndim=1] tdelta = np.empty((3,), dtype=np.float64)
 *     cdef np.ndarray[np.float64_t, ndim=1] tmax = np.empty((3,), dtype=np.float64)
 */
  __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__empty); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__int64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_1, __pyx_t_3, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_cur_ind, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_cur_ind = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_cur_ind.buf = NULL;
      {__pyx_filename = __pyx_f[4]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_cur_ind = __pyx_bstruct_cur_ind.strides[0];
      __pyx_bshape_0_cur_ind = __pyx_bstruct_cur_ind.shape[0];
    }
  }
  __pyx_t_7 = 0;
  __pyx_v_cur_ind = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":143
 *     cdef np.ndarray[np.int64_t,   ndim=1] step = np.empty((3,), dtype=np.int64)
 *     cdef np.ndarray[np.int64_t,   ndim=1] cur_ind = np.empty((3,), dtype=np.int64)
 *     cdef np.ndarray[np.float64_t, ndim=1] tdelta = np.empty((3,), dtype=np.float64)             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.float64_t, ndim=1] tmax = np.empty((3,), dtype=np.float64)
 *     cdef np.ndarray[np.float64_t, ndim=1] intersect = np.empty((3,), dtype=np.float64)
 */
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__empty); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyEval_CallObjectWithKeywords(__pyx_t_5, __pyx_t_3, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_tdelta, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_tdelta = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_tdelta.buf = NULL;
      {__pyx_filename = __pyx_f[4]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_tdelta = __pyx_bstruct_tdelta.strides[0];
      __pyx_bshape_0_tdelta = __pyx_bstruct_tdelta.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_tdelta = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":144
 *     cdef np.ndarray[np.int64_t,   ndim=1] cur_ind = np.empty((3,), dtype=np.int64)
 *     cdef np.ndarray[np.float64_t, ndim=1] tdelta = np.empty((3,), dtype=np.float64)
 *     cdef np.ndarray[np.float64_t, ndim=1] tmax = np.empty((3,), dtype=np.float64)             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.float64_t, ndim=1] intersect = np.empty((3,), dtype=np.float64)
 *     intersect_t = 1
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__empty); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float64); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_4, __pyx_t_3, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_tmax, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_tmax = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_tmax.buf = NULL;
      {__pyx_filename = __pyx_f[4]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_tmax = __pyx_bstruct_tmax.strides[0];
      __pyx_bshape_0_tmax = __pyx_bstruct_tmax.shape[0];
    }
  }
  __pyx_t_9 = 0;
  __pyx_v_tmax = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":145
 *     cdef np.ndarray[np.float64_t, ndim=1] tdelta = np.empty((3,), dtype=np.float64)
 *     cdef np.ndarray[np.float64_t, ndim=1] tmax = np.empty((3,), dtype=np.float64)
 *     cdef np.ndarray[np.float64_t, ndim=1] intersect = np.empty((3,), dtype=np.float64)             # <<<<<<<<<<<<<<
 *     intersect_t = 1
 *     dt_tolerance = 1e-6
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_intersect, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_intersect = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_intersect.buf = NULL;
      {__pyx_filename = __pyx_f[4]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_intersect = __pyx_bstruct_intersect.strides[0];
      __pyx_bshape_0_intersect = __pyx_bstruct_intersect.shape[0];
    }
  }
  __pyx_t_10 = 0;
  __pyx_v_intersect = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":146
 *     cdef np.ndarray[np.float64_t, ndim=1] tmax = np.empty((3,), dtype=np.float64)
 *     cdef np.ndarray[np.float64_t, ndim=1] intersect = np.empty((3,), dtype=np.float64)
 *     intersect_t = 1             # <<<<<<<<<<<<<<
 *     dt_tolerance = 1e-6
 *     # recall p = v * t + u
 */
  __pyx_v_intersect_t = 1;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":147
 *     cdef np.ndarray[np.float64_t, ndim=1] intersect = np.empty((3,), dtype=np.float64)
 *     intersect_t = 1
 *     dt_tolerance = 1e-6             # <<<<<<<<<<<<<<
 *     # recall p = v * t + u
 *     #  where p is position, v is our vector, u is the start point
 */
  __pyx_v_dt_tolerance = 9.9999999999999995e-07;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":150
 *     # recall p = v * t + u
 *     #  where p is position, v is our vector, u is the start point
 *     for i in range(3):             # <<<<<<<<<<<<<<
 *         # As long as we're iterating, set some other stuff, too
 *         if(v[i] < 0): step[i] = -1
 */
  for (__pyx_t_11 = 0; __pyx_t_11 < 3; __pyx_t_11+=1) {
    __pyx_v_i = __pyx_t_11;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":152
 *     for i in range(3):
 *         # As long as we're iterating, set some other stuff, too
 *         if(v[i] < 0): step[i] = -1             # <<<<<<<<<<<<<<
 *         else: step[i] = 1
 *         x = (i+1)%3
 */
    __pyx_t_12 = __pyx_v_i;
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_12, __pyx_bstride_0_v)) < 0);
    if (__pyx_t_13) {
      __pyx_t_14 = __pyx_v_i;
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_step.buf, __pyx_t_14, __pyx_bstride_0_step) = -1;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":153
 *         # As long as we're iterating, set some other stuff, too
 *         if(v[i] < 0): step[i] = -1
 *         else: step[i] = 1             # <<<<<<<<<<<<<<
 *         x = (i+1)%3
 *         y = (i+2)%3
 */
      __pyx_t_15 = __pyx_v_i;
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_step.buf, __pyx_t_15, __pyx_bstride_0_step) = 1;
    }
    __pyx_L8:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":154
 *         if(v[i] < 0): step[i] = -1
 *         else: step[i] = 1
 *         x = (i+1)%3             # <<<<<<<<<<<<<<
 *         y = (i+2)%3
 *         tl = (left_edge[i] - u[i])/v[i]
 */
    __pyx_v_x = ((__pyx_v_i + 1) % 3);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":155
 *         else: step[i] = 1
 *         x = (i+1)%3
 *         y = (i+2)%3             # <<<<<<<<<<<<<<
 *         tl = (left_edge[i] - u[i])/v[i]
 *         tr = (right_edge[i] - u[i])/v[i]
 */
    __pyx_v_y = ((__pyx_v_i + 2) % 3);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":156
 *         x = (i+1)%3
 *         y = (i+2)%3
 *         tl = (left_edge[i] - u[i])/v[i]             # <<<<<<<<<<<<<<
 *         tr = (right_edge[i] - u[i])/v[i]
 *         if (left_edge[x] <= (u[x] + tl*v[x]) <= right_edge[x]) and \
 */
    __pyx_t_16 = __pyx_v_i;
    __pyx_t_17 = __pyx_v_i;
    __pyx_t_18 = __pyx_v_i;
    __pyx_v_tl = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_16, __pyx_bstride_0_left_edge)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_17, __pyx_bstride_0_u))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_18, __pyx_bstride_0_v)));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":157
 *         y = (i+2)%3
 *         tl = (left_edge[i] - u[i])/v[i]
 *         tr = (right_edge[i] - u[i])/v[i]             # <<<<<<<<<<<<<<
 *         if (left_edge[x] <= (u[x] + tl*v[x]) <= right_edge[x]) and \
 *            (left_edge[y] <= (u[y] + tl*v[y]) <= right_edge[y]) and \
 */
    __pyx_t_19 = __pyx_v_i;
    __pyx_t_20 = __pyx_v_i;
    __pyx_t_21 = __pyx_v_i;
    __pyx_v_tr = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_19, __pyx_bstride_0_right_edge)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_20, __pyx_bstride_0_u))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_21, __pyx_bstride_0_v)));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":158
 *         tl = (left_edge[i] - u[i])/v[i]
 *         tr = (right_edge[i] - u[i])/v[i]
 *         if (left_edge[x] <= (u[x] + tl*v[x]) <= right_edge[x]) and \             # <<<<<<<<<<<<<<
 *            (left_edge[y] <= (u[y] + tl*v[y]) <= right_edge[y]) and \
 *            (0.0 <= tl < intersect_t):
 */
    __pyx_t_22 = __pyx_v_x;
    __pyx_t_23 = __pyx_v_x;
    __pyx_t_24 = __pyx_v_x;
    __pyx_t_25 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_23, __pyx_bstride_0_u)) + (__pyx_v_tl * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_24, __pyx_bstride_0_v))));
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_22, __pyx_bstride_0_left_edge)) <= __pyx_t_25);
    if (__pyx_t_13) {
      __pyx_t_26 = __pyx_v_x;
      __pyx_t_13 = (__pyx_t_25 <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_26, __pyx_bstride_0_right_edge)));
    }
    if (__pyx_t_13) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":159
 *         tr = (right_edge[i] - u[i])/v[i]
 *         if (left_edge[x] <= (u[x] + tl*v[x]) <= right_edge[x]) and \
 *            (left_edge[y] <= (u[y] + tl*v[y]) <= right_edge[y]) and \             # <<<<<<<<<<<<<<
 *            (0.0 <= tl < intersect_t):
 *             intersect_t = tl
 */
      __pyx_t_27 = __pyx_v_y;
      __pyx_t_28 = __pyx_v_y;
      __pyx_t_29 = __pyx_v_y;
      __pyx_t_25 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_28, __pyx_bstride_0_u)) + (__pyx_v_tl * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_29, __pyx_bstride_0_v))));
      __pyx_t_30 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_27, __pyx_bstride_0_left_edge)) <= __pyx_t_25);
      if (__pyx_t_30) {
        __pyx_t_31 = __pyx_v_y;
        __pyx_t_30 = (__pyx_t_25 <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_31, __pyx_bstride_0_right_edge)));
      }
      if (__pyx_t_30) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":160
 *         if (left_edge[x] <= (u[x] + tl*v[x]) <= right_edge[x]) and \
 *            (left_edge[y] <= (u[y] + tl*v[y]) <= right_edge[y]) and \
 *            (0.0 <= tl < intersect_t):             # <<<<<<<<<<<<<<
 *             intersect_t = tl
 *         if (left_edge[x] <= (u[x] + tr*v[x]) <= right_edge[x]) and \
 */
        __pyx_t_32 = (0.0 <= __pyx_v_tl);
        if (__pyx_t_32) {
          __pyx_t_32 = (__pyx_v_tl < __pyx_v_intersect_t);
        }
        __pyx_t_33 = __pyx_t_32;
      } else {
        __pyx_t_33 = __pyx_t_30;
      }
      __pyx_t_30 = __pyx_t_33;
    } else {
      __pyx_t_30 = __pyx_t_13;
    }
    if (__pyx_t_30) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":161
 *            (left_edge[y] <= (u[y] + tl*v[y]) <= right_edge[y]) and \
 *            (0.0 <= tl < intersect_t):
 *             intersect_t = tl             # <<<<<<<<<<<<<<
 *         if (left_edge[x] <= (u[x] + tr*v[x]) <= right_edge[x]) and \
 *            (left_edge[y] <= (u[y] + tr*v[y]) <= right_edge[y]) and \
 */
      __pyx_v_intersect_t = __pyx_v_tl;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":162
 *            (0.0 <= tl < intersect_t):
 *             intersect_t = tl
 *         if (left_edge[x] <= (u[x] + tr*v[x]) <= right_edge[x]) and \             # <<<<<<<<<<<<<<
 *            (left_edge[y] <= (u[y] + tr*v[y]) <= right_edge[y]) and \
 *            (0.0 <= tr < intersect_t):
 */
    __pyx_t_34 = __pyx_v_x;
    __pyx_t_35 = __pyx_v_x;
    __pyx_t_36 = __pyx_v_x;
    __pyx_t_25 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_35, __pyx_bstride_0_u)) + (__pyx_v_tr * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_36, __pyx_bstride_0_v))));
    __pyx_t_30 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_34, __pyx_bstride_0_left_edge)) <= __pyx_t_25);
    if (__pyx_t_30) {
      __pyx_t_37 = __pyx_v_x;
      __pyx_t_30 = (__pyx_t_25 <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_37, __pyx_bstride_0_right_edge)));
    }
    if (__pyx_t_30) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":163
 *             intersect_t = tl
 *         if (left_edge[x] <= (u[x] + tr*v[x]) <= right_edge[x]) and \
 *            (left_edge[y] <= (u[y] + tr*v[y]) <= right_edge[y]) and \             # <<<<<<<<<<<<<<
 *            (0.0 <= tr < intersect_t):
 *             intersect_t = tr
 */
      __pyx_t_38 = __pyx_v_y;
      __pyx_t_39 = __pyx_v_y;
      __pyx_t_40 = __pyx_v_y;
      __pyx_t_25 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_39, __pyx_bstride_0_u)) + (__pyx_v_tr * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_40, __pyx_bstride_0_v))));
      __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_38, __pyx_bstride_0_left_edge)) <= __pyx_t_25);
      if (__pyx_t_13) {
        __pyx_t_41 = __pyx_v_y;
        __pyx_t_13 = (__pyx_t_25 <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_41, __pyx_bstride_0_right_edge)));
      }
      if (__pyx_t_13) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":164
 *         if (left_edge[x] <= (u[x] + tr*v[x]) <= right_edge[x]) and \
 *            (left_edge[y] <= (u[y] + tr*v[y]) <= right_edge[y]) and \
 *            (0.0 <= tr < intersect_t):             # <<<<<<<<<<<<<<
 *             intersect_t = tr
 *     # if fully enclosed
 */
        __pyx_t_33 = (0.0 <= __pyx_v_tr);
        if (__pyx_t_33) {
          __pyx_t_33 = (__pyx_v_tr < __pyx_v_intersect_t);
        }
        __pyx_t_32 = __pyx_t_33;
      } else {
        __pyx_t_32 = __pyx_t_13;
      }
      __pyx_t_13 = __pyx_t_32;
    } else {
      __pyx_t_13 = __pyx_t_30;
    }
    if (__pyx_t_13) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":165
 *            (left_edge[y] <= (u[y] + tr*v[y]) <= right_edge[y]) and \
 *            (0.0 <= tr < intersect_t):
 *             intersect_t = tr             # <<<<<<<<<<<<<<
 *     # if fully enclosed
 *     if (left_edge[0] <= u[0] <= right_edge[0]) and \
 */
      __pyx_v_intersect_t = __pyx_v_tr;
      goto __pyx_L10;
    }
    __pyx_L10:;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":167
 *             intersect_t = tr
 *     # if fully enclosed
 *     if (left_edge[0] <= u[0] <= right_edge[0]) and \             # <<<<<<<<<<<<<<
 *        (left_edge[1] <= u[1] <= right_edge[1]) and \
 *        (left_edge[2] <= u[2] <= right_edge[2]):
 */
  __pyx_t_42 = 0;
  __pyx_t_43 = 0;
  __pyx_t_25 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_43, __pyx_bstride_0_u));
  __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_42, __pyx_bstride_0_left_edge)) <= __pyx_t_25);
  if (__pyx_t_13) {
    __pyx_t_44 = 0;
    __pyx_t_13 = (__pyx_t_25 <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_44, __pyx_bstride_0_right_edge)));
  }
  if (__pyx_t_13) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":168
 *     # if fully enclosed
 *     if (left_edge[0] <= u[0] <= right_edge[0]) and \
 *        (left_edge[1] <= u[1] <= right_edge[1]) and \             # <<<<<<<<<<<<<<
 *        (left_edge[2] <= u[2] <= right_edge[2]):
 *         intersect_t = 0.0
 */
    __pyx_t_45 = 1;
    __pyx_t_46 = 1;
    __pyx_t_25 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_46, __pyx_bstride_0_u));
    __pyx_t_30 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_45, __pyx_bstride_0_left_edge)) <= __pyx_t_25);
    if (__pyx_t_30) {
      __pyx_t_47 = 1;
      __pyx_t_30 = (__pyx_t_25 <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_47, __pyx_bstride_0_right_edge)));
    }
    if (__pyx_t_30) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":169
 *     if (left_edge[0] <= u[0] <= right_edge[0]) and \
 *        (left_edge[1] <= u[1] <= right_edge[1]) and \
 *        (left_edge[2] <= u[2] <= right_edge[2]):             # <<<<<<<<<<<<<<
 *         intersect_t = 0.0
 *     if not (0 <= intersect_t <= 1): return
 */
      __pyx_t_48 = 2;
      __pyx_t_49 = 2;
      __pyx_t_25 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_49, __pyx_bstride_0_u));
      __pyx_t_32 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_48, __pyx_bstride_0_left_edge)) <= __pyx_t_25);
      if (__pyx_t_32) {
        __pyx_t_50 = 2;
        __pyx_t_32 = (__pyx_t_25 <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_50, __pyx_bstride_0_right_edge)));
      }
      __pyx_t_33 = __pyx_t_32;
    } else {
      __pyx_t_33 = __pyx_t_30;
    }
    __pyx_t_30 = __pyx_t_33;
  } else {
    __pyx_t_30 = __pyx_t_13;
  }
  if (__pyx_t_30) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":170
 *        (left_edge[1] <= u[1] <= right_edge[1]) and \
 *        (left_edge[2] <= u[2] <= right_edge[2]):
 *         intersect_t = 0.0             # <<<<<<<<<<<<<<
 *     if not (0 <= intersect_t <= 1): return
 *     # Now get the indices of the intersection
 */
    __pyx_v_intersect_t = 0.0;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":171
 *        (left_edge[2] <= u[2] <= right_edge[2]):
 *         intersect_t = 0.0
 *     if not (0 <= intersect_t <= 1): return             # <<<<<<<<<<<<<<
 *     # Now get the indices of the intersection
 *     intersect = u + intersect_t * v
 */
  __pyx_t_30 = (0 <= __pyx_v_intersect_t);
  if (__pyx_t_30) {
    __pyx_t_30 = (__pyx_v_intersect_t <= 1);
  }
  __pyx_t_13 = (!__pyx_t_30);
  if (__pyx_t_13) {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":173
 *     if not (0 <= intersect_t <= 1): return
 *     # Now get the indices of the intersection
 *     intersect = u + intersect_t * v             # <<<<<<<<<<<<<<
 *     for i in range(3):
 *         cur_ind[i] = np.floor((intersect[i] + 1e-8*dx[i] - left_edge[i])/dx[i])
 */
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_intersect_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyNumber_Multiply(__pyx_t_5, ((PyObject *)__pyx_v_v)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_v_u), __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_10 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_intersect);
    __pyx_t_11 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_intersect, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_11 < 0)) {
      PyErr_Fetch(&__pyx_t_51, &__pyx_t_52, &__pyx_t_53);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_intersect, (PyObject*)__pyx_v_intersect, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_51); Py_XDECREF(__pyx_t_52); Py_XDECREF(__pyx_t_53);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_51, __pyx_t_52, __pyx_t_53);
      }
    }
    __pyx_bstride_0_intersect = __pyx_bstruct_intersect.strides[0];
    __pyx_bshape_0_intersect = __pyx_bstruct_intersect.shape[0];
    if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_10 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_v_intersect));
  __pyx_v_intersect = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":174
 *     # Now get the indices of the intersection
 *     intersect = u + intersect_t * v
 *     for i in range(3):             # <<<<<<<<<<<<<<
 *         cur_ind[i] = np.floor((intersect[i] + 1e-8*dx[i] - left_edge[i])/dx[i])
 *         tmax[i] = (((cur_ind[i]+step[i])*dx[i])+left_edge[i]-u[i])/v[i]
 */
  for (__pyx_t_11 = 0; __pyx_t_11 < 3; __pyx_t_11+=1) {
    __pyx_v_i = __pyx_t_11;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":175
 *     intersect = u + intersect_t * v
 *     for i in range(3):
 *         cur_ind[i] = np.floor((intersect[i] + 1e-8*dx[i] - left_edge[i])/dx[i])             # <<<<<<<<<<<<<<
 *         tmax[i] = (((cur_ind[i]+step[i])*dx[i])+left_edge[i]-u[i])/v[i]
 *         if cur_ind[i] == grid_mask.shape[i] and step[i] < 0:
 */
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__floor); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_54 = __pyx_v_i;
    __pyx_t_55 = __pyx_v_i;
    __pyx_t_56 = __pyx_v_i;
    __pyx_t_57 = __pyx_v_i;
    __pyx_t_5 = PyFloat_FromDouble(((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_intersect.buf, __pyx_t_54, __pyx_bstride_0_intersect)) + (1e-08 * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_55, __pyx_bstride_0_dx)))) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_56, __pyx_bstride_0_left_edge))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_57, __pyx_bstride_0_dx)))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_58 = __Pyx_PyInt_from_py_npy_int64(__pyx_t_5); if (unlikely((__pyx_t_58 == (npy_int64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_59 = __pyx_v_i;
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_59, __pyx_bstride_0_cur_ind) = __pyx_t_58;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":176
 *     for i in range(3):
 *         cur_ind[i] = np.floor((intersect[i] + 1e-8*dx[i] - left_edge[i])/dx[i])
 *         tmax[i] = (((cur_ind[i]+step[i])*dx[i])+left_edge[i]-u[i])/v[i]             # <<<<<<<<<<<<<<
 *         if cur_ind[i] == grid_mask.shape[i] and step[i] < 0:
 *             cur_ind[i] = grid_mask.shape[i] - 1
 */
    __pyx_t_60 = __pyx_v_i;
    __pyx_t_61 = __pyx_v_i;
    __pyx_t_62 = __pyx_v_i;
    __pyx_t_63 = __pyx_v_i;
    __pyx_t_64 = __pyx_v_i;
    __pyx_t_65 = __pyx_v_i;
    __pyx_t_66 = __pyx_v_i;
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_66, __pyx_bstride_0_tmax) = ((((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_60, __pyx_bstride_0_cur_ind)) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_step.buf, __pyx_t_61, __pyx_bstride_0_step))) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_62, __pyx_bstride_0_dx))) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_63, __pyx_bstride_0_left_edge))) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_64, __pyx_bstride_0_u))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_65, __pyx_bstride_0_v)));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":177
 *         cur_ind[i] = np.floor((intersect[i] + 1e-8*dx[i] - left_edge[i])/dx[i])
 *         tmax[i] = (((cur_ind[i]+step[i])*dx[i])+left_edge[i]-u[i])/v[i]
 *         if cur_ind[i] == grid_mask.shape[i] and step[i] < 0:             # <<<<<<<<<<<<<<
 *             cur_ind[i] = grid_mask.shape[i] - 1
 *         if step[i] > 0: tmax[i] = (((cur_ind[i]+1)*dx[i])+left_edge[i]-u[i])/v[i]
 */
    __pyx_t_67 = __pyx_v_i;
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_67, __pyx_bstride_0_cur_ind)) == (__pyx_v_grid_mask->dimensions[__pyx_v_i]));
    if (__pyx_t_13) {
      __pyx_t_68 = __pyx_v_i;
      __pyx_t_30 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_step.buf, __pyx_t_68, __pyx_bstride_0_step)) < 0);
      __pyx_t_33 = __pyx_t_30;
    } else {
      __pyx_t_33 = __pyx_t_13;
    }
    if (__pyx_t_33) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":178
 *         tmax[i] = (((cur_ind[i]+step[i])*dx[i])+left_edge[i]-u[i])/v[i]
 *         if cur_ind[i] == grid_mask.shape[i] and step[i] < 0:
 *             cur_ind[i] = grid_mask.shape[i] - 1             # <<<<<<<<<<<<<<
 *         if step[i] > 0: tmax[i] = (((cur_ind[i]+1)*dx[i])+left_edge[i]-u[i])/v[i]
 *         if step[i] < 0: tmax[i] = (((cur_ind[i]+0)*dx[i])+left_edge[i]-u[i])/v[i]
 */
      __pyx_t_69 = __pyx_v_i;
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_69, __pyx_bstride_0_cur_ind) = ((__pyx_v_grid_mask->dimensions[__pyx_v_i]) - 1);
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":179
 *         if cur_ind[i] == grid_mask.shape[i] and step[i] < 0:
 *             cur_ind[i] = grid_mask.shape[i] - 1
 *         if step[i] > 0: tmax[i] = (((cur_ind[i]+1)*dx[i])+left_edge[i]-u[i])/v[i]             # <<<<<<<<<<<<<<
 *         if step[i] < 0: tmax[i] = (((cur_ind[i]+0)*dx[i])+left_edge[i]-u[i])/v[i]
 *         tdelta[i] = (dx[i]/v[i])
 */
    __pyx_t_70 = __pyx_v_i;
    __pyx_t_33 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_step.buf, __pyx_t_70, __pyx_bstride_0_step)) > 0);
    if (__pyx_t_33) {
      __pyx_t_71 = __pyx_v_i;
      __pyx_t_72 = __pyx_v_i;
      __pyx_t_73 = __pyx_v_i;
      __pyx_t_74 = __pyx_v_i;
      __pyx_t_75 = __pyx_v_i;
      __pyx_t_76 = __pyx_v_i;
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_76, __pyx_bstride_0_tmax) = ((((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_71, __pyx_bstride_0_cur_ind)) + 1) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_72, __pyx_bstride_0_dx))) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_73, __pyx_bstride_0_left_edge))) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_74, __pyx_bstride_0_u))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_75, __pyx_bstride_0_v)));
      goto __pyx_L16;
    }
    __pyx_L16:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":180
 *             cur_ind[i] = grid_mask.shape[i] - 1
 *         if step[i] > 0: tmax[i] = (((cur_ind[i]+1)*dx[i])+left_edge[i]-u[i])/v[i]
 *         if step[i] < 0: tmax[i] = (((cur_ind[i]+0)*dx[i])+left_edge[i]-u[i])/v[i]             # <<<<<<<<<<<<<<
 *         tdelta[i] = (dx[i]/v[i])
 *         if tdelta[i] < 0: tdelta[i] *= -1
 */
    __pyx_t_77 = __pyx_v_i;
    __pyx_t_33 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_step.buf, __pyx_t_77, __pyx_bstride_0_step)) < 0);
    if (__pyx_t_33) {
      __pyx_t_78 = __pyx_v_i;
      __pyx_t_79 = __pyx_v_i;
      __pyx_t_80 = __pyx_v_i;
      __pyx_t_81 = __pyx_v_i;
      __pyx_t_82 = __pyx_v_i;
      __pyx_t_83 = __pyx_v_i;
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_83, __pyx_bstride_0_tmax) = ((((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_78, __pyx_bstride_0_cur_ind)) + 0) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_79, __pyx_bstride_0_dx))) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_80, __pyx_bstride_0_left_edge))) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_81, __pyx_bstride_0_u))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_82, __pyx_bstride_0_v)));
      goto __pyx_L17;
    }
    __pyx_L17:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":181
 *         if step[i] > 0: tmax[i] = (((cur_ind[i]+1)*dx[i])+left_edge[i]-u[i])/v[i]
 *         if step[i] < 0: tmax[i] = (((cur_ind[i]+0)*dx[i])+left_edge[i]-u[i])/v[i]
 *         tdelta[i] = (dx[i]/v[i])             # <<<<<<<<<<<<<<
 *         if tdelta[i] < 0: tdelta[i] *= -1
 *     # The variable intersect contains the point we first pierce the grid
 */
    __pyx_t_84 = __pyx_v_i;
    __pyx_t_85 = __pyx_v_i;
    __pyx_t_86 = __pyx_v_i;
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tdelta.buf, __pyx_t_86, __pyx_bstride_0_tdelta) = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_84, __pyx_bstride_0_dx)) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_85, __pyx_bstride_0_v)));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":182
 *         if step[i] < 0: tmax[i] = (((cur_ind[i]+0)*dx[i])+left_edge[i]-u[i])/v[i]
 *         tdelta[i] = (dx[i]/v[i])
 *         if tdelta[i] < 0: tdelta[i] *= -1             # <<<<<<<<<<<<<<
 *     # The variable intersect contains the point we first pierce the grid
 *     enter_t = intersect_t
 */
    __pyx_t_87 = __pyx_v_i;
    __pyx_t_33 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tdelta.buf, __pyx_t_87, __pyx_bstride_0_tdelta)) < 0);
    if (__pyx_t_33) {
      __pyx_t_88 = __pyx_v_i;
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tdelta.buf, __pyx_t_88, __pyx_bstride_0_tdelta) *= -1;
      goto __pyx_L18;
    }
    __pyx_L18:;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":184
 *         if tdelta[i] < 0: tdelta[i] *= -1
 *     # The variable intersect contains the point we first pierce the grid
 *     enter_t = intersect_t             # <<<<<<<<<<<<<<
 *     while 1:
 *         if (not (0 <= cur_ind[0] < grid_mask.shape[0])) or \
 */
  __pyx_v_enter_t = __pyx_v_intersect_t;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":185
 *     # The variable intersect contains the point we first pierce the grid
 *     enter_t = intersect_t
 *     while 1:             # <<<<<<<<<<<<<<
 *         if (not (0 <= cur_ind[0] < grid_mask.shape[0])) or \
 *            (not (0 <= cur_ind[1] < grid_mask.shape[1])) or \
 */
  while (1) {
    __pyx_t_33 = 1;
    if (!__pyx_t_33) break;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":186
 *     enter_t = intersect_t
 *     while 1:
 *         if (not (0 <= cur_ind[0] < grid_mask.shape[0])) or \             # <<<<<<<<<<<<<<
 *            (not (0 <= cur_ind[1] < grid_mask.shape[1])) or \
 *            (not (0 <= cur_ind[2] < grid_mask.shape[2])):
 */
    __pyx_t_89 = 0;
    __pyx_t_58 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_89, __pyx_bstride_0_cur_ind));
    __pyx_t_33 = (0 <= __pyx_t_58);
    if (__pyx_t_33) {
      __pyx_t_33 = (__pyx_t_58 < (__pyx_v_grid_mask->dimensions[0]));
    }
    __pyx_t_13 = (!__pyx_t_33);
    if (!__pyx_t_13) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":187
 *     while 1:
 *         if (not (0 <= cur_ind[0] < grid_mask.shape[0])) or \
 *            (not (0 <= cur_ind[1] < grid_mask.shape[1])) or \             # <<<<<<<<<<<<<<
 *            (not (0 <= cur_ind[2] < grid_mask.shape[2])):
 *             break
 */
      __pyx_t_90 = 1;
      __pyx_t_58 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_90, __pyx_bstride_0_cur_ind));
      __pyx_t_33 = (0 <= __pyx_t_58);
      if (__pyx_t_33) {
        __pyx_t_33 = (__pyx_t_58 < (__pyx_v_grid_mask->dimensions[1]));
      }
      __pyx_t_30 = (!__pyx_t_33);
      if (!__pyx_t_30) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":188
 *         if (not (0 <= cur_ind[0] < grid_mask.shape[0])) or \
 *            (not (0 <= cur_ind[1] < grid_mask.shape[1])) or \
 *            (not (0 <= cur_ind[2] < grid_mask.shape[2])):             # <<<<<<<<<<<<<<
 *             break
 *         # Note that we are calculating t on the fly, but we get *negative* t
 */
        __pyx_t_91 = 2;
        __pyx_t_58 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_91, __pyx_bstride_0_cur_ind));
        __pyx_t_33 = (0 <= __pyx_t_58);
        if (__pyx_t_33) {
          __pyx_t_33 = (__pyx_t_58 < (__pyx_v_grid_mask->dimensions[2]));
        }
        __pyx_t_32 = (!__pyx_t_33);
        __pyx_t_33 = __pyx_t_32;
      } else {
        __pyx_t_33 = __pyx_t_30;
      }
      __pyx_t_30 = __pyx_t_33;
    } else {
      __pyx_t_30 = __pyx_t_13;
    }
    if (__pyx_t_30) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":189
 *            (not (0 <= cur_ind[1] < grid_mask.shape[1])) or \
 *            (not (0 <= cur_ind[2] < grid_mask.shape[2])):
 *             break             # <<<<<<<<<<<<<<
 *         # Note that we are calculating t on the fly, but we get *negative* t
 *         # values from what they should be.
 */
      goto __pyx_L20_break;
      goto __pyx_L21;
    }
    __pyx_L21:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":193
 *         # values from what they should be.
 *         # If we've reached t = 1, we are done.
 *         grid_mask[cur_ind[0], cur_ind[1], cur_ind[2]] = 1             # <<<<<<<<<<<<<<
 *         if (tmax[0] > 1.0) and (tmax[1] > 1.0) and (tmax[2] > 1.0):
 *             grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = 1.0 - enter_t
 */
    __pyx_t_92 = 0;
    __pyx_t_93 = 1;
    __pyx_t_94 = 2;
    __pyx_t_58 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_92, __pyx_bstride_0_cur_ind));
    __pyx_t_95 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_93, __pyx_bstride_0_cur_ind));
    __pyx_t_96 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_94, __pyx_bstride_0_cur_ind));
    *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int_t *, __pyx_bstruct_grid_mask.buf, __pyx_t_58, __pyx_bstride_0_grid_mask, __pyx_t_95, __pyx_bstride_1_grid_mask, __pyx_t_96, __pyx_bstride_2_grid_mask) = 1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":194
 *         # If we've reached t = 1, we are done.
 *         grid_mask[cur_ind[0], cur_ind[1], cur_ind[2]] = 1
 *         if (tmax[0] > 1.0) and (tmax[1] > 1.0) and (tmax[2] > 1.0):             # <<<<<<<<<<<<<<
 *             grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = 1.0 - enter_t
 *             break
 */
    __pyx_t_97 = 0;
    __pyx_t_30 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_97, __pyx_bstride_0_tmax)) > 1.0);
    if (__pyx_t_30) {
      __pyx_t_98 = 1;
      __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_98, __pyx_bstride_0_tmax)) > 1.0);
      if (__pyx_t_13) {
        __pyx_t_99 = 2;
        __pyx_t_33 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_99, __pyx_bstride_0_tmax)) > 1.0);
        __pyx_t_32 = __pyx_t_33;
      } else {
        __pyx_t_32 = __pyx_t_13;
      }
      __pyx_t_13 = __pyx_t_32;
    } else {
      __pyx_t_13 = __pyx_t_30;
    }
    if (__pyx_t_13) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":195
 *         grid_mask[cur_ind[0], cur_ind[1], cur_ind[2]] = 1
 *         if (tmax[0] > 1.0) and (tmax[1] > 1.0) and (tmax[2] > 1.0):
 *             grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = 1.0 - enter_t             # <<<<<<<<<<<<<<
 *             break
 *         if tmax[0] < tmax[1]:
 */
      __pyx_t_100 = 0;
      __pyx_t_101 = 1;
      __pyx_t_102 = 2;
      __pyx_t_103 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_100, __pyx_bstride_0_cur_ind));
      __pyx_t_104 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_101, __pyx_bstride_0_cur_ind));
      __pyx_t_105 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_102, __pyx_bstride_0_cur_ind));
      *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_dt.buf, __pyx_t_103, __pyx_bstride_0_grid_dt, __pyx_t_104, __pyx_bstride_1_grid_dt, __pyx_t_105, __pyx_bstride_2_grid_dt) = (1.0 - __pyx_v_enter_t);

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":196
 *         if (tmax[0] > 1.0) and (tmax[1] > 1.0) and (tmax[2] > 1.0):
 *             grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = 1.0 - enter_t
 *             break             # <<<<<<<<<<<<<<
 *         if tmax[0] < tmax[1]:
 *             if tmax[0] < tmax[2]:
 */
      goto __pyx_L20_break;
      goto __pyx_L22;
    }
    __pyx_L22:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":197
 *             grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = 1.0 - enter_t
 *             break
 *         if tmax[0] < tmax[1]:             # <<<<<<<<<<<<<<
 *             if tmax[0] < tmax[2]:
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 */
    __pyx_t_106 = 0;
    __pyx_t_107 = 1;
    __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_106, __pyx_bstride_0_tmax)) < (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_107, __pyx_bstride_0_tmax)));
    if (__pyx_t_13) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":198
 *             break
 *         if tmax[0] < tmax[1]:
 *             if tmax[0] < tmax[2]:             # <<<<<<<<<<<<<<
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[0] - enter_t
 */
      __pyx_t_108 = 0;
      __pyx_t_109 = 2;
      __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_108, __pyx_bstride_0_tmax)) < (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_109, __pyx_bstride_0_tmax)));
      if (__pyx_t_13) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":199
 *         if tmax[0] < tmax[1]:
 *             if tmax[0] < tmax[2]:
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t             # <<<<<<<<<<<<<<
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[0] - enter_t
 *                 enter_t = tmax[0]
 */
        __pyx_t_110 = 0;
        __pyx_t_111 = 1;
        __pyx_t_112 = 2;
        __pyx_t_113 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_110, __pyx_bstride_0_cur_ind));
        __pyx_t_114 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_111, __pyx_bstride_0_cur_ind));
        __pyx_t_115 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_112, __pyx_bstride_0_cur_ind));
        *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_t.buf, __pyx_t_113, __pyx_bstride_0_grid_t, __pyx_t_114, __pyx_bstride_1_grid_t, __pyx_t_115, __pyx_bstride_2_grid_t) = __pyx_v_enter_t;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":200
 *             if tmax[0] < tmax[2]:
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[0] - enter_t             # <<<<<<<<<<<<<<
 *                 enter_t = tmax[0]
 *                 tmax[0] += tdelta[0]
 */
        __pyx_t_116 = 0;
        __pyx_t_117 = 0;
        __pyx_t_118 = 1;
        __pyx_t_119 = 2;
        __pyx_t_120 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_117, __pyx_bstride_0_cur_ind));
        __pyx_t_121 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_118, __pyx_bstride_0_cur_ind));
        __pyx_t_122 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_119, __pyx_bstride_0_cur_ind));
        *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_dt.buf, __pyx_t_120, __pyx_bstride_0_grid_dt, __pyx_t_121, __pyx_bstride_1_grid_dt, __pyx_t_122, __pyx_bstride_2_grid_dt) = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_116, __pyx_bstride_0_tmax)) - __pyx_v_enter_t);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":201
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[0] - enter_t
 *                 enter_t = tmax[0]             # <<<<<<<<<<<<<<
 *                 tmax[0] += tdelta[0]
 *                 cur_ind[0] += step[0]
 */
        __pyx_t_123 = 0;
        __pyx_v_enter_t = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_123, __pyx_bstride_0_tmax));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":202
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[0] - enter_t
 *                 enter_t = tmax[0]
 *                 tmax[0] += tdelta[0]             # <<<<<<<<<<<<<<
 *                 cur_ind[0] += step[0]
 *             else:
 */
        __pyx_t_124 = 0;
        __pyx_t_125 = 0;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_125, __pyx_bstride_0_tmax) += (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tdelta.buf, __pyx_t_124, __pyx_bstride_0_tdelta));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":203
 *                 enter_t = tmax[0]
 *                 tmax[0] += tdelta[0]
 *                 cur_ind[0] += step[0]             # <<<<<<<<<<<<<<
 *             else:
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 */
        __pyx_t_126 = 0;
        __pyx_t_127 = 0;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_127, __pyx_bstride_0_cur_ind) += (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_step.buf, __pyx_t_126, __pyx_bstride_0_step));
        goto __pyx_L24;
      }
      /*else*/ {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":205
 *                 cur_ind[0] += step[0]
 *             else:
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t             # <<<<<<<<<<<<<<
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[2] - enter_t
 *                 enter_t = tmax[2]
 */
        __pyx_t_128 = 0;
        __pyx_t_129 = 1;
        __pyx_t_130 = 2;
        __pyx_t_131 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_128, __pyx_bstride_0_cur_ind));
        __pyx_t_132 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_129, __pyx_bstride_0_cur_ind));
        __pyx_t_133 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_130, __pyx_bstride_0_cur_ind));
        *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_t.buf, __pyx_t_131, __pyx_bstride_0_grid_t, __pyx_t_132, __pyx_bstride_1_grid_t, __pyx_t_133, __pyx_bstride_2_grid_t) = __pyx_v_enter_t;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":206
 *             else:
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[2] - enter_t             # <<<<<<<<<<<<<<
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]
 */
        __pyx_t_134 = 2;
        __pyx_t_135 = 0;
        __pyx_t_136 = 1;
        __pyx_t_137 = 2;
        __pyx_t_138 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_135, __pyx_bstride_0_cur_ind));
        __pyx_t_139 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_136, __pyx_bstride_0_cur_ind));
        __pyx_t_140 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_137, __pyx_bstride_0_cur_ind));
        *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_dt.buf, __pyx_t_138, __pyx_bstride_0_grid_dt, __pyx_t_139, __pyx_bstride_1_grid_dt, __pyx_t_140, __pyx_bstride_2_grid_dt) = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_134, __pyx_bstride_0_tmax)) - __pyx_v_enter_t);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":207
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[2] - enter_t
 *                 enter_t = tmax[2]             # <<<<<<<<<<<<<<
 *                 tmax[2] += tdelta[2]
 *                 cur_ind[2] += step[2]
 */
        __pyx_t_141 = 2;
        __pyx_v_enter_t = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_141, __pyx_bstride_0_tmax));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":208
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[2] - enter_t
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]             # <<<<<<<<<<<<<<
 *                 cur_ind[2] += step[2]
 *         else:
 */
        __pyx_t_142 = 2;
        __pyx_t_143 = 2;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_143, __pyx_bstride_0_tmax) += (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tdelta.buf, __pyx_t_142, __pyx_bstride_0_tdelta));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":209
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]
 *                 cur_ind[2] += step[2]             # <<<<<<<<<<<<<<
 *         else:
 *             if tmax[1] < tmax[2]:
 */
        __pyx_t_144 = 2;
        __pyx_t_145 = 2;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_145, __pyx_bstride_0_cur_ind) += (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_step.buf, __pyx_t_144, __pyx_bstride_0_step));
      }
      __pyx_L24:;
      goto __pyx_L23;
    }
    /*else*/ {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":211
 *                 cur_ind[2] += step[2]
 *         else:
 *             if tmax[1] < tmax[2]:             # <<<<<<<<<<<<<<
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[1] - enter_t
 */
      __pyx_t_146 = 1;
      __pyx_t_147 = 2;
      __pyx_t_13 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_146, __pyx_bstride_0_tmax)) < (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_147, __pyx_bstride_0_tmax)));
      if (__pyx_t_13) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":212
 *         else:
 *             if tmax[1] < tmax[2]:
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t             # <<<<<<<<<<<<<<
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[1] - enter_t
 *                 enter_t = tmax[1]
 */
        __pyx_t_148 = 0;
        __pyx_t_149 = 1;
        __pyx_t_150 = 2;
        __pyx_t_151 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_148, __pyx_bstride_0_cur_ind));
        __pyx_t_152 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_149, __pyx_bstride_0_cur_ind));
        __pyx_t_153 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_150, __pyx_bstride_0_cur_ind));
        *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_t.buf, __pyx_t_151, __pyx_bstride_0_grid_t, __pyx_t_152, __pyx_bstride_1_grid_t, __pyx_t_153, __pyx_bstride_2_grid_t) = __pyx_v_enter_t;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":213
 *             if tmax[1] < tmax[2]:
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[1] - enter_t             # <<<<<<<<<<<<<<
 *                 enter_t = tmax[1]
 *                 tmax[1] += tdelta[1]
 */
        __pyx_t_154 = 1;
        __pyx_t_155 = 0;
        __pyx_t_156 = 1;
        __pyx_t_157 = 2;
        __pyx_t_158 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_155, __pyx_bstride_0_cur_ind));
        __pyx_t_159 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_156, __pyx_bstride_0_cur_ind));
        __pyx_t_160 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_157, __pyx_bstride_0_cur_ind));
        *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_dt.buf, __pyx_t_158, __pyx_bstride_0_grid_dt, __pyx_t_159, __pyx_bstride_1_grid_dt, __pyx_t_160, __pyx_bstride_2_grid_dt) = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_154, __pyx_bstride_0_tmax)) - __pyx_v_enter_t);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":214
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[1] - enter_t
 *                 enter_t = tmax[1]             # <<<<<<<<<<<<<<
 *                 tmax[1] += tdelta[1]
 *                 cur_ind[1] += step[1]
 */
        __pyx_t_161 = 1;
        __pyx_v_enter_t = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_161, __pyx_bstride_0_tmax));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":215
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[1] - enter_t
 *                 enter_t = tmax[1]
 *                 tmax[1] += tdelta[1]             # <<<<<<<<<<<<<<
 *                 cur_ind[1] += step[1]
 *             else:
 */
        __pyx_t_162 = 1;
        __pyx_t_163 = 1;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_163, __pyx_bstride_0_tmax) += (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tdelta.buf, __pyx_t_162, __pyx_bstride_0_tdelta));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":216
 *                 enter_t = tmax[1]
 *                 tmax[1] += tdelta[1]
 *                 cur_ind[1] += step[1]             # <<<<<<<<<<<<<<
 *             else:
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 */
        __pyx_t_164 = 1;
        __pyx_t_165 = 1;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_165, __pyx_bstride_0_cur_ind) += (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_step.buf, __pyx_t_164, __pyx_bstride_0_step));
        goto __pyx_L25;
      }
      /*else*/ {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":218
 *                 cur_ind[1] += step[1]
 *             else:
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t             # <<<<<<<<<<<<<<
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[2] - enter_t
 *                 enter_t = tmax[2]
 */
        __pyx_t_166 = 0;
        __pyx_t_167 = 1;
        __pyx_t_168 = 2;
        __pyx_t_169 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_166, __pyx_bstride_0_cur_ind));
        __pyx_t_170 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_167, __pyx_bstride_0_cur_ind));
        __pyx_t_171 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_168, __pyx_bstride_0_cur_ind));
        *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_t.buf, __pyx_t_169, __pyx_bstride_0_grid_t, __pyx_t_170, __pyx_bstride_1_grid_t, __pyx_t_171, __pyx_bstride_2_grid_t) = __pyx_v_enter_t;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":219
 *             else:
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[2] - enter_t             # <<<<<<<<<<<<<<
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]
 */
        __pyx_t_172 = 2;
        __pyx_t_173 = 0;
        __pyx_t_174 = 1;
        __pyx_t_175 = 2;
        __pyx_t_176 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_173, __pyx_bstride_0_cur_ind));
        __pyx_t_177 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_174, __pyx_bstride_0_cur_ind));
        __pyx_t_178 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_175, __pyx_bstride_0_cur_ind));
        *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_dt.buf, __pyx_t_176, __pyx_bstride_0_grid_dt, __pyx_t_177, __pyx_bstride_1_grid_dt, __pyx_t_178, __pyx_bstride_2_grid_dt) = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_172, __pyx_bstride_0_tmax)) - __pyx_v_enter_t);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":220
 *                 grid_t[cur_ind[0], cur_ind[1], cur_ind[2]] = enter_t
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[2] - enter_t
 *                 enter_t = tmax[2]             # <<<<<<<<<<<<<<
 *                 tmax[2] += tdelta[2]
 *                 cur_ind[2] += step[2]
 */
        __pyx_t_179 = 2;
        __pyx_v_enter_t = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_179, __pyx_bstride_0_tmax));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":221
 *                 grid_dt[cur_ind[0], cur_ind[1], cur_ind[2]] = tmax[2] - enter_t
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]             # <<<<<<<<<<<<<<
 *                 cur_ind[2] += step[2]
 *     return
 */
        __pyx_t_180 = 2;
        __pyx_t_181 = 2;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tmax.buf, __pyx_t_181, __pyx_bstride_0_tmax) += (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_tdelta.buf, __pyx_t_180, __pyx_bstride_0_tdelta));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":222
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]
 *                 cur_ind[2] += step[2]             # <<<<<<<<<<<<<<
 *     return
 * 
 */
        __pyx_t_182 = 2;
        __pyx_t_183 = 2;
        *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_cur_ind.buf, __pyx_t_183, __pyx_bstride_0_cur_ind) += (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_step.buf, __pyx_t_182, __pyx_bstride_0_step));
      }
      __pyx_L25:;
    }
    __pyx_L23:;
  }
  __pyx_L20_break:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":223
 *                 tmax[2] += tdelta[2]
 *                 cur_ind[2] += step[2]
 *     return             # <<<<<<<<<<<<<<
 * 
 * @cython.wraparound(False)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_intersect);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_t);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_dt);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_cur_ind);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_step);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_tdelta);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_tmax);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_mask);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_u);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_v);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.VoxelTraversal");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_intersect);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_t);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_dt);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_cur_ind);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_step);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_tdelta);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_tmax);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_mask);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_u);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_v);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_step);
  __Pyx_XDECREF((PyObject *)__pyx_v_cur_ind);
  __Pyx_XDECREF((PyObject *)__pyx_v_tdelta);
  __Pyx_XDECREF((PyObject *)__pyx_v_tmax);
  __Pyx_XDECREF((PyObject *)__pyx_v_intersect);
  __Pyx_DECREF((PyObject *)__pyx_v_grid_mask);
  __Pyx_DECREF((PyObject *)__pyx_v_grid_t);
  __Pyx_DECREF((PyObject *)__pyx_v_grid_dt);
  __Pyx_DECREF((PyObject *)__pyx_v_left_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_right_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_dx);
  __Pyx_DECREF((PyObject *)__pyx_v_u);
  __Pyx_DECREF((PyObject *)__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":227
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def PlaneVoxelIntegration(np.ndarray[np.float64_t, ndim=1] left_edge,             # <<<<<<<<<<<<<<
 *                           np.ndarray[np.float64_t, ndim=1] right_edge,
 *                           np.ndarray[np.float64_t, ndim=1] dx,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_PlaneVoxelIntegration(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_PlaneVoxelIntegration(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_left_edge = 0;
  PyArrayObject *__pyx_v_right_edge = 0;
  PyArrayObject *__pyx_v_dx = 0;
  PyArrayObject *__pyx_v_ug = 0;
  PyArrayObject *__pyx_v_v = 0;
  PyArrayObject *__pyx_v_image = 0;
  PyArrayObject *__pyx_v_data = 0;
  PyArrayObject *__pyx_v_shells = 0;
  int __pyx_v_i;
  int __pyx_v_vi;
  PyObject *__pyx_v_intersect_t;
  PyObject *__pyx_v_dt_tolerance;
  int __pyx_v_nv;
  int __pyx_v_nshells;
  PyArrayObject *__pyx_v_u = 0;
  Py_buffer __pyx_bstruct_u;
  Py_ssize_t __pyx_bstride_0_u = 0;
  Py_ssize_t __pyx_bshape_0_u = 0;
  Py_buffer __pyx_bstruct_shells;
  Py_ssize_t __pyx_bstride_0_shells = 0;
  Py_ssize_t __pyx_bstride_1_shells = 0;
  Py_ssize_t __pyx_bshape_0_shells = 0;
  Py_ssize_t __pyx_bshape_1_shells = 0;
  Py_buffer __pyx_bstruct_image;
  Py_ssize_t __pyx_bstride_0_image = 0;
  Py_ssize_t __pyx_bstride_1_image = 0;
  Py_ssize_t __pyx_bshape_0_image = 0;
  Py_ssize_t __pyx_bshape_1_image = 0;
  Py_buffer __pyx_bstruct_right_edge;
  Py_ssize_t __pyx_bstride_0_right_edge = 0;
  Py_ssize_t __pyx_bshape_0_right_edge = 0;
  Py_buffer __pyx_bstruct_dx;
  Py_ssize_t __pyx_bstride_0_dx = 0;
  Py_ssize_t __pyx_bshape_0_dx = 0;
  Py_buffer __pyx_bstruct_v;
  Py_ssize_t __pyx_bstride_0_v = 0;
  Py_ssize_t __pyx_bshape_0_v = 0;
  Py_buffer __pyx_bstruct_left_edge;
  Py_ssize_t __pyx_bstride_0_left_edge = 0;
  Py_ssize_t __pyx_bshape_0_left_edge = 0;
  Py_buffer __pyx_bstruct_ug;
  Py_ssize_t __pyx_bstride_0_ug = 0;
  Py_ssize_t __pyx_bstride_1_ug = 0;
  Py_ssize_t __pyx_bshape_0_ug = 0;
  Py_ssize_t __pyx_bshape_1_ug = 0;
  Py_buffer __pyx_bstruct_data;
  Py_ssize_t __pyx_bstride_0_data = 0;
  Py_ssize_t __pyx_bstride_1_data = 0;
  Py_ssize_t __pyx_bstride_2_data = 0;
  Py_ssize_t __pyx_bshape_0_data = 0;
  Py_ssize_t __pyx_bshape_1_data = 0;
  Py_ssize_t __pyx_bshape_2_data = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyArrayObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__left_edge,&__pyx_n_s__right_edge,&__pyx_n_s__dx,&__pyx_n_s__ug,&__pyx_n_s__v,&__pyx_n_s__image,&__pyx_n_s__data,&__pyx_n_s__shells,0};
  __Pyx_RefNannySetupContext("PlaneVoxelIntegration");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__left_edge);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__right_edge);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("PlaneVoxelIntegration", 1, 8, 8, 1); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dx);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("PlaneVoxelIntegration", 1, 8, 8, 2); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ug);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("PlaneVoxelIntegration", 1, 8, 8, 3); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__v);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("PlaneVoxelIntegration", 1, 8, 8, 4); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__image);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("PlaneVoxelIntegration", 1, 8, 8, 5); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("PlaneVoxelIntegration", 1, 8, 8, 6); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  7:
      values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__shells);
      if (likely(values[7])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("PlaneVoxelIntegration", 1, 8, 8, 7); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "PlaneVoxelIntegration") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_left_edge = ((PyArrayObject *)values[0]);
    __pyx_v_right_edge = ((PyArrayObject *)values[1]);
    __pyx_v_dx = ((PyArrayObject *)values[2]);
    __pyx_v_ug = ((PyArrayObject *)values[3]);
    __pyx_v_v = ((PyArrayObject *)values[4]);
    __pyx_v_image = ((PyArrayObject *)values[5]);
    __pyx_v_data = ((PyArrayObject *)values[6]);
    __pyx_v_shells = ((PyArrayObject *)values[7]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_left_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_right_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_dx = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_ug = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_v = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_image = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 5));
    __pyx_v_data = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 6));
    __pyx_v_shells = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 7));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("PlaneVoxelIntegration", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.PlaneVoxelIntegration");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_left_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_right_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_dx);
  __Pyx_INCREF((PyObject *)__pyx_v_ug);
  __Pyx_INCREF((PyObject *)__pyx_v_v);
  __Pyx_INCREF((PyObject *)__pyx_v_image);
  __Pyx_INCREF((PyObject *)__pyx_v_data);
  __Pyx_INCREF((PyObject *)__pyx_v_shells);
  __pyx_v_intersect_t = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_dt_tolerance = Py_None; __Pyx_INCREF(Py_None);
  __pyx_bstruct_u.buf = NULL;
  __pyx_bstruct_left_edge.buf = NULL;
  __pyx_bstruct_right_edge.buf = NULL;
  __pyx_bstruct_dx.buf = NULL;
  __pyx_bstruct_ug.buf = NULL;
  __pyx_bstruct_v.buf = NULL;
  __pyx_bstruct_image.buf = NULL;
  __pyx_bstruct_data.buf = NULL;
  __pyx_bstruct_shells.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_left_edge), __pyx_ptype_5numpy_ndarray, 1, "left_edge", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_right_edge), __pyx_ptype_5numpy_ndarray, 1, "right_edge", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dx), __pyx_ptype_5numpy_ndarray, 1, "dx", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ug), __pyx_ptype_5numpy_ndarray, 1, "ug", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_v), __pyx_ptype_5numpy_ndarray, 1, "v", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_image), __pyx_ptype_5numpy_ndarray, 1, "image", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), __pyx_ptype_5numpy_ndarray, 1, "data", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shells), __pyx_ptype_5numpy_ndarray, 1, "shells", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_left_edge, (PyObject*)__pyx_v_left_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_left_edge = __pyx_bstruct_left_edge.strides[0];
  __pyx_bshape_0_left_edge = __pyx_bstruct_left_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_right_edge, (PyObject*)__pyx_v_right_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_right_edge = __pyx_bstruct_right_edge.strides[0];
  __pyx_bshape_0_right_edge = __pyx_bstruct_right_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dx, (PyObject*)__pyx_v_dx, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_dx = __pyx_bstruct_dx.strides[0];
  __pyx_bshape_0_dx = __pyx_bstruct_dx.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_ug, (PyObject*)__pyx_v_ug, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_ug = __pyx_bstruct_ug.strides[0]; __pyx_bstride_1_ug = __pyx_bstruct_ug.strides[1];
  __pyx_bshape_0_ug = __pyx_bstruct_ug.shape[0]; __pyx_bshape_1_ug = __pyx_bstruct_ug.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_v, (PyObject*)__pyx_v_v, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_v = __pyx_bstruct_v.strides[0];
  __pyx_bshape_0_v = __pyx_bstruct_v.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_image, (PyObject*)__pyx_v_image, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_image = __pyx_bstruct_image.strides[0]; __pyx_bstride_1_image = __pyx_bstruct_image.strides[1];
  __pyx_bshape_0_image = __pyx_bstruct_image.shape[0]; __pyx_bshape_1_image = __pyx_bstruct_image.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_data, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_data = __pyx_bstruct_data.strides[0]; __pyx_bstride_1_data = __pyx_bstruct_data.strides[1]; __pyx_bstride_2_data = __pyx_bstruct_data.strides[2];
  __pyx_bshape_0_data = __pyx_bstruct_data.shape[0]; __pyx_bshape_1_data = __pyx_bstruct_data.shape[1]; __pyx_bshape_2_data = __pyx_bstruct_data.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_shells, (PyObject*)__pyx_v_shells, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_shells = __pyx_bstruct_shells.strides[0]; __pyx_bstride_1_shells = __pyx_bstruct_shells.strides[1];
  __pyx_bshape_0_shells = __pyx_bstruct_shells.shape[0]; __pyx_bshape_1_shells = __pyx_bstruct_shells.shape[1];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":239
 *     # generalized to transfer functions
 *     cdef int i, x, y, vi
 *     intersect_t = 1             # <<<<<<<<<<<<<<
 *     dt_tolerance = 1e-6
 *     cdef int nv = ug.shape[0]
 */
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_DECREF(__pyx_v_intersect_t);
  __pyx_v_intersect_t = __pyx_int_1;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":240
 *     cdef int i, x, y, vi
 *     intersect_t = 1
 *     dt_tolerance = 1e-6             # <<<<<<<<<<<<<<
 *     cdef int nv = ug.shape[0]
 *     cdef int nshells = shells.shape[0]
 */
  __pyx_t_1 = PyFloat_FromDouble(9.9999999999999995e-07); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_dt_tolerance);
  __pyx_v_dt_tolerance = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":241
 *     intersect_t = 1
 *     dt_tolerance = 1e-6
 *     cdef int nv = ug.shape[0]             # <<<<<<<<<<<<<<
 *     cdef int nshells = shells.shape[0]
 *     cdef np.ndarray[np.float64_t, ndim=1] u = np.empty((3,), dtype=np.float64)
 */
  __pyx_v_nv = (__pyx_v_ug->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":242
 *     dt_tolerance = 1e-6
 *     cdef int nv = ug.shape[0]
 *     cdef int nshells = shells.shape[0]             # <<<<<<<<<<<<<<
 *     cdef np.ndarray[np.float64_t, ndim=1] u = np.empty((3,), dtype=np.float64)
 *     # Copy things into temporary location for passing between functions
 */
  __pyx_v_nshells = (__pyx_v_shells->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":243
 *     cdef int nv = ug.shape[0]
 *     cdef int nshells = shells.shape[0]
 *     cdef np.ndarray[np.float64_t, ndim=1] u = np.empty((3,), dtype=np.float64)             # <<<<<<<<<<<<<<
 *     # Copy things into temporary location for passing between functions
 *     for vi in range(nv):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, __pyx_t_3, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_u, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_u = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_u.buf = NULL;
      {__pyx_filename = __pyx_f[4]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_u = __pyx_bstruct_u.strides[0];
      __pyx_bshape_0_u = __pyx_bstruct_u.shape[0];
    }
  }
  __pyx_t_6 = 0;
  __pyx_v_u = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":245
 *     cdef np.ndarray[np.float64_t, ndim=1] u = np.empty((3,), dtype=np.float64)
 *     # Copy things into temporary location for passing between functions
 *     for vi in range(nv):             # <<<<<<<<<<<<<<
 *         for i in range(3): u[i] = ug[vi, i]
 *         integrate_ray(u, v, left_edge, right_edge, dx,
 */
  __pyx_t_7 = __pyx_v_nv;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
    __pyx_v_vi = __pyx_t_8;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":246
 *     # Copy things into temporary location for passing between functions
 *     for vi in range(nv):
 *         for i in range(3): u[i] = ug[vi, i]             # <<<<<<<<<<<<<<
 *         integrate_ray(u, v, left_edge, right_edge, dx,
 *                       nshells, vi, data, shells, image)
 */
    for (__pyx_t_9 = 0; __pyx_t_9 < 3; __pyx_t_9+=1) {
      __pyx_v_i = __pyx_t_9;
      __pyx_t_10 = __pyx_v_vi;
      __pyx_t_11 = __pyx_v_i;
      __pyx_t_12 = __pyx_v_i;
      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_12, __pyx_bstride_0_u) = (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_ug.buf, __pyx_t_10, __pyx_bstride_0_ug, __pyx_t_11, __pyx_bstride_1_ug));
    }

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":247
 *     for vi in range(nv):
 *         for i in range(3): u[i] = ug[vi, i]
 *         integrate_ray(u, v, left_edge, right_edge, dx,             # <<<<<<<<<<<<<<
 *                       nshells, vi, data, shells, image)
 * 
 */
    __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__integrate_ray); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":248
 *         for i in range(3): u[i] = ug[vi, i]
 *         integrate_ray(u, v, left_edge, right_edge, dx,
 *                       nshells, vi, data, shells, image)             # <<<<<<<<<<<<<<
 * 
 * @cython.wraparound(False)
 */
    __pyx_t_1 = PyInt_FromLong(__pyx_v_nshells); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PyInt_FromLong(__pyx_v_vi); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyTuple_New(10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_u));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_u));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_u));
    __Pyx_INCREF(((PyObject *)__pyx_v_v));
    PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_v));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_v));
    __Pyx_INCREF(((PyObject *)__pyx_v_left_edge));
    PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_left_edge));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_left_edge));
    __Pyx_INCREF(((PyObject *)__pyx_v_right_edge));
    PyTuple_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_v_right_edge));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_right_edge));
    __Pyx_INCREF(((PyObject *)__pyx_v_dx));
    PyTuple_SET_ITEM(__pyx_t_2, 4, ((PyObject *)__pyx_v_dx));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_dx));
    PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_2, 6, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_v_data));
    PyTuple_SET_ITEM(__pyx_t_2, 7, ((PyObject *)__pyx_v_data));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
    __Pyx_INCREF(((PyObject *)__pyx_v_shells));
    PyTuple_SET_ITEM(__pyx_t_2, 8, ((PyObject *)__pyx_v_shells));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_shells));
    __Pyx_INCREF(((PyObject *)__pyx_v_image));
    PyTuple_SET_ITEM(__pyx_t_2, 9, ((PyObject *)__pyx_v_image));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_image));
    __pyx_t_1 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_u);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_shells);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_image);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_v);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_ug);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_data);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.PlaneVoxelIntegration");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_u);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_shells);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_image);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_v);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_ug);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_data);
  __pyx_L2:;
  __Pyx_DECREF(__pyx_v_intersect_t);
  __Pyx_DECREF(__pyx_v_dt_tolerance);
  __Pyx_XDECREF((PyObject *)__pyx_v_u);
  __Pyx_DECREF((PyObject *)__pyx_v_left_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_right_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_dx);
  __Pyx_DECREF((PyObject *)__pyx_v_ug);
  __Pyx_DECREF((PyObject *)__pyx_v_v);
  __Pyx_DECREF((PyObject *)__pyx_v_image);
  __Pyx_DECREF((PyObject *)__pyx_v_data);
  __Pyx_DECREF((PyObject *)__pyx_v_shells);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":252
 * @cython.wraparound(False)
 * @cython.boundscheck(False)
 * def integrate_ray(np.ndarray[np.float64_t, ndim=1] u,             # <<<<<<<<<<<<<<
 *                   np.ndarray[np.float64_t, ndim=1] v,
 *                   np.ndarray[np.float64_t, ndim=1] left_edge,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_integrate_ray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_integrate_ray(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_u = 0;
  PyArrayObject *__pyx_v_v = 0;
  PyArrayObject *__pyx_v_left_edge = 0;
  PyArrayObject *__pyx_v_right_edge = 0;
  PyArrayObject *__pyx_v_dx = 0;
  int __pyx_v_nshells;
  int __pyx_v_ind;
  PyArrayObject *__pyx_v_data = 0;
  PyArrayObject *__pyx_v_shells = 0;
  PyArrayObject *__pyx_v_image = 0;
  int __pyx_v_step[3];
  int __pyx_v_x;
  int __pyx_v_y;
  int __pyx_v_i;
  int __pyx_v_n;
  __pyx_t_5numpy_float64_t __pyx_v_intersect_t;
  __pyx_t_5numpy_float64_t __pyx_v_dt_tolerance;
  __pyx_t_5numpy_float64_t __pyx_v_tl;
  __pyx_t_5numpy_float64_t __pyx_v_tr;
  __pyx_t_5numpy_float64_t __pyx_v_enter_t;
  __pyx_t_5numpy_int64_t __pyx_v_cur_ind[3];
  __pyx_t_5numpy_float64_t __pyx_v_tdelta[3];
  __pyx_t_5numpy_float64_t __pyx_v_tmax[3];
  __pyx_t_5numpy_float64_t __pyx_v_intersect[3];
  __pyx_t_5numpy_float64_t __pyx_v_dt;
  __pyx_t_5numpy_float64_t __pyx_v_dv;
  __pyx_t_5numpy_float64_t __pyx_v_dist;
  __pyx_t_5numpy_float64_t __pyx_v_alpha;
  __pyx_t_5numpy_float64_t __pyx_v_one;
  int __pyx_v_dims[3];
  __pyx_t_5numpy_float64_t __pyx_v_temp_x;
  __pyx_t_5numpy_float64_t __pyx_v_temp_y;
  int __pyx_v_ncells;
  Py_buffer __pyx_bstruct_image;
  Py_ssize_t __pyx_bstride_0_image = 0;
  Py_ssize_t __pyx_bstride_1_image = 0;
  Py_ssize_t __pyx_bshape_0_image = 0;
  Py_ssize_t __pyx_bshape_1_image = 0;
  Py_buffer __pyx_bstruct_shells;
  Py_ssize_t __pyx_bstride_0_shells = 0;
  Py_ssize_t __pyx_bstride_1_shells = 0;
  Py_ssize_t __pyx_bshape_0_shells = 0;
  Py_ssize_t __pyx_bshape_1_shells = 0;
  Py_buffer __pyx_bstruct_right_edge;
  Py_ssize_t __pyx_bstride_0_right_edge = 0;
  Py_ssize_t __pyx_bshape_0_right_edge = 0;
  Py_buffer __pyx_bstruct_left_edge;
  Py_ssize_t __pyx_bstride_0_left_edge = 0;
  Py_ssize_t __pyx_bshape_0_left_edge = 0;
  Py_buffer __pyx_bstruct_dx;
  Py_ssize_t __pyx_bstride_0_dx = 0;
  Py_ssize_t __pyx_bshape_0_dx = 0;
  Py_buffer __pyx_bstruct_data;
  Py_ssize_t __pyx_bstride_0_data = 0;
  Py_ssize_t __pyx_bstride_1_data = 0;
  Py_ssize_t __pyx_bstride_2_data = 0;
  Py_ssize_t __pyx_bshape_0_data = 0;
  Py_ssize_t __pyx_bshape_1_data = 0;
  Py_ssize_t __pyx_bshape_2_data = 0;
  Py_buffer __pyx_bstruct_u;
  Py_ssize_t __pyx_bstride_0_u = 0;
  Py_ssize_t __pyx_bshape_0_u = 0;
  Py_buffer __pyx_bstruct_v;
  Py_ssize_t __pyx_bstride_0_v = 0;
  Py_ssize_t __pyx_bshape_0_v = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  int __pyx_t_20;
  int __pyx_t_21;
  int __pyx_t_22;
  int __pyx_t_23;
  int __pyx_t_24;
  int __pyx_t_25;
  int __pyx_t_26;
  int __pyx_t_27;
  int __pyx_t_28;
  int __pyx_t_29;
  int __pyx_t_30;
  int __pyx_t_31;
  long __pyx_t_32;
  long __pyx_t_33;
  __pyx_t_5numpy_float64_t __pyx_t_34;
  long __pyx_t_35;
  long __pyx_t_36;
  long __pyx_t_37;
  long __pyx_t_38;
  long __pyx_t_39;
  long __pyx_t_40;
  long __pyx_t_41;
  int __pyx_t_42;
  int __pyx_t_43;
  PyObject *__pyx_t_44 = NULL;
  PyObject *__pyx_t_45 = NULL;
  int __pyx_t_46;
  int __pyx_t_47;
  int __pyx_t_48;
  PyObject *__pyx_t_49 = NULL;
  __pyx_t_5numpy_int64_t __pyx_t_50;
  int __pyx_t_51;
  int __pyx_t_52;
  int __pyx_t_53;
  int __pyx_t_54;
  int __pyx_t_55;
  int __pyx_t_56;
  int __pyx_t_57;
  int __pyx_t_58;
  int __pyx_t_59;
  int __pyx_t_60;
  int __pyx_t_61;
  int __pyx_t_62;
  int __pyx_t_63;
  int __pyx_t_64;
  __pyx_t_5numpy_int64_t __pyx_t_65;
  __pyx_t_5numpy_int64_t __pyx_t_66;
  long __pyx_t_67;
  __pyx_t_5numpy_int64_t __pyx_t_68;
  int __pyx_t_69;
  int __pyx_t_70;
  int __pyx_t_71;
  long __pyx_t_72;
  int __pyx_t_73;
  long __pyx_t_74;
  int __pyx_t_75;
  long __pyx_t_76;
  int __pyx_t_77;
  long __pyx_t_78;
  int __pyx_t_79;
  long __pyx_t_80;
  int __pyx_t_81;
  long __pyx_t_82;
  int __pyx_t_83;
  long __pyx_t_84;
  int __pyx_t_85;
  long __pyx_t_86;
  int __pyx_t_87;
  long __pyx_t_88;
  int __pyx_t_89;
  long __pyx_t_90;
  int __pyx_t_91;
  long __pyx_t_92;
  int __pyx_t_93;
  long __pyx_t_94;
  __pyx_t_5numpy_int64_t __pyx_t_95;
  __pyx_t_5numpy_int64_t __pyx_t_96;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__u,&__pyx_n_s__v,&__pyx_n_s__left_edge,&__pyx_n_s__right_edge,&__pyx_n_s__dx,&__pyx_n_s__nshells,&__pyx_n_s__ind,&__pyx_n_s__data,&__pyx_n_s__shells,&__pyx_n_s__image,0};
  __Pyx_RefNannySetupContext("integrate_ray");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
      case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__u);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__v);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("integrate_ray", 1, 10, 10, 1); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__left_edge);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("integrate_ray", 1, 10, 10, 2); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__right_edge);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("integrate_ray", 1, 10, 10, 3); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dx);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("integrate_ray", 1, 10, 10, 4); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nshells);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("integrate_ray", 1, 10, 10, 5); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ind);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("integrate_ray", 1, 10, 10, 6); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  7:
      values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
      if (likely(values[7])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("integrate_ray", 1, 10, 10, 7); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  8:
      values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__shells);
      if (likely(values[8])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("integrate_ray", 1, 10, 10, 8); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  9:
      values[9] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__image);
      if (likely(values[9])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("integrate_ray", 1, 10, 10, 9); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "integrate_ray") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_u = ((PyArrayObject *)values[0]);
    __pyx_v_v = ((PyArrayObject *)values[1]);
    __pyx_v_left_edge = ((PyArrayObject *)values[2]);
    __pyx_v_right_edge = ((PyArrayObject *)values[3]);
    __pyx_v_dx = ((PyArrayObject *)values[4]);
    __pyx_v_nshells = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_nshells == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_ind = __Pyx_PyInt_AsInt(values[6]); if (unlikely((__pyx_v_ind == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_data = ((PyArrayObject *)values[7]);
    __pyx_v_shells = ((PyArrayObject *)values[8]);
    __pyx_v_image = ((PyArrayObject *)values[9]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 10) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_u = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_v = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_left_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_right_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_dx = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_nshells = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 5)); if (unlikely((__pyx_v_nshells == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_ind = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 6)); if (unlikely((__pyx_v_ind == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_data = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 7));
    __pyx_v_shells = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 8));
    __pyx_v_image = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 9));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("integrate_ray", 1, 10, 10, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.integrate_ray");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_u);
  __Pyx_INCREF((PyObject *)__pyx_v_v);
  __Pyx_INCREF((PyObject *)__pyx_v_left_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_right_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_dx);
  __Pyx_INCREF((PyObject *)__pyx_v_data);
  __Pyx_INCREF((PyObject *)__pyx_v_shells);
  __Pyx_INCREF((PyObject *)__pyx_v_image);
  __pyx_bstruct_u.buf = NULL;
  __pyx_bstruct_v.buf = NULL;
  __pyx_bstruct_left_edge.buf = NULL;
  __pyx_bstruct_right_edge.buf = NULL;
  __pyx_bstruct_dx.buf = NULL;
  __pyx_bstruct_data.buf = NULL;
  __pyx_bstruct_shells.buf = NULL;
  __pyx_bstruct_image.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_u), __pyx_ptype_5numpy_ndarray, 1, "u", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_v), __pyx_ptype_5numpy_ndarray, 1, "v", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_left_edge), __pyx_ptype_5numpy_ndarray, 1, "left_edge", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_right_edge), __pyx_ptype_5numpy_ndarray, 1, "right_edge", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dx), __pyx_ptype_5numpy_ndarray, 1, "dx", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), __pyx_ptype_5numpy_ndarray, 1, "data", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shells), __pyx_ptype_5numpy_ndarray, 1, "shells", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_image), __pyx_ptype_5numpy_ndarray, 1, "image", 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_u, (PyObject*)__pyx_v_u, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_u = __pyx_bstruct_u.strides[0];
  __pyx_bshape_0_u = __pyx_bstruct_u.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_v, (PyObject*)__pyx_v_v, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_v = __pyx_bstruct_v.strides[0];
  __pyx_bshape_0_v = __pyx_bstruct_v.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_left_edge, (PyObject*)__pyx_v_left_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_left_edge = __pyx_bstruct_left_edge.strides[0];
  __pyx_bshape_0_left_edge = __pyx_bstruct_left_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_right_edge, (PyObject*)__pyx_v_right_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_right_edge = __pyx_bstruct_right_edge.strides[0];
  __pyx_bshape_0_right_edge = __pyx_bstruct_right_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dx, (PyObject*)__pyx_v_dx, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_dx = __pyx_bstruct_dx.strides[0];
  __pyx_bshape_0_dx = __pyx_bstruct_dx.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_data, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_data = __pyx_bstruct_data.strides[0]; __pyx_bstride_1_data = __pyx_bstruct_data.strides[1]; __pyx_bstride_2_data = __pyx_bstruct_data.strides[2];
  __pyx_bshape_0_data = __pyx_bstruct_data.shape[0]; __pyx_bshape_1_data = __pyx_bstruct_data.shape[1]; __pyx_bshape_2_data = __pyx_bstruct_data.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_shells, (PyObject*)__pyx_v_shells, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_shells = __pyx_bstruct_shells.strides[0]; __pyx_bstride_1_shells = __pyx_bstruct_shells.strides[1];
  __pyx_bshape_0_shells = __pyx_bstruct_shells.shape[0]; __pyx_bshape_1_shells = __pyx_bstruct_shells.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_image, (PyObject*)__pyx_v_image, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_image = __pyx_bstruct_image.strides[0]; __pyx_bstride_1_image = __pyx_bstruct_image.strides[1];
  __pyx_bshape_0_image = __pyx_bstruct_image.shape[0]; __pyx_bshape_1_image = __pyx_bstruct_image.shape[1];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":262
 *                   np.ndarray[np.float64_t, ndim=2] image):
 *     cdef int step[3], x, y, i, n
 *     cdef np.float64_t intersect_t = 1             # <<<<<<<<<<<<<<
 *     cdef np.float64_t dt_tolerance = 1e-6
 *     cdef np.float64_t tl, tr, enter_t, exit_t
 */
  __pyx_v_intersect_t = 1;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":263
 *     cdef int step[3], x, y, i, n
 *     cdef np.float64_t intersect_t = 1
 *     cdef np.float64_t dt_tolerance = 1e-6             # <<<<<<<<<<<<<<
 *     cdef np.float64_t tl, tr, enter_t, exit_t
 *     cdef np.int64_t cur_ind[3]
 */
  __pyx_v_dt_tolerance = 9.9999999999999995e-07;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":271
 *     cdef np.float64_t dt, dv
 *     cdef np.float64_t dist, alpha
 *     cdef np.float64_t one = 1.0             # <<<<<<<<<<<<<<
 *     cdef int dims[3]
 *     cdef np.float64_t rgba[4], temp_x, temp_y
 */
  __pyx_v_one = 1.0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":274
 *     cdef int dims[3]
 *     cdef np.float64_t rgba[4], temp_x, temp_y
 *     for i in range(3):             # <<<<<<<<<<<<<<
 *         # As long as we're iterating, set some other stuff, too
 *         dims[i] = data.shape[i]
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":276
 *     for i in range(3):
 *         # As long as we're iterating, set some other stuff, too
 *         dims[i] = data.shape[i]             # <<<<<<<<<<<<<<
 *         if(v[i] < 0): step[i] = -1
 *         else: step[i] = 1
 */
    (__pyx_v_dims[__pyx_v_i]) = (__pyx_v_data->dimensions[__pyx_v_i]);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":277
 *         # As long as we're iterating, set some other stuff, too
 *         dims[i] = data.shape[i]
 *         if(v[i] < 0): step[i] = -1             # <<<<<<<<<<<<<<
 *         else: step[i] = 1
 *         x = (i+1)%3
 */
    __pyx_t_2 = __pyx_v_i;
    __pyx_t_3 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_2, __pyx_bstride_0_v)) < 0);
    if (__pyx_t_3) {
      (__pyx_v_step[__pyx_v_i]) = -1;
      goto __pyx_L8;
    }
    /*else*/ {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":278
 *         dims[i] = data.shape[i]
 *         if(v[i] < 0): step[i] = -1
 *         else: step[i] = 1             # <<<<<<<<<<<<<<
 *         x = (i+1)%3
 *         y = (i+2)%3
 */
      (__pyx_v_step[__pyx_v_i]) = 1;
    }
    __pyx_L8:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":279
 *         if(v[i] < 0): step[i] = -1
 *         else: step[i] = 1
 *         x = (i+1)%3             # <<<<<<<<<<<<<<
 *         y = (i+2)%3
 *         tl = (left_edge[i] - u[i])/v[i]
 */
    __pyx_v_x = ((__pyx_v_i + 1) % 3);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":280
 *         else: step[i] = 1
 *         x = (i+1)%3
 *         y = (i+2)%3             # <<<<<<<<<<<<<<
 *         tl = (left_edge[i] - u[i])/v[i]
 *         tr = (right_edge[i] - u[i])/v[i]
 */
    __pyx_v_y = ((__pyx_v_i + 2) % 3);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":281
 *         x = (i+1)%3
 *         y = (i+2)%3
 *         tl = (left_edge[i] - u[i])/v[i]             # <<<<<<<<<<<<<<
 *         tr = (right_edge[i] - u[i])/v[i]
 *         temp_x = (u[x] + tl*v[x])
 */
    __pyx_t_4 = __pyx_v_i;
    __pyx_t_5 = __pyx_v_i;
    __pyx_t_6 = __pyx_v_i;
    __pyx_v_tl = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_4, __pyx_bstride_0_left_edge)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_5, __pyx_bstride_0_u))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_6, __pyx_bstride_0_v)));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":282
 *         y = (i+2)%3
 *         tl = (left_edge[i] - u[i])/v[i]
 *         tr = (right_edge[i] - u[i])/v[i]             # <<<<<<<<<<<<<<
 *         temp_x = (u[x] + tl*v[x])
 *         temp_y = (u[y] + tl*v[y])
 */
    __pyx_t_7 = __pyx_v_i;
    __pyx_t_8 = __pyx_v_i;
    __pyx_t_9 = __pyx_v_i;
    __pyx_v_tr = (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_7, __pyx_bstride_0_right_edge)) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_8, __pyx_bstride_0_u))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_9, __pyx_bstride_0_v)));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":283
 *         tl = (left_edge[i] - u[i])/v[i]
 *         tr = (right_edge[i] - u[i])/v[i]
 *         temp_x = (u[x] + tl*v[x])             # <<<<<<<<<<<<<<
 *         temp_y = (u[y] + tl*v[y])
 *         if (left_edge[x] <= temp_x) and (temp_x <= right_edge[x]) and \
 */
    __pyx_t_10 = __pyx_v_x;
    __pyx_t_11 = __pyx_v_x;
    __pyx_v_temp_x = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_10, __pyx_bstride_0_u)) + (__pyx_v_tl * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_11, __pyx_bstride_0_v))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":284
 *         tr = (right_edge[i] - u[i])/v[i]
 *         temp_x = (u[x] + tl*v[x])
 *         temp_y = (u[y] + tl*v[y])             # <<<<<<<<<<<<<<
 *         if (left_edge[x] <= temp_x) and (temp_x <= right_edge[x]) and \
 *            (left_edge[y] <= temp_y) and (temp_y <= right_edge[y]) and \
 */
    __pyx_t_12 = __pyx_v_y;
    __pyx_t_13 = __pyx_v_y;
    __pyx_v_temp_y = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_12, __pyx_bstride_0_u)) + (__pyx_v_tl * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_13, __pyx_bstride_0_v))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":285
 *         temp_x = (u[x] + tl*v[x])
 *         temp_y = (u[y] + tl*v[y])
 *         if (left_edge[x] <= temp_x) and (temp_x <= right_edge[x]) and \             # <<<<<<<<<<<<<<
 *            (left_edge[y] <= temp_y) and (temp_y <= right_edge[y]) and \
 *            (0.0 <= tl) and (tl < intersect_t):
 */
    __pyx_t_14 = __pyx_v_x;
    __pyx_t_3 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_14, __pyx_bstride_0_left_edge)) <= __pyx_v_temp_x);
    if (__pyx_t_3) {
      __pyx_t_15 = __pyx_v_x;
      __pyx_t_16 = (__pyx_v_temp_x <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_15, __pyx_bstride_0_right_edge)));
      if (__pyx_t_16) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":286
 *         temp_y = (u[y] + tl*v[y])
 *         if (left_edge[x] <= temp_x) and (temp_x <= right_edge[x]) and \
 *            (left_edge[y] <= temp_y) and (temp_y <= right_edge[y]) and \             # <<<<<<<<<<<<<<
 *            (0.0 <= tl) and (tl < intersect_t):
 *             intersect_t = tl
 */
        __pyx_t_17 = __pyx_v_y;
        __pyx_t_18 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_17, __pyx_bstride_0_left_edge)) <= __pyx_v_temp_y);
        if (__pyx_t_18) {
          __pyx_t_19 = __pyx_v_y;
          __pyx_t_20 = (__pyx_v_temp_y <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_19, __pyx_bstride_0_right_edge)));
          if (__pyx_t_20) {

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":287
 *         if (left_edge[x] <= temp_x) and (temp_x <= right_edge[x]) and \
 *            (left_edge[y] <= temp_y) and (temp_y <= right_edge[y]) and \
 *            (0.0 <= tl) and (tl < intersect_t):             # <<<<<<<<<<<<<<
 *             intersect_t = tl
 *         temp_x = (u[x] + tr*v[x])
 */
            __pyx_t_21 = (0.0 <= __pyx_v_tl);
            if (__pyx_t_21) {
              __pyx_t_22 = (__pyx_v_tl < __pyx_v_intersect_t);
              __pyx_t_23 = __pyx_t_22;
            } else {
              __pyx_t_23 = __pyx_t_21;
            }
            __pyx_t_21 = __pyx_t_23;
          } else {
            __pyx_t_21 = __pyx_t_20;
          }
          __pyx_t_20 = __pyx_t_21;
        } else {
          __pyx_t_20 = __pyx_t_18;
        }
        __pyx_t_18 = __pyx_t_20;
      } else {
        __pyx_t_18 = __pyx_t_16;
      }
      __pyx_t_16 = __pyx_t_18;
    } else {
      __pyx_t_16 = __pyx_t_3;
    }
    if (__pyx_t_16) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":288
 *            (left_edge[y] <= temp_y) and (temp_y <= right_edge[y]) and \
 *            (0.0 <= tl) and (tl < intersect_t):
 *             intersect_t = tl             # <<<<<<<<<<<<<<
 *         temp_x = (u[x] + tr*v[x])
 *         temp_y = (u[y] + tr*v[y])
 */
      __pyx_v_intersect_t = __pyx_v_tl;
      goto __pyx_L9;
    }
    __pyx_L9:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":289
 *            (0.0 <= tl) and (tl < intersect_t):
 *             intersect_t = tl
 *         temp_x = (u[x] + tr*v[x])             # <<<<<<<<<<<<<<
 *         temp_y = (u[y] + tr*v[y])
 *         if (left_edge[x] <= temp_x) and (temp_x <= right_edge[x]) and \
 */
    __pyx_t_24 = __pyx_v_x;
    __pyx_t_25 = __pyx_v_x;
    __pyx_v_temp_x = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_24, __pyx_bstride_0_u)) + (__pyx_v_tr * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_25, __pyx_bstride_0_v))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":290
 *             intersect_t = tl
 *         temp_x = (u[x] + tr*v[x])
 *         temp_y = (u[y] + tr*v[y])             # <<<<<<<<<<<<<<
 *         if (left_edge[x] <= temp_x) and (temp_x <= right_edge[x]) and \
 *            (left_edge[y] <= temp_y) and (temp_y <= right_edge[y]) and \
 */
    __pyx_t_26 = __pyx_v_y;
    __pyx_t_27 = __pyx_v_y;
    __pyx_v_temp_y = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_26, __pyx_bstride_0_u)) + (__pyx_v_tr * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_27, __pyx_bstride_0_v))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":291
 *         temp_x = (u[x] + tr*v[x])
 *         temp_y = (u[y] + tr*v[y])
 *         if (left_edge[x] <= temp_x) and (temp_x <= right_edge[x]) and \             # <<<<<<<<<<<<<<
 *            (left_edge[y] <= temp_y) and (temp_y <= right_edge[y]) and \
 *            (0.0 <= tr) and (tr < intersect_t):
 */
    __pyx_t_28 = __pyx_v_x;
    __pyx_t_16 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_28, __pyx_bstride_0_left_edge)) <= __pyx_v_temp_x);
    if (__pyx_t_16) {
      __pyx_t_29 = __pyx_v_x;
      __pyx_t_3 = (__pyx_v_temp_x <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_29, __pyx_bstride_0_right_edge)));
      if (__pyx_t_3) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":292
 *         temp_y = (u[y] + tr*v[y])
 *         if (left_edge[x] <= temp_x) and (temp_x <= right_edge[x]) and \
 *            (left_edge[y] <= temp_y) and (temp_y <= right_edge[y]) and \             # <<<<<<<<<<<<<<
 *            (0.0 <= tr) and (tr < intersect_t):
 *             intersect_t = tr
 */
        __pyx_t_30 = __pyx_v_y;
        __pyx_t_18 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_30, __pyx_bstride_0_left_edge)) <= __pyx_v_temp_y);
        if (__pyx_t_18) {
          __pyx_t_31 = __pyx_v_y;
          __pyx_t_20 = (__pyx_v_temp_y <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_31, __pyx_bstride_0_right_edge)));
          if (__pyx_t_20) {

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":293
 *         if (left_edge[x] <= temp_x) and (temp_x <= right_edge[x]) and \
 *            (left_edge[y] <= temp_y) and (temp_y <= right_edge[y]) and \
 *            (0.0 <= tr) and (tr < intersect_t):             # <<<<<<<<<<<<<<
 *             intersect_t = tr
 *     # if fully enclosed
 */
            __pyx_t_21 = (0.0 <= __pyx_v_tr);
            if (__pyx_t_21) {
              __pyx_t_23 = (__pyx_v_tr < __pyx_v_intersect_t);
              __pyx_t_22 = __pyx_t_23;
            } else {
              __pyx_t_22 = __pyx_t_21;
            }
            __pyx_t_21 = __pyx_t_22;
          } else {
            __pyx_t_21 = __pyx_t_20;
          }
          __pyx_t_20 = __pyx_t_21;
        } else {
          __pyx_t_20 = __pyx_t_18;
        }
        __pyx_t_18 = __pyx_t_20;
      } else {
        __pyx_t_18 = __pyx_t_3;
      }
      __pyx_t_3 = __pyx_t_18;
    } else {
      __pyx_t_3 = __pyx_t_16;
    }
    if (__pyx_t_3) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":294
 *            (left_edge[y] <= temp_y) and (temp_y <= right_edge[y]) and \
 *            (0.0 <= tr) and (tr < intersect_t):
 *             intersect_t = tr             # <<<<<<<<<<<<<<
 *     # if fully enclosed
 *     if (left_edge[0] <= u[0] <= right_edge[0]) and \
 */
      __pyx_v_intersect_t = __pyx_v_tr;
      goto __pyx_L10;
    }
    __pyx_L10:;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":296
 *             intersect_t = tr
 *     # if fully enclosed
 *     if (left_edge[0] <= u[0] <= right_edge[0]) and \             # <<<<<<<<<<<<<<
 *        (left_edge[1] <= u[1] <= right_edge[1]) and \
 *        (left_edge[2] <= u[2] <= right_edge[2]):
 */
  __pyx_t_32 = 0;
  __pyx_t_33 = 0;
  __pyx_t_34 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_33, __pyx_bstride_0_u));
  __pyx_t_3 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_32, __pyx_bstride_0_left_edge)) <= __pyx_t_34);
  if (__pyx_t_3) {
    __pyx_t_35 = 0;
    __pyx_t_3 = (__pyx_t_34 <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_35, __pyx_bstride_0_right_edge)));
  }
  if (__pyx_t_3) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":297
 *     # if fully enclosed
 *     if (left_edge[0] <= u[0] <= right_edge[0]) and \
 *        (left_edge[1] <= u[1] <= right_edge[1]) and \             # <<<<<<<<<<<<<<
 *        (left_edge[2] <= u[2] <= right_edge[2]):
 *         intersect_t = 0.0
 */
    __pyx_t_36 = 1;
    __pyx_t_37 = 1;
    __pyx_t_34 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_37, __pyx_bstride_0_u));
    __pyx_t_16 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_36, __pyx_bstride_0_left_edge)) <= __pyx_t_34);
    if (__pyx_t_16) {
      __pyx_t_38 = 1;
      __pyx_t_16 = (__pyx_t_34 <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_38, __pyx_bstride_0_right_edge)));
    }
    if (__pyx_t_16) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":298
 *     if (left_edge[0] <= u[0] <= right_edge[0]) and \
 *        (left_edge[1] <= u[1] <= right_edge[1]) and \
 *        (left_edge[2] <= u[2] <= right_edge[2]):             # <<<<<<<<<<<<<<
 *         intersect_t = 0.0
 *     if not (0 <= intersect_t <= 1):
 */
      __pyx_t_39 = 2;
      __pyx_t_40 = 2;
      __pyx_t_34 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_40, __pyx_bstride_0_u));
      __pyx_t_18 = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_39, __pyx_bstride_0_left_edge)) <= __pyx_t_34);
      if (__pyx_t_18) {
        __pyx_t_41 = 2;
        __pyx_t_18 = (__pyx_t_34 <= (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_41, __pyx_bstride_0_right_edge)));
      }
      __pyx_t_20 = __pyx_t_18;
    } else {
      __pyx_t_20 = __pyx_t_16;
    }
    __pyx_t_16 = __pyx_t_20;
  } else {
    __pyx_t_16 = __pyx_t_3;
  }
  if (__pyx_t_16) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":299
 *        (left_edge[1] <= u[1] <= right_edge[1]) and \
 *        (left_edge[2] <= u[2] <= right_edge[2]):
 *         intersect_t = 0.0             # <<<<<<<<<<<<<<
 *     if not (0 <= intersect_t <= 1):
 *         #print "Returning: intersect_t ==", intersect_t
 */
    __pyx_v_intersect_t = 0.0;
    goto __pyx_L11;
  }
  __pyx_L11:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":300
 *        (left_edge[2] <= u[2] <= right_edge[2]):
 *         intersect_t = 0.0
 *     if not (0 <= intersect_t <= 1):             # <<<<<<<<<<<<<<
 *         #print "Returning: intersect_t ==", intersect_t
 *         return
 */
  __pyx_t_16 = (0 <= __pyx_v_intersect_t);
  if (__pyx_t_16) {
    __pyx_t_16 = (__pyx_v_intersect_t <= 1);
  }
  __pyx_t_3 = (!__pyx_t_16);
  if (__pyx_t_3) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":302
 *     if not (0 <= intersect_t <= 1):
 *         #print "Returning: intersect_t ==", intersect_t
 *         return             # <<<<<<<<<<<<<<
 *     # Now get the indices of the intersection
 *     for i in range(3): intersect[i] = u[i] + intersect_t * v[i]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":304
 *         return
 *     # Now get the indices of the intersection
 *     for i in range(3): intersect[i] = u[i] + intersect_t * v[i]             # <<<<<<<<<<<<<<
 *     cdef int ncells = 0
 *     for i in range(3):
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;
    __pyx_t_42 = __pyx_v_i;
    __pyx_t_43 = __pyx_v_i;
    (__pyx_v_intersect[__pyx_v_i]) = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_42, __pyx_bstride_0_u)) + (__pyx_v_intersect_t * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_43, __pyx_bstride_0_v))));
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":305
 *     # Now get the indices of the intersection
 *     for i in range(3): intersect[i] = u[i] + intersect_t * v[i]
 *     cdef int ncells = 0             # <<<<<<<<<<<<<<
 *     for i in range(3):
 *         cur_ind[i] = np.floor((intersect[i] + 1e-8*dx[i] - left_edge[i])/dx[i])
 */
  __pyx_v_ncells = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":306
 *     for i in range(3): intersect[i] = u[i] + intersect_t * v[i]
 *     cdef int ncells = 0
 *     for i in range(3):             # <<<<<<<<<<<<<<
 *         cur_ind[i] = np.floor((intersect[i] + 1e-8*dx[i] - left_edge[i])/dx[i])
 *         tmax[i] = (((cur_ind[i]+step[i])*dx[i])+left_edge[i]-u[i])/v[i]
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":307
 *     cdef int ncells = 0
 *     for i in range(3):
 *         cur_ind[i] = np.floor((intersect[i] + 1e-8*dx[i] - left_edge[i])/dx[i])             # <<<<<<<<<<<<<<
 *         tmax[i] = (((cur_ind[i]+step[i])*dx[i])+left_edge[i]-u[i])/v[i]
 *         if cur_ind[i] == dims[i] and step[i] < 0:
 */
    __pyx_t_44 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_44)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_44);
    __pyx_t_45 = PyObject_GetAttr(__pyx_t_44, __pyx_n_s__floor); if (unlikely(!__pyx_t_45)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_45);
    __Pyx_DECREF(__pyx_t_44); __pyx_t_44 = 0;
    __pyx_t_46 = __pyx_v_i;
    __pyx_t_47 = __pyx_v_i;
    __pyx_t_48 = __pyx_v_i;
    __pyx_t_44 = PyFloat_FromDouble(((((__pyx_v_intersect[__pyx_v_i]) + (1e-08 * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_46, __pyx_bstride_0_dx)))) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_47, __pyx_bstride_0_left_edge))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_48, __pyx_bstride_0_dx)))); if (unlikely(!__pyx_t_44)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_44);
    __pyx_t_49 = PyTuple_New(1); if (unlikely(!__pyx_t_49)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_49);
    PyTuple_SET_ITEM(__pyx_t_49, 0, __pyx_t_44);
    __Pyx_GIVEREF(__pyx_t_44);
    __pyx_t_44 = 0;
    __pyx_t_44 = PyObject_Call(__pyx_t_45, __pyx_t_49, NULL); if (unlikely(!__pyx_t_44)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_44);
    __Pyx_DECREF(__pyx_t_45); __pyx_t_45 = 0;
    __Pyx_DECREF(__pyx_t_49); __pyx_t_49 = 0;
    __pyx_t_50 = __Pyx_PyInt_from_py_npy_int64(__pyx_t_44); if (unlikely((__pyx_t_50 == (npy_int64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_44); __pyx_t_44 = 0;
    (__pyx_v_cur_ind[__pyx_v_i]) = __pyx_t_50;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":308
 *     for i in range(3):
 *         cur_ind[i] = np.floor((intersect[i] + 1e-8*dx[i] - left_edge[i])/dx[i])
 *         tmax[i] = (((cur_ind[i]+step[i])*dx[i])+left_edge[i]-u[i])/v[i]             # <<<<<<<<<<<<<<
 *         if cur_ind[i] == dims[i] and step[i] < 0:
 *             cur_ind[i] = dims[i] - 1
 */
    __pyx_t_51 = __pyx_v_i;
    __pyx_t_52 = __pyx_v_i;
    __pyx_t_53 = __pyx_v_i;
    __pyx_t_54 = __pyx_v_i;
    (__pyx_v_tmax[__pyx_v_i]) = ((((((__pyx_v_cur_ind[__pyx_v_i]) + (__pyx_v_step[__pyx_v_i])) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_51, __pyx_bstride_0_dx))) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_52, __pyx_bstride_0_left_edge))) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_53, __pyx_bstride_0_u))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_54, __pyx_bstride_0_v)));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":309
 *         cur_ind[i] = np.floor((intersect[i] + 1e-8*dx[i] - left_edge[i])/dx[i])
 *         tmax[i] = (((cur_ind[i]+step[i])*dx[i])+left_edge[i]-u[i])/v[i]
 *         if cur_ind[i] == dims[i] and step[i] < 0:             # <<<<<<<<<<<<<<
 *             cur_ind[i] = dims[i] - 1
 *         if step[i] > 0: tmax[i] = (((cur_ind[i]+1)*dx[i])+left_edge[i]-u[i])/v[i]
 */
    __pyx_t_3 = ((__pyx_v_cur_ind[__pyx_v_i]) == (__pyx_v_dims[__pyx_v_i]));
    if (__pyx_t_3) {
      __pyx_t_16 = ((__pyx_v_step[__pyx_v_i]) < 0);
      __pyx_t_20 = __pyx_t_16;
    } else {
      __pyx_t_20 = __pyx_t_3;
    }
    if (__pyx_t_20) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":310
 *         tmax[i] = (((cur_ind[i]+step[i])*dx[i])+left_edge[i]-u[i])/v[i]
 *         if cur_ind[i] == dims[i] and step[i] < 0:
 *             cur_ind[i] = dims[i] - 1             # <<<<<<<<<<<<<<
 *         if step[i] > 0: tmax[i] = (((cur_ind[i]+1)*dx[i])+left_edge[i]-u[i])/v[i]
 *         if step[i] < 0: tmax[i] = (((cur_ind[i]+0)*dx[i])+left_edge[i]-u[i])/v[i]
 */
      (__pyx_v_cur_ind[__pyx_v_i]) = ((__pyx_v_dims[__pyx_v_i]) - 1);
      goto __pyx_L17;
    }
    __pyx_L17:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":311
 *         if cur_ind[i] == dims[i] and step[i] < 0:
 *             cur_ind[i] = dims[i] - 1
 *         if step[i] > 0: tmax[i] = (((cur_ind[i]+1)*dx[i])+left_edge[i]-u[i])/v[i]             # <<<<<<<<<<<<<<
 *         if step[i] < 0: tmax[i] = (((cur_ind[i]+0)*dx[i])+left_edge[i]-u[i])/v[i]
 *         tdelta[i] = (dx[i]/v[i])
 */
    __pyx_t_20 = ((__pyx_v_step[__pyx_v_i]) > 0);
    if (__pyx_t_20) {
      __pyx_t_55 = __pyx_v_i;
      __pyx_t_56 = __pyx_v_i;
      __pyx_t_57 = __pyx_v_i;
      __pyx_t_58 = __pyx_v_i;
      (__pyx_v_tmax[__pyx_v_i]) = ((((((__pyx_v_cur_ind[__pyx_v_i]) + 1) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_55, __pyx_bstride_0_dx))) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_56, __pyx_bstride_0_left_edge))) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_57, __pyx_bstride_0_u))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_58, __pyx_bstride_0_v)));
      goto __pyx_L18;
    }
    __pyx_L18:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":312
 *             cur_ind[i] = dims[i] - 1
 *         if step[i] > 0: tmax[i] = (((cur_ind[i]+1)*dx[i])+left_edge[i]-u[i])/v[i]
 *         if step[i] < 0: tmax[i] = (((cur_ind[i]+0)*dx[i])+left_edge[i]-u[i])/v[i]             # <<<<<<<<<<<<<<
 *         tdelta[i] = (dx[i]/v[i])
 *         if tdelta[i] < 0: tdelta[i] *= -1
 */
    __pyx_t_20 = ((__pyx_v_step[__pyx_v_i]) < 0);
    if (__pyx_t_20) {
      __pyx_t_59 = __pyx_v_i;
      __pyx_t_60 = __pyx_v_i;
      __pyx_t_61 = __pyx_v_i;
      __pyx_t_62 = __pyx_v_i;
      (__pyx_v_tmax[__pyx_v_i]) = ((((((__pyx_v_cur_ind[__pyx_v_i]) + 0) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_59, __pyx_bstride_0_dx))) + (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_60, __pyx_bstride_0_left_edge))) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_u.buf, __pyx_t_61, __pyx_bstride_0_u))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_62, __pyx_bstride_0_v)));
      goto __pyx_L19;
    }
    __pyx_L19:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":313
 *         if step[i] > 0: tmax[i] = (((cur_ind[i]+1)*dx[i])+left_edge[i]-u[i])/v[i]
 *         if step[i] < 0: tmax[i] = (((cur_ind[i]+0)*dx[i])+left_edge[i]-u[i])/v[i]
 *         tdelta[i] = (dx[i]/v[i])             # <<<<<<<<<<<<<<
 *         if tdelta[i] < 0: tdelta[i] *= -1
 *     # The variable intersect contains the point we first pierce the grid
 */
    __pyx_t_63 = __pyx_v_i;
    __pyx_t_64 = __pyx_v_i;
    (__pyx_v_tdelta[__pyx_v_i]) = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_63, __pyx_bstride_0_dx)) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_v.buf, __pyx_t_64, __pyx_bstride_0_v)));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":314
 *         if step[i] < 0: tmax[i] = (((cur_ind[i]+0)*dx[i])+left_edge[i]-u[i])/v[i]
 *         tdelta[i] = (dx[i]/v[i])
 *         if tdelta[i] < 0: tdelta[i] *= -1             # <<<<<<<<<<<<<<
 *     # The variable intersect contains the point we first pierce the grid
 *     enter_t = intersect_t
 */
    __pyx_t_20 = ((__pyx_v_tdelta[__pyx_v_i]) < 0);
    if (__pyx_t_20) {
      (__pyx_v_tdelta[__pyx_v_i]) *= -1;
      goto __pyx_L20;
    }
    __pyx_L20:;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":316
 *         if tdelta[i] < 0: tdelta[i] *= -1
 *     # The variable intersect contains the point we first pierce the grid
 *     enter_t = intersect_t             # <<<<<<<<<<<<<<
 *     if (not (0 <= cur_ind[0] < dims[0])) or \
 *        (not (0 <= cur_ind[1] < dims[1])) or \
 */
  __pyx_v_enter_t = __pyx_v_intersect_t;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":317
 *     # The variable intersect contains the point we first pierce the grid
 *     enter_t = intersect_t
 *     if (not (0 <= cur_ind[0] < dims[0])) or \             # <<<<<<<<<<<<<<
 *        (not (0 <= cur_ind[1] < dims[1])) or \
 *        (not (0 <= cur_ind[2] < dims[2])):
 */
  __pyx_t_50 = (__pyx_v_cur_ind[0]);
  __pyx_t_20 = (0 <= __pyx_t_50);
  if (__pyx_t_20) {
    __pyx_t_20 = (__pyx_t_50 < (__pyx_v_dims[0]));
  }
  __pyx_t_3 = (!__pyx_t_20);
  if (!__pyx_t_3) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":318
 *     enter_t = intersect_t
 *     if (not (0 <= cur_ind[0] < dims[0])) or \
 *        (not (0 <= cur_ind[1] < dims[1])) or \             # <<<<<<<<<<<<<<
 *        (not (0 <= cur_ind[2] < dims[2])):
 *         #print "Returning: cur_ind", cur_ind[0], cur_ind[1], cur_ind[2]
 */
    __pyx_t_50 = (__pyx_v_cur_ind[1]);
    __pyx_t_20 = (0 <= __pyx_t_50);
    if (__pyx_t_20) {
      __pyx_t_20 = (__pyx_t_50 < (__pyx_v_dims[1]));
    }
    __pyx_t_16 = (!__pyx_t_20);
    if (!__pyx_t_16) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":319
 *     if (not (0 <= cur_ind[0] < dims[0])) or \
 *        (not (0 <= cur_ind[1] < dims[1])) or \
 *        (not (0 <= cur_ind[2] < dims[2])):             # <<<<<<<<<<<<<<
 *         #print "Returning: cur_ind", cur_ind[0], cur_ind[1], cur_ind[2]
 *         #print "  dims:     ", dims[0], dims[1], dims[2]
 */
      __pyx_t_50 = (__pyx_v_cur_ind[2]);
      __pyx_t_20 = (0 <= __pyx_t_50);
      if (__pyx_t_20) {
        __pyx_t_20 = (__pyx_t_50 < (__pyx_v_dims[2]));
      }
      __pyx_t_18 = (!__pyx_t_20);
      __pyx_t_20 = __pyx_t_18;
    } else {
      __pyx_t_20 = __pyx_t_16;
    }
    __pyx_t_16 = __pyx_t_20;
  } else {
    __pyx_t_16 = __pyx_t_3;
  }
  if (__pyx_t_16) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":326
 *         #print "  u        :", u[0], u[1], u[2]
 *         #
 *         return             # <<<<<<<<<<<<<<
 *     #print cur_ind[0], dims[0], cur_ind[1], dims[1], cur_ind[2], dims[2]
 *     dv = data[cur_ind[0], cur_ind[1], cur_ind[2]]
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L21;
  }
  __pyx_L21:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":328
 *         return
 *     #print cur_ind[0], dims[0], cur_ind[1], dims[1], cur_ind[2], dims[2]
 *     dv = data[cur_ind[0], cur_ind[1], cur_ind[2]]             # <<<<<<<<<<<<<<
 *     #dt = 1e300
 *     while 1:
 */
  __pyx_t_50 = (__pyx_v_cur_ind[0]);
  __pyx_t_65 = (__pyx_v_cur_ind[1]);
  __pyx_t_66 = (__pyx_v_cur_ind[2]);
  __pyx_v_dv = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_data.buf, __pyx_t_50, __pyx_bstride_0_data, __pyx_t_65, __pyx_bstride_1_data, __pyx_t_66, __pyx_bstride_2_data));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":330
 *     dv = data[cur_ind[0], cur_ind[1], cur_ind[2]]
 *     #dt = 1e300
 *     while 1:             # <<<<<<<<<<<<<<
 *         if image[ind,3] >= 1.0: break
 *         if (not (0 <= cur_ind[0] < dims[0])) or \
 */
  while (1) {
    __pyx_t_16 = 1;
    if (!__pyx_t_16) break;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":331
 *     #dt = 1e300
 *     while 1:
 *         if image[ind,3] >= 1.0: break             # <<<<<<<<<<<<<<
 *         if (not (0 <= cur_ind[0] < dims[0])) or \
 *            (not (0 <= cur_ind[1] < dims[1])) or \
 */
    __pyx_t_1 = __pyx_v_ind;
    __pyx_t_67 = 3;
    __pyx_t_16 = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_image.buf, __pyx_t_1, __pyx_bstride_0_image, __pyx_t_67, __pyx_bstride_1_image)) >= 1.0);
    if (__pyx_t_16) {
      goto __pyx_L23_break;
      goto __pyx_L24;
    }
    __pyx_L24:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":332
 *     while 1:
 *         if image[ind,3] >= 1.0: break
 *         if (not (0 <= cur_ind[0] < dims[0])) or \             # <<<<<<<<<<<<<<
 *            (not (0 <= cur_ind[1] < dims[1])) or \
 *            (not (0 <= cur_ind[2] < dims[2])):
 */
    __pyx_t_68 = (__pyx_v_cur_ind[0]);
    __pyx_t_16 = (0 <= __pyx_t_68);
    if (__pyx_t_16) {
      __pyx_t_16 = (__pyx_t_68 < (__pyx_v_dims[0]));
    }
    __pyx_t_3 = (!__pyx_t_16);
    if (!__pyx_t_3) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":333
 *         if image[ind,3] >= 1.0: break
 *         if (not (0 <= cur_ind[0] < dims[0])) or \
 *            (not (0 <= cur_ind[1] < dims[1])) or \             # <<<<<<<<<<<<<<
 *            (not (0 <= cur_ind[2] < dims[2])):
 *             break
 */
      __pyx_t_68 = (__pyx_v_cur_ind[1]);
      __pyx_t_16 = (0 <= __pyx_t_68);
      if (__pyx_t_16) {
        __pyx_t_16 = (__pyx_t_68 < (__pyx_v_dims[1]));
      }
      __pyx_t_20 = (!__pyx_t_16);
      if (!__pyx_t_20) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":334
 *         if (not (0 <= cur_ind[0] < dims[0])) or \
 *            (not (0 <= cur_ind[1] < dims[1])) or \
 *            (not (0 <= cur_ind[2] < dims[2])):             # <<<<<<<<<<<<<<
 *             break
 *         # Do our transfer here
 */
        __pyx_t_68 = (__pyx_v_cur_ind[2]);
        __pyx_t_16 = (0 <= __pyx_t_68);
        if (__pyx_t_16) {
          __pyx_t_16 = (__pyx_t_68 < (__pyx_v_dims[2]));
        }
        __pyx_t_18 = (!__pyx_t_16);
        __pyx_t_16 = __pyx_t_18;
      } else {
        __pyx_t_16 = __pyx_t_20;
      }
      __pyx_t_20 = __pyx_t_16;
    } else {
      __pyx_t_20 = __pyx_t_3;
    }
    if (__pyx_t_20) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":335
 *            (not (0 <= cur_ind[1] < dims[1])) or \
 *            (not (0 <= cur_ind[2] < dims[2])):
 *             break             # <<<<<<<<<<<<<<
 *         # Do our transfer here
 *         for n in range(nshells):
 */
      goto __pyx_L23_break;
      goto __pyx_L25;
    }
    __pyx_L25:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":337
 *             break
 *         # Do our transfer here
 *         for n in range(nshells):             # <<<<<<<<<<<<<<
 *             dist = shells[n, 0] - dv
 *             if dist < shells[n,1]:
 */
    __pyx_t_69 = __pyx_v_nshells;
    for (__pyx_t_70 = 0; __pyx_t_70 < __pyx_t_69; __pyx_t_70+=1) {
      __pyx_v_n = __pyx_t_70;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":338
 *         # Do our transfer here
 *         for n in range(nshells):
 *             dist = shells[n, 0] - dv             # <<<<<<<<<<<<<<
 *             if dist < shells[n,1]:
 *                 dist = exp(-dist/8.0)
 */
      __pyx_t_71 = __pyx_v_n;
      __pyx_t_72 = 0;
      __pyx_v_dist = ((*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_71, __pyx_bstride_0_shells, __pyx_t_72, __pyx_bstride_1_shells)) - __pyx_v_dv);

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":339
 *         for n in range(nshells):
 *             dist = shells[n, 0] - dv
 *             if dist < shells[n,1]:             # <<<<<<<<<<<<<<
 *                 dist = exp(-dist/8.0)
 *                 alpha = (1.0 - shells[n,5])*shells[n,5]#*dt
 */
      __pyx_t_73 = __pyx_v_n;
      __pyx_t_74 = 1;
      __pyx_t_20 = (__pyx_v_dist < (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_73, __pyx_bstride_0_shells, __pyx_t_74, __pyx_bstride_1_shells)));
      if (__pyx_t_20) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":340
 *             dist = shells[n, 0] - dv
 *             if dist < shells[n,1]:
 *                 dist = exp(-dist/8.0)             # <<<<<<<<<<<<<<
 *                 alpha = (1.0 - shells[n,5])*shells[n,5]#*dt
 *                 image[ind,0] += alpha*shells[n,2]*dist
 */
        __pyx_v_dist = exp(((-__pyx_v_dist) / 8.0));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":341
 *             if dist < shells[n,1]:
 *                 dist = exp(-dist/8.0)
 *                 alpha = (1.0 - shells[n,5])*shells[n,5]#*dt             # <<<<<<<<<<<<<<
 *                 image[ind,0] += alpha*shells[n,2]*dist
 *                 image[ind,1] += alpha*shells[n,3]*dist
 */
        __pyx_t_75 = __pyx_v_n;
        __pyx_t_76 = 5;
        __pyx_t_77 = __pyx_v_n;
        __pyx_t_78 = 5;
        __pyx_v_alpha = ((1.0 - (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_75, __pyx_bstride_0_shells, __pyx_t_76, __pyx_bstride_1_shells))) * (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_77, __pyx_bstride_0_shells, __pyx_t_78, __pyx_bstride_1_shells)));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":342
 *                 dist = exp(-dist/8.0)
 *                 alpha = (1.0 - shells[n,5])*shells[n,5]#*dt
 *                 image[ind,0] += alpha*shells[n,2]*dist             # <<<<<<<<<<<<<<
 *                 image[ind,1] += alpha*shells[n,3]*dist
 *                 image[ind,2] += alpha*shells[n,4]*dist
 */
        __pyx_t_79 = __pyx_v_n;
        __pyx_t_80 = 2;
        __pyx_t_81 = __pyx_v_ind;
        __pyx_t_82 = 0;
        *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_image.buf, __pyx_t_81, __pyx_bstride_0_image, __pyx_t_82, __pyx_bstride_1_image) += ((__pyx_v_alpha * (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_79, __pyx_bstride_0_shells, __pyx_t_80, __pyx_bstride_1_shells))) * __pyx_v_dist);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":343
 *                 alpha = (1.0 - shells[n,5])*shells[n,5]#*dt
 *                 image[ind,0] += alpha*shells[n,2]*dist
 *                 image[ind,1] += alpha*shells[n,3]*dist             # <<<<<<<<<<<<<<
 *                 image[ind,2] += alpha*shells[n,4]*dist
 *                 image[ind,3] += alpha*shells[n,5]*dist
 */
        __pyx_t_83 = __pyx_v_n;
        __pyx_t_84 = 3;
        __pyx_t_85 = __pyx_v_ind;
        __pyx_t_86 = 1;
        *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_image.buf, __pyx_t_85, __pyx_bstride_0_image, __pyx_t_86, __pyx_bstride_1_image) += ((__pyx_v_alpha * (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_83, __pyx_bstride_0_shells, __pyx_t_84, __pyx_bstride_1_shells))) * __pyx_v_dist);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":344
 *                 image[ind,0] += alpha*shells[n,2]*dist
 *                 image[ind,1] += alpha*shells[n,3]*dist
 *                 image[ind,2] += alpha*shells[n,4]*dist             # <<<<<<<<<<<<<<
 *                 image[ind,3] += alpha*shells[n,5]*dist
 *                 #image[ind,i] += rgba[i]*dist*rgba[3]/dt
 */
        __pyx_t_87 = __pyx_v_n;
        __pyx_t_88 = 4;
        __pyx_t_89 = __pyx_v_ind;
        __pyx_t_90 = 2;
        *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_image.buf, __pyx_t_89, __pyx_bstride_0_image, __pyx_t_90, __pyx_bstride_1_image) += ((__pyx_v_alpha * (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_87, __pyx_bstride_0_shells, __pyx_t_88, __pyx_bstride_1_shells))) * __pyx_v_dist);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":345
 *                 image[ind,1] += alpha*shells[n,3]*dist
 *                 image[ind,2] += alpha*shells[n,4]*dist
 *                 image[ind,3] += alpha*shells[n,5]*dist             # <<<<<<<<<<<<<<
 *                 #image[ind,i] += rgba[i]*dist*rgba[3]/dt
 *                 #print rgba[i], image[ind,i], dist, dt
 */
        __pyx_t_91 = __pyx_v_n;
        __pyx_t_92 = 5;
        __pyx_t_93 = __pyx_v_ind;
        __pyx_t_94 = 3;
        *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_image.buf, __pyx_t_93, __pyx_bstride_0_image, __pyx_t_94, __pyx_bstride_1_image) += ((__pyx_v_alpha * (*__Pyx_BufPtrStrided2d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_shells.buf, __pyx_t_91, __pyx_bstride_0_shells, __pyx_t_92, __pyx_bstride_1_shells))) * __pyx_v_dist);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":348
 *                 #image[ind,i] += rgba[i]*dist*rgba[3]/dt
 *                 #print rgba[i], image[ind,i], dist, dt
 *                 break             # <<<<<<<<<<<<<<
 *         if (tmax[0] > 1.0) and (tmax[1] > 1.0) and (tmax[2] > 1.0):
 *             dt = 1.0 - enter_t
 */
        goto __pyx_L27_break;
        goto __pyx_L28;
      }
      __pyx_L28:;
    }
    __pyx_L27_break:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":349
 *                 #print rgba[i], image[ind,i], dist, dt
 *                 break
 *         if (tmax[0] > 1.0) and (tmax[1] > 1.0) and (tmax[2] > 1.0):             # <<<<<<<<<<<<<<
 *             dt = 1.0 - enter_t
 *             break
 */
    __pyx_t_20 = ((__pyx_v_tmax[0]) > 1.0);
    if (__pyx_t_20) {
      __pyx_t_3 = ((__pyx_v_tmax[1]) > 1.0);
      if (__pyx_t_3) {
        __pyx_t_16 = ((__pyx_v_tmax[2]) > 1.0);
        __pyx_t_18 = __pyx_t_16;
      } else {
        __pyx_t_18 = __pyx_t_3;
      }
      __pyx_t_3 = __pyx_t_18;
    } else {
      __pyx_t_3 = __pyx_t_20;
    }
    if (__pyx_t_3) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":350
 *                 break
 *         if (tmax[0] > 1.0) and (tmax[1] > 1.0) and (tmax[2] > 1.0):
 *             dt = 1.0 - enter_t             # <<<<<<<<<<<<<<
 *             break
 *         if tmax[0] < tmax[1]:
 */
      __pyx_v_dt = (1.0 - __pyx_v_enter_t);

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":351
 *         if (tmax[0] > 1.0) and (tmax[1] > 1.0) and (tmax[2] > 1.0):
 *             dt = 1.0 - enter_t
 *             break             # <<<<<<<<<<<<<<
 *         if tmax[0] < tmax[1]:
 *             if tmax[0] < tmax[2]:
 */
      goto __pyx_L23_break;
      goto __pyx_L29;
    }
    __pyx_L29:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":352
 *             dt = 1.0 - enter_t
 *             break
 *         if tmax[0] < tmax[1]:             # <<<<<<<<<<<<<<
 *             if tmax[0] < tmax[2]:
 *                 dt = tmax[0] - enter_t
 */
    __pyx_t_3 = ((__pyx_v_tmax[0]) < (__pyx_v_tmax[1]));
    if (__pyx_t_3) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":353
 *             break
 *         if tmax[0] < tmax[1]:
 *             if tmax[0] < tmax[2]:             # <<<<<<<<<<<<<<
 *                 dt = tmax[0] - enter_t
 *                 enter_t = tmax[0]
 */
      __pyx_t_3 = ((__pyx_v_tmax[0]) < (__pyx_v_tmax[2]));
      if (__pyx_t_3) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":354
 *         if tmax[0] < tmax[1]:
 *             if tmax[0] < tmax[2]:
 *                 dt = tmax[0] - enter_t             # <<<<<<<<<<<<<<
 *                 enter_t = tmax[0]
 *                 tmax[0] += tdelta[0]
 */
        __pyx_v_dt = ((__pyx_v_tmax[0]) - __pyx_v_enter_t);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":355
 *             if tmax[0] < tmax[2]:
 *                 dt = tmax[0] - enter_t
 *                 enter_t = tmax[0]             # <<<<<<<<<<<<<<
 *                 tmax[0] += tdelta[0]
 *                 cur_ind[0] += step[0]
 */
        __pyx_v_enter_t = (__pyx_v_tmax[0]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":356
 *                 dt = tmax[0] - enter_t
 *                 enter_t = tmax[0]
 *                 tmax[0] += tdelta[0]             # <<<<<<<<<<<<<<
 *                 cur_ind[0] += step[0]
 *             else:
 */
        (__pyx_v_tmax[0]) += (__pyx_v_tdelta[0]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":357
 *                 enter_t = tmax[0]
 *                 tmax[0] += tdelta[0]
 *                 cur_ind[0] += step[0]             # <<<<<<<<<<<<<<
 *             else:
 *                 dt = tmax[2] - enter_t
 */
        (__pyx_v_cur_ind[0]) += (__pyx_v_step[0]);
        goto __pyx_L31;
      }
      /*else*/ {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":359
 *                 cur_ind[0] += step[0]
 *             else:
 *                 dt = tmax[2] - enter_t             # <<<<<<<<<<<<<<
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]
 */
        __pyx_v_dt = ((__pyx_v_tmax[2]) - __pyx_v_enter_t);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":360
 *             else:
 *                 dt = tmax[2] - enter_t
 *                 enter_t = tmax[2]             # <<<<<<<<<<<<<<
 *                 tmax[2] += tdelta[2]
 *                 cur_ind[2] += step[2]
 */
        __pyx_v_enter_t = (__pyx_v_tmax[2]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":361
 *                 dt = tmax[2] - enter_t
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]             # <<<<<<<<<<<<<<
 *                 cur_ind[2] += step[2]
 *         else:
 */
        (__pyx_v_tmax[2]) += (__pyx_v_tdelta[2]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":362
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]
 *                 cur_ind[2] += step[2]             # <<<<<<<<<<<<<<
 *         else:
 *             if tmax[1] < tmax[2]:
 */
        (__pyx_v_cur_ind[2]) += (__pyx_v_step[2]);
      }
      __pyx_L31:;
      goto __pyx_L30;
    }
    /*else*/ {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":364
 *                 cur_ind[2] += step[2]
 *         else:
 *             if tmax[1] < tmax[2]:             # <<<<<<<<<<<<<<
 *                 dt = tmax[1] - enter_t
 *                 enter_t = tmax[1]
 */
      __pyx_t_3 = ((__pyx_v_tmax[1]) < (__pyx_v_tmax[2]));
      if (__pyx_t_3) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":365
 *         else:
 *             if tmax[1] < tmax[2]:
 *                 dt = tmax[1] - enter_t             # <<<<<<<<<<<<<<
 *                 enter_t = tmax[1]
 *                 tmax[1] += tdelta[1]
 */
        __pyx_v_dt = ((__pyx_v_tmax[1]) - __pyx_v_enter_t);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":366
 *             if tmax[1] < tmax[2]:
 *                 dt = tmax[1] - enter_t
 *                 enter_t = tmax[1]             # <<<<<<<<<<<<<<
 *                 tmax[1] += tdelta[1]
 *                 cur_ind[1] += step[1]
 */
        __pyx_v_enter_t = (__pyx_v_tmax[1]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":367
 *                 dt = tmax[1] - enter_t
 *                 enter_t = tmax[1]
 *                 tmax[1] += tdelta[1]             # <<<<<<<<<<<<<<
 *                 cur_ind[1] += step[1]
 *             else:
 */
        (__pyx_v_tmax[1]) += (__pyx_v_tdelta[1]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":368
 *                 enter_t = tmax[1]
 *                 tmax[1] += tdelta[1]
 *                 cur_ind[1] += step[1]             # <<<<<<<<<<<<<<
 *             else:
 *                 dt = tmax[2] - enter_t
 */
        (__pyx_v_cur_ind[1]) += (__pyx_v_step[1]);
        goto __pyx_L32;
      }
      /*else*/ {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":370
 *                 cur_ind[1] += step[1]
 *             else:
 *                 dt = tmax[2] - enter_t             # <<<<<<<<<<<<<<
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]
 */
        __pyx_v_dt = ((__pyx_v_tmax[2]) - __pyx_v_enter_t);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":371
 *             else:
 *                 dt = tmax[2] - enter_t
 *                 enter_t = tmax[2]             # <<<<<<<<<<<<<<
 *                 tmax[2] += tdelta[2]
 *                 cur_ind[2] += step[2]
 */
        __pyx_v_enter_t = (__pyx_v_tmax[2]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":372
 *                 dt = tmax[2] - enter_t
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]             # <<<<<<<<<<<<<<
 *                 cur_ind[2] += step[2]
 *         dv = data[cur_ind[0], cur_ind[1], cur_ind[2]]
 */
        (__pyx_v_tmax[2]) += (__pyx_v_tdelta[2]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":373
 *                 enter_t = tmax[2]
 *                 tmax[2] += tdelta[2]
 *                 cur_ind[2] += step[2]             # <<<<<<<<<<<<<<
 *         dv = data[cur_ind[0], cur_ind[1], cur_ind[2]]
 */
        (__pyx_v_cur_ind[2]) += (__pyx_v_step[2]);
      }
      __pyx_L32:;
    }
    __pyx_L30:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":374
 *                 tmax[2] += tdelta[2]
 *                 cur_ind[2] += step[2]
 *         dv = data[cur_ind[0], cur_ind[1], cur_ind[2]]             # <<<<<<<<<<<<<<
 */
    __pyx_t_68 = (__pyx_v_cur_ind[0]);
    __pyx_t_95 = (__pyx_v_cur_ind[1]);
    __pyx_t_96 = (__pyx_v_cur_ind[2]);
    __pyx_v_dv = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_data.buf, __pyx_t_68, __pyx_bstride_0_data, __pyx_t_95, __pyx_bstride_1_data, __pyx_t_96, __pyx_bstride_2_data));
  }
  __pyx_L23_break:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_44);
  __Pyx_XDECREF(__pyx_t_45);
  __Pyx_XDECREF(__pyx_t_49);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_image);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_shells);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_data);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_u);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_v);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.integrate_ray");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_image);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_shells);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_data);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_u);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_v);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_u);
  __Pyx_DECREF((PyObject *)__pyx_v_v);
  __Pyx_DECREF((PyObject *)__pyx_v_left_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_right_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_dx);
  __Pyx_DECREF((PyObject *)__pyx_v_data);
  __Pyx_DECREF((PyObject *)__pyx_v_shells);
  __Pyx_DECREF((PyObject *)__pyx_v_image);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":31
 * from stdlib cimport malloc, free, abs
 * 
 * cdef inline int imax(int i0, int i1):             # <<<<<<<<<<<<<<
 *     if i0 > i1: return i0
 *     return i1
 */

static CYTHON_INLINE int __pyx_f_2yt_9amr_utils_imax(int __pyx_v_i0, int __pyx_v_i1) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("imax");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":32
 * 
 * cdef inline int imax(int i0, int i1):
 *     if i0 > i1: return i0             # <<<<<<<<<<<<<<
 *     return i1
 * 
 */
  __pyx_t_1 = (__pyx_v_i0 > __pyx_v_i1);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_i0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":33
 * cdef inline int imax(int i0, int i1):
 *     if i0 > i1: return i0
 *     return i1             # <<<<<<<<<<<<<<
 * 
 * cdef inline np.float64_t fmax(np.float64_t f0, np.float64_t f1):
 */
  __pyx_r = __pyx_v_i1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":35
 *     return i1
 * 
 * cdef inline np.float64_t fmax(np.float64_t f0, np.float64_t f1):             # <<<<<<<<<<<<<<
 *     if f0 > f1: return f0
 *     return f1
 */

static CYTHON_INLINE __pyx_t_5numpy_float64_t __pyx_f_2yt_9amr_utils_fmax(__pyx_t_5numpy_float64_t __pyx_v_f0, __pyx_t_5numpy_float64_t __pyx_v_f1) {
  __pyx_t_5numpy_float64_t __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("fmax");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":36
 * 
 * cdef inline np.float64_t fmax(np.float64_t f0, np.float64_t f1):
 *     if f0 > f1: return f0             # <<<<<<<<<<<<<<
 *     return f1
 * 
 */
  __pyx_t_1 = (__pyx_v_f0 > __pyx_v_f1);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_f0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":37
 * cdef inline np.float64_t fmax(np.float64_t f0, np.float64_t f1):
 *     if f0 > f1: return f0
 *     return f1             # <<<<<<<<<<<<<<
 * 
 * cdef inline int imin(int i0, int i1):
 */
  __pyx_r = __pyx_v_f1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":39
 *     return f1
 * 
 * cdef inline int imin(int i0, int i1):             # <<<<<<<<<<<<<<
 *     if i0 < i1: return i0
 *     return i1
 */

static CYTHON_INLINE int __pyx_f_2yt_9amr_utils_imin(int __pyx_v_i0, int __pyx_v_i1) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("imin");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":40
 * 
 * cdef inline int imin(int i0, int i1):
 *     if i0 < i1: return i0             # <<<<<<<<<<<<<<
 *     return i1
 * 
 */
  __pyx_t_1 = (__pyx_v_i0 < __pyx_v_i1);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_i0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":41
 * cdef inline int imin(int i0, int i1):
 *     if i0 < i1: return i0
 *     return i1             # <<<<<<<<<<<<<<
 * 
 * cdef inline np.float64_t fmin(np.float64_t f0, np.float64_t f1):
 */
  __pyx_r = __pyx_v_i1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":43
 *     return i1
 * 
 * cdef inline np.float64_t fmin(np.float64_t f0, np.float64_t f1):             # <<<<<<<<<<<<<<
 *     if f0 < f1: return f0
 *     return f1
 */

static CYTHON_INLINE __pyx_t_5numpy_float64_t __pyx_f_2yt_9amr_utils_fmin(__pyx_t_5numpy_float64_t __pyx_v_f0, __pyx_t_5numpy_float64_t __pyx_v_f1) {
  __pyx_t_5numpy_float64_t __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("fmin");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":44
 * 
 * cdef inline np.float64_t fmin(np.float64_t f0, np.float64_t f1):
 *     if f0 < f1: return f0             # <<<<<<<<<<<<<<
 *     return f1
 * 
 */
  __pyx_t_1 = (__pyx_v_f0 < __pyx_v_f1);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_f0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":45
 * cdef inline np.float64_t fmin(np.float64_t f0, np.float64_t f1):
 *     if f0 < f1: return f0
 *     return f1             # <<<<<<<<<<<<<<
 * 
 * cdef inline int iclip(int i, int a, int b):
 */
  __pyx_r = __pyx_v_f1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":47
 *     return f1
 * 
 * cdef inline int iclip(int i, int a, int b):             # <<<<<<<<<<<<<<
 *     if i < a: return a
 *     if i > b: return b
 */

static CYTHON_INLINE int __pyx_f_2yt_9amr_utils_iclip(int __pyx_v_i, int __pyx_v_a, int __pyx_v_b) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("iclip");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":48
 * 
 * cdef inline int iclip(int i, int a, int b):
 *     if i < a: return a             # <<<<<<<<<<<<<<
 *     if i > b: return b
 *     return i
 */
  __pyx_t_1 = (__pyx_v_i < __pyx_v_a);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_a;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":49
 * cdef inline int iclip(int i, int a, int b):
 *     if i < a: return a
 *     if i > b: return b             # <<<<<<<<<<<<<<
 *     return i
 * 
 */
  __pyx_t_1 = (__pyx_v_i > __pyx_v_b);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_b;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":50
 *     if i < a: return a
 *     if i > b: return b
 *     return i             # <<<<<<<<<<<<<<
 * 
 * cdef inline np.float64_t fclip(np.float64_t f,
 */
  __pyx_r = __pyx_v_i;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":52
 *     return i
 * 
 * cdef inline np.float64_t fclip(np.float64_t f,             # <<<<<<<<<<<<<<
 *                       np.float64_t a, np.float64_t b):
 *     return fmin(fmax(f, a), b)
 */

static CYTHON_INLINE __pyx_t_5numpy_float64_t __pyx_f_2yt_9amr_utils_fclip(__pyx_t_5numpy_float64_t __pyx_v_f, __pyx_t_5numpy_float64_t __pyx_v_a, __pyx_t_5numpy_float64_t __pyx_v_b) {
  __pyx_t_5numpy_float64_t __pyx_r;
  __Pyx_RefNannySetupContext("fclip");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":54
 * cdef inline np.float64_t fclip(np.float64_t f,
 *                       np.float64_t a, np.float64_t b):
 *     return fmin(fmax(f, a), b)             # <<<<<<<<<<<<<<
 * 
 * cdef extern from "math.h":
 */
  __pyx_r = __pyx_f_2yt_9amr_utils_fmin(__pyx_f_2yt_9amr_utils_fmax(__pyx_v_f, __pyx_v_a), __pyx_v_b);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":89
 *     int pass_through
 * 
 * cdef void FIT_initialize_table(FieldInterpolationTable *fit, int nbins,             # <<<<<<<<<<<<<<
 *               np.float64_t *values, np.float64_t bounds1, np.float64_t bounds2,
 *               int field_id, int weight_field_id = -1, int weight_table_id = -1,
 */

static  void __pyx_f_2yt_9amr_utils_FIT_initialize_table(struct __pyx_t_2yt_9amr_utils_FieldInterpolationTable *__pyx_v_fit, int __pyx_v_nbins, __pyx_t_5numpy_float64_t *__pyx_v_values, __pyx_t_5numpy_float64_t __pyx_v_bounds1, __pyx_t_5numpy_float64_t __pyx_v_bounds2, int __pyx_v_field_id, struct __pyx_opt_args_2yt_9amr_utils_FIT_initialize_table *__pyx_optional_args) {
  int __pyx_v_weight_field_id = ((int)-1);
  int __pyx_v_weight_table_id = ((int)-1);
  int __pyx_v_pass_through = ((int)0);
  __Pyx_RefNannySetupContext("FIT_initialize_table");
  if (__pyx_optional_args) {
    if (__pyx_optional_args->__pyx_n > 0) {
      __pyx_v_weight_field_id = __pyx_optional_args->weight_field_id;
      if (__pyx_optional_args->__pyx_n > 1) {
        __pyx_v_weight_table_id = __pyx_optional_args->weight_table_id;
        if (__pyx_optional_args->__pyx_n > 2) {
          __pyx_v_pass_through = __pyx_optional_args->pass_through;
        }
      }
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":93
 *               int field_id, int weight_field_id = -1, int weight_table_id = -1,
 *               int pass_through = 0):
 *     fit.bounds[0] = bounds1; fit.bounds[1] = bounds2             # <<<<<<<<<<<<<<
 *     fit.nbins = nbins
 *     fit.dbin = (fit.bounds[1] - fit.bounds[0])/fit.nbins
 */
  (__pyx_v_fit->bounds[0]) = __pyx_v_bounds1;
  (__pyx_v_fit->bounds[1]) = __pyx_v_bounds2;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":94
 *               int pass_through = 0):
 *     fit.bounds[0] = bounds1; fit.bounds[1] = bounds2
 *     fit.nbins = nbins             # <<<<<<<<<<<<<<
 *     fit.dbin = (fit.bounds[1] - fit.bounds[0])/fit.nbins
 *     fit.idbin = 1.0/fit.dbin
 */
  __pyx_v_fit->nbins = __pyx_v_nbins;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":95
 *     fit.bounds[0] = bounds1; fit.bounds[1] = bounds2
 *     fit.nbins = nbins
 *     fit.dbin = (fit.bounds[1] - fit.bounds[0])/fit.nbins             # <<<<<<<<<<<<<<
 *     fit.idbin = 1.0/fit.dbin
 *     # Better not pull this out from under us, yo
 */
  __pyx_v_fit->dbin = (((__pyx_v_fit->bounds[1]) - (__pyx_v_fit->bounds[0])) / __pyx_v_fit->nbins);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":96
 *     fit.nbins = nbins
 *     fit.dbin = (fit.bounds[1] - fit.bounds[0])/fit.nbins
 *     fit.idbin = 1.0/fit.dbin             # <<<<<<<<<<<<<<
 *     # Better not pull this out from under us, yo
 *     fit.values = values
 */
  __pyx_v_fit->idbin = (1.0 / __pyx_v_fit->dbin);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":98
 *     fit.idbin = 1.0/fit.dbin
 *     # Better not pull this out from under us, yo
 *     fit.values = values             # <<<<<<<<<<<<<<
 *     fit.field_id = field_id
 *     fit.weight_field_id = weight_field_id
 */
  __pyx_v_fit->values = __pyx_v_values;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":99
 *     # Better not pull this out from under us, yo
 *     fit.values = values
 *     fit.field_id = field_id             # <<<<<<<<<<<<<<
 *     fit.weight_field_id = weight_field_id
 *     fit.weight_table_id = weight_table_id
 */
  __pyx_v_fit->field_id = __pyx_v_field_id;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":100
 *     fit.values = values
 *     fit.field_id = field_id
 *     fit.weight_field_id = weight_field_id             # <<<<<<<<<<<<<<
 *     fit.weight_table_id = weight_table_id
 *     fit.pass_through = pass_through
 */
  __pyx_v_fit->weight_field_id = __pyx_v_weight_field_id;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":101
 *     fit.field_id = field_id
 *     fit.weight_field_id = weight_field_id
 *     fit.weight_table_id = weight_table_id             # <<<<<<<<<<<<<<
 *     fit.pass_through = pass_through
 * 
 */
  __pyx_v_fit->weight_table_id = __pyx_v_weight_table_id;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":102
 *     fit.weight_field_id = weight_field_id
 *     fit.weight_table_id = weight_table_id
 *     fit.pass_through = pass_through             # <<<<<<<<<<<<<<
 * 
 * cdef np.float64_t FIT_get_value(FieldInterpolationTable *fit,
 */
  __pyx_v_fit->pass_through = __pyx_v_pass_through;

  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":104
 *     fit.pass_through = pass_through
 * 
 * cdef np.float64_t FIT_get_value(FieldInterpolationTable *fit,             # <<<<<<<<<<<<<<
 *                             np.float64_t *dvs):
 *     cdef np.float64_t bv, dy, dd, tf
 */

static  __pyx_t_5numpy_float64_t __pyx_f_2yt_9amr_utils_FIT_get_value(struct __pyx_t_2yt_9amr_utils_FieldInterpolationTable *__pyx_v_fit, __pyx_t_5numpy_float64_t *__pyx_v_dvs) {
  __pyx_t_5numpy_float64_t __pyx_v_bv;
  __pyx_t_5numpy_float64_t __pyx_v_dy;
  __pyx_t_5numpy_float64_t __pyx_v_dd;
  int __pyx_v_bin_id;
  __pyx_t_5numpy_float64_t __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("FIT_get_value");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":108
 *     cdef np.float64_t bv, dy, dd, tf
 *     cdef int bin_id
 *     if fit.pass_through == 1: return dvs[fit.field_id]             # <<<<<<<<<<<<<<
 *     bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)
 *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
 */
  __pyx_t_1 = (__pyx_v_fit->pass_through == 1);
  if (__pyx_t_1) {
    __pyx_r = (__pyx_v_dvs[__pyx_v_fit->field_id]);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":109
 *     cdef int bin_id
 *     if fit.pass_through == 1: return dvs[fit.field_id]
 *     bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)             # <<<<<<<<<<<<<<
 *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
 *     if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0
 */
  __pyx_v_bin_id = ((int)(((__pyx_v_dvs[__pyx_v_fit->field_id]) - (__pyx_v_fit->bounds[0])) * __pyx_v_fit->idbin));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":110
 *     if fit.pass_through == 1: return dvs[fit.field_id]
 *     bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)
 *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0             # <<<<<<<<<<<<<<
 *     if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0
 *     bv = fit.values[bin_id]
 */
  __pyx_v_dd = ((__pyx_v_dvs[__pyx_v_fit->field_id]) - ((__pyx_v_fit->bounds[0]) + (__pyx_v_bin_id * __pyx_v_fit->dbin)));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":111
 *     bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)
 *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
 *     if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0             # <<<<<<<<<<<<<<
 *     bv = fit.values[bin_id]
 *     dy = fit.values[bin_id + 1] - bv
 */
  __pyx_t_1 = (__pyx_v_bin_id > (__pyx_v_fit->nbins - 2));
  if (!__pyx_t_1) {
    __pyx_t_2 = (__pyx_v_bin_id < 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {
    __pyx_r = 0.0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":112
 *     dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
 *     if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0
 *     bv = fit.values[bin_id]             # <<<<<<<<<<<<<<
 *     dy = fit.values[bin_id + 1] - bv
 *     if fit.weight_field_id != -1:
 */
  __pyx_v_bv = (__pyx_v_fit->values[__pyx_v_bin_id]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":113
 *     if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0
 *     bv = fit.values[bin_id]
 *     dy = fit.values[bin_id + 1] - bv             # <<<<<<<<<<<<<<
 *     if fit.weight_field_id != -1:
 *         return dvs[fit.weight_field_id] * (bv + dd*dy*fit.idbin)
 */
  __pyx_v_dy = ((__pyx_v_fit->values[(__pyx_v_bin_id + 1)]) - __pyx_v_bv);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":114
 *     bv = fit.values[bin_id]
 *     dy = fit.values[bin_id + 1] - bv
 *     if fit.weight_field_id != -1:             # <<<<<<<<<<<<<<
 *         return dvs[fit.weight_field_id] * (bv + dd*dy*fit.idbin)
 *     return (bv + dd*dy*fit.idbin)
 */
  __pyx_t_3 = (__pyx_v_fit->weight_field_id != -1);
  if (__pyx_t_3) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":115
 *     dy = fit.values[bin_id + 1] - bv
 *     if fit.weight_field_id != -1:
 *         return dvs[fit.weight_field_id] * (bv + dd*dy*fit.idbin)             # <<<<<<<<<<<<<<
 *     return (bv + dd*dy*fit.idbin)
 * 
 */
    __pyx_r = ((__pyx_v_dvs[__pyx_v_fit->weight_field_id]) * (__pyx_v_bv + ((__pyx_v_dd * __pyx_v_dy) * __pyx_v_fit->idbin)));
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":116
 *     if fit.weight_field_id != -1:
 *         return dvs[fit.weight_field_id] * (bv + dd*dy*fit.idbin)
 *     return (bv + dd*dy*fit.idbin)             # <<<<<<<<<<<<<<
 * 
 * cdef class TransferFunctionProxy:
 */
  __pyx_r = (__pyx_v_bv + ((__pyx_v_dd * __pyx_v_dy) * __pyx_v_fit->idbin));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":139
 *     cdef public object my_field_tables
 * 
 *     def __cinit__(self, tf_obj):             # <<<<<<<<<<<<<<
 *         # We have N fields.  We have 6 channels.  We have M field tables.
 *         # The idea is that we can have multiple channels corresponding to the
 */

static int __pyx_pf_2yt_9amr_utils_21TransferFunctionProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_2yt_9amr_utils_21TransferFunctionProxy___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_tf_obj = 0;
  int __pyx_v_i;
  PyArrayObject *__pyx_v_temp;
  Py_buffer __pyx_bstruct_temp;
  Py_ssize_t __pyx_bstride_0_temp = 0;
  Py_ssize_t __pyx_bshape_0_temp = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyArrayObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __pyx_t_5numpy_float64_t __pyx_t_10;
  __pyx_t_5numpy_float64_t __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  struct __pyx_opt_args_2yt_9amr_utils_FIT_initialize_table __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__tf_obj,0};
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tf_obj);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_tf_obj = values[0];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_tf_obj = PyTuple_GET_ITEM(__pyx_args, 0);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.TransferFunctionProxy.__cinit__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF(__pyx_v_tf_obj);
  __pyx_v_temp = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_bstruct_temp.buf = NULL;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":150
 *         cdef FieldInterpolationTable fit
 * 
 *         self.tf_obj = tf_obj             # <<<<<<<<<<<<<<
 * 
 *         self.n_field_tables = tf_obj.n_field_tables
 */
  __Pyx_INCREF(__pyx_v_tf_obj);
  __Pyx_GIVEREF(__pyx_v_tf_obj);
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->tf_obj);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->tf_obj);
  ((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->tf_obj = __pyx_v_tf_obj;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":152
 *         self.tf_obj = tf_obj
 * 
 *         self.n_field_tables = tf_obj.n_field_tables             # <<<<<<<<<<<<<<
 *         for i in range(6): self.istorage[i] = 0.0
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__n_field_tables); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  ((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->n_field_tables = __pyx_t_2;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":153
 * 
 *         self.n_field_tables = tf_obj.n_field_tables
 *         for i in range(6): self.istorage[i] = 0.0             # <<<<<<<<<<<<<<
 * 
 *         self.my_field_tables = []
 */
  for (__pyx_t_2 = 0; __pyx_t_2 < 6; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;
    (((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->istorage[__pyx_v_i]) = 0.0;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":155
 *         for i in range(6): self.istorage[i] = 0.0
 * 
 *         self.my_field_tables = []             # <<<<<<<<<<<<<<
 *         for i in range(self.n_field_tables):
 *             temp = tf_obj.tables[i].y
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->my_field_tables);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->my_field_tables);
  ((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->my_field_tables = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":156
 * 
 *         self.my_field_tables = []
 *         for i in range(self.n_field_tables):             # <<<<<<<<<<<<<<
 *             temp = tf_obj.tables[i].y
 *             FIT_initialize_table(&self.field_tables[i],
 */
  __pyx_t_2 = ((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->n_field_tables;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":157
 *         self.my_field_tables = []
 *         for i in range(self.n_field_tables):
 *             temp = tf_obj.tables[i].y             # <<<<<<<<<<<<<<
 *             FIT_initialize_table(&self.field_tables[i],
 *                       temp.shape[0],
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__tables); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__y); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_bstruct_temp);
      __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_temp, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_6 < 0)) {
        PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_temp, (PyObject*)__pyx_v_temp, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        }
      }
      __pyx_bstride_0_temp = __pyx_bstruct_temp.strides[0];
      __pyx_bshape_0_temp = __pyx_bstruct_temp.shape[0];
      if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_temp));
    __pyx_v_temp = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":161
 *                       temp.shape[0],
 *                       <np.float64_t *> temp.data,
 *                       tf_obj.tables[i].x_bounds[0],             # <<<<<<<<<<<<<<
 *                       tf_obj.tables[i].x_bounds[1],
 *                       tf_obj.field_ids[i], tf_obj.weight_field_ids[i],
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__tables); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__x_bounds); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_10 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":162
 *                       <np.float64_t *> temp.data,
 *                       tf_obj.tables[i].x_bounds[0],
 *                       tf_obj.tables[i].x_bounds[1],             # <<<<<<<<<<<<<<
 *                       tf_obj.field_ids[i], tf_obj.weight_field_ids[i],
 *                       tf_obj.weight_table_ids[i],
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__tables); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__x_bounds); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_11 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":163
 *                       tf_obj.tables[i].x_bounds[0],
 *                       tf_obj.tables[i].x_bounds[1],
 *                       tf_obj.field_ids[i], tf_obj.weight_field_ids[i],             # <<<<<<<<<<<<<<
 *                       tf_obj.weight_table_ids[i],
 *                       tf_obj.tables[i].pass_through)
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__field_ids); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__weight_field_ids); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":164
 *                       tf_obj.tables[i].x_bounds[1],
 *                       tf_obj.field_ids[i], tf_obj.weight_field_ids[i],
 *                       tf_obj.weight_table_ids[i],             # <<<<<<<<<<<<<<
 *                       tf_obj.tables[i].pass_through)
 *             self.my_field_tables.append((tf_obj.tables[i],
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__weight_table_ids); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":165
 *                       tf_obj.field_ids[i], tf_obj.weight_field_ids[i],
 *                       tf_obj.weight_table_ids[i],
 *                       tf_obj.tables[i].pass_through)             # <<<<<<<<<<<<<<
 *             self.my_field_tables.append((tf_obj.tables[i],
 *                                          tf_obj.tables[i].y))
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__tables); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__pass_through); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_14 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_15.__pyx_n = 3;
    __pyx_t_15.weight_field_id = __pyx_t_12;
    __pyx_t_15.weight_table_id = __pyx_t_13;
    __pyx_t_15.pass_through = __pyx_t_14;
    __pyx_f_2yt_9amr_utils_FIT_initialize_table((&(((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->field_tables[__pyx_v_i])), (__pyx_v_temp->dimensions[0]), ((__pyx_t_5numpy_float64_t *)__pyx_v_temp->data), __pyx_t_10, __pyx_t_11, __pyx_t_6, &__pyx_t_15); 

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":166
 *                       tf_obj.weight_table_ids[i],
 *                       tf_obj.tables[i].pass_through)
 *             self.my_field_tables.append((tf_obj.tables[i],             # <<<<<<<<<<<<<<
 *                                          tf_obj.tables[i].y))
 *             self.field_tables[i].field_id = tf_obj.field_ids[i]
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__tables); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":167
 *                       tf_obj.tables[i].pass_through)
 *             self.my_field_tables.append((tf_obj.tables[i],
 *                                          tf_obj.tables[i].y))             # <<<<<<<<<<<<<<
 *             self.field_tables[i].field_id = tf_obj.field_ids[i]
 *             self.field_tables[i].weight_field_id = tf_obj.weight_field_ids[i]
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__tables); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_4, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_16) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_GetAttr(__pyx_t_16, __pyx_n_s__y); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_1 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Append(((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->my_field_tables, __pyx_t_16); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":168
 *             self.my_field_tables.append((tf_obj.tables[i],
 *                                          tf_obj.tables[i].y))
 *             self.field_tables[i].field_id = tf_obj.field_ids[i]             # <<<<<<<<<<<<<<
 *             self.field_tables[i].weight_field_id = tf_obj.weight_field_ids[i]
 *             print "Field table", i, "corresponds to",
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__field_ids); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_16 = __Pyx_GetItemInt(__pyx_t_4, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_16) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_14 = __Pyx_PyInt_AsInt(__pyx_t_16); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    (((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->field_tables[__pyx_v_i]).field_id = __pyx_t_14;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":169
 *                                          tf_obj.tables[i].y))
 *             self.field_tables[i].field_id = tf_obj.field_ids[i]
 *             self.field_tables[i].weight_field_id = tf_obj.weight_field_ids[i]             # <<<<<<<<<<<<<<
 *             print "Field table", i, "corresponds to",
 *             print self.field_tables[i].field_id,
 */
    __pyx_t_16 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__weight_field_ids); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_16, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_14 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    (((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->field_tables[__pyx_v_i]).weight_field_id = __pyx_t_14;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":170
 *             self.field_tables[i].field_id = tf_obj.field_ids[i]
 *             self.field_tables[i].weight_field_id = tf_obj.weight_field_ids[i]
 *             print "Field table", i, "corresponds to",             # <<<<<<<<<<<<<<
 *             print self.field_tables[i].field_id,
 *             print "(Weighted with ", self.field_tables[i].weight_field_id,
 */
    __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_16 = PyTuple_New(3); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
    PyTuple_SET_ITEM(__pyx_t_16, 0, ((PyObject *)__pyx_kp_s_3));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
    PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
    PyTuple_SET_ITEM(__pyx_t_16, 2, ((PyObject *)__pyx_kp_s_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
    __pyx_t_4 = 0;
    if (__Pyx_Print(__pyx_t_16, 0) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":171
 *             self.field_tables[i].weight_field_id = tf_obj.weight_field_ids[i]
 *             print "Field table", i, "corresponds to",
 *             print self.field_tables[i].field_id,             # <<<<<<<<<<<<<<
 *             print "(Weighted with ", self.field_tables[i].weight_field_id,
 *             print ")"
 */
    __pyx_t_16 = PyInt_FromLong((((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->field_tables[__pyx_v_i]).field_id); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_16);
    __Pyx_GIVEREF(__pyx_t_16);
    __pyx_t_16 = 0;
    if (__Pyx_Print(__pyx_t_4, 0) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":172
 *             print "Field table", i, "corresponds to",
 *             print self.field_tables[i].field_id,
 *             print "(Weighted with ", self.field_tables[i].weight_field_id,             # <<<<<<<<<<<<<<
 *             print ")"
 * 
 */
    __pyx_t_4 = PyInt_FromLong((((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->field_tables[__pyx_v_i]).weight_field_id); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_16 = PyTuple_New(2); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
    PyTuple_SET_ITEM(__pyx_t_16, 0, ((PyObject *)__pyx_kp_s_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
    PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    if (__Pyx_Print(__pyx_t_16, 0) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":173
 *             print self.field_tables[i].field_id,
 *             print "(Weighted with ", self.field_tables[i].weight_field_id,
 *             print ")"             # <<<<<<<<<<<<<<
 * 
 *         for i in range(6):
 */
    if (__Pyx_PrintOne(((PyObject *)__pyx_kp_s_6)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":175
 *             print ")"
 * 
 *         for i in range(6):             # <<<<<<<<<<<<<<
 *             self.field_table_ids[i] = tf_obj.field_table_ids[i]
 *             print "Channel", i, "corresponds to", self.field_table_ids[i]
 */
  for (__pyx_t_2 = 0; __pyx_t_2 < 6; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":176
 * 
 *         for i in range(6):
 *             self.field_table_ids[i] = tf_obj.field_table_ids[i]             # <<<<<<<<<<<<<<
 *             print "Channel", i, "corresponds to", self.field_table_ids[i]
 * 
 */
    __pyx_t_16 = PyObject_GetAttr(__pyx_v_tf_obj, __pyx_n_s__field_table_ids); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_16, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    (((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->field_table_ids[__pyx_v_i]) = __pyx_t_3;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":177
 *         for i in range(6):
 *             self.field_table_ids[i] = tf_obj.field_table_ids[i]
 *             print "Channel", i, "corresponds to", self.field_table_ids[i]             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
    __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_16 = PyInt_FromLong((((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_self)->field_table_ids[__pyx_v_i])); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__Channel));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__Channel));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Channel));
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_kp_s_4));
    PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_kp_s_4));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4));
    PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_16);
    __Pyx_GIVEREF(__pyx_t_16);
    __pyx_t_4 = 0;
    __pyx_t_16 = 0;
    if (__Pyx_Print(__pyx_t_1, 1) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_16);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_temp);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.TransferFunctionProxy.__cinit__");
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_temp);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_temp);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_tf_obj);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":181
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef void eval_transfer(self, np.float64_t dt, np.float64_t *dvs,             # <<<<<<<<<<<<<<
 *                                   np.float64_t *rgba, np.float64_t *grad):
 *         cdef int i, fid, use
 */

static  void __pyx_f_2yt_9amr_utils_21TransferFunctionProxy_eval_transfer(struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *__pyx_v_self, __pyx_t_5numpy_float64_t __pyx_v_dt, __pyx_t_5numpy_float64_t *__pyx_v_dvs, __pyx_t_5numpy_float64_t *__pyx_v_rgba, __pyx_t_5numpy_float64_t *__pyx_v_grad) {
  int __pyx_v_i;
  int __pyx_v_fid;
  __pyx_t_5numpy_float64_t __pyx_v_ta;
  __pyx_t_5numpy_float64_t __pyx_v_trgba[6];
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("eval_transfer");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":194
 *         #        use = 1
 *         #        break
 *         for i in range(self.n_field_tables):             # <<<<<<<<<<<<<<
 *             self.istorage[i] = FIT_get_value(&self.field_tables[i], dvs)
 *         # We have to do this after the interpolation
 */
  __pyx_t_1 = __pyx_v_self->n_field_tables;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":195
 *         #        break
 *         for i in range(self.n_field_tables):
 *             self.istorage[i] = FIT_get_value(&self.field_tables[i], dvs)             # <<<<<<<<<<<<<<
 *         # We have to do this after the interpolation
 *         for i in range(self.n_field_tables):
 */
    (__pyx_v_self->istorage[__pyx_v_i]) = __pyx_f_2yt_9amr_utils_FIT_get_value((&(__pyx_v_self->field_tables[__pyx_v_i])), __pyx_v_dvs);
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":197
 *             self.istorage[i] = FIT_get_value(&self.field_tables[i], dvs)
 *         # We have to do this after the interpolation
 *         for i in range(self.n_field_tables):             # <<<<<<<<<<<<<<
 *             fid = self.field_tables[i].weight_table_id
 *             if fid != -1: self.istorage[i] *= self.istorage[fid]
 */
  __pyx_t_1 = __pyx_v_self->n_field_tables;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":198
 *         # We have to do this after the interpolation
 *         for i in range(self.n_field_tables):
 *             fid = self.field_tables[i].weight_table_id             # <<<<<<<<<<<<<<
 *             if fid != -1: self.istorage[i] *= self.istorage[fid]
 *         for i in range(6):
 */
    __pyx_v_fid = (__pyx_v_self->field_tables[__pyx_v_i]).weight_table_id;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":199
 *         for i in range(self.n_field_tables):
 *             fid = self.field_tables[i].weight_table_id
 *             if fid != -1: self.istorage[i] *= self.istorage[fid]             # <<<<<<<<<<<<<<
 *         for i in range(6):
 *             trgba[i] = self.istorage[self.field_table_ids[i]]
 */
    __pyx_t_3 = (__pyx_v_fid != -1);
    if (__pyx_t_3) {
      (__pyx_v_self->istorage[__pyx_v_i]) *= (__pyx_v_self->istorage[__pyx_v_fid]);
      goto __pyx_L7;
    }
    __pyx_L7:;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":200
 *             fid = self.field_tables[i].weight_table_id
 *             if fid != -1: self.istorage[i] *= self.istorage[fid]
 *         for i in range(6):             # <<<<<<<<<<<<<<
 *             trgba[i] = self.istorage[self.field_table_ids[i]]
 *             #print i, trgba[i],
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 6; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":201
 *             if fid != -1: self.istorage[i] *= self.istorage[fid]
 *         for i in range(6):
 *             trgba[i] = self.istorage[self.field_table_ids[i]]             # <<<<<<<<<<<<<<
 *             #print i, trgba[i],
 *         #print
 */
    (__pyx_v_trgba[__pyx_v_i]) = (__pyx_v_self->istorage[(__pyx_v_self->field_table_ids[__pyx_v_i])]);
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":211
 *         # integration here:
 *         #   I_{i+1} = ds * C_i + (1.0 - ds*alpha_i) * I_i
 *         for i in range(3):             # <<<<<<<<<<<<<<
 *             # This is the new way: alpha corresponds to opacity of a given
 *             # slice.  Previously it was ill-defined, but represented some
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":215
 *             # slice.  Previously it was ill-defined, but represented some
 *             # measure of emissivity.
 *             ta = fmax((1.0 - dt*trgba[i+3]), 0.0)             # <<<<<<<<<<<<<<
 *             rgba[i  ] = dt*trgba[i  ] + ta * rgba[i  ]
 *             #rgba[i+3] = dt*trgba[i+3] + ta * rgba[i+3]
 */
    __pyx_v_ta = __pyx_f_2yt_9amr_utils_fmax((1.0 - (__pyx_v_dt * (__pyx_v_trgba[(__pyx_v_i + 3)]))), 0.0);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":216
 *             # measure of emissivity.
 *             ta = fmax((1.0 - dt*trgba[i+3]), 0.0)
 *             rgba[i  ] = dt*trgba[i  ] + ta * rgba[i  ]             # <<<<<<<<<<<<<<
 *             #rgba[i+3] = dt*trgba[i+3] + ta * rgba[i+3]
 *             # This is the old way:
 */
    (__pyx_v_rgba[__pyx_v_i]) = ((__pyx_v_dt * (__pyx_v_trgba[__pyx_v_i])) + (__pyx_v_ta * (__pyx_v_rgba[__pyx_v_i])));
  }

  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":233
 *     cdef np.float64_t *x_vec, *y_vec
 * 
 *     def __cinit__(self,             # <<<<<<<<<<<<<<
 *                   np.ndarray[np.float64_t, ndim=3] vp_pos,
 *                   np.ndarray vp_dir,
 */

static int __pyx_pf_2yt_9amr_utils_11VectorPlane___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_2yt_9amr_utils_11VectorPlane___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_vp_pos = 0;
  PyArrayObject *__pyx_v_vp_dir = 0;
  PyArrayObject *__pyx_v_center = 0;
  PyObject *__pyx_v_bounds = 0;
  PyArrayObject *__pyx_v_image = 0;
  PyArrayObject *__pyx_v_x_vec = 0;
  PyArrayObject *__pyx_v_y_vec = 0;
  int __pyx_v_i;
  Py_buffer __pyx_bstruct_center;
  Py_ssize_t __pyx_bstride_0_center = 0;
  Py_ssize_t __pyx_bshape_0_center = 0;
  Py_buffer __pyx_bstruct_x_vec;
  Py_ssize_t __pyx_bstride_0_x_vec = 0;
  Py_ssize_t __pyx_bshape_0_x_vec = 0;
  Py_buffer __pyx_bstruct_y_vec;
  Py_ssize_t __pyx_bstride_0_y_vec = 0;
  Py_ssize_t __pyx_bshape_0_y_vec = 0;
  Py_buffer __pyx_bstruct_image;
  Py_ssize_t __pyx_bstride_0_image = 0;
  Py_ssize_t __pyx_bstride_1_image = 0;
  Py_ssize_t __pyx_bstride_2_image = 0;
  Py_ssize_t __pyx_bshape_0_image = 0;
  Py_ssize_t __pyx_bshape_1_image = 0;
  Py_ssize_t __pyx_bshape_2_image = 0;
  Py_buffer __pyx_bstruct_vp_pos;
  Py_ssize_t __pyx_bstride_0_vp_pos = 0;
  Py_ssize_t __pyx_bstride_1_vp_pos = 0;
  Py_ssize_t __pyx_bstride_2_vp_pos = 0;
  Py_ssize_t __pyx_bshape_0_vp_pos = 0;
  Py_ssize_t __pyx_bshape_1_vp_pos = 0;
  Py_ssize_t __pyx_bshape_2_vp_pos = 0;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  __pyx_t_5numpy_float64_t __pyx_t_3;
  int __pyx_t_4;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__vp_pos,&__pyx_n_s__vp_dir,&__pyx_n_s__center,&__pyx_n_s__bounds,&__pyx_n_s__image,&__pyx_n_s__x_vec,&__pyx_n_s__y_vec,0};
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[7] = {0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vp_pos);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vp_dir);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__center);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bounds);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__image);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 4); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x_vec);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 5); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y_vec);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, 6); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_vp_pos = ((PyArrayObject *)values[0]);
    __pyx_v_vp_dir = ((PyArrayObject *)values[1]);
    __pyx_v_center = ((PyArrayObject *)values[2]);
    __pyx_v_bounds = values[3];
    __pyx_v_image = ((PyArrayObject *)values[4]);
    __pyx_v_x_vec = ((PyArrayObject *)values[5]);
    __pyx_v_y_vec = ((PyArrayObject *)values[6]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_vp_pos = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_vp_dir = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_center = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_bounds = PyTuple_GET_ITEM(__pyx_args, 3);
    __pyx_v_image = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_x_vec = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 5));
    __pyx_v_y_vec = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 6));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.VectorPlane.__cinit__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF((PyObject *)__pyx_v_vp_pos);
  __Pyx_INCREF((PyObject *)__pyx_v_vp_dir);
  __Pyx_INCREF((PyObject *)__pyx_v_center);
  __Pyx_INCREF(__pyx_v_bounds);
  __Pyx_INCREF((PyObject *)__pyx_v_image);
  __Pyx_INCREF((PyObject *)__pyx_v_x_vec);
  __Pyx_INCREF((PyObject *)__pyx_v_y_vec);
  __pyx_bstruct_vp_pos.buf = NULL;
  __pyx_bstruct_center.buf = NULL;
  __pyx_bstruct_image.buf = NULL;
  __pyx_bstruct_x_vec.buf = NULL;
  __pyx_bstruct_y_vec.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vp_pos), __pyx_ptype_5numpy_ndarray, 1, "vp_pos", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vp_dir), __pyx_ptype_5numpy_ndarray, 1, "vp_dir", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_center), __pyx_ptype_5numpy_ndarray, 1, "center", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_image), __pyx_ptype_5numpy_ndarray, 1, "image", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x_vec), __pyx_ptype_5numpy_ndarray, 1, "x_vec", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y_vec), __pyx_ptype_5numpy_ndarray, 1, "y_vec", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_vp_pos, (PyObject*)__pyx_v_vp_pos, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_vp_pos = __pyx_bstruct_vp_pos.strides[0]; __pyx_bstride_1_vp_pos = __pyx_bstruct_vp_pos.strides[1]; __pyx_bstride_2_vp_pos = __pyx_bstruct_vp_pos.strides[2];
  __pyx_bshape_0_vp_pos = __pyx_bstruct_vp_pos.shape[0]; __pyx_bshape_1_vp_pos = __pyx_bstruct_vp_pos.shape[1]; __pyx_bshape_2_vp_pos = __pyx_bstruct_vp_pos.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_center, (PyObject*)__pyx_v_center, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_center = __pyx_bstruct_center.strides[0];
  __pyx_bshape_0_center = __pyx_bstruct_center.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_image, (PyObject*)__pyx_v_image, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_image = __pyx_bstruct_image.strides[0]; __pyx_bstride_1_image = __pyx_bstruct_image.strides[1]; __pyx_bstride_2_image = __pyx_bstruct_image.strides[2];
  __pyx_bshape_0_image = __pyx_bstruct_image.shape[0]; __pyx_bshape_1_image = __pyx_bstruct_image.shape[1]; __pyx_bshape_2_image = __pyx_bstruct_image.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x_vec, (PyObject*)__pyx_v_x_vec, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_x_vec = __pyx_bstruct_x_vec.strides[0];
  __pyx_bshape_0_x_vec = __pyx_bstruct_x_vec.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y_vec, (PyObject*)__pyx_v_y_vec, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_y_vec = __pyx_bstruct_y_vec.strides[0];
  __pyx_bshape_0_y_vec = __pyx_bstruct_y_vec.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":242
 *                   np.ndarray[np.float64_t, ndim=1] y_vec):
 *         cdef int i, j
 *         self.avp_pos = vp_pos             # <<<<<<<<<<<<<<
 *         self.avp_dir = vp_dir
 *         self.acenter = center
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_vp_pos));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_vp_pos));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->avp_pos);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->avp_pos);
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->avp_pos = ((PyObject *)__pyx_v_vp_pos);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":243
 *         cdef int i, j
 *         self.avp_pos = vp_pos
 *         self.avp_dir = vp_dir             # <<<<<<<<<<<<<<
 *         self.acenter = center
 *         self.aimage = image
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_vp_dir));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_vp_dir));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->avp_dir);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->avp_dir);
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->avp_dir = ((PyObject *)__pyx_v_vp_dir);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":244
 *         self.avp_pos = vp_pos
 *         self.avp_dir = vp_dir
 *         self.acenter = center             # <<<<<<<<<<<<<<
 *         self.aimage = image
 *         self.ax_vec = x_vec
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_center));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_center));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->acenter);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->acenter);
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->acenter = ((PyObject *)__pyx_v_center);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":245
 *         self.avp_dir = vp_dir
 *         self.acenter = center
 *         self.aimage = image             # <<<<<<<<<<<<<<
 *         self.ax_vec = x_vec
 *         self.ay_vec = y_vec
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_image));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_image));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->aimage);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->aimage);
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->aimage = ((PyObject *)__pyx_v_image);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":246
 *         self.acenter = center
 *         self.aimage = image
 *         self.ax_vec = x_vec             # <<<<<<<<<<<<<<
 *         self.ay_vec = y_vec
 *         self.vp_pos = <np.float64_t *> vp_pos.data
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_x_vec));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_x_vec));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->ax_vec);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->ax_vec);
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->ax_vec = ((PyObject *)__pyx_v_x_vec);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":247
 *         self.aimage = image
 *         self.ax_vec = x_vec
 *         self.ay_vec = y_vec             # <<<<<<<<<<<<<<
 *         self.vp_pos = <np.float64_t *> vp_pos.data
 *         self.vp_dir = <np.float64_t *> vp_dir.data
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_y_vec));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_y_vec));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->ay_vec);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->ay_vec);
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->ay_vec = ((PyObject *)__pyx_v_y_vec);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":248
 *         self.ax_vec = x_vec
 *         self.ay_vec = y_vec
 *         self.vp_pos = <np.float64_t *> vp_pos.data             # <<<<<<<<<<<<<<
 *         self.vp_dir = <np.float64_t *> vp_dir.data
 *         self.center = <np.float64_t *> center.data
 */
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->vp_pos = ((__pyx_t_5numpy_float64_t *)__pyx_v_vp_pos->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":249
 *         self.ay_vec = y_vec
 *         self.vp_pos = <np.float64_t *> vp_pos.data
 *         self.vp_dir = <np.float64_t *> vp_dir.data             # <<<<<<<<<<<<<<
 *         self.center = <np.float64_t *> center.data
 *         self.image = <np.float64_t *> image.data
 */
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->vp_dir = ((__pyx_t_5numpy_float64_t *)__pyx_v_vp_dir->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":250
 *         self.vp_pos = <np.float64_t *> vp_pos.data
 *         self.vp_dir = <np.float64_t *> vp_dir.data
 *         self.center = <np.float64_t *> center.data             # <<<<<<<<<<<<<<
 *         self.image = <np.float64_t *> image.data
 *         self.x_vec = <np.float64_t *> x_vec.data
 */
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->center = ((__pyx_t_5numpy_float64_t *)__pyx_v_center->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":251
 *         self.vp_dir = <np.float64_t *> vp_dir.data
 *         self.center = <np.float64_t *> center.data
 *         self.image = <np.float64_t *> image.data             # <<<<<<<<<<<<<<
 *         self.x_vec = <np.float64_t *> x_vec.data
 *         self.y_vec = <np.float64_t *> y_vec.data
 */
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->image = ((__pyx_t_5numpy_float64_t *)__pyx_v_image->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":252
 *         self.center = <np.float64_t *> center.data
 *         self.image = <np.float64_t *> image.data
 *         self.x_vec = <np.float64_t *> x_vec.data             # <<<<<<<<<<<<<<
 *         self.y_vec = <np.float64_t *> y_vec.data
 *         self.nv[0] = vp_pos.shape[0]
 */
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->x_vec = ((__pyx_t_5numpy_float64_t *)__pyx_v_x_vec->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":253
 *         self.image = <np.float64_t *> image.data
 *         self.x_vec = <np.float64_t *> x_vec.data
 *         self.y_vec = <np.float64_t *> y_vec.data             # <<<<<<<<<<<<<<
 *         self.nv[0] = vp_pos.shape[0]
 *         self.nv[1] = vp_pos.shape[1]
 */
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->y_vec = ((__pyx_t_5numpy_float64_t *)__pyx_v_y_vec->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":254
 *         self.x_vec = <np.float64_t *> x_vec.data
 *         self.y_vec = <np.float64_t *> y_vec.data
 *         self.nv[0] = vp_pos.shape[0]             # <<<<<<<<<<<<<<
 *         self.nv[1] = vp_pos.shape[1]
 *         for i in range(4): self.bounds[i] = bounds[i]
 */
  (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->nv[0]) = (__pyx_v_vp_pos->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":255
 *         self.y_vec = <np.float64_t *> y_vec.data
 *         self.nv[0] = vp_pos.shape[0]
 *         self.nv[1] = vp_pos.shape[1]             # <<<<<<<<<<<<<<
 *         for i in range(4): self.bounds[i] = bounds[i]
 *         self.pdx = (self.bounds[1] - self.bounds[0])/self.nv[0]
 */
  (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->nv[1]) = (__pyx_v_vp_pos->dimensions[1]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":256
 *         self.nv[0] = vp_pos.shape[0]
 *         self.nv[1] = vp_pos.shape[1]
 *         for i in range(4): self.bounds[i] = bounds[i]             # <<<<<<<<<<<<<<
 *         self.pdx = (self.bounds[1] - self.bounds[0])/self.nv[0]
 *         self.pdy = (self.bounds[3] - self.bounds[2])/self.nv[1]
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 4; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_bounds, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->bounds[__pyx_v_i]) = __pyx_t_3;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":257
 *         self.nv[1] = vp_pos.shape[1]
 *         for i in range(4): self.bounds[i] = bounds[i]
 *         self.pdx = (self.bounds[1] - self.bounds[0])/self.nv[0]             # <<<<<<<<<<<<<<
 *         self.pdy = (self.bounds[3] - self.bounds[2])/self.nv[1]
 *         for i in range(3):
 */
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->pdx = (((((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->bounds[1]) - (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->bounds[0])) / (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->nv[0]));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":258
 *         for i in range(4): self.bounds[i] = bounds[i]
 *         self.pdx = (self.bounds[1] - self.bounds[0])/self.nv[0]
 *         self.pdy = (self.bounds[3] - self.bounds[2])/self.nv[1]             # <<<<<<<<<<<<<<
 *         for i in range(3):
 *             self.vp_strides[i] = vp_pos.strides[i] / 8
 */
  ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->pdy = (((((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->bounds[3]) - (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->bounds[2])) / (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->nv[1]));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":259
 *         self.pdx = (self.bounds[1] - self.bounds[0])/self.nv[0]
 *         self.pdy = (self.bounds[3] - self.bounds[2])/self.nv[1]
 *         for i in range(3):             # <<<<<<<<<<<<<<
 *             self.vp_strides[i] = vp_pos.strides[i] / 8
 *             self.im_strides[i] = image.strides[i] / 8
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":260
 *         self.pdy = (self.bounds[3] - self.bounds[2])/self.nv[1]
 *         for i in range(3):
 *             self.vp_strides[i] = vp_pos.strides[i] / 8             # <<<<<<<<<<<<<<
 *             self.im_strides[i] = image.strides[i] / 8
 *         if vp_dir.ndim > 1:
 */
    (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->vp_strides[__pyx_v_i]) = ((__pyx_v_vp_pos->strides[__pyx_v_i]) / 8);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":261
 *         for i in range(3):
 *             self.vp_strides[i] = vp_pos.strides[i] / 8
 *             self.im_strides[i] = image.strides[i] / 8             # <<<<<<<<<<<<<<
 *         if vp_dir.ndim > 1:
 *             for i in range(3):
 */
    (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->im_strides[__pyx_v_i]) = ((__pyx_v_image->strides[__pyx_v_i]) / 8);
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":262
 *             self.vp_strides[i] = vp_pos.strides[i] / 8
 *             self.im_strides[i] = image.strides[i] / 8
 *         if vp_dir.ndim > 1:             # <<<<<<<<<<<<<<
 *             for i in range(3):
 *                 self.vd_strides[i] = vp_dir.strides[i] / 8
 */
  __pyx_t_4 = (__pyx_v_vp_dir->nd > 1);
  if (__pyx_t_4) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":263
 *             self.im_strides[i] = image.strides[i] / 8
 *         if vp_dir.ndim > 1:
 *             for i in range(3):             # <<<<<<<<<<<<<<
 *                 self.vd_strides[i] = vp_dir.strides[i] / 8
 *         else:
 */
    for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
      __pyx_v_i = __pyx_t_1;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":264
 *         if vp_dir.ndim > 1:
 *             for i in range(3):
 *                 self.vd_strides[i] = vp_dir.strides[i] / 8             # <<<<<<<<<<<<<<
 *         else:
 *             self.vd_strides[0] = self.vd_strides[1] = self.vd_strides[2] = -1
 */
      (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->vd_strides[__pyx_v_i]) = ((__pyx_v_vp_dir->strides[__pyx_v_i]) / 8);
    }
    goto __pyx_L10;
  }
  /*else*/ {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":266
 *                 self.vd_strides[i] = vp_dir.strides[i] / 8
 *         else:
 *             self.vd_strides[0] = self.vd_strides[1] = self.vd_strides[2] = -1             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
    (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->vd_strides[0]) = -1;
    (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->vd_strides[1]) = -1;
    (((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)__pyx_v_self)->vd_strides[2]) = -1;
  }
  __pyx_L10:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_center);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_vec);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_vec);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_image);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_vp_pos);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.VectorPlane.__cinit__");
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_center);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x_vec);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y_vec);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_image);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_vp_pos);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF((PyObject *)__pyx_v_vp_pos);
  __Pyx_DECREF((PyObject *)__pyx_v_vp_dir);
  __Pyx_DECREF((PyObject *)__pyx_v_center);
  __Pyx_DECREF(__pyx_v_bounds);
  __Pyx_DECREF((PyObject *)__pyx_v_image);
  __Pyx_DECREF((PyObject *)__pyx_v_x_vec);
  __Pyx_DECREF((PyObject *)__pyx_v_y_vec);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":270
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef void get_start_stop(self, np.float64_t *ex, int *rv):             # <<<<<<<<<<<<<<
 *         # Extrema need to be re-centered
 *         cdef np.float64_t cx, cy
 */

static  void __pyx_f_2yt_9amr_utils_11VectorPlane_get_start_stop(struct __pyx_obj_2yt_9amr_utils_VectorPlane *__pyx_v_self, __pyx_t_5numpy_float64_t *__pyx_v_ex, int *__pyx_v_rv) {
  __pyx_t_5numpy_float64_t __pyx_v_cx;
  __pyx_t_5numpy_float64_t __pyx_v_cy;
  int __pyx_v_i;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("get_start_stop");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":274
 *         cdef np.float64_t cx, cy
 *         cdef int i
 *         cx = cy = 0.0             # <<<<<<<<<<<<<<
 *         for i in range(3):
 *             cx += self.center[i] * self.x_vec[i]
 */
  __pyx_v_cx = 0.0;
  __pyx_v_cy = 0.0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":275
 *         cdef int i
 *         cx = cy = 0.0
 *         for i in range(3):             # <<<<<<<<<<<<<<
 *             cx += self.center[i] * self.x_vec[i]
 *             cy += self.center[i] * self.y_vec[i]
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":276
 *         cx = cy = 0.0
 *         for i in range(3):
 *             cx += self.center[i] * self.x_vec[i]             # <<<<<<<<<<<<<<
 *             cy += self.center[i] * self.y_vec[i]
 *         rv[0] = lrint((ex[0] - cx - self.bounds[0])/self.pdx)
 */
    __pyx_v_cx += ((__pyx_v_self->center[__pyx_v_i]) * (__pyx_v_self->x_vec[__pyx_v_i]));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":277
 *         for i in range(3):
 *             cx += self.center[i] * self.x_vec[i]
 *             cy += self.center[i] * self.y_vec[i]             # <<<<<<<<<<<<<<
 *         rv[0] = lrint((ex[0] - cx - self.bounds[0])/self.pdx)
 *         rv[1] = rv[0] + lrint((ex[1] - ex[0])/self.pdx)
 */
    __pyx_v_cy += ((__pyx_v_self->center[__pyx_v_i]) * (__pyx_v_self->y_vec[__pyx_v_i]));
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":278
 *             cx += self.center[i] * self.x_vec[i]
 *             cy += self.center[i] * self.y_vec[i]
 *         rv[0] = lrint((ex[0] - cx - self.bounds[0])/self.pdx)             # <<<<<<<<<<<<<<
 *         rv[1] = rv[0] + lrint((ex[1] - ex[0])/self.pdx)
 *         rv[2] = lrint((ex[2] - cy - self.bounds[2])/self.pdy)
 */
  (__pyx_v_rv[0]) = lrint(((((__pyx_v_ex[0]) - __pyx_v_cx) - (__pyx_v_self->bounds[0])) / __pyx_v_self->pdx));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":279
 *             cy += self.center[i] * self.y_vec[i]
 *         rv[0] = lrint((ex[0] - cx - self.bounds[0])/self.pdx)
 *         rv[1] = rv[0] + lrint((ex[1] - ex[0])/self.pdx)             # <<<<<<<<<<<<<<
 *         rv[2] = lrint((ex[2] - cy - self.bounds[2])/self.pdy)
 *         rv[3] = rv[2] + lrint((ex[3] - ex[2])/self.pdy)
 */
  (__pyx_v_rv[1]) = ((__pyx_v_rv[0]) + lrint((((__pyx_v_ex[1]) - (__pyx_v_ex[0])) / __pyx_v_self->pdx)));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":280
 *         rv[0] = lrint((ex[0] - cx - self.bounds[0])/self.pdx)
 *         rv[1] = rv[0] + lrint((ex[1] - ex[0])/self.pdx)
 *         rv[2] = lrint((ex[2] - cy - self.bounds[2])/self.pdy)             # <<<<<<<<<<<<<<
 *         rv[3] = rv[2] + lrint((ex[3] - ex[2])/self.pdy)
 * 
 */
  (__pyx_v_rv[2]) = lrint(((((__pyx_v_ex[2]) - __pyx_v_cy) - (__pyx_v_self->bounds[2])) / __pyx_v_self->pdy));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":281
 *         rv[1] = rv[0] + lrint((ex[1] - ex[0])/self.pdx)
 *         rv[2] = lrint((ex[2] - cy - self.bounds[2])/self.pdy)
 *         rv[3] = rv[2] + lrint((ex[3] - ex[2])/self.pdy)             # <<<<<<<<<<<<<<
 * 
 *     cdef inline void copy_into(self, np.float64_t *fv, np.float64_t *tv,
 */
  (__pyx_v_rv[3]) = ((__pyx_v_rv[2]) + lrint((((__pyx_v_ex[3]) - (__pyx_v_ex[2])) / __pyx_v_self->pdy)));

  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":283
 *         rv[3] = rv[2] + lrint((ex[3] - ex[2])/self.pdy)
 * 
 *     cdef inline void copy_into(self, np.float64_t *fv, np.float64_t *tv,             # <<<<<<<<<<<<<<
 *                         int i, int j, int nk, int strides[3]):
 *         # We know the first two dimensions of our from-vector, and our
 */

static CYTHON_INLINE void __pyx_f_2yt_9amr_utils_11VectorPlane_copy_into(struct __pyx_obj_2yt_9amr_utils_VectorPlane *__pyx_v_self, __pyx_t_5numpy_float64_t *__pyx_v_fv, __pyx_t_5numpy_float64_t *__pyx_v_tv, int __pyx_v_i, int __pyx_v_j, int __pyx_v_nk, int *__pyx_v_strides) {
  int __pyx_v_k;
  int __pyx_v_offset;
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("copy_into");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":288
 *         # to-vector is flat and 'ni' long
 *         cdef int k
 *         cdef int offset = strides[0] * i + strides[1] * j             # <<<<<<<<<<<<<<
 *         for k in range(nk):
 *             tv[k] = fv[offset + k]
 */
  __pyx_v_offset = (((__pyx_v_strides[0]) * __pyx_v_i) + ((__pyx_v_strides[1]) * __pyx_v_j));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":289
 *         cdef int k
 *         cdef int offset = strides[0] * i + strides[1] * j
 *         for k in range(nk):             # <<<<<<<<<<<<<<
 *             tv[k] = fv[offset + k]
 * 
 */
  __pyx_t_1 = __pyx_v_nk;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_k = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":290
 *         cdef int offset = strides[0] * i + strides[1] * j
 *         for k in range(nk):
 *             tv[k] = fv[offset + k]             # <<<<<<<<<<<<<<
 * 
 *     cdef inline void copy_back(self, np.float64_t *fv, np.float64_t *tv,
 */
    (__pyx_v_tv[__pyx_v_k]) = (__pyx_v_fv[(__pyx_v_offset + __pyx_v_k)]);
  }

  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":292
 *             tv[k] = fv[offset + k]
 * 
 *     cdef inline void copy_back(self, np.float64_t *fv, np.float64_t *tv,             # <<<<<<<<<<<<<<
 *                         int i, int j, int nk, int strides[3]):
 *         cdef int k
 */

static CYTHON_INLINE void __pyx_f_2yt_9amr_utils_11VectorPlane_copy_back(struct __pyx_obj_2yt_9amr_utils_VectorPlane *__pyx_v_self, __pyx_t_5numpy_float64_t *__pyx_v_fv, __pyx_t_5numpy_float64_t *__pyx_v_tv, int __pyx_v_i, int __pyx_v_j, int __pyx_v_nk, int *__pyx_v_strides) {
  int __pyx_v_k;
  int __pyx_v_offset;
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("copy_back");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":295
 *                         int i, int j, int nk, int strides[3]):
 *         cdef int k
 *         cdef int offset = strides[0] * i + strides[1] * j             # <<<<<<<<<<<<<<
 *         for k in range(nk):
 *             tv[offset + k] = fv[k]
 */
  __pyx_v_offset = (((__pyx_v_strides[0]) * __pyx_v_i) + ((__pyx_v_strides[1]) * __pyx_v_j));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":296
 *         cdef int k
 *         cdef int offset = strides[0] * i + strides[1] * j
 *         for k in range(nk):             # <<<<<<<<<<<<<<
 *             tv[offset + k] = fv[k]
 * 
 */
  __pyx_t_1 = __pyx_v_nk;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_k = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":297
 *         cdef int offset = strides[0] * i + strides[1] * j
 *         for k in range(nk):
 *             tv[offset + k] = fv[k]             # <<<<<<<<<<<<<<
 * 
 * cdef class PartitionedGrid:
 */
    (__pyx_v_tv[(__pyx_v_offset + __pyx_v_k)]) = (__pyx_v_fv[__pyx_v_k]);
  }

  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":315
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def __cinit__(self,             # <<<<<<<<<<<<<<
 *                   int parent_grid_id, int n_fields, data,
 *                   np.ndarray[np.float64_t, ndim=1] left_edge,
 */

static int __pyx_pf_2yt_9amr_utils_15PartitionedGrid___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_2yt_9amr_utils_15PartitionedGrid___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_parent_grid_id;
  int __pyx_v_n_fields;
  PyObject *__pyx_v_data = 0;
  PyArrayObject *__pyx_v_left_edge = 0;
  PyArrayObject *__pyx_v_right_edge = 0;
  PyArrayObject *__pyx_v_dims = 0;
  int __pyx_v_i;
  PyArrayObject *__pyx_v_tdata;
  Py_buffer __pyx_bstruct_tdata;
  Py_ssize_t __pyx_bstride_0_tdata = 0;
  Py_ssize_t __pyx_bstride_1_tdata = 0;
  Py_ssize_t __pyx_bstride_2_tdata = 0;
  Py_ssize_t __pyx_bshape_0_tdata = 0;
  Py_ssize_t __pyx_bshape_1_tdata = 0;
  Py_ssize_t __pyx_bshape_2_tdata = 0;
  Py_buffer __pyx_bstruct_right_edge;
  Py_ssize_t __pyx_bstride_0_right_edge = 0;
  Py_ssize_t __pyx_bshape_0_right_edge = 0;
  Py_buffer __pyx_bstruct_dims;
  Py_ssize_t __pyx_bstride_0_dims = 0;
  Py_ssize_t __pyx_bshape_0_dims = 0;
  Py_buffer __pyx_bstruct_left_edge;
  Py_ssize_t __pyx_bstride_0_left_edge = 0;
  Py_ssize_t __pyx_bshape_0_left_edge = 0;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyArrayObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__parent_grid_id,&__pyx_n_s__n_fields,&__pyx_n_s__data,&__pyx_n_s__left_edge,&__pyx_n_s__right_edge,&__pyx_n_s__dims,0};
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[6] = {0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parent_grid_id);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__n_fields);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__data);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__left_edge);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__right_edge);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, 4); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dims);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, 5); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_parent_grid_id = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_parent_grid_id == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_n_fields = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_n_fields == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_data = values[2];
    __pyx_v_left_edge = ((PyArrayObject *)values[3]);
    __pyx_v_right_edge = ((PyArrayObject *)values[4]);
    __pyx_v_dims = ((PyArrayObject *)values[5]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_parent_grid_id = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_parent_grid_id == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_n_fields = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_n_fields == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_data = PyTuple_GET_ITEM(__pyx_args, 2);
    __pyx_v_left_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_right_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_dims = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 5));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.PartitionedGrid.__cinit__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF(__pyx_v_data);
  __Pyx_INCREF((PyObject *)__pyx_v_left_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_right_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_dims);
  __pyx_v_tdata = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_bstruct_tdata.buf = NULL;
  __pyx_bstruct_left_edge.buf = NULL;
  __pyx_bstruct_right_edge.buf = NULL;
  __pyx_bstruct_dims.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_left_edge), __pyx_ptype_5numpy_ndarray, 1, "left_edge", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_right_edge), __pyx_ptype_5numpy_ndarray, 1, "right_edge", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dims), __pyx_ptype_5numpy_ndarray, 1, "dims", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_left_edge, (PyObject*)__pyx_v_left_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_left_edge = __pyx_bstruct_left_edge.strides[0];
  __pyx_bshape_0_left_edge = __pyx_bstruct_left_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_right_edge, (PyObject*)__pyx_v_right_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_right_edge = __pyx_bstruct_right_edge.strides[0];
  __pyx_bshape_0_right_edge = __pyx_bstruct_right_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dims, (PyObject*)__pyx_v_dims, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_dims = __pyx_bstruct_dims.strides[0];
  __pyx_bshape_0_dims = __pyx_bstruct_dims.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":323
 *         cdef int i, j, k, size
 *         cdef np.ndarray[np.float64_t, ndim=3] tdata
 *         self.parent_grid_id = parent_grid_id             # <<<<<<<<<<<<<<
 *         self.LeftEdge = left_edge
 *         self.RightEdge = right_edge
 */
  ((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->parent_grid_id = __pyx_v_parent_grid_id;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":324
 *         cdef np.ndarray[np.float64_t, ndim=3] tdata
 *         self.parent_grid_id = parent_grid_id
 *         self.LeftEdge = left_edge             # <<<<<<<<<<<<<<
 *         self.RightEdge = right_edge
 *         for i in range(3):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_left_edge));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_left_edge));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->LeftEdge);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->LeftEdge);
  ((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->LeftEdge = ((PyObject *)__pyx_v_left_edge);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":325
 *         self.parent_grid_id = parent_grid_id
 *         self.LeftEdge = left_edge
 *         self.RightEdge = right_edge             # <<<<<<<<<<<<<<
 *         for i in range(3):
 *             self.left_edge[i] = left_edge[i]
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_right_edge));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_right_edge));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->RightEdge);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->RightEdge);
  ((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->RightEdge = ((PyObject *)__pyx_v_right_edge);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":326
 *         self.LeftEdge = left_edge
 *         self.RightEdge = right_edge
 *         for i in range(3):             # <<<<<<<<<<<<<<
 *             self.left_edge[i] = left_edge[i]
 *             self.right_edge[i] = right_edge[i]
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":327
 *         self.RightEdge = right_edge
 *         for i in range(3):
 *             self.left_edge[i] = left_edge[i]             # <<<<<<<<<<<<<<
 *             self.right_edge[i] = right_edge[i]
 *             self.dims[i] = dims[i]
 */
    __pyx_t_2 = __pyx_v_i;
    (((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->left_edge[__pyx_v_i]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_2, __pyx_bstride_0_left_edge));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":328
 *         for i in range(3):
 *             self.left_edge[i] = left_edge[i]
 *             self.right_edge[i] = right_edge[i]             # <<<<<<<<<<<<<<
 *             self.dims[i] = dims[i]
 *             self.dds[i] = (self.right_edge[i] - self.left_edge[i])/dims[i]
 */
    __pyx_t_3 = __pyx_v_i;
    (((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->right_edge[__pyx_v_i]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_3, __pyx_bstride_0_right_edge));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":329
 *             self.left_edge[i] = left_edge[i]
 *             self.right_edge[i] = right_edge[i]
 *             self.dims[i] = dims[i]             # <<<<<<<<<<<<<<
 *             self.dds[i] = (self.right_edge[i] - self.left_edge[i])/dims[i]
 *             self.idds[i] = 1.0/self.dds[i]
 */
    __pyx_t_4 = __pyx_v_i;
    (((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->dims[__pyx_v_i]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_dims.buf, __pyx_t_4, __pyx_bstride_0_dims));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":330
 *             self.right_edge[i] = right_edge[i]
 *             self.dims[i] = dims[i]
 *             self.dds[i] = (self.right_edge[i] - self.left_edge[i])/dims[i]             # <<<<<<<<<<<<<<
 *             self.idds[i] = 1.0/self.dds[i]
 *         self.my_data = data
 */
    __pyx_t_5 = __pyx_v_i;
    (((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->dds[__pyx_v_i]) = (((((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->right_edge[__pyx_v_i]) - (((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->left_edge[__pyx_v_i])) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_dims.buf, __pyx_t_5, __pyx_bstride_0_dims)));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":331
 *             self.dims[i] = dims[i]
 *             self.dds[i] = (self.right_edge[i] - self.left_edge[i])/dims[i]
 *             self.idds[i] = 1.0/self.dds[i]             # <<<<<<<<<<<<<<
 *         self.my_data = data
 *         self.n_fields = n_fields
 */
    (((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->idds[__pyx_v_i]) = (1.0 / (((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->dds[__pyx_v_i]));
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":332
 *             self.dds[i] = (self.right_edge[i] - self.left_edge[i])/dims[i]
 *             self.idds[i] = 1.0/self.dds[i]
 *         self.my_data = data             # <<<<<<<<<<<<<<
 *         self.n_fields = n_fields
 *         for i in range(n_fields):
 */
  __Pyx_INCREF(__pyx_v_data);
  __Pyx_GIVEREF(__pyx_v_data);
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->my_data);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->my_data);
  ((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->my_data = __pyx_v_data;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":333
 *             self.idds[i] = 1.0/self.dds[i]
 *         self.my_data = data
 *         self.n_fields = n_fields             # <<<<<<<<<<<<<<
 *         for i in range(n_fields):
 *             tdata = data[i]
 */
  ((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->n_fields = __pyx_v_n_fields;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":334
 *         self.my_data = data
 *         self.n_fields = n_fields
 *         for i in range(n_fields):             # <<<<<<<<<<<<<<
 *             tdata = data[i]
 *             self.data[i] = <np.float64_t *> tdata.data
 */
  __pyx_t_1 = __pyx_v_n_fields;
  for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_1; __pyx_t_6+=1) {
    __pyx_v_i = __pyx_t_6;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":335
 *         self.n_fields = n_fields
 *         for i in range(n_fields):
 *             tdata = data[i]             # <<<<<<<<<<<<<<
 *             self.data[i] = <np.float64_t *> tdata.data
 * 
 */
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_data, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = ((PyArrayObject *)__pyx_t_7);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_bstruct_tdata);
      __pyx_t_9 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_tdata, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack);
      if (unlikely(__pyx_t_9 < 0)) {
        PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_tdata, (PyObject*)__pyx_v_tdata, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
        }
      }
      __pyx_bstride_0_tdata = __pyx_bstruct_tdata.strides[0]; __pyx_bstride_1_tdata = __pyx_bstruct_tdata.strides[1]; __pyx_bstride_2_tdata = __pyx_bstruct_tdata.strides[2];
      __pyx_bshape_0_tdata = __pyx_bstruct_tdata.shape[0]; __pyx_bshape_1_tdata = __pyx_bstruct_tdata.shape[1]; __pyx_bshape_2_tdata = __pyx_bstruct_tdata.shape[2];
      if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_8 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_tdata));
    __pyx_v_tdata = ((PyArrayObject *)__pyx_t_7);
    __pyx_t_7 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":336
 *         for i in range(n_fields):
 *             tdata = data[i]
 *             self.data[i] = <np.float64_t *> tdata.data             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
    (((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->data[__pyx_v_i]) = ((__pyx_t_5numpy_float64_t *)__pyx_v_tdata->data);
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_tdata);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dims);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.PartitionedGrid.__cinit__");
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_tdata);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dims);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_tdata);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_data);
  __Pyx_DECREF((PyObject *)__pyx_v_left_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_right_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_dims);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":340
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def cast_plane(self, TransferFunctionProxy tf, VectorPlane vp):             # <<<<<<<<<<<<<<
 *         # This routine will iterate over all of the vectors and cast each in
 *         # turn.  Might benefit from a more sophisticated intersection check,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_15PartitionedGrid_cast_plane(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_15PartitionedGrid_cast_plane(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *__pyx_v_tf = 0;
  struct __pyx_obj_2yt_9amr_utils_VectorPlane *__pyx_v_vp = 0;
  int __pyx_v_vi;
  int __pyx_v_vj;
  int __pyx_v_hit;
  int __pyx_v_iter[4];
  __pyx_t_5numpy_float64_t __pyx_v_v_pos[3];
  __pyx_t_5numpy_float64_t __pyx_v_v_dir[3];
  __pyx_t_5numpy_float64_t __pyx_v_rgba[6];
  __pyx_t_5numpy_float64_t __pyx_v_extrema[4];
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__tf,&__pyx_n_s__vp,0};
  __Pyx_RefNannySetupContext("cast_plane");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tf);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__vp);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("cast_plane", 1, 2, 2, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "cast_plane") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_tf = ((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)values[0]);
    __pyx_v_vp = ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)values[1]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_tf = ((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_vp = ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)PyTuple_GET_ITEM(__pyx_args, 1));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("cast_plane", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.PartitionedGrid.cast_plane");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF((PyObject *)__pyx_v_tf);
  __Pyx_INCREF((PyObject *)__pyx_v_vp);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tf), __pyx_ptype_2yt_9amr_utils_TransferFunctionProxy, 1, "tf", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_vp), __pyx_ptype_2yt_9amr_utils_VectorPlane, 1, "vp", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":347
 *         cdef int iter[4]
 *         cdef np.float64_t v_pos[3], v_dir[3], rgba[6], extrema[4]
 *         hit = 0             # <<<<<<<<<<<<<<
 *         self.calculate_extent(vp, extrema)
 *         vp.get_start_stop(extrema, iter)
 */
  __pyx_v_hit = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":348
 *         cdef np.float64_t v_pos[3], v_dir[3], rgba[6], extrema[4]
 *         hit = 0
 *         self.calculate_extent(vp, extrema)             # <<<<<<<<<<<<<<
 *         vp.get_start_stop(extrema, iter)
 *         iter[0] = iclip(iter[0], 0, vp.nv[0])
 */
  ((struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid *)((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->__pyx_vtab)->calculate_extent(((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self), __pyx_v_vp, __pyx_v_extrema);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":349
 *         hit = 0
 *         self.calculate_extent(vp, extrema)
 *         vp.get_start_stop(extrema, iter)             # <<<<<<<<<<<<<<
 *         iter[0] = iclip(iter[0], 0, vp.nv[0])
 *         iter[1] = iclip(iter[1], 0, vp.nv[0])
 */
  ((struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane *)__pyx_v_vp->__pyx_vtab)->get_start_stop(__pyx_v_vp, __pyx_v_extrema, __pyx_v_iter);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":350
 *         self.calculate_extent(vp, extrema)
 *         vp.get_start_stop(extrema, iter)
 *         iter[0] = iclip(iter[0], 0, vp.nv[0])             # <<<<<<<<<<<<<<
 *         iter[1] = iclip(iter[1], 0, vp.nv[0])
 *         iter[2] = iclip(iter[2], 0, vp.nv[1])
 */
  (__pyx_v_iter[0]) = __pyx_f_2yt_9amr_utils_iclip((__pyx_v_iter[0]), 0, (__pyx_v_vp->nv[0]));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":351
 *         vp.get_start_stop(extrema, iter)
 *         iter[0] = iclip(iter[0], 0, vp.nv[0])
 *         iter[1] = iclip(iter[1], 0, vp.nv[0])             # <<<<<<<<<<<<<<
 *         iter[2] = iclip(iter[2], 0, vp.nv[1])
 *         iter[3] = iclip(iter[3], 0, vp.nv[1])
 */
  (__pyx_v_iter[1]) = __pyx_f_2yt_9amr_utils_iclip((__pyx_v_iter[1]), 0, (__pyx_v_vp->nv[0]));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":352
 *         iter[0] = iclip(iter[0], 0, vp.nv[0])
 *         iter[1] = iclip(iter[1], 0, vp.nv[0])
 *         iter[2] = iclip(iter[2], 0, vp.nv[1])             # <<<<<<<<<<<<<<
 *         iter[3] = iclip(iter[3], 0, vp.nv[1])
 *         if vp.vd_strides[0] == -1:
 */
  (__pyx_v_iter[2]) = __pyx_f_2yt_9amr_utils_iclip((__pyx_v_iter[2]), 0, (__pyx_v_vp->nv[1]));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":353
 *         iter[1] = iclip(iter[1], 0, vp.nv[0])
 *         iter[2] = iclip(iter[2], 0, vp.nv[1])
 *         iter[3] = iclip(iter[3], 0, vp.nv[1])             # <<<<<<<<<<<<<<
 *         if vp.vd_strides[0] == -1:
 *             for vi in range(iter[0], iter[1]):
 */
  (__pyx_v_iter[3]) = __pyx_f_2yt_9amr_utils_iclip((__pyx_v_iter[3]), 0, (__pyx_v_vp->nv[1]));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":354
 *         iter[2] = iclip(iter[2], 0, vp.nv[1])
 *         iter[3] = iclip(iter[3], 0, vp.nv[1])
 *         if vp.vd_strides[0] == -1:             # <<<<<<<<<<<<<<
 *             for vi in range(iter[0], iter[1]):
 *                 for vj in range(iter[2], iter[3]):
 */
  __pyx_t_1 = ((__pyx_v_vp->vd_strides[0]) == -1);
  if (__pyx_t_1) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":355
 *         iter[3] = iclip(iter[3], 0, vp.nv[1])
 *         if vp.vd_strides[0] == -1:
 *             for vi in range(iter[0], iter[1]):             # <<<<<<<<<<<<<<
 *                 for vj in range(iter[2], iter[3]):
 *                     vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3, vp.vp_strides)
 */
    __pyx_t_2 = (__pyx_v_iter[1]);
    for (__pyx_t_3 = (__pyx_v_iter[0]); __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_vi = __pyx_t_3;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":356
 *         if vp.vd_strides[0] == -1:
 *             for vi in range(iter[0], iter[1]):
 *                 for vj in range(iter[2], iter[3]):             # <<<<<<<<<<<<<<
 *                     vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3, vp.vp_strides)
 *                     vp.copy_into(vp.image, rgba, vi, vj, 3, vp.im_strides)
 */
      __pyx_t_4 = (__pyx_v_iter[3]);
      for (__pyx_t_5 = (__pyx_v_iter[2]); __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
        __pyx_v_vj = __pyx_t_5;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":357
 *             for vi in range(iter[0], iter[1]):
 *                 for vj in range(iter[2], iter[3]):
 *                     vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3, vp.vp_strides)             # <<<<<<<<<<<<<<
 *                     vp.copy_into(vp.image, rgba, vi, vj, 3, vp.im_strides)
 *                     self.integrate_ray(v_pos, vp.vp_dir, rgba, tf)
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane *)__pyx_v_vp->__pyx_vtab)->copy_into(__pyx_v_vp, __pyx_v_vp->vp_pos, __pyx_v_v_pos, __pyx_v_vi, __pyx_v_vj, 3, __pyx_v_vp->vp_strides);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":358
 *                 for vj in range(iter[2], iter[3]):
 *                     vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3, vp.vp_strides)
 *                     vp.copy_into(vp.image, rgba, vi, vj, 3, vp.im_strides)             # <<<<<<<<<<<<<<
 *                     self.integrate_ray(v_pos, vp.vp_dir, rgba, tf)
 *                     vp.copy_back(rgba, vp.image, vi, vj, 3, vp.im_strides)
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane *)__pyx_v_vp->__pyx_vtab)->copy_into(__pyx_v_vp, __pyx_v_vp->image, __pyx_v_rgba, __pyx_v_vi, __pyx_v_vj, 3, __pyx_v_vp->im_strides);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":359
 *                     vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3, vp.vp_strides)
 *                     vp.copy_into(vp.image, rgba, vi, vj, 3, vp.im_strides)
 *                     self.integrate_ray(v_pos, vp.vp_dir, rgba, tf)             # <<<<<<<<<<<<<<
 *                     vp.copy_back(rgba, vp.image, vi, vj, 3, vp.im_strides)
 *         else:
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid *)((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->__pyx_vtab)->integrate_ray(((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self), __pyx_v_v_pos, __pyx_v_vp->vp_dir, __pyx_v_rgba, __pyx_v_tf);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":360
 *                     vp.copy_into(vp.image, rgba, vi, vj, 3, vp.im_strides)
 *                     self.integrate_ray(v_pos, vp.vp_dir, rgba, tf)
 *                     vp.copy_back(rgba, vp.image, vi, vj, 3, vp.im_strides)             # <<<<<<<<<<<<<<
 *         else:
 *             # If we do not have an orthographic projection, we have to cast all
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane *)__pyx_v_vp->__pyx_vtab)->copy_back(__pyx_v_vp, __pyx_v_rgba, __pyx_v_vp->image, __pyx_v_vi, __pyx_v_vj, 3, __pyx_v_vp->im_strides);
      }
    }
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":364
 *             # If we do not have an orthographic projection, we have to cast all
 *             # our rays (until we can get an extrema calculation...)
 *             for vi in range(vp.nv[0]):             # <<<<<<<<<<<<<<
 *                 for vj in range(vp.nv[1]):
 *                     vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3, vp.vp_strides)
 */
    __pyx_t_2 = (__pyx_v_vp->nv[0]);
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_vi = __pyx_t_3;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":365
 *             # our rays (until we can get an extrema calculation...)
 *             for vi in range(vp.nv[0]):
 *                 for vj in range(vp.nv[1]):             # <<<<<<<<<<<<<<
 *                     vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3, vp.vp_strides)
 *                     vp.copy_into(vp.image, rgba, vi, vj, 3, vp.im_strides)
 */
      __pyx_t_4 = (__pyx_v_vp->nv[1]);
      for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
        __pyx_v_vj = __pyx_t_5;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":366
 *             for vi in range(vp.nv[0]):
 *                 for vj in range(vp.nv[1]):
 *                     vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3, vp.vp_strides)             # <<<<<<<<<<<<<<
 *                     vp.copy_into(vp.image, rgba, vi, vj, 3, vp.im_strides)
 *                     vp.copy_into(vp.vp_dir, v_dir, vi, vj, 3, vp.vd_strides)
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane *)__pyx_v_vp->__pyx_vtab)->copy_into(__pyx_v_vp, __pyx_v_vp->vp_pos, __pyx_v_v_pos, __pyx_v_vi, __pyx_v_vj, 3, __pyx_v_vp->vp_strides);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":367
 *                 for vj in range(vp.nv[1]):
 *                     vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3, vp.vp_strides)
 *                     vp.copy_into(vp.image, rgba, vi, vj, 3, vp.im_strides)             # <<<<<<<<<<<<<<
 *                     vp.copy_into(vp.vp_dir, v_dir, vi, vj, 3, vp.vd_strides)
 *                     self.integrate_ray(v_pos, v_dir, rgba, tf)
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane *)__pyx_v_vp->__pyx_vtab)->copy_into(__pyx_v_vp, __pyx_v_vp->image, __pyx_v_rgba, __pyx_v_vi, __pyx_v_vj, 3, __pyx_v_vp->im_strides);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":368
 *                     vp.copy_into(vp.vp_pos, v_pos, vi, vj, 3, vp.vp_strides)
 *                     vp.copy_into(vp.image, rgba, vi, vj, 3, vp.im_strides)
 *                     vp.copy_into(vp.vp_dir, v_dir, vi, vj, 3, vp.vd_strides)             # <<<<<<<<<<<<<<
 *                     self.integrate_ray(v_pos, v_dir, rgba, tf)
 *                     vp.copy_back(rgba, vp.image, vi, vj, 3, vp.im_strides)
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane *)__pyx_v_vp->__pyx_vtab)->copy_into(__pyx_v_vp, __pyx_v_vp->vp_dir, __pyx_v_v_dir, __pyx_v_vi, __pyx_v_vj, 3, __pyx_v_vp->vd_strides);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":369
 *                     vp.copy_into(vp.image, rgba, vi, vj, 3, vp.im_strides)
 *                     vp.copy_into(vp.vp_dir, v_dir, vi, vj, 3, vp.vd_strides)
 *                     self.integrate_ray(v_pos, v_dir, rgba, tf)             # <<<<<<<<<<<<<<
 *                     vp.copy_back(rgba, vp.image, vi, vj, 3, vp.im_strides)
 *         return hit
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid *)((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self)->__pyx_vtab)->integrate_ray(((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self), __pyx_v_v_pos, __pyx_v_v_dir, __pyx_v_rgba, __pyx_v_tf);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":370
 *                     vp.copy_into(vp.vp_dir, v_dir, vi, vj, 3, vp.vd_strides)
 *                     self.integrate_ray(v_pos, v_dir, rgba, tf)
 *                     vp.copy_back(rgba, vp.image, vi, vj, 3, vp.im_strides)             # <<<<<<<<<<<<<<
 *         return hit
 * 
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane *)__pyx_v_vp->__pyx_vtab)->copy_back(__pyx_v_vp, __pyx_v_rgba, __pyx_v_vp->image, __pyx_v_vi, __pyx_v_vj, 3, __pyx_v_vp->im_strides);
      }
    }
  }
  __pyx_L6:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":371
 *                     self.integrate_ray(v_pos, v_dir, rgba, tf)
 *                     vp.copy_back(rgba, vp.image, vi, vj, 3, vp.im_strides)
 *         return hit             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = PyInt_FromLong(__pyx_v_hit); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("yt.amr_utils.PartitionedGrid.cast_plane");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF((PyObject *)__pyx_v_tf);
  __Pyx_DECREF((PyObject *)__pyx_v_vp);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":375
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef void calculate_extent(self, VectorPlane vp,             # <<<<<<<<<<<<<<
 *                                np.float64_t extrema[4]):
 *         # We do this for all eight corners
 */

static  void __pyx_f_2yt_9amr_utils_15PartitionedGrid_calculate_extent(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *__pyx_v_self, struct __pyx_obj_2yt_9amr_utils_VectorPlane *__pyx_v_vp, __pyx_t_5numpy_float64_t *__pyx_v_extrema) {
  __pyx_t_5numpy_float64_t *__pyx_v_edges[2];
  __pyx_t_5numpy_float64_t __pyx_v_temp;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  double __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  __Pyx_RefNannySetupContext("calculate_extent");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF((PyObject *)__pyx_v_vp);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":379
 *         # We do this for all eight corners
 *         cdef np.float64_t *edges[2], temp
 *         edges[0] = self.left_edge             # <<<<<<<<<<<<<<
 *         edges[1] = self.right_edge
 *         extrema[0] = extrema[2] = 1e300; extrema[1] = extrema[3] = -1e300
 */
  (__pyx_v_edges[0]) = __pyx_v_self->left_edge;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":380
 *         cdef np.float64_t *edges[2], temp
 *         edges[0] = self.left_edge
 *         edges[1] = self.right_edge             # <<<<<<<<<<<<<<
 *         extrema[0] = extrema[2] = 1e300; extrema[1] = extrema[3] = -1e300
 *         cdef int i, j, k
 */
  (__pyx_v_edges[1]) = __pyx_v_self->right_edge;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":381
 *         edges[0] = self.left_edge
 *         edges[1] = self.right_edge
 *         extrema[0] = extrema[2] = 1e300; extrema[1] = extrema[3] = -1e300             # <<<<<<<<<<<<<<
 *         cdef int i, j, k
 *         for i in range(2):
 */
  (__pyx_v_extrema[0]) = 1.0000000000000001e+300;
  (__pyx_v_extrema[2]) = 1.0000000000000001e+300;
  __pyx_t_1 = (-1.0000000000000001e+300);
  (__pyx_v_extrema[1]) = __pyx_t_1;
  (__pyx_v_extrema[3]) = __pyx_t_1;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":383
 *         extrema[0] = extrema[2] = 1e300; extrema[1] = extrema[3] = -1e300
 *         cdef int i, j, k
 *         for i in range(2):             # <<<<<<<<<<<<<<
 *             for j in range(2):
 *                 for k in range(2):
 */
  for (__pyx_t_2 = 0; __pyx_t_2 < 2; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":384
 *         cdef int i, j, k
 *         for i in range(2):
 *             for j in range(2):             # <<<<<<<<<<<<<<
 *                 for k in range(2):
 *                     # This should rotate it into the vector plane
 */
    for (__pyx_t_3 = 0; __pyx_t_3 < 2; __pyx_t_3+=1) {
      __pyx_v_j = __pyx_t_3;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":385
 *         for i in range(2):
 *             for j in range(2):
 *                 for k in range(2):             # <<<<<<<<<<<<<<
 *                     # This should rotate it into the vector plane
 *                     temp  = edges[i][0] * vp.x_vec[0]
 */
      for (__pyx_t_4 = 0; __pyx_t_4 < 2; __pyx_t_4+=1) {
        __pyx_v_k = __pyx_t_4;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":387
 *                 for k in range(2):
 *                     # This should rotate it into the vector plane
 *                     temp  = edges[i][0] * vp.x_vec[0]             # <<<<<<<<<<<<<<
 *                     temp += edges[j][1] * vp.x_vec[1]
 *                     temp += edges[k][2] * vp.x_vec[2]
 */
        __pyx_v_temp = (((__pyx_v_edges[__pyx_v_i])[0]) * (__pyx_v_vp->x_vec[0]));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":388
 *                     # This should rotate it into the vector plane
 *                     temp  = edges[i][0] * vp.x_vec[0]
 *                     temp += edges[j][1] * vp.x_vec[1]             # <<<<<<<<<<<<<<
 *                     temp += edges[k][2] * vp.x_vec[2]
 *                     if temp < extrema[0]: extrema[0] = temp
 */
        __pyx_v_temp += (((__pyx_v_edges[__pyx_v_j])[1]) * (__pyx_v_vp->x_vec[1]));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":389
 *                     temp  = edges[i][0] * vp.x_vec[0]
 *                     temp += edges[j][1] * vp.x_vec[1]
 *                     temp += edges[k][2] * vp.x_vec[2]             # <<<<<<<<<<<<<<
 *                     if temp < extrema[0]: extrema[0] = temp
 *                     if temp > extrema[1]: extrema[1] = temp
 */
        __pyx_v_temp += (((__pyx_v_edges[__pyx_v_k])[2]) * (__pyx_v_vp->x_vec[2]));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":390
 *                     temp += edges[j][1] * vp.x_vec[1]
 *                     temp += edges[k][2] * vp.x_vec[2]
 *                     if temp < extrema[0]: extrema[0] = temp             # <<<<<<<<<<<<<<
 *                     if temp > extrema[1]: extrema[1] = temp
 *                     temp  = edges[i][0] * vp.y_vec[0]
 */
        __pyx_t_5 = (__pyx_v_temp < (__pyx_v_extrema[0]));
        if (__pyx_t_5) {
          (__pyx_v_extrema[0]) = __pyx_v_temp;
          goto __pyx_L9;
        }
        __pyx_L9:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":391
 *                     temp += edges[k][2] * vp.x_vec[2]
 *                     if temp < extrema[0]: extrema[0] = temp
 *                     if temp > extrema[1]: extrema[1] = temp             # <<<<<<<<<<<<<<
 *                     temp  = edges[i][0] * vp.y_vec[0]
 *                     temp += edges[j][1] * vp.y_vec[1]
 */
        __pyx_t_5 = (__pyx_v_temp > (__pyx_v_extrema[1]));
        if (__pyx_t_5) {
          (__pyx_v_extrema[1]) = __pyx_v_temp;
          goto __pyx_L10;
        }
        __pyx_L10:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":392
 *                     if temp < extrema[0]: extrema[0] = temp
 *                     if temp > extrema[1]: extrema[1] = temp
 *                     temp  = edges[i][0] * vp.y_vec[0]             # <<<<<<<<<<<<<<
 *                     temp += edges[j][1] * vp.y_vec[1]
 *                     temp += edges[k][2] * vp.y_vec[2]
 */
        __pyx_v_temp = (((__pyx_v_edges[__pyx_v_i])[0]) * (__pyx_v_vp->y_vec[0]));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":393
 *                     if temp > extrema[1]: extrema[1] = temp
 *                     temp  = edges[i][0] * vp.y_vec[0]
 *                     temp += edges[j][1] * vp.y_vec[1]             # <<<<<<<<<<<<<<
 *                     temp += edges[k][2] * vp.y_vec[2]
 *                     if temp < extrema[2]: extrema[2] = temp
 */
        __pyx_v_temp += (((__pyx_v_edges[__pyx_v_j])[1]) * (__pyx_v_vp->y_vec[1]));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":394
 *                     temp  = edges[i][0] * vp.y_vec[0]
 *                     temp += edges[j][1] * vp.y_vec[1]
 *                     temp += edges[k][2] * vp.y_vec[2]             # <<<<<<<<<<<<<<
 *                     if temp < extrema[2]: extrema[2] = temp
 *                     if temp > extrema[3]: extrema[3] = temp
 */
        __pyx_v_temp += (((__pyx_v_edges[__pyx_v_k])[2]) * (__pyx_v_vp->y_vec[2]));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":395
 *                     temp += edges[j][1] * vp.y_vec[1]
 *                     temp += edges[k][2] * vp.y_vec[2]
 *                     if temp < extrema[2]: extrema[2] = temp             # <<<<<<<<<<<<<<
 *                     if temp > extrema[3]: extrema[3] = temp
 *         #print extrema[0], extrema[1], extrema[2], extrema[3]
 */
        __pyx_t_5 = (__pyx_v_temp < (__pyx_v_extrema[2]));
        if (__pyx_t_5) {
          (__pyx_v_extrema[2]) = __pyx_v_temp;
          goto __pyx_L11;
        }
        __pyx_L11:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":396
 *                     temp += edges[k][2] * vp.y_vec[2]
 *                     if temp < extrema[2]: extrema[2] = temp
 *                     if temp > extrema[3]: extrema[3] = temp             # <<<<<<<<<<<<<<
 *         #print extrema[0], extrema[1], extrema[2], extrema[3]
 * 
 */
        __pyx_t_5 = (__pyx_v_temp > (__pyx_v_extrema[3]));
        if (__pyx_t_5) {
          (__pyx_v_extrema[3]) = __pyx_v_temp;
          goto __pyx_L12;
        }
        __pyx_L12:;
      }
    }
  }

  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF((PyObject *)__pyx_v_vp);
  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":401
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef int integrate_ray(self, np.float64_t v_pos[3],             # <<<<<<<<<<<<<<
 *                                  np.float64_t v_dir[3],
 *                                  np.float64_t rgba[4],
 */

static  int __pyx_f_2yt_9amr_utils_15PartitionedGrid_integrate_ray(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *__pyx_v_self, __pyx_t_5numpy_float64_t *__pyx_v_v_pos, __pyx_t_5numpy_float64_t *__pyx_v_v_dir, __pyx_t_5numpy_float64_t *__pyx_v_rgba, struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *__pyx_v_tf) {
  int __pyx_v_cur_ind[3];
  int __pyx_v_step[3];
  int __pyx_v_x;
  int __pyx_v_y;
  int __pyx_v_i;
  int __pyx_v_hit;
  int __pyx_v_direction;
  __pyx_t_5numpy_float64_t __pyx_v_intersect_t;
  __pyx_t_5numpy_float64_t __pyx_v_iv_dir[3];
  __pyx_t_5numpy_float64_t __pyx_v_intersect[3];
  __pyx_t_5numpy_float64_t __pyx_v_tmax[3];
  __pyx_t_5numpy_float64_t __pyx_v_tdelta[3];
  __pyx_t_5numpy_float64_t __pyx_v_enter_t;
  __pyx_t_5numpy_float64_t __pyx_v_exit_t;
  __pyx_t_5numpy_float64_t __pyx_v_tr;
  __pyx_t_5numpy_float64_t __pyx_v_tl;
  __pyx_t_5numpy_float64_t __pyx_v_temp_x;
  __pyx_t_5numpy_float64_t __pyx_v_temp_y;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  __Pyx_RefNannySetupContext("integrate_ray");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF((PyObject *)__pyx_v_tf);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":406
 *                                  TransferFunctionProxy tf):
 *         cdef int cur_ind[3], step[3], x, y, i, n, flat_ind, hit, direction
 *         cdef np.float64_t intersect_t = 1.0             # <<<<<<<<<<<<<<
 *         cdef np.float64_t iv_dir[3]
 *         cdef np.float64_t intersect[3], tmax[3], tdelta[3]
 */
  __pyx_v_intersect_t = 1.0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":411
 *         cdef np.float64_t enter_t, dist, alpha, dt, exit_t
 *         cdef np.float64_t tr, tl, temp_x, temp_y, dv
 *         for i in range(3):             # <<<<<<<<<<<<<<
 *             if (v_dir[i] < 0):
 *                 step[i] = -1
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":412
 *         cdef np.float64_t tr, tl, temp_x, temp_y, dv
 *         for i in range(3):
 *             if (v_dir[i] < 0):             # <<<<<<<<<<<<<<
 *                 step[i] = -1
 *             else:
 */
    __pyx_t_2 = ((__pyx_v_v_dir[__pyx_v_i]) < 0);
    if (__pyx_t_2) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":413
 *         for i in range(3):
 *             if (v_dir[i] < 0):
 *                 step[i] = -1             # <<<<<<<<<<<<<<
 *             else:
 *                 step[i] = 1
 */
      (__pyx_v_step[__pyx_v_i]) = -1;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":415
 *                 step[i] = -1
 *             else:
 *                 step[i] = 1             # <<<<<<<<<<<<<<
 *             x = (i+1) % 3
 *             y = (i+2) % 3
 */
      (__pyx_v_step[__pyx_v_i]) = 1;
    }
    __pyx_L5:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":416
 *             else:
 *                 step[i] = 1
 *             x = (i+1) % 3             # <<<<<<<<<<<<<<
 *             y = (i+2) % 3
 *             iv_dir[i] = 1.0/v_dir[0]
 */
    __pyx_v_x = ((__pyx_v_i + 1) % 3);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":417
 *                 step[i] = 1
 *             x = (i+1) % 3
 *             y = (i+2) % 3             # <<<<<<<<<<<<<<
 *             iv_dir[i] = 1.0/v_dir[0]
 *             tl = (self.left_edge[i] - v_pos[i])*iv_dir[i]
 */
    __pyx_v_y = ((__pyx_v_i + 2) % 3);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":418
 *             x = (i+1) % 3
 *             y = (i+2) % 3
 *             iv_dir[i] = 1.0/v_dir[0]             # <<<<<<<<<<<<<<
 *             tl = (self.left_edge[i] - v_pos[i])*iv_dir[i]
 *             temp_x = (v_pos[x] + tl*v_dir[x])
 */
    (__pyx_v_iv_dir[__pyx_v_i]) = (1.0 / (__pyx_v_v_dir[0]));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":419
 *             y = (i+2) % 3
 *             iv_dir[i] = 1.0/v_dir[0]
 *             tl = (self.left_edge[i] - v_pos[i])*iv_dir[i]             # <<<<<<<<<<<<<<
 *             temp_x = (v_pos[x] + tl*v_dir[x])
 *             temp_y = (v_pos[y] + tl*v_dir[y])
 */
    __pyx_v_tl = (((__pyx_v_self->left_edge[__pyx_v_i]) - (__pyx_v_v_pos[__pyx_v_i])) * (__pyx_v_iv_dir[__pyx_v_i]));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":420
 *             iv_dir[i] = 1.0/v_dir[0]
 *             tl = (self.left_edge[i] - v_pos[i])*iv_dir[i]
 *             temp_x = (v_pos[x] + tl*v_dir[x])             # <<<<<<<<<<<<<<
 *             temp_y = (v_pos[y] + tl*v_dir[y])
 *             if self.left_edge[x] <= temp_x and temp_x <= self.right_edge[x] and \
 */
    __pyx_v_temp_x = ((__pyx_v_v_pos[__pyx_v_x]) + (__pyx_v_tl * (__pyx_v_v_dir[__pyx_v_x])));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":421
 *             tl = (self.left_edge[i] - v_pos[i])*iv_dir[i]
 *             temp_x = (v_pos[x] + tl*v_dir[x])
 *             temp_y = (v_pos[y] + tl*v_dir[y])             # <<<<<<<<<<<<<<
 *             if self.left_edge[x] <= temp_x and temp_x <= self.right_edge[x] and \
 *                self.left_edge[y] <= temp_y and temp_y <= self.right_edge[y] and \
 */
    __pyx_v_temp_y = ((__pyx_v_v_pos[__pyx_v_y]) + (__pyx_v_tl * (__pyx_v_v_dir[__pyx_v_y])));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":422
 *             temp_x = (v_pos[x] + tl*v_dir[x])
 *             temp_y = (v_pos[y] + tl*v_dir[y])
 *             if self.left_edge[x] <= temp_x and temp_x <= self.right_edge[x] and \             # <<<<<<<<<<<<<<
 *                self.left_edge[y] <= temp_y and temp_y <= self.right_edge[y] and \
 *                0.0 <= tl and tl < intersect_t:
 */
    __pyx_t_2 = ((__pyx_v_self->left_edge[__pyx_v_x]) <= __pyx_v_temp_x);
    if (__pyx_t_2) {
      __pyx_t_3 = (__pyx_v_temp_x <= (__pyx_v_self->right_edge[__pyx_v_x]));
      if (__pyx_t_3) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":423
 *             temp_y = (v_pos[y] + tl*v_dir[y])
 *             if self.left_edge[x] <= temp_x and temp_x <= self.right_edge[x] and \
 *                self.left_edge[y] <= temp_y and temp_y <= self.right_edge[y] and \             # <<<<<<<<<<<<<<
 *                0.0 <= tl and tl < intersect_t:
 *                 direction = i
 */
        __pyx_t_4 = ((__pyx_v_self->left_edge[__pyx_v_y]) <= __pyx_v_temp_y);
        if (__pyx_t_4) {
          __pyx_t_5 = (__pyx_v_temp_y <= (__pyx_v_self->right_edge[__pyx_v_y]));
          if (__pyx_t_5) {

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":424
 *             if self.left_edge[x] <= temp_x and temp_x <= self.right_edge[x] and \
 *                self.left_edge[y] <= temp_y and temp_y <= self.right_edge[y] and \
 *                0.0 <= tl and tl < intersect_t:             # <<<<<<<<<<<<<<
 *                 direction = i
 *                 intersect_t = tl
 */
            __pyx_t_6 = (0.0 <= __pyx_v_tl);
            if (__pyx_t_6) {
              __pyx_t_7 = (__pyx_v_tl < __pyx_v_intersect_t);
              __pyx_t_8 = __pyx_t_7;
            } else {
              __pyx_t_8 = __pyx_t_6;
            }
            __pyx_t_6 = __pyx_t_8;
          } else {
            __pyx_t_6 = __pyx_t_5;
          }
          __pyx_t_5 = __pyx_t_6;
        } else {
          __pyx_t_5 = __pyx_t_4;
        }
        __pyx_t_4 = __pyx_t_5;
      } else {
        __pyx_t_4 = __pyx_t_3;
      }
      __pyx_t_3 = __pyx_t_4;
    } else {
      __pyx_t_3 = __pyx_t_2;
    }
    if (__pyx_t_3) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":425
 *                self.left_edge[y] <= temp_y and temp_y <= self.right_edge[y] and \
 *                0.0 <= tl and tl < intersect_t:
 *                 direction = i             # <<<<<<<<<<<<<<
 *                 intersect_t = tl
 *             tr = (self.right_edge[i] - v_pos[i])*iv_dir[i]
 */
      __pyx_v_direction = __pyx_v_i;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":426
 *                0.0 <= tl and tl < intersect_t:
 *                 direction = i
 *                 intersect_t = tl             # <<<<<<<<<<<<<<
 *             tr = (self.right_edge[i] - v_pos[i])*iv_dir[i]
 *             temp_x = (v_pos[x] + tr*v_dir[x])
 */
      __pyx_v_intersect_t = __pyx_v_tl;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":427
 *                 direction = i
 *                 intersect_t = tl
 *             tr = (self.right_edge[i] - v_pos[i])*iv_dir[i]             # <<<<<<<<<<<<<<
 *             temp_x = (v_pos[x] + tr*v_dir[x])
 *             temp_y = (v_pos[y] + tr*v_dir[y])
 */
    __pyx_v_tr = (((__pyx_v_self->right_edge[__pyx_v_i]) - (__pyx_v_v_pos[__pyx_v_i])) * (__pyx_v_iv_dir[__pyx_v_i]));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":428
 *                 intersect_t = tl
 *             tr = (self.right_edge[i] - v_pos[i])*iv_dir[i]
 *             temp_x = (v_pos[x] + tr*v_dir[x])             # <<<<<<<<<<<<<<
 *             temp_y = (v_pos[y] + tr*v_dir[y])
 *             if self.left_edge[x] <= temp_x and temp_x <= self.right_edge[x] and \
 */
    __pyx_v_temp_x = ((__pyx_v_v_pos[__pyx_v_x]) + (__pyx_v_tr * (__pyx_v_v_dir[__pyx_v_x])));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":429
 *             tr = (self.right_edge[i] - v_pos[i])*iv_dir[i]
 *             temp_x = (v_pos[x] + tr*v_dir[x])
 *             temp_y = (v_pos[y] + tr*v_dir[y])             # <<<<<<<<<<<<<<
 *             if self.left_edge[x] <= temp_x and temp_x <= self.right_edge[x] and \
 *                self.left_edge[y] <= temp_y and temp_y <= self.right_edge[y] and \
 */
    __pyx_v_temp_y = ((__pyx_v_v_pos[__pyx_v_y]) + (__pyx_v_tr * (__pyx_v_v_dir[__pyx_v_y])));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":430
 *             temp_x = (v_pos[x] + tr*v_dir[x])
 *             temp_y = (v_pos[y] + tr*v_dir[y])
 *             if self.left_edge[x] <= temp_x and temp_x <= self.right_edge[x] and \             # <<<<<<<<<<<<<<
 *                self.left_edge[y] <= temp_y and temp_y <= self.right_edge[y] and \
 *                0.0 <= tr and tr < intersect_t:
 */
    __pyx_t_3 = ((__pyx_v_self->left_edge[__pyx_v_x]) <= __pyx_v_temp_x);
    if (__pyx_t_3) {
      __pyx_t_2 = (__pyx_v_temp_x <= (__pyx_v_self->right_edge[__pyx_v_x]));
      if (__pyx_t_2) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":431
 *             temp_y = (v_pos[y] + tr*v_dir[y])
 *             if self.left_edge[x] <= temp_x and temp_x <= self.right_edge[x] and \
 *                self.left_edge[y] <= temp_y and temp_y <= self.right_edge[y] and \             # <<<<<<<<<<<<<<
 *                0.0 <= tr and tr < intersect_t:
 *                 direction = i
 */
        __pyx_t_4 = ((__pyx_v_self->left_edge[__pyx_v_y]) <= __pyx_v_temp_y);
        if (__pyx_t_4) {
          __pyx_t_5 = (__pyx_v_temp_y <= (__pyx_v_self->right_edge[__pyx_v_y]));
          if (__pyx_t_5) {

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":432
 *             if self.left_edge[x] <= temp_x and temp_x <= self.right_edge[x] and \
 *                self.left_edge[y] <= temp_y and temp_y <= self.right_edge[y] and \
 *                0.0 <= tr and tr < intersect_t:             # <<<<<<<<<<<<<<
 *                 direction = i
 *                 intersect_t = tr
 */
            __pyx_t_6 = (0.0 <= __pyx_v_tr);
            if (__pyx_t_6) {
              __pyx_t_8 = (__pyx_v_tr < __pyx_v_intersect_t);
              __pyx_t_7 = __pyx_t_8;
            } else {
              __pyx_t_7 = __pyx_t_6;
            }
            __pyx_t_6 = __pyx_t_7;
          } else {
            __pyx_t_6 = __pyx_t_5;
          }
          __pyx_t_5 = __pyx_t_6;
        } else {
          __pyx_t_5 = __pyx_t_4;
        }
        __pyx_t_4 = __pyx_t_5;
      } else {
        __pyx_t_4 = __pyx_t_2;
      }
      __pyx_t_2 = __pyx_t_4;
    } else {
      __pyx_t_2 = __pyx_t_3;
    }
    if (__pyx_t_2) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":433
 *                self.left_edge[y] <= temp_y and temp_y <= self.right_edge[y] and \
 *                0.0 <= tr and tr < intersect_t:
 *                 direction = i             # <<<<<<<<<<<<<<
 *                 intersect_t = tr
 *         if self.left_edge[0] <= v_pos[0] and v_pos[0] <= self.right_edge[0] and \
 */
      __pyx_v_direction = __pyx_v_i;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":434
 *                0.0 <= tr and tr < intersect_t:
 *                 direction = i
 *                 intersect_t = tr             # <<<<<<<<<<<<<<
 *         if self.left_edge[0] <= v_pos[0] and v_pos[0] <= self.right_edge[0] and \
 *            self.left_edge[1] <= v_pos[1] and v_pos[1] <= self.right_edge[1] and \
 */
      __pyx_v_intersect_t = __pyx_v_tr;
      goto __pyx_L7;
    }
    __pyx_L7:;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":435
 *                 direction = i
 *                 intersect_t = tr
 *         if self.left_edge[0] <= v_pos[0] and v_pos[0] <= self.right_edge[0] and \             # <<<<<<<<<<<<<<
 *            self.left_edge[1] <= v_pos[1] and v_pos[1] <= self.right_edge[1] and \
 *            self.left_edge[2] <= v_pos[2] and v_pos[2] <= self.right_edge[2]:
 */
  __pyx_t_2 = ((__pyx_v_self->left_edge[0]) <= (__pyx_v_v_pos[0]));
  if (__pyx_t_2) {
    __pyx_t_3 = ((__pyx_v_v_pos[0]) <= (__pyx_v_self->right_edge[0]));
    if (__pyx_t_3) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":436
 *                 intersect_t = tr
 *         if self.left_edge[0] <= v_pos[0] and v_pos[0] <= self.right_edge[0] and \
 *            self.left_edge[1] <= v_pos[1] and v_pos[1] <= self.right_edge[1] and \             # <<<<<<<<<<<<<<
 *            self.left_edge[2] <= v_pos[2] and v_pos[2] <= self.right_edge[2]:
 *             intersect_t = 0.0
 */
      __pyx_t_4 = ((__pyx_v_self->left_edge[1]) <= (__pyx_v_v_pos[1]));
      if (__pyx_t_4) {
        __pyx_t_5 = ((__pyx_v_v_pos[1]) <= (__pyx_v_self->right_edge[1]));
        if (__pyx_t_5) {

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":437
 *         if self.left_edge[0] <= v_pos[0] and v_pos[0] <= self.right_edge[0] and \
 *            self.left_edge[1] <= v_pos[1] and v_pos[1] <= self.right_edge[1] and \
 *            self.left_edge[2] <= v_pos[2] and v_pos[2] <= self.right_edge[2]:             # <<<<<<<<<<<<<<
 *             intersect_t = 0.0
 *         if not ((0.0 <= intersect_t) and (intersect_t < 1.0)): return 0
 */
          __pyx_t_6 = ((__pyx_v_self->left_edge[2]) <= (__pyx_v_v_pos[2]));
          if (__pyx_t_6) {
            __pyx_t_7 = ((__pyx_v_v_pos[2]) <= (__pyx_v_self->right_edge[2]));
            __pyx_t_8 = __pyx_t_7;
          } else {
            __pyx_t_8 = __pyx_t_6;
          }
          __pyx_t_6 = __pyx_t_8;
        } else {
          __pyx_t_6 = __pyx_t_5;
        }
        __pyx_t_5 = __pyx_t_6;
      } else {
        __pyx_t_5 = __pyx_t_4;
      }
      __pyx_t_4 = __pyx_t_5;
    } else {
      __pyx_t_4 = __pyx_t_3;
    }
    __pyx_t_3 = __pyx_t_4;
  } else {
    __pyx_t_3 = __pyx_t_2;
  }
  if (__pyx_t_3) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":438
 *            self.left_edge[1] <= v_pos[1] and v_pos[1] <= self.right_edge[1] and \
 *            self.left_edge[2] <= v_pos[2] and v_pos[2] <= self.right_edge[2]:
 *             intersect_t = 0.0             # <<<<<<<<<<<<<<
 *         if not ((0.0 <= intersect_t) and (intersect_t < 1.0)): return 0
 *         for i in range(3):
 */
    __pyx_v_intersect_t = 0.0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":439
 *            self.left_edge[2] <= v_pos[2] and v_pos[2] <= self.right_edge[2]:
 *             intersect_t = 0.0
 *         if not ((0.0 <= intersect_t) and (intersect_t < 1.0)): return 0             # <<<<<<<<<<<<<<
 *         for i in range(3):
 *             intersect[i] = v_pos[i] + intersect_t * v_dir[i]
 */
  __pyx_t_3 = (0.0 <= __pyx_v_intersect_t);
  if (__pyx_t_3) {
    __pyx_t_2 = (__pyx_v_intersect_t < 1.0);
    __pyx_t_4 = __pyx_t_2;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  __pyx_t_3 = (!__pyx_t_4);
  if (__pyx_t_3) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":440
 *             intersect_t = 0.0
 *         if not ((0.0 <= intersect_t) and (intersect_t < 1.0)): return 0
 *         for i in range(3):             # <<<<<<<<<<<<<<
 *             intersect[i] = v_pos[i] + intersect_t * v_dir[i]
 *             cur_ind[i] = <int> floor((intersect[i] +
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":441
 *         if not ((0.0 <= intersect_t) and (intersect_t < 1.0)): return 0
 *         for i in range(3):
 *             intersect[i] = v_pos[i] + intersect_t * v_dir[i]             # <<<<<<<<<<<<<<
 *             cur_ind[i] = <int> floor((intersect[i] +
 *                                       step[i]*1e-8*self.dds[i] -
 */
    (__pyx_v_intersect[__pyx_v_i]) = ((__pyx_v_v_pos[__pyx_v_i]) + (__pyx_v_intersect_t * (__pyx_v_v_dir[__pyx_v_i])));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":442
 *         for i in range(3):
 *             intersect[i] = v_pos[i] + intersect_t * v_dir[i]
 *             cur_ind[i] = <int> floor((intersect[i] +             # <<<<<<<<<<<<<<
 *                                       step[i]*1e-8*self.dds[i] -
 *                                       self.left_edge[i])*self.idds[i])
 */
    (__pyx_v_cur_ind[__pyx_v_i]) = ((int)floor(((((__pyx_v_intersect[__pyx_v_i]) + (((__pyx_v_step[__pyx_v_i]) * 1e-08) * (__pyx_v_self->dds[__pyx_v_i]))) - (__pyx_v_self->left_edge[__pyx_v_i])) * (__pyx_v_self->idds[__pyx_v_i]))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":445
 *                                       step[i]*1e-8*self.dds[i] -
 *                                       self.left_edge[i])*self.idds[i])
 *             tmax[i] = (((cur_ind[i]+step[i])*self.dds[i])+             # <<<<<<<<<<<<<<
 *                         self.left_edge[i]-v_pos[i])*iv_dir[i]
 *             # This deals with the asymmetry in having our indices refer to the
 */
    (__pyx_v_tmax[__pyx_v_i]) = ((((((__pyx_v_cur_ind[__pyx_v_i]) + (__pyx_v_step[__pyx_v_i])) * (__pyx_v_self->dds[__pyx_v_i])) + (__pyx_v_self->left_edge[__pyx_v_i])) - (__pyx_v_v_pos[__pyx_v_i])) * (__pyx_v_iv_dir[__pyx_v_i]));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":450
 *             # left edge of a cell, but the right edge of the brick being one
 *             # extra zone out.
 *             if cur_ind[i] == self.dims[i] and step[i] < 0:             # <<<<<<<<<<<<<<
 *                 cur_ind[i] = self.dims[i] - 1
 *             if cur_ind[i] < 0 or cur_ind[i] >= self.dims[i]: return 0
 */
    __pyx_t_3 = ((__pyx_v_cur_ind[__pyx_v_i]) == (__pyx_v_self->dims[__pyx_v_i]));
    if (__pyx_t_3) {
      __pyx_t_4 = ((__pyx_v_step[__pyx_v_i]) < 0);
      __pyx_t_2 = __pyx_t_4;
    } else {
      __pyx_t_2 = __pyx_t_3;
    }
    if (__pyx_t_2) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":451
 *             # extra zone out.
 *             if cur_ind[i] == self.dims[i] and step[i] < 0:
 *                 cur_ind[i] = self.dims[i] - 1             # <<<<<<<<<<<<<<
 *             if cur_ind[i] < 0 or cur_ind[i] >= self.dims[i]: return 0
 *             if step[i] > 0:
 */
      (__pyx_v_cur_ind[__pyx_v_i]) = ((__pyx_v_self->dims[__pyx_v_i]) - 1);
      goto __pyx_L12;
    }
    __pyx_L12:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":452
 *             if cur_ind[i] == self.dims[i] and step[i] < 0:
 *                 cur_ind[i] = self.dims[i] - 1
 *             if cur_ind[i] < 0 or cur_ind[i] >= self.dims[i]: return 0             # <<<<<<<<<<<<<<
 *             if step[i] > 0:
 *                 tmax[i] = (((cur_ind[i]+1)*self.dds[i])
 */
    __pyx_t_2 = ((__pyx_v_cur_ind[__pyx_v_i]) < 0);
    if (!__pyx_t_2) {
      __pyx_t_3 = ((__pyx_v_cur_ind[__pyx_v_i]) >= (__pyx_v_self->dims[__pyx_v_i]));
      __pyx_t_4 = __pyx_t_3;
    } else {
      __pyx_t_4 = __pyx_t_2;
    }
    if (__pyx_t_4) {
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L13;
    }
    __pyx_L13:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":453
 *                 cur_ind[i] = self.dims[i] - 1
 *             if cur_ind[i] < 0 or cur_ind[i] >= self.dims[i]: return 0
 *             if step[i] > 0:             # <<<<<<<<<<<<<<
 *                 tmax[i] = (((cur_ind[i]+1)*self.dds[i])
 *                             +self.left_edge[i]-v_pos[i])*iv_dir[i]
 */
    __pyx_t_4 = ((__pyx_v_step[__pyx_v_i]) > 0);
    if (__pyx_t_4) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":454
 *             if cur_ind[i] < 0 or cur_ind[i] >= self.dims[i]: return 0
 *             if step[i] > 0:
 *                 tmax[i] = (((cur_ind[i]+1)*self.dds[i])             # <<<<<<<<<<<<<<
 *                             +self.left_edge[i]-v_pos[i])*iv_dir[i]
 *             if step[i] < 0:
 */
      (__pyx_v_tmax[__pyx_v_i]) = ((((((__pyx_v_cur_ind[__pyx_v_i]) + 1) * (__pyx_v_self->dds[__pyx_v_i])) + (__pyx_v_self->left_edge[__pyx_v_i])) - (__pyx_v_v_pos[__pyx_v_i])) * (__pyx_v_iv_dir[__pyx_v_i]));
      goto __pyx_L14;
    }
    __pyx_L14:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":456
 *                 tmax[i] = (((cur_ind[i]+1)*self.dds[i])
 *                             +self.left_edge[i]-v_pos[i])*iv_dir[i]
 *             if step[i] < 0:             # <<<<<<<<<<<<<<
 *                 tmax[i] = (((cur_ind[i]+0)*self.dds[i])
 *                             +self.left_edge[i]-v_pos[i])*iv_dir[i]
 */
    __pyx_t_4 = ((__pyx_v_step[__pyx_v_i]) < 0);
    if (__pyx_t_4) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":457
 *                             +self.left_edge[i]-v_pos[i])*iv_dir[i]
 *             if step[i] < 0:
 *                 tmax[i] = (((cur_ind[i]+0)*self.dds[i])             # <<<<<<<<<<<<<<
 *                             +self.left_edge[i]-v_pos[i])*iv_dir[i]
 *             tdelta[i] = (self.dds[i]*iv_dir[i])
 */
      (__pyx_v_tmax[__pyx_v_i]) = ((((((__pyx_v_cur_ind[__pyx_v_i]) + 0) * (__pyx_v_self->dds[__pyx_v_i])) + (__pyx_v_self->left_edge[__pyx_v_i])) - (__pyx_v_v_pos[__pyx_v_i])) * (__pyx_v_iv_dir[__pyx_v_i]));
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":459
 *                 tmax[i] = (((cur_ind[i]+0)*self.dds[i])
 *                             +self.left_edge[i]-v_pos[i])*iv_dir[i]
 *             tdelta[i] = (self.dds[i]*iv_dir[i])             # <<<<<<<<<<<<<<
 *             if tdelta[i] < 0: tdelta[i] *= -1
 *         # We have to jumpstart our calculation
 */
    (__pyx_v_tdelta[__pyx_v_i]) = ((__pyx_v_self->dds[__pyx_v_i]) * (__pyx_v_iv_dir[__pyx_v_i]));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":460
 *                             +self.left_edge[i]-v_pos[i])*iv_dir[i]
 *             tdelta[i] = (self.dds[i]*iv_dir[i])
 *             if tdelta[i] < 0: tdelta[i] *= -1             # <<<<<<<<<<<<<<
 *         # We have to jumpstart our calculation
 *         enter_t = intersect_t
 */
    __pyx_t_4 = ((__pyx_v_tdelta[__pyx_v_i]) < 0);
    if (__pyx_t_4) {
      (__pyx_v_tdelta[__pyx_v_i]) *= -1;
      goto __pyx_L16;
    }
    __pyx_L16:;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":462
 *             if tdelta[i] < 0: tdelta[i] *= -1
 *         # We have to jumpstart our calculation
 *         enter_t = intersect_t             # <<<<<<<<<<<<<<
 *         while 1:
 *             # dims here is one less than the dimensions of the data,
 */
  __pyx_v_enter_t = __pyx_v_intersect_t;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":463
 *         # We have to jumpstart our calculation
 *         enter_t = intersect_t
 *         while 1:             # <<<<<<<<<<<<<<
 *             # dims here is one less than the dimensions of the data,
 *             # but we are tracing on the grid, not on the data...
 */
  while (1) {
    __pyx_t_4 = 1;
    if (!__pyx_t_4) break;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":466
 *             # dims here is one less than the dimensions of the data,
 *             # but we are tracing on the grid, not on the data...
 *             if (not (0 <= cur_ind[0] < self.dims[0])) or \             # <<<<<<<<<<<<<<
 *                (not (0 <= cur_ind[1] < self.dims[1])) or \
 *                (not (0 <= cur_ind[2] < self.dims[2])):
 */
    __pyx_t_1 = (__pyx_v_cur_ind[0]);
    __pyx_t_4 = (0 <= __pyx_t_1);
    if (__pyx_t_4) {
      __pyx_t_4 = (__pyx_t_1 < (__pyx_v_self->dims[0]));
    }
    __pyx_t_2 = (!__pyx_t_4);
    if (!__pyx_t_2) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":467
 *             # but we are tracing on the grid, not on the data...
 *             if (not (0 <= cur_ind[0] < self.dims[0])) or \
 *                (not (0 <= cur_ind[1] < self.dims[1])) or \             # <<<<<<<<<<<<<<
 *                (not (0 <= cur_ind[2] < self.dims[2])):
 *                 break
 */
      __pyx_t_1 = (__pyx_v_cur_ind[1]);
      __pyx_t_4 = (0 <= __pyx_t_1);
      if (__pyx_t_4) {
        __pyx_t_4 = (__pyx_t_1 < (__pyx_v_self->dims[1]));
      }
      __pyx_t_3 = (!__pyx_t_4);
      if (!__pyx_t_3) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":468
 *             if (not (0 <= cur_ind[0] < self.dims[0])) or \
 *                (not (0 <= cur_ind[1] < self.dims[1])) or \
 *                (not (0 <= cur_ind[2] < self.dims[2])):             # <<<<<<<<<<<<<<
 *                 break
 *             hit += 1
 */
        __pyx_t_1 = (__pyx_v_cur_ind[2]);
        __pyx_t_4 = (0 <= __pyx_t_1);
        if (__pyx_t_4) {
          __pyx_t_4 = (__pyx_t_1 < (__pyx_v_self->dims[2]));
        }
        __pyx_t_5 = (!__pyx_t_4);
        __pyx_t_4 = __pyx_t_5;
      } else {
        __pyx_t_4 = __pyx_t_3;
      }
      __pyx_t_3 = __pyx_t_4;
    } else {
      __pyx_t_3 = __pyx_t_2;
    }
    if (__pyx_t_3) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":469
 *                (not (0 <= cur_ind[1] < self.dims[1])) or \
 *                (not (0 <= cur_ind[2] < self.dims[2])):
 *                 break             # <<<<<<<<<<<<<<
 *             hit += 1
 *             if tmax[0] < tmax[1]:
 */
      goto __pyx_L18_break;
      goto __pyx_L19;
    }
    __pyx_L19:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":470
 *                (not (0 <= cur_ind[2] < self.dims[2])):
 *                 break
 *             hit += 1             # <<<<<<<<<<<<<<
 *             if tmax[0] < tmax[1]:
 *                 if tmax[0] < tmax[2]:
 */
    __pyx_v_hit += 1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":471
 *                 break
 *             hit += 1
 *             if tmax[0] < tmax[1]:             # <<<<<<<<<<<<<<
 *                 if tmax[0] < tmax[2]:
 *                     exit_t = fmin(tmax[0], 1.0)
 */
    __pyx_t_3 = ((__pyx_v_tmax[0]) < (__pyx_v_tmax[1]));
    if (__pyx_t_3) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":472
 *             hit += 1
 *             if tmax[0] < tmax[1]:
 *                 if tmax[0] < tmax[2]:             # <<<<<<<<<<<<<<
 *                     exit_t = fmin(tmax[0], 1.0)
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 */
      __pyx_t_3 = ((__pyx_v_tmax[0]) < (__pyx_v_tmax[2]));
      if (__pyx_t_3) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":473
 *             if tmax[0] < tmax[1]:
 *                 if tmax[0] < tmax[2]:
 *                     exit_t = fmin(tmax[0], 1.0)             # <<<<<<<<<<<<<<
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)
 */
        __pyx_v_exit_t = __pyx_f_2yt_9amr_utils_fmin((__pyx_v_tmax[0]), 1.0);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":475
 *                     exit_t = fmin(tmax[0], 1.0)
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)             # <<<<<<<<<<<<<<
 *                     cur_ind[0] += step[0]
 *                     enter_t = tmax[0]
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self->__pyx_vtab)->sample_values(__pyx_v_self, __pyx_v_v_pos, __pyx_v_v_dir, __pyx_v_enter_t, __pyx_v_exit_t, __pyx_v_cur_ind, __pyx_v_rgba, __pyx_v_tf);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":476
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)
 *                     cur_ind[0] += step[0]             # <<<<<<<<<<<<<<
 *                     enter_t = tmax[0]
 *                     tmax[0] += tdelta[0]
 */
        (__pyx_v_cur_ind[0]) += (__pyx_v_step[0]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":477
 *                                        rgba, tf)
 *                     cur_ind[0] += step[0]
 *                     enter_t = tmax[0]             # <<<<<<<<<<<<<<
 *                     tmax[0] += tdelta[0]
 *                 else:
 */
        __pyx_v_enter_t = (__pyx_v_tmax[0]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":478
 *                     cur_ind[0] += step[0]
 *                     enter_t = tmax[0]
 *                     tmax[0] += tdelta[0]             # <<<<<<<<<<<<<<
 *                 else:
 *                     exit_t = fmin(tmax[2], 1.0)
 */
        (__pyx_v_tmax[0]) += (__pyx_v_tdelta[0]);
        goto __pyx_L21;
      }
      /*else*/ {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":480
 *                     tmax[0] += tdelta[0]
 *                 else:
 *                     exit_t = fmin(tmax[2], 1.0)             # <<<<<<<<<<<<<<
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)
 */
        __pyx_v_exit_t = __pyx_f_2yt_9amr_utils_fmin((__pyx_v_tmax[2]), 1.0);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":482
 *                     exit_t = fmin(tmax[2], 1.0)
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)             # <<<<<<<<<<<<<<
 *                     cur_ind[2] += step[2]
 *                     enter_t = tmax[2]
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self->__pyx_vtab)->sample_values(__pyx_v_self, __pyx_v_v_pos, __pyx_v_v_dir, __pyx_v_enter_t, __pyx_v_exit_t, __pyx_v_cur_ind, __pyx_v_rgba, __pyx_v_tf);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":483
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)
 *                     cur_ind[2] += step[2]             # <<<<<<<<<<<<<<
 *                     enter_t = tmax[2]
 *                     tmax[2] += tdelta[2]
 */
        (__pyx_v_cur_ind[2]) += (__pyx_v_step[2]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":484
 *                                        rgba, tf)
 *                     cur_ind[2] += step[2]
 *                     enter_t = tmax[2]             # <<<<<<<<<<<<<<
 *                     tmax[2] += tdelta[2]
 *             else:
 */
        __pyx_v_enter_t = (__pyx_v_tmax[2]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":485
 *                     cur_ind[2] += step[2]
 *                     enter_t = tmax[2]
 *                     tmax[2] += tdelta[2]             # <<<<<<<<<<<<<<
 *             else:
 *                 if tmax[1] < tmax[2]:
 */
        (__pyx_v_tmax[2]) += (__pyx_v_tdelta[2]);
      }
      __pyx_L21:;
      goto __pyx_L20;
    }
    /*else*/ {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":487
 *                     tmax[2] += tdelta[2]
 *             else:
 *                 if tmax[1] < tmax[2]:             # <<<<<<<<<<<<<<
 *                     exit_t = fmin(tmax[1], 1.0)
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 */
      __pyx_t_3 = ((__pyx_v_tmax[1]) < (__pyx_v_tmax[2]));
      if (__pyx_t_3) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":488
 *             else:
 *                 if tmax[1] < tmax[2]:
 *                     exit_t = fmin(tmax[1], 1.0)             # <<<<<<<<<<<<<<
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)
 */
        __pyx_v_exit_t = __pyx_f_2yt_9amr_utils_fmin((__pyx_v_tmax[1]), 1.0);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":490
 *                     exit_t = fmin(tmax[1], 1.0)
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)             # <<<<<<<<<<<<<<
 *                     cur_ind[1] += step[1]
 *                     enter_t = tmax[1]
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self->__pyx_vtab)->sample_values(__pyx_v_self, __pyx_v_v_pos, __pyx_v_v_dir, __pyx_v_enter_t, __pyx_v_exit_t, __pyx_v_cur_ind, __pyx_v_rgba, __pyx_v_tf);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":491
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)
 *                     cur_ind[1] += step[1]             # <<<<<<<<<<<<<<
 *                     enter_t = tmax[1]
 *                     tmax[1] += tdelta[1]
 */
        (__pyx_v_cur_ind[1]) += (__pyx_v_step[1]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":492
 *                                        rgba, tf)
 *                     cur_ind[1] += step[1]
 *                     enter_t = tmax[1]             # <<<<<<<<<<<<<<
 *                     tmax[1] += tdelta[1]
 *                 else:
 */
        __pyx_v_enter_t = (__pyx_v_tmax[1]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":493
 *                     cur_ind[1] += step[1]
 *                     enter_t = tmax[1]
 *                     tmax[1] += tdelta[1]             # <<<<<<<<<<<<<<
 *                 else:
 *                     exit_t = fmin(tmax[2], 1.0)
 */
        (__pyx_v_tmax[1]) += (__pyx_v_tdelta[1]);
        goto __pyx_L22;
      }
      /*else*/ {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":495
 *                     tmax[1] += tdelta[1]
 *                 else:
 *                     exit_t = fmin(tmax[2], 1.0)             # <<<<<<<<<<<<<<
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)
 */
        __pyx_v_exit_t = __pyx_f_2yt_9amr_utils_fmin((__pyx_v_tmax[2]), 1.0);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":497
 *                     exit_t = fmin(tmax[2], 1.0)
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)             # <<<<<<<<<<<<<<
 *                     cur_ind[2] += step[2]
 *                     enter_t = tmax[2]
 */
        ((struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid *)__pyx_v_self->__pyx_vtab)->sample_values(__pyx_v_self, __pyx_v_v_pos, __pyx_v_v_dir, __pyx_v_enter_t, __pyx_v_exit_t, __pyx_v_cur_ind, __pyx_v_rgba, __pyx_v_tf);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":498
 *                     self.sample_values(v_pos, v_dir, enter_t, exit_t, cur_ind,
 *                                        rgba, tf)
 *                     cur_ind[2] += step[2]             # <<<<<<<<<<<<<<
 *                     enter_t = tmax[2]
 *                     tmax[2] += tdelta[2]
 */
        (__pyx_v_cur_ind[2]) += (__pyx_v_step[2]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":499
 *                                        rgba, tf)
 *                     cur_ind[2] += step[2]
 *                     enter_t = tmax[2]             # <<<<<<<<<<<<<<
 *                     tmax[2] += tdelta[2]
 *             if enter_t > 1.0: break
 */
        __pyx_v_enter_t = (__pyx_v_tmax[2]);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":500
 *                     cur_ind[2] += step[2]
 *                     enter_t = tmax[2]
 *                     tmax[2] += tdelta[2]             # <<<<<<<<<<<<<<
 *             if enter_t > 1.0: break
 *         return hit
 */
        (__pyx_v_tmax[2]) += (__pyx_v_tdelta[2]);
      }
      __pyx_L22:;
    }
    __pyx_L20:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":501
 *                     enter_t = tmax[2]
 *                     tmax[2] += tdelta[2]
 *             if enter_t > 1.0: break             # <<<<<<<<<<<<<<
 *         return hit
 * 
 */
    __pyx_t_3 = (__pyx_v_enter_t > 1.0);
    if (__pyx_t_3) {
      goto __pyx_L18_break;
      goto __pyx_L23;
    }
    __pyx_L23:;
  }
  __pyx_L18_break:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":502
 *                     tmax[2] += tdelta[2]
 *             if enter_t > 1.0: break
 *         return hit             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __pyx_r = __pyx_v_hit;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF((PyObject *)__pyx_v_tf);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":506
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef void sample_values(self,             # <<<<<<<<<<<<<<
 *                             np.float64_t v_pos[3],
 *                             np.float64_t v_dir[3],
 */

static  void __pyx_f_2yt_9amr_utils_15PartitionedGrid_sample_values(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *__pyx_v_self, __pyx_t_5numpy_float64_t *__pyx_v_v_pos, __pyx_t_5numpy_float64_t *__pyx_v_v_dir, __pyx_t_5numpy_float64_t __pyx_v_enter_t, __pyx_t_5numpy_float64_t __pyx_v_exit_t, int *__pyx_v_ci, __pyx_t_5numpy_float64_t *__pyx_v_rgba, struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *__pyx_v_tf) {
  __pyx_t_5numpy_float64_t __pyx_v_dp[3];
  __pyx_t_5numpy_float64_t __pyx_v_temp;
  __pyx_t_5numpy_float64_t __pyx_v_dt;
  __pyx_t_5numpy_float64_t __pyx_v_grad[3];
  __pyx_t_5numpy_float64_t __pyx_v_ds[3];
  int __pyx_v_dti;
  int __pyx_v_i;
  int __pyx_v_offset;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("sample_values");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF((PyObject *)__pyx_v_tf);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":516
 *         cdef np.float64_t cp[3], dp[3], temp, dt, t, dv
 *         cdef np.float64_t grad[3], ds[3]
 *         grad[0] = grad[1] = grad[2] = 0.0             # <<<<<<<<<<<<<<
 *         cdef int dti, i
 *         dt = (exit_t - enter_t) / tf.ns # 4 samples should be dt=0.25
 */
  (__pyx_v_grad[0]) = 0.0;
  (__pyx_v_grad[1]) = 0.0;
  (__pyx_v_grad[2]) = 0.0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":518
 *         grad[0] = grad[1] = grad[2] = 0.0
 *         cdef int dti, i
 *         dt = (exit_t - enter_t) / tf.ns # 4 samples should be dt=0.25             # <<<<<<<<<<<<<<
 *         cdef int offset = ci[0] * (self.dims[1] + 1) * (self.dims[2] + 1) \
 *                         + ci[1] * (self.dims[2] + 1) + ci[2]
 */
  __pyx_v_dt = ((__pyx_v_exit_t - __pyx_v_enter_t) / __pyx_v_tf->ns);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":520
 *         dt = (exit_t - enter_t) / tf.ns # 4 samples should be dt=0.25
 *         cdef int offset = ci[0] * (self.dims[1] + 1) * (self.dims[2] + 1) \
 *                         + ci[1] * (self.dims[2] + 1) + ci[2]             # <<<<<<<<<<<<<<
 *         for i in range(3):
 *             # temp is the left edge of the current cell
 */
  __pyx_v_offset = (((((__pyx_v_ci[0]) * ((__pyx_v_self->dims[1]) + 1)) * ((__pyx_v_self->dims[2]) + 1)) + ((__pyx_v_ci[1]) * ((__pyx_v_self->dims[2]) + 1))) + (__pyx_v_ci[2]));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":521
 *         cdef int offset = ci[0] * (self.dims[1] + 1) * (self.dims[2] + 1) \
 *                         + ci[1] * (self.dims[2] + 1) + ci[2]
 *         for i in range(3):             # <<<<<<<<<<<<<<
 *             # temp is the left edge of the current cell
 *             temp = ci[i] * self.dds[i] + self.left_edge[i]
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":523
 *         for i in range(3):
 *             # temp is the left edge of the current cell
 *             temp = ci[i] * self.dds[i] + self.left_edge[i]             # <<<<<<<<<<<<<<
 *             # this gets us dp as the current first sample position
 *             dp[i] = (enter_t + 0.5 * dt) * v_dir[i] + v_pos[i] - temp
 */
    __pyx_v_temp = (((__pyx_v_ci[__pyx_v_i]) * (__pyx_v_self->dds[__pyx_v_i])) + (__pyx_v_self->left_edge[__pyx_v_i]));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":525
 *             temp = ci[i] * self.dds[i] + self.left_edge[i]
 *             # this gets us dp as the current first sample position
 *             dp[i] = (enter_t + 0.5 * dt) * v_dir[i] + v_pos[i] - temp             # <<<<<<<<<<<<<<
 *             dp[i] *= self.idds[i]
 *             ds[i] = v_dir[i] * self.idds[i] * dt
 */
    (__pyx_v_dp[__pyx_v_i]) = ((((__pyx_v_enter_t + (0.5 * __pyx_v_dt)) * (__pyx_v_v_dir[__pyx_v_i])) + (__pyx_v_v_pos[__pyx_v_i])) - __pyx_v_temp);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":526
 *             # this gets us dp as the current first sample position
 *             dp[i] = (enter_t + 0.5 * dt) * v_dir[i] + v_pos[i] - temp
 *             dp[i] *= self.idds[i]             # <<<<<<<<<<<<<<
 *             ds[i] = v_dir[i] * self.idds[i] * dt
 *         for dti in range(tf.ns):
 */
    (__pyx_v_dp[__pyx_v_i]) *= (__pyx_v_self->idds[__pyx_v_i]);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":527
 *             dp[i] = (enter_t + 0.5 * dt) * v_dir[i] + v_pos[i] - temp
 *             dp[i] *= self.idds[i]
 *             ds[i] = v_dir[i] * self.idds[i] * dt             # <<<<<<<<<<<<<<
 *         for dti in range(tf.ns):
 *             for i in range(self.n_fields):
 */
    (__pyx_v_ds[__pyx_v_i]) = (((__pyx_v_v_dir[__pyx_v_i]) * (__pyx_v_self->idds[__pyx_v_i])) * __pyx_v_dt);
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":528
 *             dp[i] *= self.idds[i]
 *             ds[i] = v_dir[i] * self.idds[i] * dt
 *         for dti in range(tf.ns):             # <<<<<<<<<<<<<<
 *             for i in range(self.n_fields):
 *                 self.dvs[i] = offset_interpolate(self.dims, dp, self.data[i] + offset)
 */
  __pyx_t_1 = __pyx_v_tf->ns;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_dti = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":529
 *             ds[i] = v_dir[i] * self.idds[i] * dt
 *         for dti in range(tf.ns):
 *             for i in range(self.n_fields):             # <<<<<<<<<<<<<<
 *                 self.dvs[i] = offset_interpolate(self.dims, dp, self.data[i] + offset)
 *             #if (dv < tf.x_bounds[0]) or (dv > tf.x_bounds[1]):
 */
    __pyx_t_3 = __pyx_v_self->n_fields;
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_i = __pyx_t_4;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":530
 *         for dti in range(tf.ns):
 *             for i in range(self.n_fields):
 *                 self.dvs[i] = offset_interpolate(self.dims, dp, self.data[i] + offset)             # <<<<<<<<<<<<<<
 *             #if (dv < tf.x_bounds[0]) or (dv > tf.x_bounds[1]):
 *             #    continue
 */
      (__pyx_v_self->dvs[__pyx_v_i]) = offset_interpolate(__pyx_v_self->dims, __pyx_v_dp, ((__pyx_v_self->data[__pyx_v_i]) + __pyx_v_offset));
    }

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":533
 *             #if (dv < tf.x_bounds[0]) or (dv > tf.x_bounds[1]):
 *             #    continue
 *             for i in range(3):             # <<<<<<<<<<<<<<
 *                 dp[i] += ds[i]
 *             tf.eval_transfer(dt, self.dvs, rgba, grad)
 */
    for (__pyx_t_3 = 0; __pyx_t_3 < 3; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":534
 *             #    continue
 *             for i in range(3):
 *                 dp[i] += ds[i]             # <<<<<<<<<<<<<<
 *             tf.eval_transfer(dt, self.dvs, rgba, grad)
 * 
 */
      (__pyx_v_dp[__pyx_v_i]) += (__pyx_v_ds[__pyx_v_i]);
    }

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":535
 *             for i in range(3):
 *                 dp[i] += ds[i]
 *             tf.eval_transfer(dt, self.dvs, rgba, grad)             # <<<<<<<<<<<<<<
 * 
 * cdef class GridFace:
 */
    ((struct __pyx_vtabstruct_2yt_9amr_utils_TransferFunctionProxy *)__pyx_v_tf->__pyx_vtab)->eval_transfer(__pyx_v_tf, __pyx_v_dt, __pyx_v_self->dvs, __pyx_v_rgba, __pyx_v_grad);
  }

  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF((PyObject *)__pyx_v_tf);
  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":545
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def __init__(self, grid, int direction, int left):             # <<<<<<<<<<<<<<
 *         self.direction = direction
 *         if left == 1:
 */

static int __pyx_pf_2yt_9amr_utils_8GridFace___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_2yt_9amr_utils_8GridFace___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_grid = 0;
  int __pyx_v_direction;
  int __pyx_v_left;
  int __pyx_v_i;
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __pyx_t_5numpy_float64_t __pyx_t_4;
  int __pyx_t_5;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__grid,&__pyx_n_s__direction,&__pyx_n_s__left,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grid);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__direction);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__left);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_grid = values[0];
    __pyx_v_direction = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_direction == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_left = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_left == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_grid = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_direction = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_direction == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_left = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_left == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.GridFace.__init__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF(__pyx_v_grid);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":546
 *     @cython.wraparound(False)
 *     def __init__(self, grid, int direction, int left):
 *         self.direction = direction             # <<<<<<<<<<<<<<
 *         if left == 1:
 *             self.coord = grid.LeftEdge[direction]
 */
  ((struct __pyx_obj_2yt_9amr_utils_GridFace *)__pyx_v_self)->direction = __pyx_v_direction;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":547
 *     def __init__(self, grid, int direction, int left):
 *         self.direction = direction
 *         if left == 1:             # <<<<<<<<<<<<<<
 *             self.coord = grid.LeftEdge[direction]
 *         else:
 */
  __pyx_t_1 = (__pyx_v_left == 1);
  if (__pyx_t_1) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":548
 *         self.direction = direction
 *         if left == 1:
 *             self.coord = grid.LeftEdge[direction]             # <<<<<<<<<<<<<<
 *         else:
 *             self.coord = grid.RightEdge[direction]
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_grid, __pyx_n_s__LeftEdge); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_direction, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    ((struct __pyx_obj_2yt_9amr_utils_GridFace *)__pyx_v_self)->coord = __pyx_t_4;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":550
 *             self.coord = grid.LeftEdge[direction]
 *         else:
 *             self.coord = grid.RightEdge[direction]             # <<<<<<<<<<<<<<
 *         cdef int i
 *         for i in range(3):
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_grid, __pyx_n_s__RightEdge); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_direction, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    ((struct __pyx_obj_2yt_9amr_utils_GridFace *)__pyx_v_self)->coord = __pyx_t_4;
  }
  __pyx_L6:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":552
 *             self.coord = grid.RightEdge[direction]
 *         cdef int i
 *         for i in range(3):             # <<<<<<<<<<<<<<
 *             self.left_edge[i] = grid.LeftEdge[i]
 *             self.right_edge[i] = grid.RightEdge[i]
 */
  for (__pyx_t_5 = 0; __pyx_t_5 < 3; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":553
 *         cdef int i
 *         for i in range(3):
 *             self.left_edge[i] = grid.LeftEdge[i]             # <<<<<<<<<<<<<<
 *             self.right_edge[i] = grid.RightEdge[i]
 *         self.left_edge[direction] = self.right_edge[direction] = self.coord
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_grid, __pyx_n_s__LeftEdge); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    (((struct __pyx_obj_2yt_9amr_utils_GridFace *)__pyx_v_self)->left_edge[__pyx_v_i]) = __pyx_t_4;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":554
 *         for i in range(3):
 *             self.left_edge[i] = grid.LeftEdge[i]
 *             self.right_edge[i] = grid.RightEdge[i]             # <<<<<<<<<<<<<<
 *         self.left_edge[direction] = self.right_edge[direction] = self.coord
 * 
 */
    __pyx_t_3 = PyObject_GetAttr(__pyx_v_grid, __pyx_n_s__RightEdge); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    (((struct __pyx_obj_2yt_9amr_utils_GridFace *)__pyx_v_self)->right_edge[__pyx_v_i]) = __pyx_t_4;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":555
 *             self.left_edge[i] = grid.LeftEdge[i]
 *             self.right_edge[i] = grid.RightEdge[i]
 *         self.left_edge[direction] = self.right_edge[direction] = self.coord             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  (((struct __pyx_obj_2yt_9amr_utils_GridFace *)__pyx_v_self)->left_edge[__pyx_v_direction]) = ((struct __pyx_obj_2yt_9amr_utils_GridFace *)__pyx_v_self)->coord;
  (((struct __pyx_obj_2yt_9amr_utils_GridFace *)__pyx_v_self)->right_edge[__pyx_v_direction]) = ((struct __pyx_obj_2yt_9amr_utils_GridFace *)__pyx_v_self)->coord;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("yt.amr_utils.GridFace.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF(__pyx_v_grid);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":559
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef int proj_overlap(self, np.float64_t *left_edge, np.float64_t *right_edge):             # <<<<<<<<<<<<<<
 *         cdef int xax, yax
 *         xax = (self.direction + 1) % 3
 */

static  int __pyx_f_2yt_9amr_utils_8GridFace_proj_overlap(struct __pyx_obj_2yt_9amr_utils_GridFace *__pyx_v_self, __pyx_t_5numpy_float64_t *__pyx_v_left_edge, __pyx_t_5numpy_float64_t *__pyx_v_right_edge) {
  int __pyx_v_xax;
  int __pyx_v_yax;
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("proj_overlap");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":561
 *     cdef int proj_overlap(self, np.float64_t *left_edge, np.float64_t *right_edge):
 *         cdef int xax, yax
 *         xax = (self.direction + 1) % 3             # <<<<<<<<<<<<<<
 *         yax = (self.direction + 2) % 3
 *         if left_edge[xax] >= self.right_edge[xax]: return 0
 */
  __pyx_v_xax = ((__pyx_v_self->direction + 1) % 3);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":562
 *         cdef int xax, yax
 *         xax = (self.direction + 1) % 3
 *         yax = (self.direction + 2) % 3             # <<<<<<<<<<<<<<
 *         if left_edge[xax] >= self.right_edge[xax]: return 0
 *         if right_edge[xax] <= self.left_edge[xax]: return 0
 */
  __pyx_v_yax = ((__pyx_v_self->direction + 2) % 3);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":563
 *         xax = (self.direction + 1) % 3
 *         yax = (self.direction + 2) % 3
 *         if left_edge[xax] >= self.right_edge[xax]: return 0             # <<<<<<<<<<<<<<
 *         if right_edge[xax] <= self.left_edge[xax]: return 0
 *         if left_edge[yax] >= self.right_edge[yax]: return 0
 */
  __pyx_t_1 = ((__pyx_v_left_edge[__pyx_v_xax]) >= (__pyx_v_self->right_edge[__pyx_v_xax]));
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":564
 *         yax = (self.direction + 2) % 3
 *         if left_edge[xax] >= self.right_edge[xax]: return 0
 *         if right_edge[xax] <= self.left_edge[xax]: return 0             # <<<<<<<<<<<<<<
 *         if left_edge[yax] >= self.right_edge[yax]: return 0
 *         if right_edge[yax] <= self.left_edge[yax]: return 0
 */
  __pyx_t_1 = ((__pyx_v_right_edge[__pyx_v_xax]) <= (__pyx_v_self->left_edge[__pyx_v_xax]));
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":565
 *         if left_edge[xax] >= self.right_edge[xax]: return 0
 *         if right_edge[xax] <= self.left_edge[xax]: return 0
 *         if left_edge[yax] >= self.right_edge[yax]: return 0             # <<<<<<<<<<<<<<
 *         if right_edge[yax] <= self.left_edge[yax]: return 0
 *         return 1
 */
  __pyx_t_1 = ((__pyx_v_left_edge[__pyx_v_yax]) >= (__pyx_v_self->right_edge[__pyx_v_yax]));
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":566
 *         if right_edge[xax] <= self.left_edge[xax]: return 0
 *         if left_edge[yax] >= self.right_edge[yax]: return 0
 *         if right_edge[yax] <= self.left_edge[yax]: return 0             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
  __pyx_t_1 = ((__pyx_v_right_edge[__pyx_v_yax]) <= (__pyx_v_self->left_edge[__pyx_v_yax]));
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":567
 *         if left_edge[yax] >= self.right_edge[yax]: return 0
 *         if right_edge[yax] <= self.left_edge[yax]: return 0
 *         return 1             # <<<<<<<<<<<<<<
 * 
 * cdef class ProtoPrism:
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":576
 *     cdef public object subgrid_faces
 *     cdef public int parent_grid_id
 *     def __cinit__(self, int parent_grid_id,             # <<<<<<<<<<<<<<
 *                   np.ndarray[np.float64_t, ndim=1] left_edge,
 *                   np.ndarray[np.float64_t, ndim=1] right_edge,
 */

static int __pyx_pf_2yt_9amr_utils_10ProtoPrism___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_2yt_9amr_utils_10ProtoPrism___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_parent_grid_id;
  PyArrayObject *__pyx_v_left_edge = 0;
  PyArrayObject *__pyx_v_right_edge = 0;
  PyObject *__pyx_v_subgrid_faces = 0;
  int __pyx_v_i;
  Py_buffer __pyx_bstruct_right_edge;
  Py_ssize_t __pyx_bstride_0_right_edge = 0;
  Py_ssize_t __pyx_bshape_0_right_edge = 0;
  Py_buffer __pyx_bstruct_left_edge;
  Py_ssize_t __pyx_bstride_0_left_edge = 0;
  Py_ssize_t __pyx_bshape_0_left_edge = 0;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__parent_grid_id,&__pyx_n_s__left_edge,&__pyx_n_s__right_edge,&__pyx_n_s__subgrid_faces,0};
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parent_grid_id);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__left_edge);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__right_edge);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__subgrid_faces);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_parent_grid_id = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_parent_grid_id == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_left_edge = ((PyArrayObject *)values[1]);
    __pyx_v_right_edge = ((PyArrayObject *)values[2]);
    __pyx_v_subgrid_faces = values[3];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_parent_grid_id = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_parent_grid_id == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_left_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_right_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_subgrid_faces = PyTuple_GET_ITEM(__pyx_args, 3);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.ProtoPrism.__cinit__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF((PyObject *)__pyx_v_left_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_right_edge);
  __Pyx_INCREF(__pyx_v_subgrid_faces);
  __pyx_bstruct_left_edge.buf = NULL;
  __pyx_bstruct_right_edge.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_left_edge), __pyx_ptype_5numpy_ndarray, 1, "left_edge", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_right_edge), __pyx_ptype_5numpy_ndarray, 1, "right_edge", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_left_edge, (PyObject*)__pyx_v_left_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_left_edge = __pyx_bstruct_left_edge.strides[0];
  __pyx_bshape_0_left_edge = __pyx_bstruct_left_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_right_edge, (PyObject*)__pyx_v_right_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_right_edge = __pyx_bstruct_right_edge.strides[0];
  __pyx_bshape_0_right_edge = __pyx_bstruct_right_edge.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":580
 *                   np.ndarray[np.float64_t, ndim=1] right_edge,
 *                   subgrid_faces):
 *         self.parent_grid_id = parent_grid_id             # <<<<<<<<<<<<<<
 *         cdef int i
 *         self.LeftEdge = left_edge
 */
  ((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->parent_grid_id = __pyx_v_parent_grid_id;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":582
 *         self.parent_grid_id = parent_grid_id
 *         cdef int i
 *         self.LeftEdge = left_edge             # <<<<<<<<<<<<<<
 *         self.RightEdge = right_edge
 *         for i in range(3):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_left_edge));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_left_edge));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->LeftEdge);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->LeftEdge);
  ((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->LeftEdge = ((PyObject *)__pyx_v_left_edge);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":583
 *         cdef int i
 *         self.LeftEdge = left_edge
 *         self.RightEdge = right_edge             # <<<<<<<<<<<<<<
 *         for i in range(3):
 *             self.left_edge[i] = left_edge[i]
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_right_edge));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_right_edge));
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->RightEdge);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->RightEdge);
  ((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->RightEdge = ((PyObject *)__pyx_v_right_edge);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":584
 *         self.LeftEdge = left_edge
 *         self.RightEdge = right_edge
 *         for i in range(3):             # <<<<<<<<<<<<<<
 *             self.left_edge[i] = left_edge[i]
 *             self.right_edge[i] = right_edge[i]
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":585
 *         self.RightEdge = right_edge
 *         for i in range(3):
 *             self.left_edge[i] = left_edge[i]             # <<<<<<<<<<<<<<
 *             self.right_edge[i] = right_edge[i]
 *         self.subgrid_faces = subgrid_faces
 */
    __pyx_t_2 = __pyx_v_i;
    __pyx_t_3 = -1;
    if (__pyx_t_2 < 0) {
      __pyx_t_2 += __pyx_bshape_0_left_edge;
      if (unlikely(__pyx_t_2 < 0)) __pyx_t_3 = 0;
    } else if (unlikely(__pyx_t_2 >= __pyx_bshape_0_left_edge)) __pyx_t_3 = 0;
    if (unlikely(__pyx_t_3 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_3);
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->left_edge[__pyx_v_i]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_left_edge.buf, __pyx_t_2, __pyx_bstride_0_left_edge));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":586
 *         for i in range(3):
 *             self.left_edge[i] = left_edge[i]
 *             self.right_edge[i] = right_edge[i]             # <<<<<<<<<<<<<<
 *         self.subgrid_faces = subgrid_faces
 * 
 */
    __pyx_t_3 = __pyx_v_i;
    __pyx_t_4 = -1;
    if (__pyx_t_3 < 0) {
      __pyx_t_3 += __pyx_bshape_0_right_edge;
      if (unlikely(__pyx_t_3 < 0)) __pyx_t_4 = 0;
    } else if (unlikely(__pyx_t_3 >= __pyx_bshape_0_right_edge)) __pyx_t_4 = 0;
    if (unlikely(__pyx_t_4 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_4);
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    (((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->right_edge[__pyx_v_i]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_right_edge.buf, __pyx_t_3, __pyx_bstride_0_right_edge));
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":587
 *             self.left_edge[i] = left_edge[i]
 *             self.right_edge[i] = right_edge[i]
 *         self.subgrid_faces = subgrid_faces             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __Pyx_INCREF(__pyx_v_subgrid_faces);
  __Pyx_GIVEREF(__pyx_v_subgrid_faces);
  __Pyx_GOTREF(((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->subgrid_faces);
  __Pyx_DECREF(((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->subgrid_faces);
  ((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->subgrid_faces = __pyx_v_subgrid_faces;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.ProtoPrism.__cinit__");
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_right_edge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_left_edge);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF((PyObject *)__pyx_v_left_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_right_edge);
  __Pyx_DECREF(__pyx_v_subgrid_faces);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":591
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def sweep(self, int direction = 0, int stack = 0):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef GridFace face
 */

static PyObject *__pyx_pf_2yt_9amr_utils_10ProtoPrism_sweep(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_10ProtoPrism_sweep(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_direction;
  int __pyx_v_stack;
  int __pyx_v_i;
  struct __pyx_obj_2yt_9amr_utils_GridFace *__pyx_v_face;
  __pyx_t_5numpy_float64_t __pyx_v_proto_split[3];
  PyObject *__pyx_v_left;
  PyObject *__pyx_v_right;
  PyObject *__pyx_v_LC;
  PyObject *__pyx_v_RC;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__direction,&__pyx_n_s__stack,0};
  __Pyx_RefNannySetupContext("sweep");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__direction);
        if (unlikely(value)) { values[0] = value; kw_args--; }
      }
      case  1:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stack);
        if (unlikely(value)) { values[1] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "sweep") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    if (values[0]) {
      __pyx_v_direction = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_direction == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_direction = ((int)0);
    }
    if (values[1]) {
      __pyx_v_stack = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_stack == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_stack = ((int)0);
    }
  } else {
    __pyx_v_direction = ((int)0);
    __pyx_v_stack = ((int)0);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_stack = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_stack == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  1: __pyx_v_direction = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_direction == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sweep", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.ProtoPrism.sweep");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_face = ((struct __pyx_obj_2yt_9amr_utils_GridFace *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_left = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_right = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_LC = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_RC = Py_None; __Pyx_INCREF(Py_None);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":595
 *         cdef GridFace face
 *         cdef np.float64_t proto_split[3]
 *         for i in range(3): proto_split[i] = self.right_edge[i]             # <<<<<<<<<<<<<<
 *         for face in self.subgrid_faces[direction]:
 *             proto_split[direction] = face.coord
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;
    (__pyx_v_proto_split[__pyx_v_i]) = (((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->right_edge[__pyx_v_i]);
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":596
 *         cdef np.float64_t proto_split[3]
 *         for i in range(3): proto_split[i] = self.right_edge[i]
 *         for face in self.subgrid_faces[direction]:             # <<<<<<<<<<<<<<
 *             proto_split[direction] = face.coord
 *             if proto_split[direction] <= self.left_edge[direction]:
 */
  __pyx_t_3 = __Pyx_GetItemInt(((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->subgrid_faces, __pyx_v_direction, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = 0; __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4);
  } else {
    __pyx_t_2 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_t_4))) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_4)) break;
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_4))) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
    } else {
      __pyx_t_3 = PyIter_Next(__pyx_t_4);
      if (!__pyx_t_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_2yt_9amr_utils_GridFace))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_face));
    __pyx_v_face = ((struct __pyx_obj_2yt_9amr_utils_GridFace *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":597
 *         for i in range(3): proto_split[i] = self.right_edge[i]
 *         for face in self.subgrid_faces[direction]:
 *             proto_split[direction] = face.coord             # <<<<<<<<<<<<<<
 *             if proto_split[direction] <= self.left_edge[direction]:
 *                 continue
 */
    (__pyx_v_proto_split[__pyx_v_direction]) = __pyx_v_face->coord;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":598
 *         for face in self.subgrid_faces[direction]:
 *             proto_split[direction] = face.coord
 *             if proto_split[direction] <= self.left_edge[direction]:             # <<<<<<<<<<<<<<
 *                 continue
 *             if proto_split[direction] == self.right_edge[direction]:
 */
    __pyx_t_5 = ((__pyx_v_proto_split[__pyx_v_direction]) <= (((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->left_edge[__pyx_v_direction]));
    if (__pyx_t_5) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":599
 *             proto_split[direction] = face.coord
 *             if proto_split[direction] <= self.left_edge[direction]:
 *                 continue             # <<<<<<<<<<<<<<
 *             if proto_split[direction] == self.right_edge[direction]:
 *                 if stack == 2: return [self]
 */
      goto __pyx_L8_continue;
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":600
 *             if proto_split[direction] <= self.left_edge[direction]:
 *                 continue
 *             if proto_split[direction] == self.right_edge[direction]:             # <<<<<<<<<<<<<<
 *                 if stack == 2: return [self]
 *                 return self.sweep((direction + 1) % 3, stack + 1)
 */
    __pyx_t_5 = ((__pyx_v_proto_split[__pyx_v_direction]) == (((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->right_edge[__pyx_v_direction]));
    if (__pyx_t_5) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":601
 *                 continue
 *             if proto_split[direction] == self.right_edge[direction]:
 *                 if stack == 2: return [self]             # <<<<<<<<<<<<<<
 *                 return self.sweep((direction + 1) % 3, stack + 1)
 *             if face.proj_overlap(self.left_edge, proto_split) == 1:
 */
      __pyx_t_5 = (__pyx_v_stack == 2);
      if (__pyx_t_5) {
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
        __Pyx_INCREF(__pyx_v_self);
        PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_self);
        __Pyx_GIVEREF(__pyx_v_self);
        __pyx_r = ((PyObject *)__pyx_t_3);
        __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L0;
        goto __pyx_L12;
      }
      __pyx_L12:;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":602
 *             if proto_split[direction] == self.right_edge[direction]:
 *                 if stack == 2: return [self]
 *                 return self.sweep((direction + 1) % 3, stack + 1)             # <<<<<<<<<<<<<<
 *             if face.proj_overlap(self.left_edge, proto_split) == 1:
 *                 left, right = self.split(proto_split, direction)
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__sweep); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyInt_FromLong(((__pyx_v_direction + 1) % 3)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PyInt_FromLong((__pyx_v_stack + 1)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_7;
      __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L0;
      goto __pyx_L11;
    }
    __pyx_L11:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":603
 *                 if stack == 2: return [self]
 *                 return self.sweep((direction + 1) % 3, stack + 1)
 *             if face.proj_overlap(self.left_edge, proto_split) == 1:             # <<<<<<<<<<<<<<
 *                 left, right = self.split(proto_split, direction)
 *                 LC = left.sweep((direction + 1) % 3)
 */
    __pyx_t_5 = (((struct __pyx_vtabstruct_2yt_9amr_utils_GridFace *)__pyx_v_face->__pyx_vtab)->proj_overlap(__pyx_v_face, ((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->left_edge, __pyx_v_proto_split) == 1);
    if (__pyx_t_5) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":604
 *                 return self.sweep((direction + 1) % 3, stack + 1)
 *             if face.proj_overlap(self.left_edge, proto_split) == 1:
 *                 left, right = self.split(proto_split, direction)             # <<<<<<<<<<<<<<
 *                 LC = left.sweep((direction + 1) % 3)
 *                 RC = right.sweep(direction)
 */
      __pyx_t_7 = ((struct __pyx_vtabstruct_2yt_9amr_utils_ProtoPrism *)((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->__pyx_vtab)->split(((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self), __pyx_v_proto_split, __pyx_v_direction); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      if (PyTuple_CheckExact(__pyx_t_7) && likely(PyTuple_GET_SIZE(__pyx_t_7) == 2)) {
        PyObject* tuple = __pyx_t_7;
        __pyx_t_8 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_8);
        __pyx_t_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_v_left);
        __pyx_v_left = __pyx_t_8;
        __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_v_right);
        __pyx_v_right = __pyx_t_3;
        __pyx_t_3 = 0;
      } else {
        __pyx_t_6 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_EndUnpack(__pyx_t_6) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_v_left);
        __pyx_v_left = __pyx_t_8;
        __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_v_right);
        __pyx_v_right = __pyx_t_3;
        __pyx_t_3 = 0;
      }

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":605
 *             if face.proj_overlap(self.left_edge, proto_split) == 1:
 *                 left, right = self.split(proto_split, direction)
 *                 LC = left.sweep((direction + 1) % 3)             # <<<<<<<<<<<<<<
 *                 RC = right.sweep(direction)
 *                 return LC + RC
 */
      __pyx_t_7 = PyObject_GetAttr(__pyx_v_left, __pyx_n_s__sweep); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_3 = PyInt_FromLong(((__pyx_v_direction + 1) % 3)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 605; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_v_LC);
      __pyx_v_LC = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":606
 *                 left, right = self.split(proto_split, direction)
 *                 LC = left.sweep((direction + 1) % 3)
 *                 RC = right.sweep(direction)             # <<<<<<<<<<<<<<
 *                 return LC + RC
 *         raise RuntimeError
 */
      __pyx_t_3 = PyObject_GetAttr(__pyx_v_right, __pyx_n_s__sweep); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = PyInt_FromLong(__pyx_v_direction); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_t_3, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_v_RC);
      __pyx_v_RC = __pyx_t_8;
      __pyx_t_8 = 0;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":607
 *                 LC = left.sweep((direction + 1) % 3)
 *                 RC = right.sweep(direction)
 *                 return LC + RC             # <<<<<<<<<<<<<<
 *         raise RuntimeError
 * 
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyNumber_Add(__pyx_v_LC, __pyx_v_RC); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_r = __pyx_t_8;
      __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L0;
      goto __pyx_L13;
    }
    __pyx_L13:;
    __pyx_L8_continue:;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":608
 *                 RC = right.sweep(direction)
 *                 return LC + RC
 *         raise RuntimeError             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __Pyx_Raise(__pyx_builtin_RuntimeError, 0, 0);
  {__pyx_filename = __pyx_f[2]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("yt.amr_utils.ProtoPrism.sweep");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_face);
  __Pyx_DECREF(__pyx_v_left);
  __Pyx_DECREF(__pyx_v_right);
  __Pyx_DECREF(__pyx_v_LC);
  __Pyx_DECREF(__pyx_v_RC);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":612
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     cdef object split(self, np.float64_t *sp, int direction):             # <<<<<<<<<<<<<<
 *         cdef int i
 *         cdef np.ndarray split_left = self.LeftEdge.copy()
 */

static  PyObject *__pyx_f_2yt_9amr_utils_10ProtoPrism_split(struct __pyx_obj_2yt_9amr_utils_ProtoPrism *__pyx_v_self, __pyx_t_5numpy_float64_t *__pyx_v_sp, int __pyx_v_direction) {
  int __pyx_v_i;
  PyArrayObject *__pyx_v_split_left = 0;
  PyArrayObject *__pyx_v_split_right = 0;
  PyObject *__pyx_v_left;
  PyObject *__pyx_v_right;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("split");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_left = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_right = Py_None; __Pyx_INCREF(Py_None);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":614
 *     cdef object split(self, np.float64_t *sp, int direction):
 *         cdef int i
 *         cdef np.ndarray split_left = self.LeftEdge.copy()             # <<<<<<<<<<<<<<
 *         cdef np.ndarray split_right = self.RightEdge.copy()
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self->LeftEdge, __pyx_n_s__copy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_split_left = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":615
 *         cdef int i
 *         cdef np.ndarray split_left = self.LeftEdge.copy()
 *         cdef np.ndarray split_right = self.RightEdge.copy()             # <<<<<<<<<<<<<<
 * 
 *         for i in range(3): split_left[i] = self.right_edge[i]
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self->RightEdge, __pyx_n_s__copy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_split_right = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":617
 *         cdef np.ndarray split_right = self.RightEdge.copy()
 * 
 *         for i in range(3): split_left[i] = self.right_edge[i]             # <<<<<<<<<<<<<<
 *         split_left[direction] = sp[direction]
 *         left = ProtoPrism(self.parent_grid_id, self.LeftEdge, split_left,
 */
  for (__pyx_t_3 = 0; __pyx_t_3 < 3; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;
    __pyx_t_1 = PyFloat_FromDouble((__pyx_v_self->right_edge[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_SetItemInt(((PyObject *)__pyx_v_split_left), __pyx_v_i, __pyx_t_1, sizeof(int), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":618
 * 
 *         for i in range(3): split_left[i] = self.right_edge[i]
 *         split_left[direction] = sp[direction]             # <<<<<<<<<<<<<<
 *         left = ProtoPrism(self.parent_grid_id, self.LeftEdge, split_left,
 *                           self.subgrid_faces)
 */
  __pyx_t_1 = PyFloat_FromDouble((__pyx_v_sp[__pyx_v_direction])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_SetItemInt(((PyObject *)__pyx_v_split_left), __pyx_v_direction, __pyx_t_1, sizeof(int), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":619
 *         for i in range(3): split_left[i] = self.right_edge[i]
 *         split_left[direction] = sp[direction]
 *         left = ProtoPrism(self.parent_grid_id, self.LeftEdge, split_left,             # <<<<<<<<<<<<<<
 *                           self.subgrid_faces)
 * 
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->parent_grid_id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":620
 *         split_left[direction] = sp[direction]
 *         left = ProtoPrism(self.parent_grid_id, self.LeftEdge, split_left,
 *                           self.subgrid_faces)             # <<<<<<<<<<<<<<
 * 
 *         for i in range(3): split_right[i] = self.left_edge[i]
 */
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->LeftEdge);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->LeftEdge);
  __Pyx_GIVEREF(__pyx_v_self->LeftEdge);
  __Pyx_INCREF(((PyObject *)__pyx_v_split_left));
  PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_split_left));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_split_left));
  __Pyx_INCREF(__pyx_v_self->subgrid_faces);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_self->subgrid_faces);
  __Pyx_GIVEREF(__pyx_v_self->subgrid_faces);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2yt_9amr_utils_ProtoPrism)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_left);
  __pyx_v_left = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":622
 *                           self.subgrid_faces)
 * 
 *         for i in range(3): split_right[i] = self.left_edge[i]             # <<<<<<<<<<<<<<
 *         split_right[direction] = sp[direction]
 *         right = ProtoPrism(self.parent_grid_id, split_right, self.RightEdge,
 */
  for (__pyx_t_3 = 0; __pyx_t_3 < 3; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;
    __pyx_t_1 = PyFloat_FromDouble((__pyx_v_self->left_edge[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_SetItemInt(((PyObject *)__pyx_v_split_right), __pyx_v_i, __pyx_t_1, sizeof(int), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":623
 * 
 *         for i in range(3): split_right[i] = self.left_edge[i]
 *         split_right[direction] = sp[direction]             # <<<<<<<<<<<<<<
 *         right = ProtoPrism(self.parent_grid_id, split_right, self.RightEdge,
 *                            self.subgrid_faces)
 */
  __pyx_t_1 = PyFloat_FromDouble((__pyx_v_sp[__pyx_v_direction])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_SetItemInt(((PyObject *)__pyx_v_split_right), __pyx_v_direction, __pyx_t_1, sizeof(int), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":624
 *         for i in range(3): split_right[i] = self.left_edge[i]
 *         split_right[direction] = sp[direction]
 *         right = ProtoPrism(self.parent_grid_id, split_right, self.RightEdge,             # <<<<<<<<<<<<<<
 *                            self.subgrid_faces)
 * 
 */
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->parent_grid_id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":625
 *         split_right[direction] = sp[direction]
 *         right = ProtoPrism(self.parent_grid_id, split_right, self.RightEdge,
 *                            self.subgrid_faces)             # <<<<<<<<<<<<<<
 * 
 *         return (left, right)
 */
  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_split_right));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_split_right));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_split_right));
  __Pyx_INCREF(__pyx_v_self->RightEdge);
  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_self->RightEdge);
  __Pyx_GIVEREF(__pyx_v_self->RightEdge);
  __Pyx_INCREF(__pyx_v_self->subgrid_faces);
  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_self->subgrid_faces);
  __Pyx_GIVEREF(__pyx_v_self->subgrid_faces);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2yt_9amr_utils_ProtoPrism)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_v_right);
  __pyx_v_right = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":627
 *                            self.subgrid_faces)
 * 
 *         return (left, right)             # <<<<<<<<<<<<<<
 * 
 *     @cython.boundscheck(False)
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_left);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_left);
  __Pyx_GIVEREF(__pyx_v_left);
  __Pyx_INCREF(__pyx_v_right);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_right);
  __Pyx_GIVEREF(__pyx_v_right);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("yt.amr_utils.ProtoPrism.split");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_split_left);
  __Pyx_XDECREF((PyObject *)__pyx_v_split_right);
  __Pyx_DECREF(__pyx_v_left);
  __Pyx_DECREF(__pyx_v_right);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":631
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def get_brick(self, np.ndarray[np.float64_t, ndim=1] grid_left_edge,             # <<<<<<<<<<<<<<
 *                         np.ndarray[np.float64_t, ndim=1] grid_dds,
 *                         child_mask):
 */

static PyObject *__pyx_pf_2yt_9amr_utils_10ProtoPrism_get_brick(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_10ProtoPrism_get_brick(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_grid_left_edge = 0;
  PyArrayObject *__pyx_v_grid_dds = 0;
  PyObject *__pyx_v_child_mask = 0;
  int __pyx_v_li[3];
  int __pyx_v_ri[3];
  int __pyx_v_idims[3];
  int __pyx_v_i;
  PyArrayObject *__pyx_v_dims = 0;
  Py_buffer __pyx_bstruct_grid_dds;
  Py_ssize_t __pyx_bstride_0_grid_dds = 0;
  Py_ssize_t __pyx_bshape_0_grid_dds = 0;
  Py_buffer __pyx_bstruct_dims;
  Py_ssize_t __pyx_bstride_0_dims = 0;
  Py_ssize_t __pyx_bshape_0_dims = 0;
  Py_buffer __pyx_bstruct_grid_left_edge;
  Py_ssize_t __pyx_bstride_0_grid_left_edge = 0;
  Py_ssize_t __pyx_bshape_0_grid_left_edge = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyArrayObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__grid_left_edge,&__pyx_n_s__grid_dds,&__pyx_n_s__child_mask,0};
  __Pyx_RefNannySetupContext("get_brick");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grid_left_edge);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__grid_dds);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("get_brick", 1, 3, 3, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__child_mask);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("get_brick", 1, 3, 3, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "get_brick") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_grid_left_edge = ((PyArrayObject *)values[0]);
    __pyx_v_grid_dds = ((PyArrayObject *)values[1]);
    __pyx_v_child_mask = values[2];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_grid_left_edge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_grid_dds = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_child_mask = PyTuple_GET_ITEM(__pyx_args, 2);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_brick", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.ProtoPrism.get_brick");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF((PyObject *)__pyx_v_grid_left_edge);
  __Pyx_INCREF((PyObject *)__pyx_v_grid_dds);
  __Pyx_INCREF(__pyx_v_child_mask);
  __pyx_bstruct_dims.buf = NULL;
  __pyx_bstruct_grid_left_edge.buf = NULL;
  __pyx_bstruct_grid_dds.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grid_left_edge), __pyx_ptype_5numpy_ndarray, 1, "grid_left_edge", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grid_dds), __pyx_ptype_5numpy_ndarray, 1, "grid_dds", 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_grid_left_edge, (PyObject*)__pyx_v_grid_left_edge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_grid_left_edge = __pyx_bstruct_grid_left_edge.strides[0];
  __pyx_bshape_0_grid_left_edge = __pyx_bstruct_grid_left_edge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_grid_dds, (PyObject*)__pyx_v_grid_dds, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_grid_dds = __pyx_bstruct_grid_dds.strides[0];
  __pyx_bshape_0_grid_dds = __pyx_bstruct_grid_dds.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":638
 *         cdef PartitionedGrid PG
 *         cdef int li[3], ri[3], idims[3], i
 *         for i in range(3):             # <<<<<<<<<<<<<<
 *             li[i] = lrint((self.left_edge[i] - grid_left_edge[i])/grid_dds[i])
 *             ri[i] = lrint((self.right_edge[i] - grid_left_edge[i])/grid_dds[i])
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":639
 *         cdef int li[3], ri[3], idims[3], i
 *         for i in range(3):
 *             li[i] = lrint((self.left_edge[i] - grid_left_edge[i])/grid_dds[i])             # <<<<<<<<<<<<<<
 *             ri[i] = lrint((self.right_edge[i] - grid_left_edge[i])/grid_dds[i])
 *             idims[i] = ri[i] - li[i]
 */
    __pyx_t_2 = __pyx_v_i;
    __pyx_t_3 = __pyx_v_i;
    (__pyx_v_li[__pyx_v_i]) = lrint((((((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->left_edge[__pyx_v_i]) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_left_edge.buf, __pyx_t_2, __pyx_bstride_0_grid_left_edge))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_dds.buf, __pyx_t_3, __pyx_bstride_0_grid_dds))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":640
 *         for i in range(3):
 *             li[i] = lrint((self.left_edge[i] - grid_left_edge[i])/grid_dds[i])
 *             ri[i] = lrint((self.right_edge[i] - grid_left_edge[i])/grid_dds[i])             # <<<<<<<<<<<<<<
 *             idims[i] = ri[i] - li[i]
 *         if child_mask[li[0], li[1], li[2]] == 0: return []
 */
    __pyx_t_4 = __pyx_v_i;
    __pyx_t_5 = __pyx_v_i;
    (__pyx_v_ri[__pyx_v_i]) = lrint((((((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)__pyx_v_self)->right_edge[__pyx_v_i]) - (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_left_edge.buf, __pyx_t_4, __pyx_bstride_0_grid_left_edge))) / (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_grid_dds.buf, __pyx_t_5, __pyx_bstride_0_grid_dds))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":641
 *             li[i] = lrint((self.left_edge[i] - grid_left_edge[i])/grid_dds[i])
 *             ri[i] = lrint((self.right_edge[i] - grid_left_edge[i])/grid_dds[i])
 *             idims[i] = ri[i] - li[i]             # <<<<<<<<<<<<<<
 *         if child_mask[li[0], li[1], li[2]] == 0: return []
 *         cdef np.ndarray[np.int64_t, ndim=1] dims = np.empty(3, dtype='int64')
 */
    (__pyx_v_idims[__pyx_v_i]) = ((__pyx_v_ri[__pyx_v_i]) - (__pyx_v_li[__pyx_v_i]));
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":642
 *             ri[i] = lrint((self.right_edge[i] - grid_left_edge[i])/grid_dds[i])
 *             idims[i] = ri[i] - li[i]
 *         if child_mask[li[0], li[1], li[2]] == 0: return []             # <<<<<<<<<<<<<<
 *         cdef np.ndarray[np.int64_t, ndim=1] dims = np.empty(3, dtype='int64')
 *         for i in range(3):
 */
  __pyx_t_6 = PyInt_FromLong((__pyx_v_li[0])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyInt_FromLong((__pyx_v_li[1])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = PyInt_FromLong((__pyx_v_li[2])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_8 = PyObject_GetItem(__pyx_v_child_mask, __pyx_t_9); if (!__pyx_t_8) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyObject_RichCompare(__pyx_t_8, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_10) {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_9));
    __pyx_r = ((PyObject *)__pyx_t_9);
    __pyx_t_9 = 0;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":643
 *             idims[i] = ri[i] - li[i]
 *         if child_mask[li[0], li[1], li[2]] == 0: return []
 *         cdef np.ndarray[np.int64_t, ndim=1] dims = np.empty(3, dtype='int64')             # <<<<<<<<<<<<<<
 *         for i in range(3):
 *             dims[i] = idims[i]
 */
  __pyx_t_9 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_8 = PyObject_GetAttr(__pyx_t_9, __pyx_n_s__empty); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
  if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)__pyx_n_s__int64)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyEval_CallObjectWithKeywords(__pyx_t_8, __pyx_t_9, ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_6);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dims, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_dims = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_bstruct_dims.buf = NULL;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    } else {__pyx_bstride_0_dims = __pyx_bstruct_dims.strides[0];
      __pyx_bshape_0_dims = __pyx_bstruct_dims.shape[0];
    }
  }
  __pyx_t_11 = 0;
  __pyx_v_dims = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":644
 *         if child_mask[li[0], li[1], li[2]] == 0: return []
 *         cdef np.ndarray[np.int64_t, ndim=1] dims = np.empty(3, dtype='int64')
 *         for i in range(3):             # <<<<<<<<<<<<<<
 *             dims[i] = idims[i]
 *         #cdef np.ndarray[np.float64_t, ndim=3] new_data
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 3; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":645
 *         cdef np.ndarray[np.int64_t, ndim=1] dims = np.empty(3, dtype='int64')
 *         for i in range(3):
 *             dims[i] = idims[i]             # <<<<<<<<<<<<<<
 *         #cdef np.ndarray[np.float64_t, ndim=3] new_data
 *         #new_data = data[li[0]:ri[0]+1,li[1]:ri[1]+1,li[2]:ri[2]+1].copy()
 */
    __pyx_t_12 = __pyx_v_i;
    *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_dims.buf, __pyx_t_12, __pyx_bstride_0_dims) = (__pyx_v_idims[__pyx_v_i]);
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":650
 *         #PG = PartitionedGrid(self.parent_grid_id, new_data,
 *         #                     self.LeftEdge, self.RightEdge, dims)
 *         return ((li[0], ri[0]), (li[1], ri[1]), (li[2], ri[2]), dims)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = PyInt_FromLong((__pyx_v_li[0])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyInt_FromLong((__pyx_v_ri[0])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = PyInt_FromLong((__pyx_v_li[1])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = PyInt_FromLong((__pyx_v_ri[1])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_7 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = PyInt_FromLong((__pyx_v_li[2])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyInt_FromLong((__pyx_v_ri[2])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_13);
  __Pyx_INCREF(((PyObject *)__pyx_v_dims));
  PyTuple_SET_ITEM(__pyx_t_7, 3, ((PyObject *)__pyx_v_dims));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dims));
  __pyx_t_9 = 0;
  __pyx_t_8 = 0;
  __pyx_t_13 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_13);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_dds);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dims);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_left_edge);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.ProtoPrism.get_brick");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_dds);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dims);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_grid_left_edge);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_dims);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF((PyObject *)__pyx_v_grid_left_edge);
  __Pyx_DECREF((PyObject *)__pyx_v_grid_dds);
  __Pyx_DECREF(__pyx_v_child_mask);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":28
 * @cython.boundscheck(False)
 * @cython.wraparound(False)
 * def CICDeposit_3(np.ndarray[np.float64_t, ndim=1] posx,             # <<<<<<<<<<<<<<
 *                  np.ndarray[np.float64_t, ndim=1] posy,
 *                  np.ndarray[np.float64_t, ndim=1] posz,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_CICDeposit_3(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_CICDeposit_3(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_posx = 0;
  PyArrayObject *__pyx_v_posy = 0;
  PyArrayObject *__pyx_v_posz = 0;
  PyArrayObject *__pyx_v_mass = 0;
  __pyx_t_5numpy_int64_t __pyx_v_npositions;
  PyArrayObject *__pyx_v_field = 0;
  PyArrayObject *__pyx_v_leftEdge = 0;
  PyArrayObject *__pyx_v_gridDimension = 0;
  __pyx_t_5numpy_float64_t __pyx_v_cellSize;
  int __pyx_v_i1;
  int __pyx_v_j1;
  int __pyx_v_k1;
  int __pyx_v_n;
  double __pyx_v_xpos;
  double __pyx_v_ypos;
  double __pyx_v_zpos;
  double __pyx_v_fact;
  double __pyx_v_edge0;
  double __pyx_v_edge1;
  double __pyx_v_edge2;
  double __pyx_v_le0;
  double __pyx_v_le1;
  double __pyx_v_le2;
  float __pyx_v_dx;
  float __pyx_v_dy;
  float __pyx_v_dz;
  float __pyx_v_dx2;
  float __pyx_v_dy2;
  float __pyx_v_dz2;
  Py_buffer __pyx_bstruct_field;
  Py_ssize_t __pyx_bstride_0_field = 0;
  Py_ssize_t __pyx_bstride_1_field = 0;
  Py_ssize_t __pyx_bstride_2_field = 0;
  Py_ssize_t __pyx_bshape_0_field = 0;
  Py_ssize_t __pyx_bshape_1_field = 0;
  Py_ssize_t __pyx_bshape_2_field = 0;
  Py_buffer __pyx_bstruct_leftEdge;
  Py_ssize_t __pyx_bstride_0_leftEdge = 0;
  Py_ssize_t __pyx_bshape_0_leftEdge = 0;
  Py_buffer __pyx_bstruct_posz;
  Py_ssize_t __pyx_bstride_0_posz = 0;
  Py_ssize_t __pyx_bshape_0_posz = 0;
  Py_buffer __pyx_bstruct_posx;
  Py_ssize_t __pyx_bstride_0_posx = 0;
  Py_ssize_t __pyx_bshape_0_posx = 0;
  Py_buffer __pyx_bstruct_posy;
  Py_ssize_t __pyx_bstride_0_posy = 0;
  Py_ssize_t __pyx_bshape_0_posy = 0;
  Py_buffer __pyx_bstruct_gridDimension;
  Py_ssize_t __pyx_bstride_0_gridDimension = 0;
  Py_ssize_t __pyx_bshape_0_gridDimension = 0;
  Py_buffer __pyx_bstruct_mass;
  Py_ssize_t __pyx_bstride_0_mass = 0;
  Py_ssize_t __pyx_bshape_0_mass = 0;
  PyObject *__pyx_r = NULL;
  long __pyx_t_1;
  long __pyx_t_2;
  long __pyx_t_3;
  long __pyx_t_4;
  long __pyx_t_5;
  long __pyx_t_6;
  __pyx_t_5numpy_int64_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  long __pyx_t_13;
  long __pyx_t_14;
  long __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  long __pyx_t_18;
  long __pyx_t_19;
  int __pyx_t_20;
  long __pyx_t_21;
  int __pyx_t_22;
  long __pyx_t_23;
  int __pyx_t_24;
  int __pyx_t_25;
  int __pyx_t_26;
  long __pyx_t_27;
  int __pyx_t_28;
  long __pyx_t_29;
  long __pyx_t_30;
  int __pyx_t_31;
  int __pyx_t_32;
  int __pyx_t_33;
  long __pyx_t_34;
  int __pyx_t_35;
  int __pyx_t_36;
  long __pyx_t_37;
  int __pyx_t_38;
  int __pyx_t_39;
  int __pyx_t_40;
  int __pyx_t_41;
  int __pyx_t_42;
  int __pyx_t_43;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__posx,&__pyx_n_s__posy,&__pyx_n_s__posz,&__pyx_n_s__mass,&__pyx_n_s__npositions,&__pyx_n_s__field,&__pyx_n_s__leftEdge,&__pyx_n_s__gridDimension,&__pyx_n_s__cellSize,0};
  __Pyx_RefNannySetupContext("CICDeposit_3");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
      case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__posx);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__posy);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("CICDeposit_3", 1, 9, 9, 1); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__posz);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("CICDeposit_3", 1, 9, 9, 2); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mass);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("CICDeposit_3", 1, 9, 9, 3); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__npositions);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("CICDeposit_3", 1, 9, 9, 4); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__field);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("CICDeposit_3", 1, 9, 9, 5); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__leftEdge);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("CICDeposit_3", 1, 9, 9, 6); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  7:
      values[7] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__gridDimension);
      if (likely(values[7])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("CICDeposit_3", 1, 9, 9, 7); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  8:
      values[8] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cellSize);
      if (likely(values[8])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("CICDeposit_3", 1, 9, 9, 8); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "CICDeposit_3") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_posx = ((PyArrayObject *)values[0]);
    __pyx_v_posy = ((PyArrayObject *)values[1]);
    __pyx_v_posz = ((PyArrayObject *)values[2]);
    __pyx_v_mass = ((PyArrayObject *)values[3]);
    __pyx_v_npositions = __Pyx_PyInt_from_py_npy_int64(values[4]); if (unlikely((__pyx_v_npositions == (npy_int64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_field = ((PyArrayObject *)values[5]);
    __pyx_v_leftEdge = ((PyArrayObject *)values[6]);
    __pyx_v_gridDimension = ((PyArrayObject *)values[7]);
    __pyx_v_cellSize = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_cellSize == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 9) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_posx = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_posy = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_posz = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_mass = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_npositions = __Pyx_PyInt_from_py_npy_int64(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_npositions == (npy_int64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_field = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 5));
    __pyx_v_leftEdge = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 6));
    __pyx_v_gridDimension = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 7));
    __pyx_v_cellSize = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 8)); if (unlikely((__pyx_v_cellSize == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("CICDeposit_3", 1, 9, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.CICDeposit_3");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_posx);
  __Pyx_INCREF((PyObject *)__pyx_v_posy);
  __Pyx_INCREF((PyObject *)__pyx_v_posz);
  __Pyx_INCREF((PyObject *)__pyx_v_mass);
  __Pyx_INCREF((PyObject *)__pyx_v_field);
  __Pyx_INCREF((PyObject *)__pyx_v_leftEdge);
  __Pyx_INCREF((PyObject *)__pyx_v_gridDimension);
  __pyx_bstruct_posx.buf = NULL;
  __pyx_bstruct_posy.buf = NULL;
  __pyx_bstruct_posz.buf = NULL;
  __pyx_bstruct_mass.buf = NULL;
  __pyx_bstruct_field.buf = NULL;
  __pyx_bstruct_leftEdge.buf = NULL;
  __pyx_bstruct_gridDimension.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_posx), __pyx_ptype_5numpy_ndarray, 1, "posx", 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_posy), __pyx_ptype_5numpy_ndarray, 1, "posy", 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_posz), __pyx_ptype_5numpy_ndarray, 1, "posz", 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mass), __pyx_ptype_5numpy_ndarray, 1, "mass", 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_field), __pyx_ptype_5numpy_ndarray, 1, "field", 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_leftEdge), __pyx_ptype_5numpy_ndarray, 1, "leftEdge", 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gridDimension), __pyx_ptype_5numpy_ndarray, 1, "gridDimension", 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_posx, (PyObject*)__pyx_v_posx, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_posx = __pyx_bstruct_posx.strides[0];
  __pyx_bshape_0_posx = __pyx_bstruct_posx.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_posy, (PyObject*)__pyx_v_posy, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_posy = __pyx_bstruct_posy.strides[0];
  __pyx_bshape_0_posy = __pyx_bstruct_posy.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_posz, (PyObject*)__pyx_v_posz, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_posz = __pyx_bstruct_posz.strides[0];
  __pyx_bshape_0_posz = __pyx_bstruct_posz.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_mass, (PyObject*)__pyx_v_mass, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_mass = __pyx_bstruct_mass.strides[0];
  __pyx_bshape_0_mass = __pyx_bstruct_mass.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_field, (PyObject*)__pyx_v_field, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float32_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_field = __pyx_bstruct_field.strides[0]; __pyx_bstride_1_field = __pyx_bstruct_field.strides[1]; __pyx_bstride_2_field = __pyx_bstruct_field.strides[2];
  __pyx_bshape_0_field = __pyx_bstruct_field.shape[0]; __pyx_bshape_1_field = __pyx_bstruct_field.shape[1]; __pyx_bshape_2_field = __pyx_bstruct_field.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_leftEdge, (PyObject*)__pyx_v_leftEdge, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_leftEdge = __pyx_bstruct_leftEdge.strides[0];
  __pyx_bshape_0_leftEdge = __pyx_bstruct_leftEdge.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_gridDimension, (PyObject*)__pyx_v_gridDimension, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_gridDimension = __pyx_bstruct_gridDimension.strides[0];
  __pyx_bshape_0_gridDimension = __pyx_bstruct_gridDimension.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":44
 *     cdef float dx, dy, dz, dx2, dy2, dz2
 * 
 *     edge0 = (<float> gridDimension[0]) - 0.5001             # <<<<<<<<<<<<<<
 *     edge1 = (<float> gridDimension[1]) - 0.5001
 *     edge2 = (<float> gridDimension[2]) - 0.5001
 */
  __pyx_t_1 = 0;
  __pyx_v_edge0 = (((float)(*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_gridDimension.buf, __pyx_t_1, __pyx_bstride_0_gridDimension))) - 0.50009999999999999);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":45
 * 
 *     edge0 = (<float> gridDimension[0]) - 0.5001
 *     edge1 = (<float> gridDimension[1]) - 0.5001             # <<<<<<<<<<<<<<
 *     edge2 = (<float> gridDimension[2]) - 0.5001
 *     fact = 1.0 / cellSize
 */
  __pyx_t_2 = 1;
  __pyx_v_edge1 = (((float)(*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_gridDimension.buf, __pyx_t_2, __pyx_bstride_0_gridDimension))) - 0.50009999999999999);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":46
 *     edge0 = (<float> gridDimension[0]) - 0.5001
 *     edge1 = (<float> gridDimension[1]) - 0.5001
 *     edge2 = (<float> gridDimension[2]) - 0.5001             # <<<<<<<<<<<<<<
 *     fact = 1.0 / cellSize
 * 
 */
  __pyx_t_3 = 2;
  __pyx_v_edge2 = (((float)(*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int32_t *, __pyx_bstruct_gridDimension.buf, __pyx_t_3, __pyx_bstride_0_gridDimension))) - 0.50009999999999999);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":47
 *     edge1 = (<float> gridDimension[1]) - 0.5001
 *     edge2 = (<float> gridDimension[2]) - 0.5001
 *     fact = 1.0 / cellSize             # <<<<<<<<<<<<<<
 * 
 *     le0 = leftEdge[0]
 */
  __pyx_v_fact = (1.0 / __pyx_v_cellSize);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":49
 *     fact = 1.0 / cellSize
 * 
 *     le0 = leftEdge[0]             # <<<<<<<<<<<<<<
 *     le1 = leftEdge[1]
 *     le2 = leftEdge[2]
 */
  __pyx_t_4 = 0;
  __pyx_v_le0 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_leftEdge.buf, __pyx_t_4, __pyx_bstride_0_leftEdge));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":50
 * 
 *     le0 = leftEdge[0]
 *     le1 = leftEdge[1]             # <<<<<<<<<<<<<<
 *     le2 = leftEdge[2]
 * 
 */
  __pyx_t_5 = 1;
  __pyx_v_le1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_leftEdge.buf, __pyx_t_5, __pyx_bstride_0_leftEdge));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":51
 *     le0 = leftEdge[0]
 *     le1 = leftEdge[1]
 *     le2 = leftEdge[2]             # <<<<<<<<<<<<<<
 * 
 *     for n in range(npositions):
 */
  __pyx_t_6 = 2;
  __pyx_v_le2 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_leftEdge.buf, __pyx_t_6, __pyx_bstride_0_leftEdge));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":53
 *     le2 = leftEdge[2]
 * 
 *     for n in range(npositions):             # <<<<<<<<<<<<<<
 * 
 *         # Compute the position of the central cell
 */
  __pyx_t_7 = __pyx_v_npositions;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
    __pyx_v_n = __pyx_t_8;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":56
 * 
 *         # Compute the position of the central cell
 *         xpos = fmin(fmax((posx[n] - le0)*fact, 0.5001), edge0)             # <<<<<<<<<<<<<<
 *         ypos = fmin(fmax((posy[n] - le1)*fact, 0.5001), edge1)
 *         zpos = fmin(fmax((posz[n] - le2)*fact, 0.5001), edge2)
 */
    __pyx_t_9 = __pyx_v_n;
    __pyx_v_xpos = __pyx_f_2yt_9amr_utils_fmin(__pyx_f_2yt_9amr_utils_fmax((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_posx.buf, __pyx_t_9, __pyx_bstride_0_posx)) - __pyx_v_le0) * __pyx_v_fact), 0.50009999999999999), __pyx_v_edge0);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":57
 *         # Compute the position of the central cell
 *         xpos = fmin(fmax((posx[n] - le0)*fact, 0.5001), edge0)
 *         ypos = fmin(fmax((posy[n] - le1)*fact, 0.5001), edge1)             # <<<<<<<<<<<<<<
 *         zpos = fmin(fmax((posz[n] - le2)*fact, 0.5001), edge2)
 * 
 */
    __pyx_t_10 = __pyx_v_n;
    __pyx_v_ypos = __pyx_f_2yt_9amr_utils_fmin(__pyx_f_2yt_9amr_utils_fmax((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_posy.buf, __pyx_t_10, __pyx_bstride_0_posy)) - __pyx_v_le1) * __pyx_v_fact), 0.50009999999999999), __pyx_v_edge1);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":58
 *         xpos = fmin(fmax((posx[n] - le0)*fact, 0.5001), edge0)
 *         ypos = fmin(fmax((posy[n] - le1)*fact, 0.5001), edge1)
 *         zpos = fmin(fmax((posz[n] - le2)*fact, 0.5001), edge2)             # <<<<<<<<<<<<<<
 * 
 *         i1  = <int> (xpos + 0.5)
 */
    __pyx_t_11 = __pyx_v_n;
    __pyx_v_zpos = __pyx_f_2yt_9amr_utils_fmin(__pyx_f_2yt_9amr_utils_fmax((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_posz.buf, __pyx_t_11, __pyx_bstride_0_posz)) - __pyx_v_le2) * __pyx_v_fact), 0.50009999999999999), __pyx_v_edge2);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":60
 *         zpos = fmin(fmax((posz[n] - le2)*fact, 0.5001), edge2)
 * 
 *         i1  = <int> (xpos + 0.5)             # <<<<<<<<<<<<<<
 *         j1  = <int> (ypos + 0.5)
 *         k1  = <int> (zpos + 0.5)
 */
    __pyx_v_i1 = ((int)(__pyx_v_xpos + 0.5));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":61
 * 
 *         i1  = <int> (xpos + 0.5)
 *         j1  = <int> (ypos + 0.5)             # <<<<<<<<<<<<<<
 *         k1  = <int> (zpos + 0.5)
 * 
 */
    __pyx_v_j1 = ((int)(__pyx_v_ypos + 0.5));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":62
 *         i1  = <int> (xpos + 0.5)
 *         j1  = <int> (ypos + 0.5)
 *         k1  = <int> (zpos + 0.5)             # <<<<<<<<<<<<<<
 * 
 *         # Compute the weights
 */
    __pyx_v_k1 = ((int)(__pyx_v_zpos + 0.5));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":65
 * 
 *         # Compute the weights
 *         dx = (<float> i1) + 0.5 - xpos             # <<<<<<<<<<<<<<
 *         dy = (<float> j1) + 0.5 - ypos
 *         dz = (<float> k1) + 0.5 - zpos
 */
    __pyx_v_dx = ((((float)__pyx_v_i1) + 0.5) - __pyx_v_xpos);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":66
 *         # Compute the weights
 *         dx = (<float> i1) + 0.5 - xpos
 *         dy = (<float> j1) + 0.5 - ypos             # <<<<<<<<<<<<<<
 *         dz = (<float> k1) + 0.5 - zpos
 *         dx2 =  1.0 - dx
 */
    __pyx_v_dy = ((((float)__pyx_v_j1) + 0.5) - __pyx_v_ypos);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":67
 *         dx = (<float> i1) + 0.5 - xpos
 *         dy = (<float> j1) + 0.5 - ypos
 *         dz = (<float> k1) + 0.5 - zpos             # <<<<<<<<<<<<<<
 *         dx2 =  1.0 - dx
 *         dy2 =  1.0 - dy
 */
    __pyx_v_dz = ((((float)__pyx_v_k1) + 0.5) - __pyx_v_zpos);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":68
 *         dy = (<float> j1) + 0.5 - ypos
 *         dz = (<float> k1) + 0.5 - zpos
 *         dx2 =  1.0 - dx             # <<<<<<<<<<<<<<
 *         dy2 =  1.0 - dy
 *         dz2 =  1.0 - dz
 */
    __pyx_v_dx2 = (1.0 - __pyx_v_dx);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":69
 *         dz = (<float> k1) + 0.5 - zpos
 *         dx2 =  1.0 - dx
 *         dy2 =  1.0 - dy             # <<<<<<<<<<<<<<
 *         dz2 =  1.0 - dz
 * 
 */
    __pyx_v_dy2 = (1.0 - __pyx_v_dy);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":70
 *         dx2 =  1.0 - dx
 *         dy2 =  1.0 - dy
 *         dz2 =  1.0 - dz             # <<<<<<<<<<<<<<
 * 
 *         # Interpolate from field into sumfield
 */
    __pyx_v_dz2 = (1.0 - __pyx_v_dz);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":73
 * 
 *         # Interpolate from field into sumfield
 *         field[i1-1,j1-1,k1-1] += mass[n] * dx  * dy  * dz             # <<<<<<<<<<<<<<
 *         field[i1  ,j1-1,k1-1] += mass[n] * dx2 * dy  * dz
 *         field[i1-1,j1  ,k1-1] += mass[n] * dx  * dy2 * dz
 */
    __pyx_t_12 = __pyx_v_n;
    __pyx_t_13 = (__pyx_v_i1 - 1);
    __pyx_t_14 = (__pyx_v_j1 - 1);
    __pyx_t_15 = (__pyx_v_k1 - 1);
    *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_field.buf, __pyx_t_13, __pyx_bstride_0_field, __pyx_t_14, __pyx_bstride_1_field, __pyx_t_15, __pyx_bstride_2_field) += ((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_mass.buf, __pyx_t_12, __pyx_bstride_0_mass)) * __pyx_v_dx) * __pyx_v_dy) * __pyx_v_dz);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":74
 *         # Interpolate from field into sumfield
 *         field[i1-1,j1-1,k1-1] += mass[n] * dx  * dy  * dz
 *         field[i1  ,j1-1,k1-1] += mass[n] * dx2 * dy  * dz             # <<<<<<<<<<<<<<
 *         field[i1-1,j1  ,k1-1] += mass[n] * dx  * dy2 * dz
 *         field[i1  ,j1  ,k1-1] += mass[n] * dx2 * dy2 * dz
 */
    __pyx_t_16 = __pyx_v_n;
    __pyx_t_17 = __pyx_v_i1;
    __pyx_t_18 = (__pyx_v_j1 - 1);
    __pyx_t_19 = (__pyx_v_k1 - 1);
    *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_field.buf, __pyx_t_17, __pyx_bstride_0_field, __pyx_t_18, __pyx_bstride_1_field, __pyx_t_19, __pyx_bstride_2_field) += ((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_mass.buf, __pyx_t_16, __pyx_bstride_0_mass)) * __pyx_v_dx2) * __pyx_v_dy) * __pyx_v_dz);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":75
 *         field[i1-1,j1-1,k1-1] += mass[n] * dx  * dy  * dz
 *         field[i1  ,j1-1,k1-1] += mass[n] * dx2 * dy  * dz
 *         field[i1-1,j1  ,k1-1] += mass[n] * dx  * dy2 * dz             # <<<<<<<<<<<<<<
 *         field[i1  ,j1  ,k1-1] += mass[n] * dx2 * dy2 * dz
 *         field[i1-1,j1-1,k1  ] += mass[n] * dx  * dy  * dz2
 */
    __pyx_t_20 = __pyx_v_n;
    __pyx_t_21 = (__pyx_v_i1 - 1);
    __pyx_t_22 = __pyx_v_j1;
    __pyx_t_23 = (__pyx_v_k1 - 1);
    *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_field.buf, __pyx_t_21, __pyx_bstride_0_field, __pyx_t_22, __pyx_bstride_1_field, __pyx_t_23, __pyx_bstride_2_field) += ((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_mass.buf, __pyx_t_20, __pyx_bstride_0_mass)) * __pyx_v_dx) * __pyx_v_dy2) * __pyx_v_dz);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":76
 *         field[i1  ,j1-1,k1-1] += mass[n] * dx2 * dy  * dz
 *         field[i1-1,j1  ,k1-1] += mass[n] * dx  * dy2 * dz
 *         field[i1  ,j1  ,k1-1] += mass[n] * dx2 * dy2 * dz             # <<<<<<<<<<<<<<
 *         field[i1-1,j1-1,k1  ] += mass[n] * dx  * dy  * dz2
 *         field[i1  ,j1-1,k1  ] += mass[n] * dx2 * dy  * dz2
 */
    __pyx_t_24 = __pyx_v_n;
    __pyx_t_25 = __pyx_v_i1;
    __pyx_t_26 = __pyx_v_j1;
    __pyx_t_27 = (__pyx_v_k1 - 1);
    *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_field.buf, __pyx_t_25, __pyx_bstride_0_field, __pyx_t_26, __pyx_bstride_1_field, __pyx_t_27, __pyx_bstride_2_field) += ((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_mass.buf, __pyx_t_24, __pyx_bstride_0_mass)) * __pyx_v_dx2) * __pyx_v_dy2) * __pyx_v_dz);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":77
 *         field[i1-1,j1  ,k1-1] += mass[n] * dx  * dy2 * dz
 *         field[i1  ,j1  ,k1-1] += mass[n] * dx2 * dy2 * dz
 *         field[i1-1,j1-1,k1  ] += mass[n] * dx  * dy  * dz2             # <<<<<<<<<<<<<<
 *         field[i1  ,j1-1,k1  ] += mass[n] * dx2 * dy  * dz2
 *         field[i1-1,j1  ,k1  ] += mass[n] * dx  * dy2 * dz2
 */
    __pyx_t_28 = __pyx_v_n;
    __pyx_t_29 = (__pyx_v_i1 - 1);
    __pyx_t_30 = (__pyx_v_j1 - 1);
    __pyx_t_31 = __pyx_v_k1;
    *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_field.buf, __pyx_t_29, __pyx_bstride_0_field, __pyx_t_30, __pyx_bstride_1_field, __pyx_t_31, __pyx_bstride_2_field) += ((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_mass.buf, __pyx_t_28, __pyx_bstride_0_mass)) * __pyx_v_dx) * __pyx_v_dy) * __pyx_v_dz2);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":78
 *         field[i1  ,j1  ,k1-1] += mass[n] * dx2 * dy2 * dz
 *         field[i1-1,j1-1,k1  ] += mass[n] * dx  * dy  * dz2
 *         field[i1  ,j1-1,k1  ] += mass[n] * dx2 * dy  * dz2             # <<<<<<<<<<<<<<
 *         field[i1-1,j1  ,k1  ] += mass[n] * dx  * dy2 * dz2
 *         field[i1  ,j1  ,k1  ] += mass[n] * dx2 * dy2 * dz2
 */
    __pyx_t_32 = __pyx_v_n;
    __pyx_t_33 = __pyx_v_i1;
    __pyx_t_34 = (__pyx_v_j1 - 1);
    __pyx_t_35 = __pyx_v_k1;
    *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_field.buf, __pyx_t_33, __pyx_bstride_0_field, __pyx_t_34, __pyx_bstride_1_field, __pyx_t_35, __pyx_bstride_2_field) += ((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_mass.buf, __pyx_t_32, __pyx_bstride_0_mass)) * __pyx_v_dx2) * __pyx_v_dy) * __pyx_v_dz2);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":79
 *         field[i1-1,j1-1,k1  ] += mass[n] * dx  * dy  * dz2
 *         field[i1  ,j1-1,k1  ] += mass[n] * dx2 * dy  * dz2
 *         field[i1-1,j1  ,k1  ] += mass[n] * dx  * dy2 * dz2             # <<<<<<<<<<<<<<
 *         field[i1  ,j1  ,k1  ] += mass[n] * dx2 * dy2 * dz2
 */
    __pyx_t_36 = __pyx_v_n;
    __pyx_t_37 = (__pyx_v_i1 - 1);
    __pyx_t_38 = __pyx_v_j1;
    __pyx_t_39 = __pyx_v_k1;
    *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_field.buf, __pyx_t_37, __pyx_bstride_0_field, __pyx_t_38, __pyx_bstride_1_field, __pyx_t_39, __pyx_bstride_2_field) += ((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_mass.buf, __pyx_t_36, __pyx_bstride_0_mass)) * __pyx_v_dx) * __pyx_v_dy2) * __pyx_v_dz2);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/CICDeposit.pyx":80
 *         field[i1  ,j1-1,k1  ] += mass[n] * dx2 * dy  * dz2
 *         field[i1-1,j1  ,k1  ] += mass[n] * dx  * dy2 * dz2
 *         field[i1  ,j1  ,k1  ] += mass[n] * dx2 * dy2 * dz2             # <<<<<<<<<<<<<<
 */
    __pyx_t_40 = __pyx_v_n;
    __pyx_t_41 = __pyx_v_i1;
    __pyx_t_42 = __pyx_v_j1;
    __pyx_t_43 = __pyx_v_k1;
    *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_field.buf, __pyx_t_41, __pyx_bstride_0_field, __pyx_t_42, __pyx_bstride_1_field, __pyx_t_43, __pyx_bstride_2_field) += ((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float32_t *, __pyx_bstruct_mass.buf, __pyx_t_40, __pyx_bstride_0_mass)) * __pyx_v_dx2) * __pyx_v_dy2) * __pyx_v_dz2);
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_field);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_leftEdge);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_posz);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_posx);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_posy);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_gridDimension);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_mass);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.CICDeposit_3");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_field);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_leftEdge);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_posz);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_posx);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_posy);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_gridDimension);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_mass);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_posx);
  __Pyx_DECREF((PyObject *)__pyx_v_posy);
  __Pyx_DECREF((PyObject *)__pyx_v_posz);
  __Pyx_DECREF((PyObject *)__pyx_v_mass);
  __Pyx_DECREF((PyObject *)__pyx_v_field);
  __Pyx_DECREF((PyObject *)__pyx_v_leftEdge);
  __Pyx_DECREF((PyObject *)__pyx_v_gridDimension);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":33
 *     double fabs(double x)
 * 
 * cdef inline np.int64_t i64max(np.int64_t i0, np.int64_t i1):             # <<<<<<<<<<<<<<
 *     if i0 > i1: return i0
 *     return i1
 */

static CYTHON_INLINE __pyx_t_5numpy_int64_t __pyx_f_2yt_9amr_utils_i64max(__pyx_t_5numpy_int64_t __pyx_v_i0, __pyx_t_5numpy_int64_t __pyx_v_i1) {
  __pyx_t_5numpy_int64_t __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("i64max");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":34
 * 
 * cdef inline np.int64_t i64max(np.int64_t i0, np.int64_t i1):
 *     if i0 > i1: return i0             # <<<<<<<<<<<<<<
 *     return i1
 * 
 */
  __pyx_t_1 = (__pyx_v_i0 > __pyx_v_i1);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_i0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":35
 * cdef inline np.int64_t i64max(np.int64_t i0, np.int64_t i1):
 *     if i0 > i1: return i0
 *     return i1             # <<<<<<<<<<<<<<
 * 
 * cdef inline np.int64_t i64min(np.int64_t i0, np.int64_t i1):
 */
  __pyx_r = __pyx_v_i1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":37
 *     return i1
 * 
 * cdef inline np.int64_t i64min(np.int64_t i0, np.int64_t i1):             # <<<<<<<<<<<<<<
 *     if i0 < i1: return i0
 *     return i1
 */

static CYTHON_INLINE __pyx_t_5numpy_int64_t __pyx_f_2yt_9amr_utils_i64min(__pyx_t_5numpy_int64_t __pyx_v_i0, __pyx_t_5numpy_int64_t __pyx_v_i1) {
  __pyx_t_5numpy_int64_t __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("i64min");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":38
 * 
 * cdef inline np.int64_t i64min(np.int64_t i0, np.int64_t i1):
 *     if i0 < i1: return i0             # <<<<<<<<<<<<<<
 *     return i1
 * 
 */
  __pyx_t_1 = (__pyx_v_i0 < __pyx_v_i1);
  if (__pyx_t_1) {
    __pyx_r = __pyx_v_i0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":39
 * cdef inline np.int64_t i64min(np.int64_t i0, np.int64_t i1):
 *     if i0 < i1: return i0
 *     return i1             # <<<<<<<<<<<<<<
 * 
 * @cython.boundscheck(False)
 */
  __pyx_r = __pyx_v_i1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":42
 * 
 * @cython.boundscheck(False)
 * def construct_boundary_relationships(             # <<<<<<<<<<<<<<
 *         np.ndarray[dtype=np.int64_t, ndim=3] contour_ids):
 *     # We only look at the boundary and one cell in
 */

static PyObject *__pyx_pf_2yt_9amr_utils_construct_boundary_relationships(PyObject *__pyx_self, PyObject *__pyx_v_contour_ids); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_construct_boundary_relationships(PyObject *__pyx_self, PyObject *__pyx_v_contour_ids) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_nx;
  int __pyx_v_ny;
  int __pyx_v_nz;
  int __pyx_v_offset_i;
  int __pyx_v_offset_j;
  int __pyx_v_oi;
  int __pyx_v_oj;
  __pyx_t_5numpy_int64_t __pyx_v_c1;
  __pyx_t_5numpy_int64_t __pyx_v_c2;
  PyObject *__pyx_v_tree;
  Py_buffer __pyx_bstruct_contour_ids;
  Py_ssize_t __pyx_bstride_0_contour_ids = 0;
  Py_ssize_t __pyx_bstride_1_contour_ids = 0;
  Py_ssize_t __pyx_bstride_2_contour_ids = 0;
  Py_ssize_t __pyx_bshape_0_contour_ids = 0;
  Py_ssize_t __pyx_bshape_1_contour_ids = 0;
  Py_ssize_t __pyx_bshape_2_contour_ids = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  long __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  long __pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  long __pyx_t_19;
  int __pyx_t_20;
  int __pyx_t_21;
  long __pyx_t_22;
  int __pyx_t_23;
  int __pyx_t_24;
  int __pyx_t_25;
  long __pyx_t_26;
  int __pyx_t_27;
  int __pyx_t_28;
  long __pyx_t_29;
  int __pyx_t_30;
  int __pyx_t_31;
  long __pyx_t_32;
  int __pyx_t_33;
  int __pyx_t_34;
  long __pyx_t_35;
  int __pyx_t_36;
  int __pyx_t_37;
  int __pyx_t_38;
  long __pyx_t_39;
  int __pyx_t_40;
  int __pyx_t_41;
  long __pyx_t_42;
  int __pyx_t_43;
  int __pyx_t_44;
  long __pyx_t_45;
  int __pyx_t_46;
  int __pyx_t_47;
  long __pyx_t_48;
  __Pyx_RefNannySetupContext("construct_boundary_relationships");
  __pyx_self = __pyx_self;
  __Pyx_INCREF((PyObject *)__pyx_v_contour_ids);
  __pyx_v_tree = Py_None; __Pyx_INCREF(Py_None);
  __pyx_bstruct_contour_ids.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_contour_ids), __pyx_ptype_5numpy_ndarray, 1, "contour_ids", 0))) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_contour_ids, (PyObject*)__pyx_v_contour_ids, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_contour_ids = __pyx_bstruct_contour_ids.strides[0]; __pyx_bstride_1_contour_ids = __pyx_bstruct_contour_ids.strides[1]; __pyx_bstride_2_contour_ids = __pyx_bstruct_contour_ids.strides[2];
  __pyx_bshape_0_contour_ids = __pyx_bstruct_contour_ids.shape[0]; __pyx_bshape_1_contour_ids = __pyx_bstruct_contour_ids.shape[1]; __pyx_bshape_2_contour_ids = __pyx_bstruct_contour_ids.shape[2];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":47
 *     cdef int i, j, nx, ny, nz, offset_i, offset_j, oi, oj
 *     cdef np.int64_t c1, c2
 *     tree = []             # <<<<<<<<<<<<<<
 *     nx = contour_ids.shape[0]
 *     ny = contour_ids.shape[1]
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(__pyx_v_tree);
  __pyx_v_tree = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":48
 *     cdef np.int64_t c1, c2
 *     tree = []
 *     nx = contour_ids.shape[0]             # <<<<<<<<<<<<<<
 *     ny = contour_ids.shape[1]
 *     nz = contour_ids.shape[2]
 */
  __pyx_v_nx = (((PyArrayObject *)__pyx_v_contour_ids)->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":49
 *     tree = []
 *     nx = contour_ids.shape[0]
 *     ny = contour_ids.shape[1]             # <<<<<<<<<<<<<<
 *     nz = contour_ids.shape[2]
 *     # First x-pass
 */
  __pyx_v_ny = (((PyArrayObject *)__pyx_v_contour_ids)->dimensions[1]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":50
 *     nx = contour_ids.shape[0]
 *     ny = contour_ids.shape[1]
 *     nz = contour_ids.shape[2]             # <<<<<<<<<<<<<<
 *     # First x-pass
 *     for i in range(ny):
 */
  __pyx_v_nz = (((PyArrayObject *)__pyx_v_contour_ids)->dimensions[2]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":52
 *     nz = contour_ids.shape[2]
 *     # First x-pass
 *     for i in range(ny):             # <<<<<<<<<<<<<<
 *         for j in range(nz):
 *             for offset_i in range(3):
 */
  __pyx_t_2 = __pyx_v_ny;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":53
 *     # First x-pass
 *     for i in range(ny):
 *         for j in range(nz):             # <<<<<<<<<<<<<<
 *             for offset_i in range(3):
 *                 oi = offset_i - 1
 */
    __pyx_t_4 = __pyx_v_nz;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_j = __pyx_t_5;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":54
 *     for i in range(ny):
 *         for j in range(nz):
 *             for offset_i in range(3):             # <<<<<<<<<<<<<<
 *                 oi = offset_i - 1
 *                 if i == 0 and oi == -1: continue
 */
      for (__pyx_t_6 = 0; __pyx_t_6 < 3; __pyx_t_6+=1) {
        __pyx_v_offset_i = __pyx_t_6;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":55
 *         for j in range(nz):
 *             for offset_i in range(3):
 *                 oi = offset_i - 1             # <<<<<<<<<<<<<<
 *                 if i == 0 and oi == -1: continue
 *                 if i == ny - 1 and oj == 1: continue
 */
        __pyx_v_oi = (__pyx_v_offset_i - 1);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":56
 *             for offset_i in range(3):
 *                 oi = offset_i - 1
 *                 if i == 0 and oi == -1: continue             # <<<<<<<<<<<<<<
 *                 if i == ny - 1 and oj == 1: continue
 *                 for offset_j in range(3):
 */
        __pyx_t_7 = (__pyx_v_i == 0);
        if (__pyx_t_7) {
          __pyx_t_8 = (__pyx_v_oi == -1);
          __pyx_t_9 = __pyx_t_8;
        } else {
          __pyx_t_9 = __pyx_t_7;
        }
        if (__pyx_t_9) {
          goto __pyx_L9_continue;
          goto __pyx_L11;
        }
        __pyx_L11:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":57
 *                 oi = offset_i - 1
 *                 if i == 0 and oi == -1: continue
 *                 if i == ny - 1 and oj == 1: continue             # <<<<<<<<<<<<<<
 *                 for offset_j in range(3):
 *                     oj = offset_j - 1
 */
        __pyx_t_9 = (__pyx_v_i == (__pyx_v_ny - 1));
        if (__pyx_t_9) {
          __pyx_t_7 = (__pyx_v_oj == 1);
          __pyx_t_8 = __pyx_t_7;
        } else {
          __pyx_t_8 = __pyx_t_9;
        }
        if (__pyx_t_8) {
          goto __pyx_L9_continue;
          goto __pyx_L12;
        }
        __pyx_L12:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":58
 *                 if i == 0 and oi == -1: continue
 *                 if i == ny - 1 and oj == 1: continue
 *                 for offset_j in range(3):             # <<<<<<<<<<<<<<
 *                     oj = offset_j - 1
 *                     if j == 0 and oj == -1: continue
 */
        for (__pyx_t_10 = 0; __pyx_t_10 < 3; __pyx_t_10+=1) {
          __pyx_v_offset_j = __pyx_t_10;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":59
 *                 if i == ny - 1 and oj == 1: continue
 *                 for offset_j in range(3):
 *                     oj = offset_j - 1             # <<<<<<<<<<<<<<
 *                     if j == 0 and oj == -1: continue
 *                     if j == nz - 1 and oj == 1: continue
 */
          __pyx_v_oj = (__pyx_v_offset_j - 1);

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":60
 *                 for offset_j in range(3):
 *                     oj = offset_j - 1
 *                     if j == 0 and oj == -1: continue             # <<<<<<<<<<<<<<
 *                     if j == nz - 1 and oj == 1: continue
 *                     c1 = contour_ids[0, i, j]
 */
          __pyx_t_8 = (__pyx_v_j == 0);
          if (__pyx_t_8) {
            __pyx_t_9 = (__pyx_v_oj == -1);
            __pyx_t_7 = __pyx_t_9;
          } else {
            __pyx_t_7 = __pyx_t_8;
          }
          if (__pyx_t_7) {
            goto __pyx_L13_continue;
            goto __pyx_L15;
          }
          __pyx_L15:;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":61
 *                     oj = offset_j - 1
 *                     if j == 0 and oj == -1: continue
 *                     if j == nz - 1 and oj == 1: continue             # <<<<<<<<<<<<<<
 *                     c1 = contour_ids[0, i, j]
 *                     c2 = contour_ids[1, i + oi, j + oj]
 */
          __pyx_t_7 = (__pyx_v_j == (__pyx_v_nz - 1));
          if (__pyx_t_7) {
            __pyx_t_8 = (__pyx_v_oj == 1);
            __pyx_t_9 = __pyx_t_8;
          } else {
            __pyx_t_9 = __pyx_t_7;
          }
          if (__pyx_t_9) {
            goto __pyx_L13_continue;
            goto __pyx_L16;
          }
          __pyx_L16:;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":62
 *                     if j == 0 and oj == -1: continue
 *                     if j == nz - 1 and oj == 1: continue
 *                     c1 = contour_ids[0, i, j]             # <<<<<<<<<<<<<<
 *                     c2 = contour_ids[1, i + oi, j + oj]
 *                     if c1 > -1 and c2 > -1:
 */
          __pyx_t_11 = 0;
          __pyx_t_12 = __pyx_v_i;
          __pyx_t_13 = __pyx_v_j;
          if (__pyx_t_11 < 0) __pyx_t_11 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_12 < 0) __pyx_t_12 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_13 < 0) __pyx_t_13 += __pyx_bshape_2_contour_ids;
          __pyx_v_c1 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_11, __pyx_bstride_0_contour_ids, __pyx_t_12, __pyx_bstride_1_contour_ids, __pyx_t_13, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":63
 *                     if j == nz - 1 and oj == 1: continue
 *                     c1 = contour_ids[0, i, j]
 *                     c2 = contour_ids[1, i + oi, j + oj]             # <<<<<<<<<<<<<<
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 */
          __pyx_t_14 = 1;
          __pyx_t_15 = (__pyx_v_i + __pyx_v_oi);
          __pyx_t_16 = (__pyx_v_j + __pyx_v_oj);
          if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_bshape_2_contour_ids;
          __pyx_v_c2 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_14, __pyx_bstride_0_contour_ids, __pyx_t_15, __pyx_bstride_1_contour_ids, __pyx_t_16, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":64
 *                     c1 = contour_ids[0, i, j]
 *                     c2 = contour_ids[1, i + oi, j + oj]
 *                     if c1 > -1 and c2 > -1:             # <<<<<<<<<<<<<<
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *                     c1 = contour_ids[nx-1, i, j]
 */
          __pyx_t_9 = (__pyx_v_c1 > -1);
          if (__pyx_t_9) {
            __pyx_t_7 = (__pyx_v_c2 > -1);
            __pyx_t_8 = __pyx_t_7;
          } else {
            __pyx_t_8 = __pyx_t_9;
          }
          if (__pyx_t_8) {

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":65
 *                     c2 = contour_ids[1, i + oi, j + oj]
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))             # <<<<<<<<<<<<<<
 *                     c1 = contour_ids[nx-1, i, j]
 *                     c2 = contour_ids[nx-2, i + oi, j + oj]
 */
            __pyx_t_1 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64max(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_17 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64min(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_18);
            PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_17);
            __Pyx_GIVEREF(__pyx_t_17);
            __pyx_t_1 = 0;
            __pyx_t_17 = 0;
            __pyx_t_17 = __Pyx_PyObject_Append(__pyx_v_tree, __pyx_t_18); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            goto __pyx_L17;
          }
          __pyx_L17:;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":66
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *                     c1 = contour_ids[nx-1, i, j]             # <<<<<<<<<<<<<<
 *                     c2 = contour_ids[nx-2, i + oi, j + oj]
 *                     if c1 > -1 and c2 > -1:
 */
          __pyx_t_19 = (__pyx_v_nx - 1);
          __pyx_t_20 = __pyx_v_i;
          __pyx_t_21 = __pyx_v_j;
          if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_bshape_2_contour_ids;
          __pyx_v_c1 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_19, __pyx_bstride_0_contour_ids, __pyx_t_20, __pyx_bstride_1_contour_ids, __pyx_t_21, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":67
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *                     c1 = contour_ids[nx-1, i, j]
 *                     c2 = contour_ids[nx-2, i + oi, j + oj]             # <<<<<<<<<<<<<<
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 */
          __pyx_t_22 = (__pyx_v_nx - 2);
          __pyx_t_23 = (__pyx_v_i + __pyx_v_oi);
          __pyx_t_24 = (__pyx_v_j + __pyx_v_oj);
          if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_bshape_2_contour_ids;
          __pyx_v_c2 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_22, __pyx_bstride_0_contour_ids, __pyx_t_23, __pyx_bstride_1_contour_ids, __pyx_t_24, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":68
 *                     c1 = contour_ids[nx-1, i, j]
 *                     c2 = contour_ids[nx-2, i + oi, j + oj]
 *                     if c1 > -1 and c2 > -1:             # <<<<<<<<<<<<<<
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *     # Now y-pass
 */
          __pyx_t_8 = (__pyx_v_c1 > -1);
          if (__pyx_t_8) {
            __pyx_t_9 = (__pyx_v_c2 > -1);
            __pyx_t_7 = __pyx_t_9;
          } else {
            __pyx_t_7 = __pyx_t_8;
          }
          if (__pyx_t_7) {

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":69
 *                     c2 = contour_ids[nx-2, i + oi, j + oj]
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))             # <<<<<<<<<<<<<<
 *     # Now y-pass
 *     for i in range(nx):
 */
            __pyx_t_17 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64max(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_18 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64min(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_17);
            __Pyx_GIVEREF(__pyx_t_17);
            PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_18);
            __Pyx_GIVEREF(__pyx_t_18);
            __pyx_t_17 = 0;
            __pyx_t_18 = 0;
            __pyx_t_18 = __Pyx_PyObject_Append(__pyx_v_tree, __pyx_t_1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_18);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            goto __pyx_L18;
          }
          __pyx_L18:;
          __pyx_L13_continue:;
        }
        __pyx_L9_continue:;
      }
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":71
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *     # Now y-pass
 *     for i in range(nx):             # <<<<<<<<<<<<<<
 *         for j in range(nz):
 *             for offset_i in range(3):
 */
  __pyx_t_2 = __pyx_v_nx;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":72
 *     # Now y-pass
 *     for i in range(nx):
 *         for j in range(nz):             # <<<<<<<<<<<<<<
 *             for offset_i in range(3):
 *                 oi = offset_i - 1
 */
    __pyx_t_4 = __pyx_v_nz;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_j = __pyx_t_5;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":73
 *     for i in range(nx):
 *         for j in range(nz):
 *             for offset_i in range(3):             # <<<<<<<<<<<<<<
 *                 oi = offset_i - 1
 *                 if i == 0 and oi == -1: continue
 */
      for (__pyx_t_6 = 0; __pyx_t_6 < 3; __pyx_t_6+=1) {
        __pyx_v_offset_i = __pyx_t_6;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":74
 *         for j in range(nz):
 *             for offset_i in range(3):
 *                 oi = offset_i - 1             # <<<<<<<<<<<<<<
 *                 if i == 0 and oi == -1: continue
 *                 if i == nx - 1 and oj == 1: continue
 */
        __pyx_v_oi = (__pyx_v_offset_i - 1);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":75
 *             for offset_i in range(3):
 *                 oi = offset_i - 1
 *                 if i == 0 and oi == -1: continue             # <<<<<<<<<<<<<<
 *                 if i == nx - 1 and oj == 1: continue
 *                 for offset_j in range(3):
 */
        __pyx_t_7 = (__pyx_v_i == 0);
        if (__pyx_t_7) {
          __pyx_t_8 = (__pyx_v_oi == -1);
          __pyx_t_9 = __pyx_t_8;
        } else {
          __pyx_t_9 = __pyx_t_7;
        }
        if (__pyx_t_9) {
          goto __pyx_L23_continue;
          goto __pyx_L25;
        }
        __pyx_L25:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":76
 *                 oi = offset_i - 1
 *                 if i == 0 and oi == -1: continue
 *                 if i == nx - 1 and oj == 1: continue             # <<<<<<<<<<<<<<
 *                 for offset_j in range(3):
 *                     oj = offset_j - 1
 */
        __pyx_t_9 = (__pyx_v_i == (__pyx_v_nx - 1));
        if (__pyx_t_9) {
          __pyx_t_7 = (__pyx_v_oj == 1);
          __pyx_t_8 = __pyx_t_7;
        } else {
          __pyx_t_8 = __pyx_t_9;
        }
        if (__pyx_t_8) {
          goto __pyx_L23_continue;
          goto __pyx_L26;
        }
        __pyx_L26:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":77
 *                 if i == 0 and oi == -1: continue
 *                 if i == nx - 1 and oj == 1: continue
 *                 for offset_j in range(3):             # <<<<<<<<<<<<<<
 *                     oj = offset_j - 1
 *                     if j == 0 and oj == -1: continue
 */
        for (__pyx_t_10 = 0; __pyx_t_10 < 3; __pyx_t_10+=1) {
          __pyx_v_offset_j = __pyx_t_10;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":78
 *                 if i == nx - 1 and oj == 1: continue
 *                 for offset_j in range(3):
 *                     oj = offset_j - 1             # <<<<<<<<<<<<<<
 *                     if j == 0 and oj == -1: continue
 *                     if j == nz - 1 and oj == 1: continue
 */
          __pyx_v_oj = (__pyx_v_offset_j - 1);

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":79
 *                 for offset_j in range(3):
 *                     oj = offset_j - 1
 *                     if j == 0 and oj == -1: continue             # <<<<<<<<<<<<<<
 *                     if j == nz - 1 and oj == 1: continue
 *                     c1 = contour_ids[i, 0, j]
 */
          __pyx_t_8 = (__pyx_v_j == 0);
          if (__pyx_t_8) {
            __pyx_t_9 = (__pyx_v_oj == -1);
            __pyx_t_7 = __pyx_t_9;
          } else {
            __pyx_t_7 = __pyx_t_8;
          }
          if (__pyx_t_7) {
            goto __pyx_L27_continue;
            goto __pyx_L29;
          }
          __pyx_L29:;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":80
 *                     oj = offset_j - 1
 *                     if j == 0 and oj == -1: continue
 *                     if j == nz - 1 and oj == 1: continue             # <<<<<<<<<<<<<<
 *                     c1 = contour_ids[i, 0, j]
 *                     c2 = contour_ids[i + oi, 1, j + oj]
 */
          __pyx_t_7 = (__pyx_v_j == (__pyx_v_nz - 1));
          if (__pyx_t_7) {
            __pyx_t_8 = (__pyx_v_oj == 1);
            __pyx_t_9 = __pyx_t_8;
          } else {
            __pyx_t_9 = __pyx_t_7;
          }
          if (__pyx_t_9) {
            goto __pyx_L27_continue;
            goto __pyx_L30;
          }
          __pyx_L30:;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":81
 *                     if j == 0 and oj == -1: continue
 *                     if j == nz - 1 and oj == 1: continue
 *                     c1 = contour_ids[i, 0, j]             # <<<<<<<<<<<<<<
 *                     c2 = contour_ids[i + oi, 1, j + oj]
 *                     if c1 > -1 and c2 > -1:
 */
          __pyx_t_25 = __pyx_v_i;
          __pyx_t_26 = 0;
          __pyx_t_27 = __pyx_v_j;
          if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_27 < 0) __pyx_t_27 += __pyx_bshape_2_contour_ids;
          __pyx_v_c1 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_25, __pyx_bstride_0_contour_ids, __pyx_t_26, __pyx_bstride_1_contour_ids, __pyx_t_27, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":82
 *                     if j == nz - 1 and oj == 1: continue
 *                     c1 = contour_ids[i, 0, j]
 *                     c2 = contour_ids[i + oi, 1, j + oj]             # <<<<<<<<<<<<<<
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 */
          __pyx_t_28 = (__pyx_v_i + __pyx_v_oi);
          __pyx_t_29 = 1;
          __pyx_t_30 = (__pyx_v_j + __pyx_v_oj);
          if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_29 < 0) __pyx_t_29 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_30 < 0) __pyx_t_30 += __pyx_bshape_2_contour_ids;
          __pyx_v_c2 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_28, __pyx_bstride_0_contour_ids, __pyx_t_29, __pyx_bstride_1_contour_ids, __pyx_t_30, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":83
 *                     c1 = contour_ids[i, 0, j]
 *                     c2 = contour_ids[i + oi, 1, j + oj]
 *                     if c1 > -1 and c2 > -1:             # <<<<<<<<<<<<<<
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *                     c1 = contour_ids[i, ny-1, j]
 */
          __pyx_t_9 = (__pyx_v_c1 > -1);
          if (__pyx_t_9) {
            __pyx_t_7 = (__pyx_v_c2 > -1);
            __pyx_t_8 = __pyx_t_7;
          } else {
            __pyx_t_8 = __pyx_t_9;
          }
          if (__pyx_t_8) {

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":84
 *                     c2 = contour_ids[i + oi, 1, j + oj]
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))             # <<<<<<<<<<<<<<
 *                     c1 = contour_ids[i, ny-1, j]
 *                     c2 = contour_ids[i + oi, ny-2, j + oj]
 */
            __pyx_t_18 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64max(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_1 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64min(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_17);
            PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_18);
            __Pyx_GIVEREF(__pyx_t_18);
            PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            __pyx_t_18 = 0;
            __pyx_t_1 = 0;
            __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_tree, __pyx_t_17); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L31;
          }
          __pyx_L31:;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":85
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *                     c1 = contour_ids[i, ny-1, j]             # <<<<<<<<<<<<<<
 *                     c2 = contour_ids[i + oi, ny-2, j + oj]
 *                     if c1 > -1 and c2 > -1:
 */
          __pyx_t_31 = __pyx_v_i;
          __pyx_t_32 = (__pyx_v_ny - 1);
          __pyx_t_33 = __pyx_v_j;
          if (__pyx_t_31 < 0) __pyx_t_31 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_32 < 0) __pyx_t_32 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_33 < 0) __pyx_t_33 += __pyx_bshape_2_contour_ids;
          __pyx_v_c1 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_31, __pyx_bstride_0_contour_ids, __pyx_t_32, __pyx_bstride_1_contour_ids, __pyx_t_33, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":86
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *                     c1 = contour_ids[i, ny-1, j]
 *                     c2 = contour_ids[i + oi, ny-2, j + oj]             # <<<<<<<<<<<<<<
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 */
          __pyx_t_34 = (__pyx_v_i + __pyx_v_oi);
          __pyx_t_35 = (__pyx_v_ny - 2);
          __pyx_t_36 = (__pyx_v_j + __pyx_v_oj);
          if (__pyx_t_34 < 0) __pyx_t_34 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_35 < 0) __pyx_t_35 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_36 < 0) __pyx_t_36 += __pyx_bshape_2_contour_ids;
          __pyx_v_c2 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_34, __pyx_bstride_0_contour_ids, __pyx_t_35, __pyx_bstride_1_contour_ids, __pyx_t_36, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":87
 *                     c1 = contour_ids[i, ny-1, j]
 *                     c2 = contour_ids[i + oi, ny-2, j + oj]
 *                     if c1 > -1 and c2 > -1:             # <<<<<<<<<<<<<<
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *     for i in range(nx):
 */
          __pyx_t_8 = (__pyx_v_c1 > -1);
          if (__pyx_t_8) {
            __pyx_t_9 = (__pyx_v_c2 > -1);
            __pyx_t_7 = __pyx_t_9;
          } else {
            __pyx_t_7 = __pyx_t_8;
          }
          if (__pyx_t_7) {

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":88
 *                     c2 = contour_ids[i + oi, ny-2, j + oj]
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))             # <<<<<<<<<<<<<<
 *     for i in range(nx):
 *         for j in range(ny):
 */
            __pyx_t_1 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64max(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_17 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64min(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_18 = PyTuple_New(2); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_18);
            PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_t_17);
            __Pyx_GIVEREF(__pyx_t_17);
            __pyx_t_1 = 0;
            __pyx_t_17 = 0;
            __pyx_t_17 = __Pyx_PyObject_Append(__pyx_v_tree, __pyx_t_18); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            goto __pyx_L32;
          }
          __pyx_L32:;
          __pyx_L27_continue:;
        }
        __pyx_L23_continue:;
      }
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":89
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *     for i in range(nx):             # <<<<<<<<<<<<<<
 *         for j in range(ny):
 *             for offset_i in range(3):
 */
  __pyx_t_2 = __pyx_v_nx;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":90
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *     for i in range(nx):
 *         for j in range(ny):             # <<<<<<<<<<<<<<
 *             for offset_i in range(3):
 *                 oi = offset_i - 1
 */
    __pyx_t_4 = __pyx_v_ny;
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_j = __pyx_t_5;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":91
 *     for i in range(nx):
 *         for j in range(ny):
 *             for offset_i in range(3):             # <<<<<<<<<<<<<<
 *                 oi = offset_i - 1
 *                 if i == 0 and oi == -1: continue
 */
      for (__pyx_t_6 = 0; __pyx_t_6 < 3; __pyx_t_6+=1) {
        __pyx_v_offset_i = __pyx_t_6;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":92
 *         for j in range(ny):
 *             for offset_i in range(3):
 *                 oi = offset_i - 1             # <<<<<<<<<<<<<<
 *                 if i == 0 and oi == -1: continue
 *                 if i == nx - 1 and oj == 1: continue
 */
        __pyx_v_oi = (__pyx_v_offset_i - 1);

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":93
 *             for offset_i in range(3):
 *                 oi = offset_i - 1
 *                 if i == 0 and oi == -1: continue             # <<<<<<<<<<<<<<
 *                 if i == nx - 1 and oj == 1: continue
 *                 for offset_j in range(3):
 */
        __pyx_t_7 = (__pyx_v_i == 0);
        if (__pyx_t_7) {
          __pyx_t_8 = (__pyx_v_oi == -1);
          __pyx_t_9 = __pyx_t_8;
        } else {
          __pyx_t_9 = __pyx_t_7;
        }
        if (__pyx_t_9) {
          goto __pyx_L37_continue;
          goto __pyx_L39;
        }
        __pyx_L39:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":94
 *                 oi = offset_i - 1
 *                 if i == 0 and oi == -1: continue
 *                 if i == nx - 1 and oj == 1: continue             # <<<<<<<<<<<<<<
 *                 for offset_j in range(3):
 *                     oj = offset_j - 1
 */
        __pyx_t_9 = (__pyx_v_i == (__pyx_v_nx - 1));
        if (__pyx_t_9) {
          __pyx_t_7 = (__pyx_v_oj == 1);
          __pyx_t_8 = __pyx_t_7;
        } else {
          __pyx_t_8 = __pyx_t_9;
        }
        if (__pyx_t_8) {
          goto __pyx_L37_continue;
          goto __pyx_L40;
        }
        __pyx_L40:;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":95
 *                 if i == 0 and oi == -1: continue
 *                 if i == nx - 1 and oj == 1: continue
 *                 for offset_j in range(3):             # <<<<<<<<<<<<<<
 *                     oj = offset_j - 1
 *                     if j == 0 and oj == -1: continue
 */
        for (__pyx_t_10 = 0; __pyx_t_10 < 3; __pyx_t_10+=1) {
          __pyx_v_offset_j = __pyx_t_10;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":96
 *                 if i == nx - 1 and oj == 1: continue
 *                 for offset_j in range(3):
 *                     oj = offset_j - 1             # <<<<<<<<<<<<<<
 *                     if j == 0 and oj == -1: continue
 *                     if j == ny - 1 and oj == 1: continue
 */
          __pyx_v_oj = (__pyx_v_offset_j - 1);

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":97
 *                 for offset_j in range(3):
 *                     oj = offset_j - 1
 *                     if j == 0 and oj == -1: continue             # <<<<<<<<<<<<<<
 *                     if j == ny - 1 and oj == 1: continue
 *                     c1 = contour_ids[i, j, 0]
 */
          __pyx_t_8 = (__pyx_v_j == 0);
          if (__pyx_t_8) {
            __pyx_t_9 = (__pyx_v_oj == -1);
            __pyx_t_7 = __pyx_t_9;
          } else {
            __pyx_t_7 = __pyx_t_8;
          }
          if (__pyx_t_7) {
            goto __pyx_L41_continue;
            goto __pyx_L43;
          }
          __pyx_L43:;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":98
 *                     oj = offset_j - 1
 *                     if j == 0 and oj == -1: continue
 *                     if j == ny - 1 and oj == 1: continue             # <<<<<<<<<<<<<<
 *                     c1 = contour_ids[i, j, 0]
 *                     c2 = contour_ids[i + oi, j + oj, 1]
 */
          __pyx_t_7 = (__pyx_v_j == (__pyx_v_ny - 1));
          if (__pyx_t_7) {
            __pyx_t_8 = (__pyx_v_oj == 1);
            __pyx_t_9 = __pyx_t_8;
          } else {
            __pyx_t_9 = __pyx_t_7;
          }
          if (__pyx_t_9) {
            goto __pyx_L41_continue;
            goto __pyx_L44;
          }
          __pyx_L44:;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":99
 *                     if j == 0 and oj == -1: continue
 *                     if j == ny - 1 and oj == 1: continue
 *                     c1 = contour_ids[i, j, 0]             # <<<<<<<<<<<<<<
 *                     c2 = contour_ids[i + oi, j + oj, 1]
 *                     if c1 > -1 and c2 > -1:
 */
          __pyx_t_37 = __pyx_v_i;
          __pyx_t_38 = __pyx_v_j;
          __pyx_t_39 = 0;
          if (__pyx_t_37 < 0) __pyx_t_37 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_38 < 0) __pyx_t_38 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_39 < 0) __pyx_t_39 += __pyx_bshape_2_contour_ids;
          __pyx_v_c1 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_37, __pyx_bstride_0_contour_ids, __pyx_t_38, __pyx_bstride_1_contour_ids, __pyx_t_39, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":100
 *                     if j == ny - 1 and oj == 1: continue
 *                     c1 = contour_ids[i, j, 0]
 *                     c2 = contour_ids[i + oi, j + oj, 1]             # <<<<<<<<<<<<<<
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 */
          __pyx_t_40 = (__pyx_v_i + __pyx_v_oi);
          __pyx_t_41 = (__pyx_v_j + __pyx_v_oj);
          __pyx_t_42 = 1;
          if (__pyx_t_40 < 0) __pyx_t_40 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_41 < 0) __pyx_t_41 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_42 < 0) __pyx_t_42 += __pyx_bshape_2_contour_ids;
          __pyx_v_c2 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_40, __pyx_bstride_0_contour_ids, __pyx_t_41, __pyx_bstride_1_contour_ids, __pyx_t_42, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":101
 *                     c1 = contour_ids[i, j, 0]
 *                     c2 = contour_ids[i + oi, j + oj, 1]
 *                     if c1 > -1 and c2 > -1:             # <<<<<<<<<<<<<<
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *                     c1 = contour_ids[i, j, nz-1]
 */
          __pyx_t_9 = (__pyx_v_c1 > -1);
          if (__pyx_t_9) {
            __pyx_t_7 = (__pyx_v_c2 > -1);
            __pyx_t_8 = __pyx_t_7;
          } else {
            __pyx_t_8 = __pyx_t_9;
          }
          if (__pyx_t_8) {

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":102
 *                     c2 = contour_ids[i + oi, j + oj, 1]
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))             # <<<<<<<<<<<<<<
 *                     c1 = contour_ids[i, j, nz-1]
 *                     c2 = contour_ids[i + oi, j + oj, nz-2]
 */
            __pyx_t_17 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64max(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_18 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64min(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_17);
            __Pyx_GIVEREF(__pyx_t_17);
            PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_18);
            __Pyx_GIVEREF(__pyx_t_18);
            __pyx_t_17 = 0;
            __pyx_t_18 = 0;
            __pyx_t_18 = __Pyx_PyObject_Append(__pyx_v_tree, __pyx_t_1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_18);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            goto __pyx_L45;
          }
          __pyx_L45:;

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":103
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *                     c1 = contour_ids[i, j, nz-1]             # <<<<<<<<<<<<<<
 *                     c2 = contour_ids[i + oi, j + oj, nz-2]
 *                     if c1 > -1 and c2 > -1:
 */
          __pyx_t_43 = __pyx_v_i;
          __pyx_t_44 = __pyx_v_j;
          __pyx_t_45 = (__pyx_v_nz - 1);
          if (__pyx_t_43 < 0) __pyx_t_43 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_44 < 0) __pyx_t_44 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_45 < 0) __pyx_t_45 += __pyx_bshape_2_contour_ids;
          __pyx_v_c1 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_43, __pyx_bstride_0_contour_ids, __pyx_t_44, __pyx_bstride_1_contour_ids, __pyx_t_45, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":104
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *                     c1 = contour_ids[i, j, nz-1]
 *                     c2 = contour_ids[i + oi, j + oj, nz-2]             # <<<<<<<<<<<<<<
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 */
          __pyx_t_46 = (__pyx_v_i + __pyx_v_oi);
          __pyx_t_47 = (__pyx_v_j + __pyx_v_oj);
          __pyx_t_48 = (__pyx_v_nz - 2);
          if (__pyx_t_46 < 0) __pyx_t_46 += __pyx_bshape_0_contour_ids;
          if (__pyx_t_47 < 0) __pyx_t_47 += __pyx_bshape_1_contour_ids;
          if (__pyx_t_48 < 0) __pyx_t_48 += __pyx_bshape_2_contour_ids;
          __pyx_v_c2 = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_contour_ids.buf, __pyx_t_46, __pyx_bstride_0_contour_ids, __pyx_t_47, __pyx_bstride_1_contour_ids, __pyx_t_48, __pyx_bstride_2_contour_ids));

          /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":105
 *                     c1 = contour_ids[i, j, nz-1]
 *                     c2 = contour_ids[i + oi, j + oj, nz-2]
 *                     if c1 > -1 and c2 > -1:             # <<<<<<<<<<<<<<
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *     return tree
 */
          __pyx_t_8 = (__pyx_v_c1 > -1);
          if (__pyx_t_8) {
            __pyx_t_9 = (__pyx_v_c2 > -1);
            __pyx_t_7 = __pyx_t_9;
          } else {
            __pyx_t_7 = __pyx_t_8;
          }
          if (__pyx_t_7) {

            /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":106
 *                     c2 = contour_ids[i + oi, j + oj, nz-2]
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))             # <<<<<<<<<<<<<<
 *     return tree
 * 
 */
            __pyx_t_18 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64max(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_1 = __Pyx_PyInt_to_py_npy_int64(__pyx_f_2yt_9amr_utils_i64min(__pyx_v_c1, __pyx_v_c2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_17);
            PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_18);
            __Pyx_GIVEREF(__pyx_t_18);
            PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            __pyx_t_18 = 0;
            __pyx_t_1 = 0;
            __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_tree, __pyx_t_17); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L46;
          }
          __pyx_L46:;
          __pyx_L41_continue:;
        }
        __pyx_L37_continue:;
      }
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":107
 *                     if c1 > -1 and c2 > -1:
 *                         tree.append((i64max(c1,c2), i64min(c1,c2)))
 *     return tree             # <<<<<<<<<<<<<<
 * 
 * cdef inline int are_neighbors(
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_tree);
  __pyx_r = __pyx_v_tree;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_contour_ids);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.construct_boundary_relationships");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_contour_ids);
  __pyx_L2:;
  __Pyx_DECREF(__pyx_v_tree);
  __Pyx_DECREF((PyObject *)__pyx_v_contour_ids);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":109
 *     return tree
 * 
 * cdef inline int are_neighbors(             # <<<<<<<<<<<<<<
 *             np.float64_t x1, np.float64_t y1, np.float64_t z1,
 *             np.float64_t dx1, np.float64_t dy1, np.float64_t dz1,
 */

static CYTHON_INLINE int __pyx_f_2yt_9amr_utils_are_neighbors(__pyx_t_5numpy_float64_t __pyx_v_x1, __pyx_t_5numpy_float64_t __pyx_v_y1, __pyx_t_5numpy_float64_t __pyx_v_z1, __pyx_t_5numpy_float64_t __pyx_v_dx1, __pyx_t_5numpy_float64_t __pyx_v_dy1, __pyx_t_5numpy_float64_t __pyx_v_dz1, __pyx_t_5numpy_float64_t __pyx_v_x2, __pyx_t_5numpy_float64_t __pyx_v_y2, __pyx_t_5numpy_float64_t __pyx_v_z2, __pyx_t_5numpy_float64_t __pyx_v_dx2, __pyx_t_5numpy_float64_t __pyx_v_dy2, __pyx_t_5numpy_float64_t __pyx_v_dz2) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("are_neighbors");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":116
 *         ):
 *     # We assume an epsilon of 1e-15
 *     if fabs(x1-x2) > 0.5*(dx1+dx2): return 0             # <<<<<<<<<<<<<<
 *     if fabs(y1-y2) > 0.5*(dy1+dy2): return 0
 *     if fabs(z1-z2) > 0.5*(dz1+dz2): return 0
 */
  __pyx_t_1 = (fabs((__pyx_v_x1 - __pyx_v_x2)) > (0.5 * (__pyx_v_dx1 + __pyx_v_dx2)));
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":117
 *     # We assume an epsilon of 1e-15
 *     if fabs(x1-x2) > 0.5*(dx1+dx2): return 0
 *     if fabs(y1-y2) > 0.5*(dy1+dy2): return 0             # <<<<<<<<<<<<<<
 *     if fabs(z1-z2) > 0.5*(dz1+dz2): return 0
 *     return 1
 */
  __pyx_t_1 = (fabs((__pyx_v_y1 - __pyx_v_y2)) > (0.5 * (__pyx_v_dy1 + __pyx_v_dy2)));
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":118
 *     if fabs(x1-x2) > 0.5*(dx1+dx2): return 0
 *     if fabs(y1-y2) > 0.5*(dy1+dy2): return 0
 *     if fabs(z1-z2) > 0.5*(dz1+dz2): return 0             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
  __pyx_t_1 = (fabs((__pyx_v_z1 - __pyx_v_z2)) > (0.5 * (__pyx_v_dz1 + __pyx_v_dz2)));
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":119
 *     if fabs(y1-y2) > 0.5*(dy1+dy2): return 0
 *     if fabs(z1-z2) > 0.5*(dz1+dz2): return 0
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * @cython.boundscheck(False)
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":123
 * @cython.boundscheck(False)
 * @cython.wraparound(False)
 * def identify_field_neighbors(             # <<<<<<<<<<<<<<
 *             np.ndarray[dtype=np.float64_t, ndim=1] field,
 *             np.ndarray[dtype=np.float64_t, ndim=1] x,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_identify_field_neighbors(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_identify_field_neighbors(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_field = 0;
  PyArrayObject *__pyx_v_x = 0;
  PyArrayObject *__pyx_v_y = 0;
  PyArrayObject *__pyx_v_z = 0;
  PyArrayObject *__pyx_v_dx = 0;
  PyArrayObject *__pyx_v_dy = 0;
  PyArrayObject *__pyx_v_dz = 0;
  int __pyx_v_outer;
  int __pyx_v_inner;
  int __pyx_v_N;
  int __pyx_v_added;
  __pyx_t_5numpy_float64_t __pyx_v_x1;
  __pyx_t_5numpy_float64_t __pyx_v_y1;
  __pyx_t_5numpy_float64_t __pyx_v_z1;
  __pyx_t_5numpy_float64_t __pyx_v_dx1;
  __pyx_t_5numpy_float64_t __pyx_v_dy1;
  __pyx_t_5numpy_float64_t __pyx_v_dz1;
  PyObject *__pyx_v_joins;
  PyObject *__pyx_v_this_joins;
  Py_buffer __pyx_bstruct_field;
  Py_ssize_t __pyx_bstride_0_field = 0;
  Py_ssize_t __pyx_bshape_0_field = 0;
  Py_buffer __pyx_bstruct_dz;
  Py_ssize_t __pyx_bstride_0_dz = 0;
  Py_ssize_t __pyx_bshape_0_dz = 0;
  Py_buffer __pyx_bstruct_dx;
  Py_ssize_t __pyx_bstride_0_dx = 0;
  Py_ssize_t __pyx_bshape_0_dx = 0;
  Py_buffer __pyx_bstruct_dy;
  Py_ssize_t __pyx_bstride_0_dy = 0;
  Py_ssize_t __pyx_bshape_0_dy = 0;
  Py_buffer __pyx_bstruct_y;
  Py_ssize_t __pyx_bstride_0_y = 0;
  Py_ssize_t __pyx_bshape_0_y = 0;
  Py_buffer __pyx_bstruct_x;
  Py_ssize_t __pyx_bstride_0_x = 0;
  Py_ssize_t __pyx_bshape_0_x = 0;
  Py_buffer __pyx_bstruct_z;
  Py_ssize_t __pyx_bstride_0_z = 0;
  Py_ssize_t __pyx_bshape_0_z = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  int __pyx_t_18;
  int __pyx_t_19;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__field,&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__z,&__pyx_n_s__dx,&__pyx_n_s__dy,&__pyx_n_s__dz,0};
  __Pyx_RefNannySetupContext("identify_field_neighbors");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[7] = {0,0,0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__field);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("identify_field_neighbors", 1, 7, 7, 1); {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("identify_field_neighbors", 1, 7, 7, 2); {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__z);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("identify_field_neighbors", 1, 7, 7, 3); {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dx);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("identify_field_neighbors", 1, 7, 7, 4); {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  5:
      values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dy);
      if (likely(values[5])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("identify_field_neighbors", 1, 7, 7, 5); {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  6:
      values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dz);
      if (likely(values[6])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("identify_field_neighbors", 1, 7, 7, 6); {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "identify_field_neighbors") < 0)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_field = ((PyArrayObject *)values[0]);
    __pyx_v_x = ((PyArrayObject *)values[1]);
    __pyx_v_y = ((PyArrayObject *)values[2]);
    __pyx_v_z = ((PyArrayObject *)values[3]);
    __pyx_v_dx = ((PyArrayObject *)values[4]);
    __pyx_v_dy = ((PyArrayObject *)values[5]);
    __pyx_v_dz = ((PyArrayObject *)values[6]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_field = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_x = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_y = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_z = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_dx = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
    __pyx_v_dy = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 5));
    __pyx_v_dz = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 6));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("identify_field_neighbors", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.identify_field_neighbors");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_field);
  __Pyx_INCREF((PyObject *)__pyx_v_x);
  __Pyx_INCREF((PyObject *)__pyx_v_y);
  __Pyx_INCREF((PyObject *)__pyx_v_z);
  __Pyx_INCREF((PyObject *)__pyx_v_dx);
  __Pyx_INCREF((PyObject *)__pyx_v_dy);
  __Pyx_INCREF((PyObject *)__pyx_v_dz);
  __pyx_v_joins = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_this_joins = Py_None; __Pyx_INCREF(Py_None);
  __pyx_bstruct_field.buf = NULL;
  __pyx_bstruct_x.buf = NULL;
  __pyx_bstruct_y.buf = NULL;
  __pyx_bstruct_z.buf = NULL;
  __pyx_bstruct_dx.buf = NULL;
  __pyx_bstruct_dy.buf = NULL;
  __pyx_bstruct_dz.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_field), __pyx_ptype_5numpy_ndarray, 1, "field", 0))) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 1, "x", 0))) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 1, "y", 0))) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_z), __pyx_ptype_5numpy_ndarray, 1, "z", 0))) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dx), __pyx_ptype_5numpy_ndarray, 1, "dx", 0))) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dy), __pyx_ptype_5numpy_ndarray, 1, "dy", 0))) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dz), __pyx_ptype_5numpy_ndarray, 1, "dz", 0))) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_field, (PyObject*)__pyx_v_field, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_field = __pyx_bstruct_field.strides[0];
  __pyx_bshape_0_field = __pyx_bstruct_field.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_x, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_x = __pyx_bstruct_x.strides[0];
  __pyx_bshape_0_x = __pyx_bstruct_x.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_y, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_y = __pyx_bstruct_y.strides[0];
  __pyx_bshape_0_y = __pyx_bstruct_y.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_z, (PyObject*)__pyx_v_z, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_z = __pyx_bstruct_z.strides[0];
  __pyx_bshape_0_z = __pyx_bstruct_z.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dx, (PyObject*)__pyx_v_dx, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_dx = __pyx_bstruct_dx.strides[0];
  __pyx_bshape_0_dx = __pyx_bstruct_dx.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dy, (PyObject*)__pyx_v_dy, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_dy = __pyx_bstruct_dy.strides[0];
  __pyx_bshape_0_dy = __pyx_bstruct_dy.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_dz, (PyObject*)__pyx_v_dz, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_dz = __pyx_bstruct_dz.strides[0];
  __pyx_bshape_0_dz = __pyx_bstruct_dz.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":135
 *     cdef int outer, inner, N, added
 *     cdef np.float64_t x1, y1, z1, dx1, dy1, dz1
 *     N = field.shape[0]             # <<<<<<<<<<<<<<
 *     #cdef np.ndarray[dtype=np.object_t] joins
 *     joins = [[] for outer in range(N)]
 */
  __pyx_v_N = (__pyx_v_field->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":137
 *     N = field.shape[0]
 *     #cdef np.ndarray[dtype=np.object_t] joins
 *     joins = [[] for outer in range(N)]             # <<<<<<<<<<<<<<
 *     #joins = np.empty(N, dtype='object')
 *     for outer in range(N):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = __pyx_v_N;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_outer = __pyx_t_3;
    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __pyx_t_5 = PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_4); if (unlikely(__pyx_t_5)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  }
  __Pyx_INCREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(__pyx_v_joins);
  __pyx_v_joins = ((PyObject *)__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":139
 *     joins = [[] for outer in range(N)]
 *     #joins = np.empty(N, dtype='object')
 *     for outer in range(N):             # <<<<<<<<<<<<<<
 *         if (outer % 10000) == 0: print outer, N
 *         x1 = x[outer]
 */
  __pyx_t_2 = __pyx_v_N;
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_outer = __pyx_t_3;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":140
 *     #joins = np.empty(N, dtype='object')
 *     for outer in range(N):
 *         if (outer % 10000) == 0: print outer, N             # <<<<<<<<<<<<<<
 *         x1 = x[outer]
 *         y1 = y[outer]
 */
    __pyx_t_6 = ((__pyx_v_outer % 10000) == 0);
    if (__pyx_t_6) {
      __pyx_t_1 = PyInt_FromLong(__pyx_v_outer); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_1 = 0;
      __pyx_t_4 = 0;
      if (__Pyx_Print(__pyx_t_7, 1) < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L10;
    }
    __pyx_L10:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":141
 *     for outer in range(N):
 *         if (outer % 10000) == 0: print outer, N
 *         x1 = x[outer]             # <<<<<<<<<<<<<<
 *         y1 = y[outer]
 *         z1 = z[outer]
 */
    __pyx_t_5 = __pyx_v_outer;
    __pyx_v_x1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x.buf, __pyx_t_5, __pyx_bstride_0_x));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":142
 *         if (outer % 10000) == 0: print outer, N
 *         x1 = x[outer]
 *         y1 = y[outer]             # <<<<<<<<<<<<<<
 *         z1 = z[outer]
 *         dx1 = dx[outer]
 */
    __pyx_t_8 = __pyx_v_outer;
    __pyx_v_y1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y.buf, __pyx_t_8, __pyx_bstride_0_y));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":143
 *         x1 = x[outer]
 *         y1 = y[outer]
 *         z1 = z[outer]             # <<<<<<<<<<<<<<
 *         dx1 = dx[outer]
 *         dy1 = dy[outer]
 */
    __pyx_t_9 = __pyx_v_outer;
    __pyx_v_z1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_z.buf, __pyx_t_9, __pyx_bstride_0_z));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":144
 *         y1 = y[outer]
 *         z1 = z[outer]
 *         dx1 = dx[outer]             # <<<<<<<<<<<<<<
 *         dy1 = dy[outer]
 *         dz1 = dz[outer]
 */
    __pyx_t_10 = __pyx_v_outer;
    __pyx_v_dx1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_10, __pyx_bstride_0_dx));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":145
 *         z1 = z[outer]
 *         dx1 = dx[outer]
 *         dy1 = dy[outer]             # <<<<<<<<<<<<<<
 *         dz1 = dz[outer]
 *         this_joins = joins[outer]
 */
    __pyx_t_11 = __pyx_v_outer;
    __pyx_v_dy1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dy.buf, __pyx_t_11, __pyx_bstride_0_dy));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":146
 *         dx1 = dx[outer]
 *         dy1 = dy[outer]
 *         dz1 = dz[outer]             # <<<<<<<<<<<<<<
 *         this_joins = joins[outer]
 *         added = 0
 */
    __pyx_t_12 = __pyx_v_outer;
    __pyx_v_dz1 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dz.buf, __pyx_t_12, __pyx_bstride_0_dz));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":147
 *         dy1 = dy[outer]
 *         dz1 = dz[outer]
 *         this_joins = joins[outer]             # <<<<<<<<<<<<<<
 *         added = 0
 *         # Go in reverse order
 */
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_joins, __pyx_v_outer, sizeof(int), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_v_this_joins);
    __pyx_v_this_joins = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":148
 *         dz1 = dz[outer]
 *         this_joins = joins[outer]
 *         added = 0             # <<<<<<<<<<<<<<
 *         # Go in reverse order
 *         for inner in range(outer, 0, -1):
 */
    __pyx_v_added = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":150
 *         added = 0
 *         # Go in reverse order
 *         for inner in range(outer, 0, -1):             # <<<<<<<<<<<<<<
 *             if not are_neighbors(x1, y1, z1, dx1, dy1, dz1,
 *                                  x[inner], y[inner], z[inner],
 */
    __pyx_t_7 = PyInt_FromLong(__pyx_v_outer); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_int_0);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_0);
    __Pyx_GIVEREF(__pyx_int_0);
    __Pyx_INCREF(__pyx_int_neg_1);
    PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_int_neg_1);
    __Pyx_GIVEREF(__pyx_int_neg_1);
    __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (PyList_CheckExact(__pyx_t_7) || PyTuple_CheckExact(__pyx_t_7)) {
      __pyx_t_13 = 0; __pyx_t_4 = __pyx_t_7; __Pyx_INCREF(__pyx_t_4);
    } else {
      __pyx_t_13 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_4)) break;
        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_7); __pyx_t_13++;
      } else if (likely(PyTuple_CheckExact(__pyx_t_4))) {
        if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_13); __Pyx_INCREF(__pyx_t_7); __pyx_t_13++;
      } else {
        __pyx_t_7 = PyIter_Next(__pyx_t_4);
        if (!__pyx_t_7) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
        __Pyx_GOTREF(__pyx_t_7);
      }
      __pyx_t_14 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_v_inner = __pyx_t_14;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":152
 *         for inner in range(outer, 0, -1):
 *             if not are_neighbors(x1, y1, z1, dx1, dy1, dz1,
 *                                  x[inner], y[inner], z[inner],             # <<<<<<<<<<<<<<
 *                                  dx[inner], dy[inner], dz[inner]):
 *                 continue
 */
      __pyx_t_14 = __pyx_v_inner;
      __pyx_t_15 = __pyx_v_inner;
      __pyx_t_16 = __pyx_v_inner;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":153
 *             if not are_neighbors(x1, y1, z1, dx1, dy1, dz1,
 *                                  x[inner], y[inner], z[inner],
 *                                  dx[inner], dy[inner], dz[inner]):             # <<<<<<<<<<<<<<
 *                 continue
 *             # Hot dog, we have a weiner!
 */
      __pyx_t_17 = __pyx_v_inner;
      __pyx_t_18 = __pyx_v_inner;
      __pyx_t_19 = __pyx_v_inner;
      __pyx_t_6 = (!__pyx_f_2yt_9amr_utils_are_neighbors(__pyx_v_x1, __pyx_v_y1, __pyx_v_z1, __pyx_v_dx1, __pyx_v_dy1, __pyx_v_dz1, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_x.buf, __pyx_t_14, __pyx_bstride_0_x)), (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_y.buf, __pyx_t_15, __pyx_bstride_0_y)), (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_z.buf, __pyx_t_16, __pyx_bstride_0_z)), (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dx.buf, __pyx_t_17, __pyx_bstride_0_dx)), (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dy.buf, __pyx_t_18, __pyx_bstride_0_dy)), (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_dz.buf, __pyx_t_19, __pyx_bstride_0_dz))));
      if (__pyx_t_6) {

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":154
 *                                  x[inner], y[inner], z[inner],
 *                                  dx[inner], dy[inner], dz[inner]):
 *                 continue             # <<<<<<<<<<<<<<
 *             # Hot dog, we have a weiner!
 *             this_joins.append(inner)
 */
        goto __pyx_L11_continue;
        goto __pyx_L13;
      }
      __pyx_L13:;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":156
 *                 continue
 *             # Hot dog, we have a weiner!
 *             this_joins.append(inner)             # <<<<<<<<<<<<<<
 *             added += 1
 *             if added == 26: break
 */
      __pyx_t_7 = PyInt_FromLong(__pyx_v_inner); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_this_joins, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":157
 *             # Hot dog, we have a weiner!
 *             this_joins.append(inner)
 *             added += 1             # <<<<<<<<<<<<<<
 *             if added == 26: break
 *     return joins
 */
      __pyx_v_added += 1;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":158
 *             this_joins.append(inner)
 *             added += 1
 *             if added == 26: break             # <<<<<<<<<<<<<<
 *     return joins
 * 
 */
      __pyx_t_6 = (__pyx_v_added == 26);
      if (__pyx_t_6) {
        goto __pyx_L12_break;
        goto __pyx_L14;
      }
      __pyx_L14:;
      __pyx_L11_continue:;
    }
    __pyx_L12_break:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":159
 *             added += 1
 *             if added == 26: break
 *     return joins             # <<<<<<<<<<<<<<
 * 
 * @cython.boundscheck(False)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_joins);
  __pyx_r = __pyx_v_joins;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_field);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dz);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dy);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_z);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.identify_field_neighbors");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_field);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dz);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dx);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_dy);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_y);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_x);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_z);
  __pyx_L2:;
  __Pyx_DECREF(__pyx_v_joins);
  __Pyx_DECREF(__pyx_v_this_joins);
  __Pyx_DECREF((PyObject *)__pyx_v_field);
  __Pyx_DECREF((PyObject *)__pyx_v_x);
  __Pyx_DECREF((PyObject *)__pyx_v_y);
  __Pyx_DECREF((PyObject *)__pyx_v_z);
  __Pyx_DECREF((PyObject *)__pyx_v_dx);
  __Pyx_DECREF((PyObject *)__pyx_v_dy);
  __Pyx_DECREF((PyObject *)__pyx_v_dz);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":163
 * @cython.boundscheck(False)
 * @cython.wraparound(False)
 * def extract_identified_contours(int max_ind, joins):             # <<<<<<<<<<<<<<
 *     cdef int i
 *     contours = []
 */

static PyObject *__pyx_pf_2yt_9amr_utils_extract_identified_contours(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_extract_identified_contours(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_max_ind;
  PyObject *__pyx_v_joins = 0;
  int __pyx_v_i;
  PyObject *__pyx_v_contours;
  PyObject *__pyx_v_proto_contour;
  PyObject *__pyx_v_j;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  long __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__max_ind,&__pyx_n_s__joins,0};
  __Pyx_RefNannySetupContext("extract_identified_contours");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_ind);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__joins);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("extract_identified_contours", 1, 2, 2, 1); {__pyx_filename = __pyx_f[6]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "extract_identified_contours") < 0)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_max_ind = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_max_ind == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_joins = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_max_ind = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_max_ind == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_joins = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("extract_identified_contours", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[6]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.extract_identified_contours");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_joins);
  __pyx_v_contours = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_proto_contour = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_j = Py_None; __Pyx_INCREF(Py_None);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":165
 * def extract_identified_contours(int max_ind, joins):
 *     cdef int i
 *     contours = []             # <<<<<<<<<<<<<<
 *     for i in range(max_ind + 1): # +1 to get to the max_ind itself
 *         contours.append(set([i]))
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(__pyx_v_contours);
  __pyx_v_contours = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":166
 *     cdef int i
 *     contours = []
 *     for i in range(max_ind + 1): # +1 to get to the max_ind itself             # <<<<<<<<<<<<<<
 *         contours.append(set([i]))
 *         if len(joins[i]) == 0:
 */
  __pyx_t_2 = (__pyx_v_max_ind + 1);
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":167
 *     contours = []
 *     for i in range(max_ind + 1): # +1 to get to the max_ind itself
 *         contours.append(set([i]))             # <<<<<<<<<<<<<<
 *         if len(joins[i]) == 0:
 *             continue
 */
    __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(PySet_Add(__pyx_t_1, __pyx_t_4) < 0)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_contours, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":168
 *     for i in range(max_ind + 1): # +1 to get to the max_ind itself
 *         contours.append(set([i]))
 *         if len(joins[i]) == 0:             # <<<<<<<<<<<<<<
 *             continue
 *         proto_contour = [i]
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_joins, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = (__pyx_t_5 == 0);
    if (__pyx_t_6) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":169
 *         contours.append(set([i]))
 *         if len(joins[i]) == 0:
 *             continue             # <<<<<<<<<<<<<<
 *         proto_contour = [i]
 *         for j in joins[i]:
 */
      goto __pyx_L6_continue;
      goto __pyx_L8;
    }
    __pyx_L8:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":170
 *         if len(joins[i]) == 0:
 *             continue
 *         proto_contour = [i]             # <<<<<<<<<<<<<<
 *         for j in joins[i]:
 *             proto_contour += contours[j]
 */
    __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_v_proto_contour);
    __pyx_v_proto_contour = ((PyObject *)__pyx_t_1);
    __pyx_t_1 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":171
 *             continue
 *         proto_contour = [i]
 *         for j in joins[i]:             # <<<<<<<<<<<<<<
 *             proto_contour += contours[j]
 *         proto_contour = set(proto_contour)
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_joins, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_5 = 0; __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4);
    } else {
      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
      } else if (likely(PyTuple_CheckExact(__pyx_t_4))) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
      } else {
        __pyx_t_1 = PyIter_Next(__pyx_t_4);
        if (!__pyx_t_1) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_DECREF(__pyx_v_j);
      __pyx_v_j = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":172
 *         proto_contour = [i]
 *         for j in joins[i]:
 *             proto_contour += contours[j]             # <<<<<<<<<<<<<<
 *         proto_contour = set(proto_contour)
 *         for j in proto_contour:
 */
      __pyx_t_1 = PyObject_GetItem(__pyx_v_contours, __pyx_v_j); if (!__pyx_t_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_proto_contour, __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_v_proto_contour);
      __pyx_v_proto_contour = __pyx_t_7;
      __pyx_t_7 = 0;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":173
 *         for j in joins[i]:
 *             proto_contour += contours[j]
 *         proto_contour = set(proto_contour)             # <<<<<<<<<<<<<<
 *         for j in proto_contour:
 *             contours[j] = proto_contour
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_v_proto_contour);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_proto_contour);
    __Pyx_GIVEREF(__pyx_v_proto_contour);
    __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)&PySet_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_v_proto_contour);
    __pyx_v_proto_contour = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":174
 *             proto_contour += contours[j]
 *         proto_contour = set(proto_contour)
 *         for j in proto_contour:             # <<<<<<<<<<<<<<
 *             contours[j] = proto_contour
 *     return contours
 */
    if (PyList_CheckExact(__pyx_v_proto_contour) || PyTuple_CheckExact(__pyx_v_proto_contour)) {
      __pyx_t_5 = 0; __pyx_t_7 = __pyx_v_proto_contour; __Pyx_INCREF(__pyx_t_7);
    } else {
      __pyx_t_5 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_proto_contour); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
    }
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_t_7))) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_7)) break;
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++;
      } else if (likely(PyTuple_CheckExact(__pyx_t_7))) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++;
      } else {
        __pyx_t_4 = PyIter_Next(__pyx_t_7);
        if (!__pyx_t_4) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_v_j);
      __pyx_v_j = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":175
 *         proto_contour = set(proto_contour)
 *         for j in proto_contour:
 *             contours[j] = proto_contour             # <<<<<<<<<<<<<<
 *     return contours
 */
      if (PyObject_SetItem(__pyx_v_contours, __pyx_v_j, __pyx_v_proto_contour) < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_L6_continue:;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":176
 *         for j in proto_contour:
 *             contours[j] = proto_contour
 *     return contours             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_contours);
  __pyx_r = __pyx_v_contours;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("yt.amr_utils.extract_identified_contours");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_contours);
  __Pyx_DECREF(__pyx_v_proto_contour);
  __Pyx_DECREF(__pyx_v_j);
  __Pyx_DECREF(__pyx_v_joins);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":102
 *         png_structp *png_ptr_ptr, png_infop *info_ptr_ptr)
 * 
 * def write_png(np.ndarray[np.uint8_t, ndim=3] buffer,             # <<<<<<<<<<<<<<
 *               char *filename, int dpi=100):
 * 
 */

static PyObject *__pyx_pf_2yt_9amr_utils_write_png(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_write_png(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_buffer = 0;
  char *__pyx_v_filename;
  int __pyx_v_dpi;
  png_byte *__pyx_v_pix_buffer;
  int __pyx_v_width;
  int __pyx_v_height;
  FILE *__pyx_v_fileobj;
  png_bytep *__pyx_v_row_pointers;
  png_structp __pyx_v_png_ptr;
  png_infop __pyx_v_info_ptr;
  png_color_8 __pyx_v_sig_bit;
  png_uint_32 __pyx_v_row;
  size_t __pyx_v_dots_per_meter;
  Py_buffer __pyx_bstruct_buffer;
  Py_ssize_t __pyx_bstride_0_buffer = 0;
  Py_ssize_t __pyx_bstride_1_buffer = 0;
  Py_ssize_t __pyx_bstride_2_buffer = 0;
  Py_ssize_t __pyx_bshape_0_buffer = 0;
  Py_ssize_t __pyx_bshape_1_buffer = 0;
  Py_ssize_t __pyx_bshape_2_buffer = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  png_uint_32 __pyx_t_2;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__filename,&__pyx_n_s__dpi,0};
  __Pyx_RefNannySetupContext("write_png");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("write_png", 0, 2, 3, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dpi);
        if (unlikely(value)) { values[2] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "write_png") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_buffer = ((PyArrayObject *)values[0]);
    __pyx_v_filename = __Pyx_PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[2]) {
      __pyx_v_dpi = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_dpi == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_dpi = ((int)100);
    }
  } else {
    __pyx_v_dpi = ((int)100);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3:
      __pyx_v_dpi = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_dpi == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  2:
      __pyx_v_filename = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_buffer = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_png", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.write_png");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_buffer);
  __pyx_bstruct_buffer.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_buffer), __pyx_ptype_5numpy_ndarray, 1, "buffer", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_buffer, (PyObject*)__pyx_v_buffer, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_buffer = __pyx_bstruct_buffer.strides[0]; __pyx_bstride_1_buffer = __pyx_bstruct_buffer.strides[1]; __pyx_bstride_2_buffer = __pyx_bstruct_buffer.strides[2];
  __pyx_bshape_0_buffer = __pyx_bstruct_buffer.shape[0]; __pyx_bshape_1_buffer = __pyx_bstruct_buffer.shape[1]; __pyx_bshape_2_buffer = __pyx_bstruct_buffer.shape[2];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":106
 * 
 *     # This is something of a translation of the matplotlib _png module
 *     cdef png_byte *pix_buffer = <png_byte *> buffer.data             # <<<<<<<<<<<<<<
 *     cdef int width = buffer.shape[1]
 *     cdef int height = buffer.shape[0]
 */
  __pyx_v_pix_buffer = ((png_byte *)__pyx_v_buffer->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":107
 *     # This is something of a translation of the matplotlib _png module
 *     cdef png_byte *pix_buffer = <png_byte *> buffer.data
 *     cdef int width = buffer.shape[1]             # <<<<<<<<<<<<<<
 *     cdef int height = buffer.shape[0]
 * 
 */
  __pyx_v_width = (__pyx_v_buffer->dimensions[1]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":108
 *     cdef png_byte *pix_buffer = <png_byte *> buffer.data
 *     cdef int width = buffer.shape[1]
 *     cdef int height = buffer.shape[0]             # <<<<<<<<<<<<<<
 * 
 *     cdef FILE* fileobj = fopen(filename, "wb")
 */
  __pyx_v_height = (__pyx_v_buffer->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":110
 *     cdef int height = buffer.shape[0]
 * 
 *     cdef FILE* fileobj = fopen(filename, "wb")             # <<<<<<<<<<<<<<
 *     cdef png_bytep *row_pointers
 *     cdef png_structp png_ptr
 */
  __pyx_v_fileobj = fopen(__pyx_v_filename, __pyx_k__wb);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":118
 *     cdef png_uint_32 row
 * 
 *     row_pointers = <png_bytep *> alloca(sizeof(png_bytep) * height)             # <<<<<<<<<<<<<<
 * 
 *     for row in range(height):
 */
  __pyx_v_row_pointers = ((png_bytep *)alloca(((sizeof(png_bytep)) * __pyx_v_height)));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":120
 *     row_pointers = <png_bytep *> alloca(sizeof(png_bytep) * height)
 * 
 *     for row in range(height):             # <<<<<<<<<<<<<<
 *         row_pointers[row] = pix_buffer + row * width * 4
 *     png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)
 */
  __pyx_t_1 = __pyx_v_height;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_row = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":121
 * 
 *     for row in range(height):
 *         row_pointers[row] = pix_buffer + row * width * 4             # <<<<<<<<<<<<<<
 *     png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)
 *     info_ptr = png_create_info_struct(png_ptr)
 */
    (__pyx_v_row_pointers[__pyx_v_row]) = (__pyx_v_pix_buffer + ((__pyx_v_row * __pyx_v_width) * 4));
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":122
 *     for row in range(height):
 *         row_pointers[row] = pix_buffer + row * width * 4
 *     png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)             # <<<<<<<<<<<<<<
 *     info_ptr = png_create_info_struct(png_ptr)
 * 
 */
  __pyx_v_png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":123
 *         row_pointers[row] = pix_buffer + row * width * 4
 *     png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)
 *     info_ptr = png_create_info_struct(png_ptr)             # <<<<<<<<<<<<<<
 * 
 *     # Um we are ignoring setjmp sorry guys
 */
  __pyx_v_info_ptr = png_create_info_struct(__pyx_v_png_ptr);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":127
 *     # Um we are ignoring setjmp sorry guys
 * 
 *     png_init_io(png_ptr, fileobj)             # <<<<<<<<<<<<<<
 * 
 *     png_set_IHDR(png_ptr, info_ptr, width, height, 8,
 */
  png_init_io(__pyx_v_png_ptr, __pyx_v_fileobj);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":131
 *     png_set_IHDR(png_ptr, info_ptr, width, height, 8,
 *                  PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE,
 *                  PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE)             # <<<<<<<<<<<<<<
 * 
 *     cdef size_t dots_per_meter = <size_t> (dpi / (2.54 / 100.0))
 */
  png_set_IHDR(__pyx_v_png_ptr, __pyx_v_info_ptr, __pyx_v_width, __pyx_v_height, 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":133
 *                  PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE)
 * 
 *     cdef size_t dots_per_meter = <size_t> (dpi / (2.54 / 100.0))             # <<<<<<<<<<<<<<
 *     png_set_pHYs(png_ptr, info_ptr, dots_per_meter, dots_per_meter,
 *                  PNG_RESOLUTION_METER)
 */
  __pyx_v_dots_per_meter = ((size_t)(__pyx_v_dpi / (2.54 / 100.0)));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":135
 *     cdef size_t dots_per_meter = <size_t> (dpi / (2.54 / 100.0))
 *     png_set_pHYs(png_ptr, info_ptr, dots_per_meter, dots_per_meter,
 *                  PNG_RESOLUTION_METER)             # <<<<<<<<<<<<<<
 * 
 *     sig_bit.gray = 0
 */
  png_set_pHYs(__pyx_v_png_ptr, __pyx_v_info_ptr, __pyx_v_dots_per_meter, __pyx_v_dots_per_meter, PNG_RESOLUTION_METER);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":137
 *                  PNG_RESOLUTION_METER)
 * 
 *     sig_bit.gray = 0             # <<<<<<<<<<<<<<
 *     sig_bit.red = sig_bit.green = sig_bit.blue = sig_bit.alpha = 8
 * 
 */
  __pyx_v_sig_bit.gray = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":138
 * 
 *     sig_bit.gray = 0
 *     sig_bit.red = sig_bit.green = sig_bit.blue = sig_bit.alpha = 8             # <<<<<<<<<<<<<<
 * 
 *     png_set_sBIT(png_ptr, info_ptr, &sig_bit)
 */
  __pyx_v_sig_bit.red = 8;
  __pyx_v_sig_bit.green = 8;
  __pyx_v_sig_bit.blue = 8;
  __pyx_v_sig_bit.alpha = 8;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":140
 *     sig_bit.red = sig_bit.green = sig_bit.blue = sig_bit.alpha = 8
 * 
 *     png_set_sBIT(png_ptr, info_ptr, &sig_bit)             # <<<<<<<<<<<<<<
 * 
 *     png_write_info(png_ptr, info_ptr)
 */
  png_set_sBIT(__pyx_v_png_ptr, __pyx_v_info_ptr, (&__pyx_v_sig_bit));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":142
 *     png_set_sBIT(png_ptr, info_ptr, &sig_bit)
 * 
 *     png_write_info(png_ptr, info_ptr)             # <<<<<<<<<<<<<<
 *     png_write_image(png_ptr, row_pointers)
 *     png_write_end(png_ptr, info_ptr)
 */
  png_write_info(__pyx_v_png_ptr, __pyx_v_info_ptr);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":143
 * 
 *     png_write_info(png_ptr, info_ptr)
 *     png_write_image(png_ptr, row_pointers)             # <<<<<<<<<<<<<<
 *     png_write_end(png_ptr, info_ptr)
 * 
 */
  png_write_image(__pyx_v_png_ptr, __pyx_v_row_pointers);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":144
 *     png_write_info(png_ptr, info_ptr)
 *     png_write_image(png_ptr, row_pointers)
 *     png_write_end(png_ptr, info_ptr)             # <<<<<<<<<<<<<<
 * 
 *     fclose(fileobj)
 */
  png_write_end(__pyx_v_png_ptr, __pyx_v_info_ptr);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":146
 *     png_write_end(png_ptr, info_ptr)
 * 
 *     fclose(fileobj)             # <<<<<<<<<<<<<<
 *     png_destroy_write_struct(&png_ptr, &info_ptr)
 * 
 */
  fclose(__pyx_v_fileobj);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":147
 * 
 *     fclose(fileobj)
 *     png_destroy_write_struct(&png_ptr, &info_ptr)             # <<<<<<<<<<<<<<
 * 
 * def add_points_to_image(
 */
  png_destroy_write_struct((&__pyx_v_png_ptr), (&__pyx_v_info_ptr));

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_buffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.write_png");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_buffer);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_buffer);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":149
 *     png_destroy_write_struct(&png_ptr, &info_ptr)
 * 
 * def add_points_to_image(             # <<<<<<<<<<<<<<
 *         np.ndarray[np.uint8_t, ndim=3] buffer,
 *         np.ndarray[np.float64_t, ndim=1] px,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_add_points_to_image(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_add_points_to_image(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_buffer = 0;
  PyArrayObject *__pyx_v_px = 0;
  PyArrayObject *__pyx_v_py = 0;
  __pyx_t_5numpy_float64_t __pyx_v_pv;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_k;
  int __pyx_v_pi;
  int __pyx_v_np;
  int __pyx_v_xs;
  int __pyx_v_ys;
  int __pyx_v_v;
  Py_buffer __pyx_bstruct_buffer;
  Py_ssize_t __pyx_bstride_0_buffer = 0;
  Py_ssize_t __pyx_bstride_1_buffer = 0;
  Py_ssize_t __pyx_bstride_2_buffer = 0;
  Py_ssize_t __pyx_bshape_0_buffer = 0;
  Py_ssize_t __pyx_bshape_1_buffer = 0;
  Py_ssize_t __pyx_bshape_2_buffer = 0;
  Py_buffer __pyx_bstruct_px;
  Py_ssize_t __pyx_bstride_0_px = 0;
  Py_ssize_t __pyx_bshape_0_px = 0;
  Py_buffer __pyx_bstruct_py;
  Py_ssize_t __pyx_bstride_0_py = 0;
  Py_ssize_t __pyx_bshape_0_py = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__px,&__pyx_n_s__py,&__pyx_n_s__pv,0};
  __Pyx_RefNannySetupContext("add_points_to_image");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__px);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_points_to_image", 1, 4, 4, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__py);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_points_to_image", 1, 4, 4, 2); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pv);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_points_to_image", 1, 4, 4, 3); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "add_points_to_image") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_buffer = ((PyArrayObject *)values[0]);
    __pyx_v_px = ((PyArrayObject *)values[1]);
    __pyx_v_py = ((PyArrayObject *)values[2]);
    __pyx_v_pv = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_pv == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_buffer = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_px = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_py = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_pv = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_pv == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_points_to_image", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.add_points_to_image");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_buffer);
  __Pyx_INCREF((PyObject *)__pyx_v_px);
  __Pyx_INCREF((PyObject *)__pyx_v_py);
  __pyx_bstruct_buffer.buf = NULL;
  __pyx_bstruct_px.buf = NULL;
  __pyx_bstruct_py.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_buffer), __pyx_ptype_5numpy_ndarray, 1, "buffer", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_px), __pyx_ptype_5numpy_ndarray, 1, "px", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_py), __pyx_ptype_5numpy_ndarray, 1, "py", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_buffer, (PyObject*)__pyx_v_buffer, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint8_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_buffer = __pyx_bstruct_buffer.strides[0]; __pyx_bstride_1_buffer = __pyx_bstruct_buffer.strides[1]; __pyx_bstride_2_buffer = __pyx_bstruct_buffer.strides[2];
  __pyx_bshape_0_buffer = __pyx_bstruct_buffer.shape[0]; __pyx_bshape_1_buffer = __pyx_bstruct_buffer.shape[1]; __pyx_bshape_2_buffer = __pyx_bstruct_buffer.shape[2];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_px, (PyObject*)__pyx_v_px, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_px = __pyx_bstruct_px.strides[0];
  __pyx_bshape_0_px = __pyx_bstruct_px.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_py, (PyObject*)__pyx_v_py, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_py = __pyx_bstruct_py.strides[0];
  __pyx_bshape_0_py = __pyx_bstruct_py.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":155
 *         np.float64_t pv):
 *     cdef int i, j, k, pi
 *     cdef int np = px.shape[0]             # <<<<<<<<<<<<<<
 *     cdef int xs = buffer.shape[0]
 *     cdef int ys = buffer.shape[1]
 */
  __pyx_v_np = (__pyx_v_px->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":156
 *     cdef int i, j, k, pi
 *     cdef int np = px.shape[0]
 *     cdef int xs = buffer.shape[0]             # <<<<<<<<<<<<<<
 *     cdef int ys = buffer.shape[1]
 *     cdef int v
 */
  __pyx_v_xs = (__pyx_v_buffer->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":157
 *     cdef int np = px.shape[0]
 *     cdef int xs = buffer.shape[0]
 *     cdef int ys = buffer.shape[1]             # <<<<<<<<<<<<<<
 *     cdef int v
 *     v = iclip(<int>(pv * 255), 0, 255)
 */
  __pyx_v_ys = (__pyx_v_buffer->dimensions[1]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":159
 *     cdef int ys = buffer.shape[1]
 *     cdef int v
 *     v = iclip(<int>(pv * 255), 0, 255)             # <<<<<<<<<<<<<<
 *     for pi in range(np):
 *         j = <int> (xs * px[pi])
 */
  __pyx_v_v = __pyx_f_2yt_9amr_utils_iclip(((int)(__pyx_v_pv * 255)), 0, 255);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":160
 *     cdef int v
 *     v = iclip(<int>(pv * 255), 0, 255)
 *     for pi in range(np):             # <<<<<<<<<<<<<<
 *         j = <int> (xs * px[pi])
 *         i = <int> (ys * py[pi])
 */
  __pyx_t_1 = __pyx_v_np;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_pi = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":161
 *     v = iclip(<int>(pv * 255), 0, 255)
 *     for pi in range(np):
 *         j = <int> (xs * px[pi])             # <<<<<<<<<<<<<<
 *         i = <int> (ys * py[pi])
 *         for k in range(3):
 */
    __pyx_t_3 = __pyx_v_pi;
    __pyx_t_4 = -1;
    if (__pyx_t_3 < 0) {
      __pyx_t_3 += __pyx_bshape_0_px;
      if (unlikely(__pyx_t_3 < 0)) __pyx_t_4 = 0;
    } else if (unlikely(__pyx_t_3 >= __pyx_bshape_0_px)) __pyx_t_4 = 0;
    if (unlikely(__pyx_t_4 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_4);
      {__pyx_filename = __pyx_f[8]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_j = ((int)(__pyx_v_xs * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_px.buf, __pyx_t_3, __pyx_bstride_0_px))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":162
 *     for pi in range(np):
 *         j = <int> (xs * px[pi])
 *         i = <int> (ys * py[pi])             # <<<<<<<<<<<<<<
 *         for k in range(3):
 *             buffer[i, j, k] = 0
 */
    __pyx_t_4 = __pyx_v_pi;
    __pyx_t_5 = -1;
    if (__pyx_t_4 < 0) {
      __pyx_t_4 += __pyx_bshape_0_py;
      if (unlikely(__pyx_t_4 < 0)) __pyx_t_5 = 0;
    } else if (unlikely(__pyx_t_4 >= __pyx_bshape_0_py)) __pyx_t_5 = 0;
    if (unlikely(__pyx_t_5 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_5);
      {__pyx_filename = __pyx_f[8]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_v_i = ((int)(__pyx_v_ys * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_py.buf, __pyx_t_4, __pyx_bstride_0_py))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":163
 *         j = <int> (xs * px[pi])
 *         i = <int> (ys * py[pi])
 *         for k in range(3):             # <<<<<<<<<<<<<<
 *             buffer[i, j, k] = 0
 *     return
 */
    for (__pyx_t_5 = 0; __pyx_t_5 < 3; __pyx_t_5+=1) {
      __pyx_v_k = __pyx_t_5;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":164
 *         i = <int> (ys * py[pi])
 *         for k in range(3):
 *             buffer[i, j, k] = 0             # <<<<<<<<<<<<<<
 *     return
 *     for i in range(xs):
 */
      __pyx_t_6 = __pyx_v_i;
      __pyx_t_7 = __pyx_v_j;
      __pyx_t_8 = __pyx_v_k;
      __pyx_t_9 = -1;
      if (__pyx_t_6 < 0) {
        __pyx_t_6 += __pyx_bshape_0_buffer;
        if (unlikely(__pyx_t_6 < 0)) __pyx_t_9 = 0;
      } else if (unlikely(__pyx_t_6 >= __pyx_bshape_0_buffer)) __pyx_t_9 = 0;
      if (__pyx_t_7 < 0) {
        __pyx_t_7 += __pyx_bshape_1_buffer;
        if (unlikely(__pyx_t_7 < 0)) __pyx_t_9 = 1;
      } else if (unlikely(__pyx_t_7 >= __pyx_bshape_1_buffer)) __pyx_t_9 = 1;
      if (__pyx_t_8 < 0) {
        __pyx_t_8 += __pyx_bshape_2_buffer;
        if (unlikely(__pyx_t_8 < 0)) __pyx_t_9 = 2;
      } else if (unlikely(__pyx_t_8 >= __pyx_bshape_2_buffer)) __pyx_t_9 = 2;
      if (unlikely(__pyx_t_9 != -1)) {
        __Pyx_RaiseBufferIndexError(__pyx_t_9);
        {__pyx_filename = __pyx_f[8]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_uint8_t *, __pyx_bstruct_buffer.buf, __pyx_t_6, __pyx_bstride_0_buffer, __pyx_t_7, __pyx_bstride_1_buffer, __pyx_t_8, __pyx_bstride_2_buffer) = 0;
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":165
 *         for k in range(3):
 *             buffer[i, j, k] = 0
 *     return             # <<<<<<<<<<<<<<
 *     for i in range(xs):
 *         for j in range(ys):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":166
 *             buffer[i, j, k] = 0
 *     return
 *     for i in range(xs):             # <<<<<<<<<<<<<<
 *         for j in range(ys):
 *             for k in range(3):
 */
  __pyx_t_1 = __pyx_v_xs;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":167
 *     return
 *     for i in range(xs):
 *         for j in range(ys):             # <<<<<<<<<<<<<<
 *             for k in range(3):
 *                 v = buffer[i, j, k]
 */
    __pyx_t_5 = __pyx_v_ys;
    for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_5; __pyx_t_9+=1) {
      __pyx_v_j = __pyx_t_9;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":168
 *     for i in range(xs):
 *         for j in range(ys):
 *             for k in range(3):             # <<<<<<<<<<<<<<
 *                 v = buffer[i, j, k]
 *                 buffer[i, j, k] = iclip(v, 0, 255)
 */
      for (__pyx_t_10 = 0; __pyx_t_10 < 3; __pyx_t_10+=1) {
        __pyx_v_k = __pyx_t_10;

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":169
 *         for j in range(ys):
 *             for k in range(3):
 *                 v = buffer[i, j, k]             # <<<<<<<<<<<<<<
 *                 buffer[i, j, k] = iclip(v, 0, 255)
 */
        __pyx_t_11 = __pyx_v_i;
        __pyx_t_12 = __pyx_v_j;
        __pyx_t_13 = __pyx_v_k;
        __pyx_t_14 = -1;
        if (__pyx_t_11 < 0) {
          __pyx_t_11 += __pyx_bshape_0_buffer;
          if (unlikely(__pyx_t_11 < 0)) __pyx_t_14 = 0;
        } else if (unlikely(__pyx_t_11 >= __pyx_bshape_0_buffer)) __pyx_t_14 = 0;
        if (__pyx_t_12 < 0) {
          __pyx_t_12 += __pyx_bshape_1_buffer;
          if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 1;
        } else if (unlikely(__pyx_t_12 >= __pyx_bshape_1_buffer)) __pyx_t_14 = 1;
        if (__pyx_t_13 < 0) {
          __pyx_t_13 += __pyx_bshape_2_buffer;
          if (unlikely(__pyx_t_13 < 0)) __pyx_t_14 = 2;
        } else if (unlikely(__pyx_t_13 >= __pyx_bshape_2_buffer)) __pyx_t_14 = 2;
        if (unlikely(__pyx_t_14 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_14);
          {__pyx_filename = __pyx_f[8]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        __pyx_v_v = (*__Pyx_BufPtrStrided3d(__pyx_t_5numpy_uint8_t *, __pyx_bstruct_buffer.buf, __pyx_t_11, __pyx_bstride_0_buffer, __pyx_t_12, __pyx_bstride_1_buffer, __pyx_t_13, __pyx_bstride_2_buffer));

        /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":170
 *             for k in range(3):
 *                 v = buffer[i, j, k]
 *                 buffer[i, j, k] = iclip(v, 0, 255)             # <<<<<<<<<<<<<<
 */
        __pyx_t_14 = __pyx_v_i;
        __pyx_t_15 = __pyx_v_j;
        __pyx_t_16 = __pyx_v_k;
        __pyx_t_17 = -1;
        if (__pyx_t_14 < 0) {
          __pyx_t_14 += __pyx_bshape_0_buffer;
          if (unlikely(__pyx_t_14 < 0)) __pyx_t_17 = 0;
        } else if (unlikely(__pyx_t_14 >= __pyx_bshape_0_buffer)) __pyx_t_17 = 0;
        if (__pyx_t_15 < 0) {
          __pyx_t_15 += __pyx_bshape_1_buffer;
          if (unlikely(__pyx_t_15 < 0)) __pyx_t_17 = 1;
        } else if (unlikely(__pyx_t_15 >= __pyx_bshape_1_buffer)) __pyx_t_17 = 1;
        if (__pyx_t_16 < 0) {
          __pyx_t_16 += __pyx_bshape_2_buffer;
          if (unlikely(__pyx_t_16 < 0)) __pyx_t_17 = 2;
        } else if (unlikely(__pyx_t_16 >= __pyx_bshape_2_buffer)) __pyx_t_17 = 2;
        if (unlikely(__pyx_t_17 != -1)) {
          __Pyx_RaiseBufferIndexError(__pyx_t_17);
          {__pyx_filename = __pyx_f[8]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        *__Pyx_BufPtrStrided3d(__pyx_t_5numpy_uint8_t *, __pyx_bstruct_buffer.buf, __pyx_t_14, __pyx_bstride_0_buffer, __pyx_t_15, __pyx_bstride_1_buffer, __pyx_t_16, __pyx_bstride_2_buffer) = __pyx_f_2yt_9amr_utils_iclip(__pyx_v_v, 0, 255);
      }
    }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_buffer);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_px);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_py);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.add_points_to_image");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_buffer);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_px);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_py);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_buffer);
  __Pyx_DECREF((PyObject *)__pyx_v_px);
  __Pyx_DECREF((PyObject *)__pyx_v_py);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":42
 * @cython.boundscheck(False)
 * @cython.wraparound(False)
 * def read_tiger_section(             # <<<<<<<<<<<<<<
 *                      char *fn,
 *                      np.ndarray[np.int64_t, ndim=1] slab_start,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_read_tiger_section(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_read_tiger_section(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  char *__pyx_v_fn;
  PyArrayObject *__pyx_v_slab_start = 0;
  PyArrayObject *__pyx_v_slab_size = 0;
  PyArrayObject *__pyx_v_root_size = 0;
  int __pyx_v_offset;
  int __pyx_v_strides[3];
  __pyx_t_5numpy_int64_t __pyx_v_i;
  __pyx_t_5numpy_int64_t __pyx_v_j;
  PyArrayObject *__pyx_v_buffer = 0;
  FILE *__pyx_v_f;
  __pyx_t_5numpy_int64_t __pyx_v_pos;
  __pyx_t_5numpy_int64_t __pyx_v_moff;
  float *__pyx_v_data;
  Py_buffer __pyx_bstruct_slab_size;
  Py_ssize_t __pyx_bstride_0_slab_size = 0;
  Py_ssize_t __pyx_bshape_0_slab_size = 0;
  Py_buffer __pyx_bstruct_slab_start;
  Py_ssize_t __pyx_bstride_0_slab_start = 0;
  Py_ssize_t __pyx_bshape_0_slab_start = 0;
  Py_buffer __pyx_bstruct_root_size;
  Py_ssize_t __pyx_bstride_0_root_size = 0;
  Py_ssize_t __pyx_bshape_0_root_size = 0;
  PyObject *__pyx_r = NULL;
  long __pyx_t_1;
  long __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  long __pyx_t_7;
  __pyx_t_5numpy_int64_t __pyx_t_8;
  __pyx_t_5numpy_int64_t __pyx_t_9;
  long __pyx_t_10;
  __pyx_t_5numpy_int64_t __pyx_t_11;
  __pyx_t_5numpy_int64_t __pyx_t_12;
  long __pyx_t_13;
  long __pyx_t_14;
  long __pyx_t_15;
  long __pyx_t_16;
  long __pyx_t_17;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fn,&__pyx_n_s__slab_start,&__pyx_n_s__slab_size,&__pyx_n_s__root_size,&__pyx_n_s__offset,0};
  __Pyx_RefNannySetupContext("read_tiger_section");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fn);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__slab_start);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("read_tiger_section", 0, 4, 5, 1); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__slab_size);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("read_tiger_section", 0, 4, 5, 2); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__root_size);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("read_tiger_section", 0, 4, 5, 3); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__offset);
        if (unlikely(value)) { values[4] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "read_tiger_section") < 0)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_fn = __Pyx_PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_fn) && PyErr_Occurred())) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_slab_start = ((PyArrayObject *)values[1]);
    __pyx_v_slab_size = ((PyArrayObject *)values[2]);
    __pyx_v_root_size = ((PyArrayObject *)values[3]);
    if (values[4]) {
      __pyx_v_offset = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_offset == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_offset = ((int)36);
    }
  } else {
    __pyx_v_offset = ((int)36);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5:
      __pyx_v_offset = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_offset == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  4:
      __pyx_v_root_size = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
      __pyx_v_slab_size = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
      __pyx_v_slab_start = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
      __pyx_v_fn = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_fn) && PyErr_Occurred())) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("read_tiger_section", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[9]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.read_tiger_section");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_slab_start);
  __Pyx_INCREF((PyObject *)__pyx_v_slab_size);
  __Pyx_INCREF((PyObject *)__pyx_v_root_size);
  __pyx_bstruct_slab_start.buf = NULL;
  __pyx_bstruct_slab_size.buf = NULL;
  __pyx_bstruct_root_size.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slab_start), __pyx_ptype_5numpy_ndarray, 1, "slab_start", 0))) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_slab_size), __pyx_ptype_5numpy_ndarray, 1, "slab_size", 0))) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_root_size), __pyx_ptype_5numpy_ndarray, 1, "root_size", 0))) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_slab_start, (PyObject*)__pyx_v_slab_start, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_slab_start = __pyx_bstruct_slab_start.strides[0];
  __pyx_bshape_0_slab_start = __pyx_bstruct_slab_start.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_slab_size, (PyObject*)__pyx_v_slab_size, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_slab_size = __pyx_bstruct_slab_size.strides[0];
  __pyx_bshape_0_slab_size = __pyx_bstruct_slab_size.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_root_size, (PyObject*)__pyx_v_root_size, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_root_size = __pyx_bstruct_root_size.strides[0];
  __pyx_bshape_0_root_size = __pyx_bstruct_root_size.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":49
 *                      int offset = 36):
 *     cdef int strides[3]
 *     strides[0] = 1             # <<<<<<<<<<<<<<
 *     strides[1] = root_size[0] * strides[0]
 *     strides[2] = strides[1] * root_size[1] + 2
 */
  (__pyx_v_strides[0]) = 1;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":50
 *     cdef int strides[3]
 *     strides[0] = 1
 *     strides[1] = root_size[0] * strides[0]             # <<<<<<<<<<<<<<
 *     strides[2] = strides[1] * root_size[1] + 2
 *     cdef np.int64_t i, j, k
 */
  __pyx_t_1 = 0;
  (__pyx_v_strides[1]) = ((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_root_size.buf, __pyx_t_1, __pyx_bstride_0_root_size)) * (__pyx_v_strides[0]));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":51
 *     strides[0] = 1
 *     strides[1] = root_size[0] * strides[0]
 *     strides[2] = strides[1] * root_size[1] + 2             # <<<<<<<<<<<<<<
 *     cdef np.int64_t i, j, k
 *     cdef np.ndarray buffer = np.zeros(slab_size, dtype='float32', order='F')
 */
  __pyx_t_2 = 1;
  (__pyx_v_strides[2]) = (((__pyx_v_strides[1]) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_root_size.buf, __pyx_t_2, __pyx_bstride_0_root_size))) + 2);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":53
 *     strides[2] = strides[1] * root_size[1] + 2
 *     cdef np.int64_t i, j, k
 *     cdef np.ndarray buffer = np.zeros(slab_size, dtype='float32', order='F')             # <<<<<<<<<<<<<<
 *     cdef FILE *f = fopen(fn, "rb")
 *     #for i in range(3): offset += strides[i] * slab_start[i]
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_slab_size));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_slab_size));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_slab_size));
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)__pyx_n_s__float32)) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__order), ((PyObject *)__pyx_n_s__F)) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyEval_CallObjectWithKeywords(__pyx_t_4, __pyx_t_3, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_buffer = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":54
 *     cdef np.int64_t i, j, k
 *     cdef np.ndarray buffer = np.zeros(slab_size, dtype='float32', order='F')
 *     cdef FILE *f = fopen(fn, "rb")             # <<<<<<<<<<<<<<
 *     #for i in range(3): offset += strides[i] * slab_start[i]
 *     cdef np.int64_t pos = 0
 */
  __pyx_v_f = fopen(__pyx_v_fn, __pyx_k__rb);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":56
 *     cdef FILE *f = fopen(fn, "rb")
 *     #for i in range(3): offset += strides[i] * slab_start[i]
 *     cdef np.int64_t pos = 0             # <<<<<<<<<<<<<<
 *     cdef np.int64_t moff = 0
 *     cdef float *data = <float *> buffer.data
 */
  __pyx_v_pos = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":57
 *     #for i in range(3): offset += strides[i] * slab_start[i]
 *     cdef np.int64_t pos = 0
 *     cdef np.int64_t moff = 0             # <<<<<<<<<<<<<<
 *     cdef float *data = <float *> buffer.data
 *     fseek(f, offset, 0)
 */
  __pyx_v_moff = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":58
 *     cdef np.int64_t pos = 0
 *     cdef np.int64_t moff = 0
 *     cdef float *data = <float *> buffer.data             # <<<<<<<<<<<<<<
 *     fseek(f, offset, 0)
 *     # If anybody wants to convert this loop to a SEEK_CUR, that'd be great.
 */
  __pyx_v_data = ((float *)__pyx_v_buffer->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":59
 *     cdef np.int64_t moff = 0
 *     cdef float *data = <float *> buffer.data
 *     fseek(f, offset, 0)             # <<<<<<<<<<<<<<
 *     # If anybody wants to convert this loop to a SEEK_CUR, that'd be great.
 *     for i in range(slab_size[2]):
 */
  fseek(__pyx_v_f, __pyx_v_offset, 0);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":61
 *     fseek(f, offset, 0)
 *     # If anybody wants to convert this loop to a SEEK_CUR, that'd be great.
 *     for i in range(slab_size[2]):             # <<<<<<<<<<<<<<
 *         for j in range(slab_size[1]):
 *             moff = (slab_start[0]    ) * strides[0] \
 */
  __pyx_t_7 = 2;
  __pyx_t_8 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_slab_size.buf, __pyx_t_7, __pyx_bstride_0_slab_size));
  for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) {
    __pyx_v_i = __pyx_t_9;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":62
 *     # If anybody wants to convert this loop to a SEEK_CUR, that'd be great.
 *     for i in range(slab_size[2]):
 *         for j in range(slab_size[1]):             # <<<<<<<<<<<<<<
 *             moff = (slab_start[0]    ) * strides[0] \
 *                  + (slab_start[1] + j) * strides[1] \
 */
    __pyx_t_10 = 1;
    __pyx_t_11 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_slab_size.buf, __pyx_t_10, __pyx_bstride_0_slab_size));
    for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {
      __pyx_v_j = __pyx_t_12;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":63
 *     for i in range(slab_size[2]):
 *         for j in range(slab_size[1]):
 *             moff = (slab_start[0]    ) * strides[0] \             # <<<<<<<<<<<<<<
 *                  + (slab_start[1] + j) * strides[1] \
 *                  + (slab_start[2] + i) * strides[2]
 */
      __pyx_t_13 = 0;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":64
 *         for j in range(slab_size[1]):
 *             moff = (slab_start[0]    ) * strides[0] \
 *                  + (slab_start[1] + j) * strides[1] \             # <<<<<<<<<<<<<<
 *                  + (slab_start[2] + i) * strides[2]
 *             #print offset + 4 * moff, pos
 */
      __pyx_t_14 = 1;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":65
 *             moff = (slab_start[0]    ) * strides[0] \
 *                  + (slab_start[1] + j) * strides[1] \
 *                  + (slab_start[2] + i) * strides[2]             # <<<<<<<<<<<<<<
 *             #print offset + 4 * moff, pos
 *             fseek(f, offset + 4 * moff, SEEK_SET)
 */
      __pyx_t_15 = 2;
      __pyx_v_moff = ((((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_slab_start.buf, __pyx_t_13, __pyx_bstride_0_slab_start)) * (__pyx_v_strides[0])) + (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_slab_start.buf, __pyx_t_14, __pyx_bstride_0_slab_start)) + __pyx_v_j) * (__pyx_v_strides[1]))) + (((*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_slab_start.buf, __pyx_t_15, __pyx_bstride_0_slab_start)) + __pyx_v_i) * (__pyx_v_strides[2])));

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":67
 *                  + (slab_start[2] + i) * strides[2]
 *             #print offset + 4 * moff, pos
 *             fseek(f, offset + 4 * moff, SEEK_SET)             # <<<<<<<<<<<<<<
 *             fread(<void *> (data + pos), 4, slab_size[0], f)
 *             pos += slab_size[0]
 */
      fseek(__pyx_v_f, (__pyx_v_offset + (4 * __pyx_v_moff)), SEEK_SET);

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":68
 *             #print offset + 4 * moff, pos
 *             fseek(f, offset + 4 * moff, SEEK_SET)
 *             fread(<void *> (data + pos), 4, slab_size[0], f)             # <<<<<<<<<<<<<<
 *             pos += slab_size[0]
 *     return buffer
 */
      __pyx_t_16 = 0;
      fread(((void *)(__pyx_v_data + __pyx_v_pos)), 4, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_slab_size.buf, __pyx_t_16, __pyx_bstride_0_slab_size)), __pyx_v_f);

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":69
 *             fseek(f, offset + 4 * moff, SEEK_SET)
 *             fread(<void *> (data + pos), 4, slab_size[0], f)
 *             pos += slab_size[0]             # <<<<<<<<<<<<<<
 *     return buffer
 */
      __pyx_t_17 = 0;
      __pyx_v_pos += (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_slab_size.buf, __pyx_t_17, __pyx_bstride_0_slab_size));
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":70
 *             fread(<void *> (data + pos), 4, slab_size[0], f)
 *             pos += slab_size[0]
 *     return buffer             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_buffer));
  __pyx_r = ((PyObject *)__pyx_v_buffer);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_slab_size);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_slab_start);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_root_size);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.read_tiger_section");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_slab_size);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_slab_start);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_root_size);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_buffer);
  __Pyx_DECREF((PyObject *)__pyx_v_slab_start);
  __Pyx_DECREF((PyObject *)__pyx_v_slab_size);
  __Pyx_DECREF((PyObject *)__pyx_v_root_size);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":47
 *     QuadTreeNode *children[2][2]
 * 
 * cdef void QTN_add_value(QuadTreeNode *self,             # <<<<<<<<<<<<<<
 *         np.float64_t *val, np.float64_t weight_val):
 *     cdef int i
 */

static  void __pyx_f_2yt_9amr_utils_QTN_add_value(struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_v_self, __pyx_t_5numpy_float64_t *__pyx_v_val, __pyx_t_5numpy_float64_t __pyx_v_weight_val) {
  int __pyx_v_i;
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("QTN_add_value");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":50
 *         np.float64_t *val, np.float64_t weight_val):
 *     cdef int i
 *     for i in range(self.nvals):             # <<<<<<<<<<<<<<
 *         self.val[i] += val[i]
 *     self.weight_val += weight_val
 */
  __pyx_t_1 = __pyx_v_self->nvals;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":51
 *     cdef int i
 *     for i in range(self.nvals):
 *         self.val[i] += val[i]             # <<<<<<<<<<<<<<
 *     self.weight_val += weight_val
 * 
 */
    (__pyx_v_self->val[__pyx_v_i]) += (__pyx_v_val[__pyx_v_i]);
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":52
 *     for i in range(self.nvals):
 *         self.val[i] += val[i]
 *     self.weight_val += weight_val             # <<<<<<<<<<<<<<
 * 
 * cdef void QTN_refine(QuadTreeNode *self):
 */
  __pyx_v_self->weight_val += __pyx_v_weight_val;

  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":54
 *     self.weight_val += weight_val
 * 
 * cdef void QTN_refine(QuadTreeNode *self):             # <<<<<<<<<<<<<<
 *     cdef int i, j, i1, j1
 *     cdef np.int64_t npos[2]
 */

static  void __pyx_f_2yt_9amr_utils_QTN_refine(struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  __pyx_t_5numpy_int64_t __pyx_v_npos[2];
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("QTN_refine");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":58
 *     cdef np.int64_t npos[2]
 *     cdef QuadTreeNode *node
 *     for i in range(2):             # <<<<<<<<<<<<<<
 *         npos[0] = self.pos[0] * 2 + i
 *         for j in range(2):
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 2; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":59
 *     cdef QuadTreeNode *node
 *     for i in range(2):
 *         npos[0] = self.pos[0] * 2 + i             # <<<<<<<<<<<<<<
 *         for j in range(2):
 *             npos[1] = self.pos[1] * 2 + j
 */
    (__pyx_v_npos[0]) = (((__pyx_v_self->pos[0]) * 2) + __pyx_v_i);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":60
 *     for i in range(2):
 *         npos[0] = self.pos[0] * 2 + i
 *         for j in range(2):             # <<<<<<<<<<<<<<
 *             npos[1] = self.pos[1] * 2 + j
 *             # We have to be careful with allocation...
 */
    for (__pyx_t_2 = 0; __pyx_t_2 < 2; __pyx_t_2+=1) {
      __pyx_v_j = __pyx_t_2;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":61
 *         npos[0] = self.pos[0] * 2 + i
 *         for j in range(2):
 *             npos[1] = self.pos[1] * 2 + j             # <<<<<<<<<<<<<<
 *             # We have to be careful with allocation...
 *             self.children[i][j] = QTN_initialize(
 */
      (__pyx_v_npos[1]) = (((__pyx_v_self->pos[1]) * 2) + __pyx_v_j);

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":63
 *             npos[1] = self.pos[1] * 2 + j
 *             # We have to be careful with allocation...
 *             self.children[i][j] = QTN_initialize(             # <<<<<<<<<<<<<<
 *                         npos,
 *                         self.nvals, self.val, self.weight_val,
 */
      ((__pyx_v_self->children[__pyx_v_i])[__pyx_v_j]) = __pyx_f_2yt_9amr_utils_QTN_initialize(__pyx_v_npos, __pyx_v_self->nvals, __pyx_v_self->val, __pyx_v_self->weight_val, (__pyx_v_self->level + 1));
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":67
 *                         self.nvals, self.val, self.weight_val,
 *                         self.level + 1)
 *     for i in range(self.nvals): self.val[i] = 0.0             # <<<<<<<<<<<<<<
 *     self.weight_val = 0.0
 * 
 */
  __pyx_t_1 = __pyx_v_self->nvals;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;
    (__pyx_v_self->val[__pyx_v_i]) = 0.0;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":68
 *                         self.level + 1)
 *     for i in range(self.nvals): self.val[i] = 0.0
 *     self.weight_val = 0.0             # <<<<<<<<<<<<<<
 * 
 * cdef QuadTreeNode *QTN_initialize(np.int64_t pos[2], int nvals,
 */
  __pyx_v_self->weight_val = 0.0;

  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":70
 *     self.weight_val = 0.0
 * 
 * cdef QuadTreeNode *QTN_initialize(np.int64_t pos[2], int nvals,             # <<<<<<<<<<<<<<
 *                         np.float64_t *val, np.float64_t weight_val,
 *                         int level):
 */

static  struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_f_2yt_9amr_utils_QTN_initialize(__pyx_t_5numpy_int64_t *__pyx_v_pos, int __pyx_v_nvals, __pyx_t_5numpy_float64_t *__pyx_v_val, __pyx_t_5numpy_float64_t __pyx_v_weight_val, int __pyx_v_level) {
  struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_v_node;
  int __pyx_v_i;
  int __pyx_v_j;
  struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("QTN_initialize");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":75
 *     cdef QuadTreeNode *node
 *     cdef int i, j
 *     node = <QuadTreeNode *> malloc(sizeof(QuadTreeNode))             # <<<<<<<<<<<<<<
 *     node.pos[0] = pos[0]
 *     node.pos[1] = pos[1]
 */
  __pyx_v_node = ((struct __pyx_t_2yt_9amr_utils_QuadTreeNode *)malloc((sizeof(struct __pyx_t_2yt_9amr_utils_QuadTreeNode))));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":76
 *     cdef int i, j
 *     node = <QuadTreeNode *> malloc(sizeof(QuadTreeNode))
 *     node.pos[0] = pos[0]             # <<<<<<<<<<<<<<
 *     node.pos[1] = pos[1]
 *     node.nvals = nvals
 */
  (__pyx_v_node->pos[0]) = (__pyx_v_pos[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":77
 *     node = <QuadTreeNode *> malloc(sizeof(QuadTreeNode))
 *     node.pos[0] = pos[0]
 *     node.pos[1] = pos[1]             # <<<<<<<<<<<<<<
 *     node.nvals = nvals
 *     node.val = <np.float64_t *> malloc(
 */
  (__pyx_v_node->pos[1]) = (__pyx_v_pos[1]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":78
 *     node.pos[0] = pos[0]
 *     node.pos[1] = pos[1]
 *     node.nvals = nvals             # <<<<<<<<<<<<<<
 *     node.val = <np.float64_t *> malloc(
 *                 nvals * sizeof(np.float64_t))
 */
  __pyx_v_node->nvals = __pyx_v_nvals;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":79
 *     node.pos[1] = pos[1]
 *     node.nvals = nvals
 *     node.val = <np.float64_t *> malloc(             # <<<<<<<<<<<<<<
 *                 nvals * sizeof(np.float64_t))
 *     for i in range(nvals):
 */
  __pyx_v_node->val = ((__pyx_t_5numpy_float64_t *)malloc((__pyx_v_nvals * (sizeof(__pyx_t_5numpy_float64_t)))));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":81
 *     node.val = <np.float64_t *> malloc(
 *                 nvals * sizeof(np.float64_t))
 *     for i in range(nvals):             # <<<<<<<<<<<<<<
 *         node.val[i] = val[i]
 *     node.weight_val = weight_val
 */
  __pyx_t_1 = __pyx_v_nvals;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":82
 *                 nvals * sizeof(np.float64_t))
 *     for i in range(nvals):
 *         node.val[i] = val[i]             # <<<<<<<<<<<<<<
 *     node.weight_val = weight_val
 *     for i in range(2):
 */
    (__pyx_v_node->val[__pyx_v_i]) = (__pyx_v_val[__pyx_v_i]);
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":83
 *     for i in range(nvals):
 *         node.val[i] = val[i]
 *     node.weight_val = weight_val             # <<<<<<<<<<<<<<
 *     for i in range(2):
 *         for j in range(2):
 */
  __pyx_v_node->weight_val = __pyx_v_weight_val;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":84
 *         node.val[i] = val[i]
 *     node.weight_val = weight_val
 *     for i in range(2):             # <<<<<<<<<<<<<<
 *         for j in range(2):
 *             node.children[i][j] = NULL
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 2; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":85
 *     node.weight_val = weight_val
 *     for i in range(2):
 *         for j in range(2):             # <<<<<<<<<<<<<<
 *             node.children[i][j] = NULL
 *     node.level = level
 */
    for (__pyx_t_2 = 0; __pyx_t_2 < 2; __pyx_t_2+=1) {
      __pyx_v_j = __pyx_t_2;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":86
 *     for i in range(2):
 *         for j in range(2):
 *             node.children[i][j] = NULL             # <<<<<<<<<<<<<<
 *     node.level = level
 *     return node
 */
      ((__pyx_v_node->children[__pyx_v_i])[__pyx_v_j]) = NULL;
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":87
 *         for j in range(2):
 *             node.children[i][j] = NULL
 *     node.level = level             # <<<<<<<<<<<<<<
 *     return node
 * 
 */
  __pyx_v_node->level = __pyx_v_level;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":88
 *             node.children[i][j] = NULL
 *     node.level = level
 *     return node             # <<<<<<<<<<<<<<
 * 
 * cdef void QTN_free(QuadTreeNode *node):
 */
  __pyx_r = __pyx_v_node;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":90
 *     return node
 * 
 * cdef void QTN_free(QuadTreeNode *node):             # <<<<<<<<<<<<<<
 *     cdef int i, j
 *     for i in range(2):
 */

static  void __pyx_f_2yt_9amr_utils_QTN_free(struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_v_node) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("QTN_free");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":92
 * cdef void QTN_free(QuadTreeNode *node):
 *     cdef int i, j
 *     for i in range(2):             # <<<<<<<<<<<<<<
 *         for j in range(2):
 *             if node.children[i][j] == NULL: continue
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 2; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":93
 *     cdef int i, j
 *     for i in range(2):
 *         for j in range(2):             # <<<<<<<<<<<<<<
 *             if node.children[i][j] == NULL: continue
 *             QTN_free(node.children[i][j])
 */
    for (__pyx_t_2 = 0; __pyx_t_2 < 2; __pyx_t_2+=1) {
      __pyx_v_j = __pyx_t_2;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":94
 *     for i in range(2):
 *         for j in range(2):
 *             if node.children[i][j] == NULL: continue             # <<<<<<<<<<<<<<
 *             QTN_free(node.children[i][j])
 *     free(node.val)
 */
      __pyx_t_3 = (((__pyx_v_node->children[__pyx_v_i])[__pyx_v_j]) == NULL);
      if (__pyx_t_3) {
        goto __pyx_L5_continue;
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":95
 *         for j in range(2):
 *             if node.children[i][j] == NULL: continue
 *             QTN_free(node.children[i][j])             # <<<<<<<<<<<<<<
 *     free(node.val)
 *     free(node)
 */
      __pyx_f_2yt_9amr_utils_QTN_free(((__pyx_v_node->children[__pyx_v_i])[__pyx_v_j]));
      __pyx_L5_continue:;
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":96
 *             if node.children[i][j] == NULL: continue
 *             QTN_free(node.children[i][j])
 *     free(node.val)             # <<<<<<<<<<<<<<
 *     free(node)
 * 
 */
  free(__pyx_v_node->val);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":97
 *             QTN_free(node.children[i][j])
 *     free(node.val)
 *     free(node)             # <<<<<<<<<<<<<<
 * 
 * cdef class QuadTree:
 */
  free(__pyx_v_node);

  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":105
 *     cdef np.int64_t top_grid_dims[2]
 * 
 *     def __cinit__(self, np.ndarray[np.int64_t, ndim=1] top_grid_dims,             # <<<<<<<<<<<<<<
 *                   int nvals):
 *         cdef int i, j
 */

static int __pyx_pf_2yt_9amr_utils_8QuadTree___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_2yt_9amr_utils_8QuadTree___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyArrayObject *__pyx_v_top_grid_dims = 0;
  int __pyx_v_nvals;
  int __pyx_v_i;
  int __pyx_v_j;
  __pyx_t_5numpy_int64_t __pyx_v_pos[2];
  __pyx_t_5numpy_float64_t *__pyx_v_vals;
  __pyx_t_5numpy_float64_t __pyx_v_weight_val;
  Py_buffer __pyx_bstruct_top_grid_dims;
  Py_ssize_t __pyx_bstride_0_top_grid_dims = 0;
  Py_ssize_t __pyx_bshape_0_top_grid_dims = 0;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  long __pyx_t_3;
  long __pyx_t_4;
  long __pyx_t_5;
  long __pyx_t_6;
  __pyx_t_5numpy_int64_t __pyx_t_7;
  long __pyx_t_8;
  long __pyx_t_9;
  __pyx_t_5numpy_int64_t __pyx_t_10;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__top_grid_dims,&__pyx_n_s__nvals,0};
  __Pyx_RefNannySetupContext("__cinit__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__top_grid_dims);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nvals);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_top_grid_dims = ((PyArrayObject *)values[0]);
    __pyx_v_nvals = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_nvals == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_top_grid_dims = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_nvals = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_nvals == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.QuadTree.__cinit__");
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF((PyObject *)__pyx_v_top_grid_dims);
  __pyx_bstruct_top_grid_dims.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_top_grid_dims), __pyx_ptype_5numpy_ndarray, 1, "top_grid_dims", 0))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_top_grid_dims, (PyObject*)__pyx_v_top_grid_dims, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_top_grid_dims = __pyx_bstruct_top_grid_dims.strides[0];
  __pyx_bshape_0_top_grid_dims = __pyx_bstruct_top_grid_dims.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":111
 *         cdef np.int64_t pos[2]
 *         cdef np.float64_t *vals = <np.float64_t *> alloca(
 *                 sizeof(np.float64_t)*nvals)             # <<<<<<<<<<<<<<
 *         cdef np.float64_t weight_val = 0.0
 *         self.nvals = nvals
 */
  __pyx_v_vals = ((__pyx_t_5numpy_float64_t *)alloca(((sizeof(__pyx_t_5numpy_float64_t)) * __pyx_v_nvals)));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":112
 *         cdef np.float64_t *vals = <np.float64_t *> alloca(
 *                 sizeof(np.float64_t)*nvals)
 *         cdef np.float64_t weight_val = 0.0             # <<<<<<<<<<<<<<
 *         self.nvals = nvals
 *         for i in range(nvals): vals[i] = 0.0
 */
  __pyx_v_weight_val = 0.0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":113
 *                 sizeof(np.float64_t)*nvals)
 *         cdef np.float64_t weight_val = 0.0
 *         self.nvals = nvals             # <<<<<<<<<<<<<<
 *         for i in range(nvals): vals[i] = 0.0
 * 
 */
  ((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->nvals = __pyx_v_nvals;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":114
 *         cdef np.float64_t weight_val = 0.0
 *         self.nvals = nvals
 *         for i in range(nvals): vals[i] = 0.0             # <<<<<<<<<<<<<<
 * 
 *         self.top_grid_dims[0] = top_grid_dims[0]
 */
  __pyx_t_1 = __pyx_v_nvals;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;
    (__pyx_v_vals[__pyx_v_i]) = 0.0;
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":116
 *         for i in range(nvals): vals[i] = 0.0
 * 
 *         self.top_grid_dims[0] = top_grid_dims[0]             # <<<<<<<<<<<<<<
 *         self.top_grid_dims[1] = top_grid_dims[1]
 * 
 */
  __pyx_t_3 = 0;
  __pyx_t_1 = -1;
  if (__pyx_t_3 < 0) {
    __pyx_t_3 += __pyx_bshape_0_top_grid_dims;
    if (unlikely(__pyx_t_3 < 0)) __pyx_t_1 = 0;
  } else if (unlikely(__pyx_t_3 >= __pyx_bshape_0_top_grid_dims)) __pyx_t_1 = 0;
  if (unlikely(__pyx_t_1 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_1);
    {__pyx_filename = __pyx_f[10]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  (((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->top_grid_dims[0]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_top_grid_dims.buf, __pyx_t_3, __pyx_bstride_0_top_grid_dims));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":117
 * 
 *         self.top_grid_dims[0] = top_grid_dims[0]
 *         self.top_grid_dims[1] = top_grid_dims[1]             # <<<<<<<<<<<<<<
 * 
 *         # This wouldn't be necessary if we did bitshifting...
 */
  __pyx_t_4 = 1;
  __pyx_t_1 = -1;
  if (__pyx_t_4 < 0) {
    __pyx_t_4 += __pyx_bshape_0_top_grid_dims;
    if (unlikely(__pyx_t_4 < 0)) __pyx_t_1 = 0;
  } else if (unlikely(__pyx_t_4 >= __pyx_bshape_0_top_grid_dims)) __pyx_t_1 = 0;
  if (unlikely(__pyx_t_1 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_1);
    {__pyx_filename = __pyx_f[10]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  (((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->top_grid_dims[1]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_top_grid_dims.buf, __pyx_t_4, __pyx_bstride_0_top_grid_dims));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":120
 * 
 *         # This wouldn't be necessary if we did bitshifting...
 *         for i in range(80):             # <<<<<<<<<<<<<<
 *             self.po2[i] = 2**i
 *         self.root_nodes = <QuadTreeNode ***> \
 */
  for (__pyx_t_1 = 0; __pyx_t_1 < 80; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":121
 *         # This wouldn't be necessary if we did bitshifting...
 *         for i in range(80):
 *             self.po2[i] = 2**i             # <<<<<<<<<<<<<<
 *         self.root_nodes = <QuadTreeNode ***> \
 *             malloc(sizeof(QuadTreeNode **) * top_grid_dims[0])
 */
    (((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->po2[__pyx_v_i]) = __Pyx_pow_long(2, __pyx_v_i);
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":123
 *             self.po2[i] = 2**i
 *         self.root_nodes = <QuadTreeNode ***> \
 *             malloc(sizeof(QuadTreeNode **) * top_grid_dims[0])             # <<<<<<<<<<<<<<
 * 
 *         # We initialize our root values to 0.0.
 */
  __pyx_t_5 = 0;
  __pyx_t_1 = -1;
  if (__pyx_t_5 < 0) {
    __pyx_t_5 += __pyx_bshape_0_top_grid_dims;
    if (unlikely(__pyx_t_5 < 0)) __pyx_t_1 = 0;
  } else if (unlikely(__pyx_t_5 >= __pyx_bshape_0_top_grid_dims)) __pyx_t_1 = 0;
  if (unlikely(__pyx_t_1 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_1);
    {__pyx_filename = __pyx_f[10]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":122
 *         for i in range(80):
 *             self.po2[i] = 2**i
 *         self.root_nodes = <QuadTreeNode ***> \             # <<<<<<<<<<<<<<
 *             malloc(sizeof(QuadTreeNode **) * top_grid_dims[0])
 * 
 */
  ((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->root_nodes = ((struct __pyx_t_2yt_9amr_utils_QuadTreeNode ***)malloc(((sizeof(struct __pyx_t_2yt_9amr_utils_QuadTreeNode **)) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_top_grid_dims.buf, __pyx_t_5, __pyx_bstride_0_top_grid_dims)))));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":126
 * 
 *         # We initialize our root values to 0.0.
 *         for i in range(top_grid_dims[0]):             # <<<<<<<<<<<<<<
 *             pos[0] = i
 *             self.root_nodes[i] = <QuadTreeNode **> \
 */
  __pyx_t_6 = 0;
  __pyx_t_1 = -1;
  if (__pyx_t_6 < 0) {
    __pyx_t_6 += __pyx_bshape_0_top_grid_dims;
    if (unlikely(__pyx_t_6 < 0)) __pyx_t_1 = 0;
  } else if (unlikely(__pyx_t_6 >= __pyx_bshape_0_top_grid_dims)) __pyx_t_1 = 0;
  if (unlikely(__pyx_t_1 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_1);
    {__pyx_filename = __pyx_f[10]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_top_grid_dims.buf, __pyx_t_6, __pyx_bstride_0_top_grid_dims));
  for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_7; __pyx_t_1+=1) {
    __pyx_v_i = __pyx_t_1;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":127
 *         # We initialize our root values to 0.0.
 *         for i in range(top_grid_dims[0]):
 *             pos[0] = i             # <<<<<<<<<<<<<<
 *             self.root_nodes[i] = <QuadTreeNode **> \
 *                 malloc(sizeof(QuadTreeNode *) * top_grid_dims[1])
 */
    (__pyx_v_pos[0]) = __pyx_v_i;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":129
 *             pos[0] = i
 *             self.root_nodes[i] = <QuadTreeNode **> \
 *                 malloc(sizeof(QuadTreeNode *) * top_grid_dims[1])             # <<<<<<<<<<<<<<
 *             for j in range(top_grid_dims[1]):
 *                 pos[1] = j
 */
    __pyx_t_8 = 1;
    __pyx_t_2 = -1;
    if (__pyx_t_8 < 0) {
      __pyx_t_8 += __pyx_bshape_0_top_grid_dims;
      if (unlikely(__pyx_t_8 < 0)) __pyx_t_2 = 0;
    } else if (unlikely(__pyx_t_8 >= __pyx_bshape_0_top_grid_dims)) __pyx_t_2 = 0;
    if (unlikely(__pyx_t_2 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_2);
      {__pyx_filename = __pyx_f[10]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":128
 *         for i in range(top_grid_dims[0]):
 *             pos[0] = i
 *             self.root_nodes[i] = <QuadTreeNode **> \             # <<<<<<<<<<<<<<
 *                 malloc(sizeof(QuadTreeNode *) * top_grid_dims[1])
 *             for j in range(top_grid_dims[1]):
 */
    (((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->root_nodes[__pyx_v_i]) = ((struct __pyx_t_2yt_9amr_utils_QuadTreeNode **)malloc(((sizeof(struct __pyx_t_2yt_9amr_utils_QuadTreeNode *)) * (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_top_grid_dims.buf, __pyx_t_8, __pyx_bstride_0_top_grid_dims)))));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":130
 *             self.root_nodes[i] = <QuadTreeNode **> \
 *                 malloc(sizeof(QuadTreeNode *) * top_grid_dims[1])
 *             for j in range(top_grid_dims[1]):             # <<<<<<<<<<<<<<
 *                 pos[1] = j
 *                 self.root_nodes[i][j] = QTN_initialize(
 */
    __pyx_t_9 = 1;
    __pyx_t_2 = -1;
    if (__pyx_t_9 < 0) {
      __pyx_t_9 += __pyx_bshape_0_top_grid_dims;
      if (unlikely(__pyx_t_9 < 0)) __pyx_t_2 = 0;
    } else if (unlikely(__pyx_t_9 >= __pyx_bshape_0_top_grid_dims)) __pyx_t_2 = 0;
    if (unlikely(__pyx_t_2 != -1)) {
      __Pyx_RaiseBufferIndexError(__pyx_t_2);
      {__pyx_filename = __pyx_f[10]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_t_10 = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_top_grid_dims.buf, __pyx_t_9, __pyx_bstride_0_top_grid_dims));
    for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_10; __pyx_t_2+=1) {
      __pyx_v_j = __pyx_t_2;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":131
 *                 malloc(sizeof(QuadTreeNode *) * top_grid_dims[1])
 *             for j in range(top_grid_dims[1]):
 *                 pos[1] = j             # <<<<<<<<<<<<<<
 *                 self.root_nodes[i][j] = QTN_initialize(
 *                     pos, nvals, vals, weight_val, 0)
 */
      (__pyx_v_pos[1]) = __pyx_v_j;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":132
 *             for j in range(top_grid_dims[1]):
 *                 pos[1] = j
 *                 self.root_nodes[i][j] = QTN_initialize(             # <<<<<<<<<<<<<<
 *                     pos, nvals, vals, weight_val, 0)
 * 
 */
      ((((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->root_nodes[__pyx_v_i])[__pyx_v_j]) = __pyx_f_2yt_9amr_utils_QTN_initialize(__pyx_v_pos, __pyx_v_nvals, __pyx_v_vals, __pyx_v_weight_val, 0);
    }
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_top_grid_dims);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.QuadTree.__cinit__");
  __pyx_r = -1;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_top_grid_dims);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF((PyObject *)__pyx_v_top_grid_dims);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":135
 *                     pos, nvals, vals, weight_val, 0)
 * 
 *     cdef void add_to_position(self,             # <<<<<<<<<<<<<<
 *                  int level, np.int64_t pos[2],
 *                  np.float64_t *val,
 */

static  void __pyx_f_2yt_9amr_utils_8QuadTree_add_to_position(struct __pyx_obj_2yt_9amr_utils_QuadTree *__pyx_v_self, int __pyx_v_level, __pyx_t_5numpy_int64_t *__pyx_v_pos, __pyx_t_5numpy_float64_t *__pyx_v_val, __pyx_t_5numpy_float64_t __pyx_v_weight_val) {
  int __pyx_v_i;
  int __pyx_v_j;
  struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_v_node;
  __pyx_t_5numpy_int64_t __pyx_v_fac;
  PyObject *__pyx_v_L;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  __Pyx_RefNannySetupContext("add_to_position");
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_L = Py_None; __Pyx_INCREF(Py_None);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":141
 *         cdef int i, j
 *         cdef QuadTreeNode *node
 *         node = self.find_on_root_level(pos, level)             # <<<<<<<<<<<<<<
 *         cdef np.int64_t fac
 *         for L in range(level):
 */
  __pyx_v_node = ((struct __pyx_vtabstruct_2yt_9amr_utils_QuadTree *)__pyx_v_self->__pyx_vtab)->find_on_root_level(__pyx_v_self, __pyx_v_pos, __pyx_v_level);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":143
 *         node = self.find_on_root_level(pos, level)
 *         cdef np.int64_t fac
 *         for L in range(level):             # <<<<<<<<<<<<<<
 *             if node.children[0][0] == NULL:
 *                 QTN_refine(node)
 */
  __pyx_t_2 = PyInt_FromLong(__pyx_v_level); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
    __pyx_t_1 = 0; __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3);
  } else {
    __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_t_3))) {
      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
      if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++;
    } else {
      __pyx_t_2 = PyIter_Next(__pyx_t_3);
      if (!__pyx_t_2) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_DECREF(__pyx_v_L);
    __pyx_v_L = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":144
 *         cdef np.int64_t fac
 *         for L in range(level):
 *             if node.children[0][0] == NULL:             # <<<<<<<<<<<<<<
 *                 QTN_refine(node)
 *             # Maybe we should use bitwise operators?
 */
    __pyx_t_4 = (((__pyx_v_node->children[0])[0]) == NULL);
    if (__pyx_t_4) {

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":145
 *         for L in range(level):
 *             if node.children[0][0] == NULL:
 *                 QTN_refine(node)             # <<<<<<<<<<<<<<
 *             # Maybe we should use bitwise operators?
 *             fac = self.po2[level - L - 1]
 */
      __pyx_f_2yt_9amr_utils_QTN_refine(__pyx_v_node);
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":147
 *                 QTN_refine(node)
 *             # Maybe we should use bitwise operators?
 *             fac = self.po2[level - L - 1]             # <<<<<<<<<<<<<<
 *             i = (pos[0] >= fac*(2*node.pos[0]+1))
 *             j = (pos[1] >= fac*(2*node.pos[1]+1))
 */
    __pyx_t_2 = PyInt_FromLong(__pyx_v_level); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyNumber_Subtract(__pyx_t_2, __pyx_v_L); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_fac = (__pyx_v_self->po2[__pyx_t_6]);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":148
 *             # Maybe we should use bitwise operators?
 *             fac = self.po2[level - L - 1]
 *             i = (pos[0] >= fac*(2*node.pos[0]+1))             # <<<<<<<<<<<<<<
 *             j = (pos[1] >= fac*(2*node.pos[1]+1))
 *             node = node.children[i][j]
 */
    __pyx_v_i = ((__pyx_v_pos[0]) >= (__pyx_v_fac * ((2 * (__pyx_v_node->pos[0])) + 1)));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":149
 *             fac = self.po2[level - L - 1]
 *             i = (pos[0] >= fac*(2*node.pos[0]+1))
 *             j = (pos[1] >= fac*(2*node.pos[1]+1))             # <<<<<<<<<<<<<<
 *             node = node.children[i][j]
 *         QTN_add_value(node, val, weight_val)
 */
    __pyx_v_j = ((__pyx_v_pos[1]) >= (__pyx_v_fac * ((2 * (__pyx_v_node->pos[1])) + 1)));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":150
 *             i = (pos[0] >= fac*(2*node.pos[0]+1))
 *             j = (pos[1] >= fac*(2*node.pos[1]+1))
 *             node = node.children[i][j]             # <<<<<<<<<<<<<<
 *         QTN_add_value(node, val, weight_val)
 * 
 */
    __pyx_v_node = ((__pyx_v_node->children[__pyx_v_i])[__pyx_v_j]);
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":151
 *             j = (pos[1] >= fac*(2*node.pos[1]+1))
 *             node = node.children[i][j]
 *         QTN_add_value(node, val, weight_val)             # <<<<<<<<<<<<<<
 * 
 *     cdef QuadTreeNode *find_on_root_level(self, np.int64_t pos[2], int level):
 */
  __pyx_f_2yt_9amr_utils_QTN_add_value(__pyx_v_node, __pyx_v_val, __pyx_v_weight_val);

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("yt.amr_utils.QuadTree.add_to_position");
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_L);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":153
 *         QTN_add_value(node, val, weight_val)
 * 
 *     cdef QuadTreeNode *find_on_root_level(self, np.int64_t pos[2], int level):             # <<<<<<<<<<<<<<
 *         # We need this because the root level won't just have four children
 *         # So we find on the root level, then we traverse the tree.
 */

static  struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_f_2yt_9amr_utils_8QuadTree_find_on_root_level(struct __pyx_obj_2yt_9amr_utils_QuadTree *__pyx_v_self, __pyx_t_5numpy_int64_t *__pyx_v_pos, int __pyx_v_level) {
  __pyx_t_5numpy_int64_t __pyx_v_i;
  __pyx_t_5numpy_int64_t __pyx_v_j;
  struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_r;
  __Pyx_RefNannySetupContext("find_on_root_level");

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":157
 *         # So we find on the root level, then we traverse the tree.
 *         cdef np.int64_t i, j
 *         i = <np.int64_t> (pos[0] / self.po2[level])             # <<<<<<<<<<<<<<
 *         j = <np.int64_t> (pos[1] / self.po2[level])
 *         return self.root_nodes[i][j]
 */
  __pyx_v_i = ((__pyx_t_5numpy_int64_t)((__pyx_v_pos[0]) / (__pyx_v_self->po2[__pyx_v_level])));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":158
 *         cdef np.int64_t i, j
 *         i = <np.int64_t> (pos[0] / self.po2[level])
 *         j = <np.int64_t> (pos[1] / self.po2[level])             # <<<<<<<<<<<<<<
 *         return self.root_nodes[i][j]
 * 
 */
  __pyx_v_j = ((__pyx_t_5numpy_int64_t)((__pyx_v_pos[1]) / (__pyx_v_self->po2[__pyx_v_level])));

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":159
 *         i = <np.int64_t> (pos[0] / self.po2[level])
 *         j = <np.int64_t> (pos[1] / self.po2[level])
 *         return self.root_nodes[i][j]             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((__pyx_v_self->root_nodes[__pyx_v_i])[__pyx_v_j]);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":164
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def add_array_to_tree(self, int level,             # <<<<<<<<<<<<<<
 *             np.ndarray[np.int64_t, ndim=1] pxs,
 *             np.ndarray[np.int64_t, ndim=1] pys,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_8QuadTree_add_array_to_tree(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_8QuadTree_add_array_to_tree(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_level;
  PyArrayObject *__pyx_v_pxs = 0;
  PyArrayObject *__pyx_v_pys = 0;
  PyArrayObject *__pyx_v_pvals = 0;
  PyArrayObject *__pyx_v_pweight_vals = 0;
  int __pyx_v_np;
  int __pyx_v_p;
  __pyx_t_5numpy_float64_t *__pyx_v_vals;
  __pyx_t_5numpy_float64_t *__pyx_v_data;
  __pyx_t_5numpy_int64_t __pyx_v_pos[2];
  Py_buffer __pyx_bstruct_pweight_vals;
  Py_ssize_t __pyx_bstride_0_pweight_vals = 0;
  Py_ssize_t __pyx_bshape_0_pweight_vals = 0;
  Py_buffer __pyx_bstruct_pxs;
  Py_ssize_t __pyx_bstride_0_pxs = 0;
  Py_ssize_t __pyx_bshape_0_pxs = 0;
  Py_buffer __pyx_bstruct_pvals;
  Py_ssize_t __pyx_bstride_0_pvals = 0;
  Py_ssize_t __pyx_bstride_1_pvals = 0;
  Py_ssize_t __pyx_bshape_0_pvals = 0;
  Py_ssize_t __pyx_bshape_1_pvals = 0;
  Py_buffer __pyx_bstruct_pys;
  Py_ssize_t __pyx_bstride_0_pys = 0;
  Py_ssize_t __pyx_bshape_0_pys = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__level,&__pyx_n_s__pxs,&__pyx_n_s__pys,&__pyx_n_s__pvals,&__pyx_n_s__pweight_vals,0};
  __Pyx_RefNannySetupContext("add_array_to_tree");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__level);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pxs);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_array_to_tree", 1, 5, 5, 1); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pys);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_array_to_tree", 1, 5, 5, 2); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pvals);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_array_to_tree", 1, 5, 5, 3); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pweight_vals);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_array_to_tree", 1, 5, 5, 4); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "add_array_to_tree") < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_level = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_level == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_pxs = ((PyArrayObject *)values[1]);
    __pyx_v_pys = ((PyArrayObject *)values[2]);
    __pyx_v_pvals = ((PyArrayObject *)values[3]);
    __pyx_v_pweight_vals = ((PyArrayObject *)values[4]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_level = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_level == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_pxs = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_pys = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_pvals = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_pweight_vals = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_array_to_tree", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.QuadTree.add_array_to_tree");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __Pyx_INCREF((PyObject *)__pyx_v_pxs);
  __Pyx_INCREF((PyObject *)__pyx_v_pys);
  __Pyx_INCREF((PyObject *)__pyx_v_pvals);
  __Pyx_INCREF((PyObject *)__pyx_v_pweight_vals);
  __pyx_bstruct_pxs.buf = NULL;
  __pyx_bstruct_pys.buf = NULL;
  __pyx_bstruct_pvals.buf = NULL;
  __pyx_bstruct_pweight_vals.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pxs), __pyx_ptype_5numpy_ndarray, 1, "pxs", 0))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pys), __pyx_ptype_5numpy_ndarray, 1, "pys", 0))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pvals), __pyx_ptype_5numpy_ndarray, 1, "pvals", 0))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pweight_vals), __pyx_ptype_5numpy_ndarray, 1, "pweight_vals", 0))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_pxs, (PyObject*)__pyx_v_pxs, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_pxs = __pyx_bstruct_pxs.strides[0];
  __pyx_bshape_0_pxs = __pyx_bstruct_pxs.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_pys, (PyObject*)__pyx_v_pys, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_pys = __pyx_bstruct_pys.strides[0];
  __pyx_bshape_0_pys = __pyx_bstruct_pys.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_pvals, (PyObject*)__pyx_v_pvals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_pvals = __pyx_bstruct_pvals.strides[0]; __pyx_bstride_1_pvals = __pyx_bstruct_pvals.strides[1];
  __pyx_bshape_0_pvals = __pyx_bstruct_pvals.shape[0]; __pyx_bshape_1_pvals = __pyx_bstruct_pvals.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_pweight_vals, (PyObject*)__pyx_v_pweight_vals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_pweight_vals = __pyx_bstruct_pweight_vals.strides[0];
  __pyx_bshape_0_pweight_vals = __pyx_bstruct_pweight_vals.shape[0];

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":169
 *             np.ndarray[np.float64_t, ndim=2] pvals,
 *             np.ndarray[np.float64_t, ndim=1] pweight_vals):
 *         cdef int np = pxs.shape[0]             # <<<<<<<<<<<<<<
 *         cdef int p
 *         cdef cnp.float64_t *vals
 */
  __pyx_v_np = (__pyx_v_pxs->dimensions[0]);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":172
 *         cdef int p
 *         cdef cnp.float64_t *vals
 *         cdef cnp.float64_t *data = <cnp.float64_t *> pvals.data             # <<<<<<<<<<<<<<
 *         cdef cnp.int64_t pos[2]
 *         for p in range(np):
 */
  __pyx_v_data = ((__pyx_t_5numpy_float64_t *)__pyx_v_pvals->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":174
 *         cdef cnp.float64_t *data = <cnp.float64_t *> pvals.data
 *         cdef cnp.int64_t pos[2]
 *         for p in range(np):             # <<<<<<<<<<<<<<
 *             vals = data + self.nvals*p
 *             pos[0] = pxs[p]
 */
  __pyx_t_1 = __pyx_v_np;
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_p = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":175
 *         cdef cnp.int64_t pos[2]
 *         for p in range(np):
 *             vals = data + self.nvals*p             # <<<<<<<<<<<<<<
 *             pos[0] = pxs[p]
 *             pos[1] = pys[p]
 */
    __pyx_v_vals = (__pyx_v_data + (((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->nvals * __pyx_v_p));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":176
 *         for p in range(np):
 *             vals = data + self.nvals*p
 *             pos[0] = pxs[p]             # <<<<<<<<<<<<<<
 *             pos[1] = pys[p]
 *             self.add_to_position(level, pos, vals, pweight_vals[p])
 */
    __pyx_t_3 = __pyx_v_p;
    (__pyx_v_pos[0]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_pxs.buf, __pyx_t_3, __pyx_bstride_0_pxs));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":177
 *             vals = data + self.nvals*p
 *             pos[0] = pxs[p]
 *             pos[1] = pys[p]             # <<<<<<<<<<<<<<
 *             self.add_to_position(level, pos, vals, pweight_vals[p])
 * 
 */
    __pyx_t_4 = __pyx_v_p;
    (__pyx_v_pos[1]) = (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_int64_t *, __pyx_bstruct_pys.buf, __pyx_t_4, __pyx_bstride_0_pys));

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":178
 *             pos[0] = pxs[p]
 *             pos[1] = pys[p]
 *             self.add_to_position(level, pos, vals, pweight_vals[p])             # <<<<<<<<<<<<<<
 * 
 *     def add_grid_to_tree(self, int level,
 */
    __pyx_t_5 = __pyx_v_p;
    ((struct __pyx_vtabstruct_2yt_9amr_utils_QuadTree *)((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->__pyx_vtab)->add_to_position(((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self), __pyx_v_level, __pyx_v_pos, __pyx_v_vals, (*__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_pweight_vals.buf, __pyx_t_5, __pyx_bstride_0_pweight_vals)));
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pweight_vals);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pxs);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pvals);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pys);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.QuadTree.add_array_to_tree");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pweight_vals);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pxs);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pvals);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pys);
  __pyx_L2:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_DECREF((PyObject *)__pyx_v_pxs);
  __Pyx_DECREF((PyObject *)__pyx_v_pys);
  __Pyx_DECREF((PyObject *)__pyx_v_pvals);
  __Pyx_DECREF((PyObject *)__pyx_v_pweight_vals);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":180
 *             self.add_to_position(level, pos, vals, pweight_vals[p])
 * 
 *     def add_grid_to_tree(self, int level,             # <<<<<<<<<<<<<<
 *                          np.ndarray[np.int64_t, ndim=1] start_index,
 *                          np.ndarray[np.float64_t, ndim=2] pvals,
 */

static PyObject *__pyx_pf_2yt_9amr_utils_8QuadTree_add_grid_to_tree(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_8QuadTree_add_grid_to_tree(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_level;
  PyArrayObject *__pyx_v_start_index = 0;
  PyArrayObject *__pyx_v_pvals = 0;
  PyArrayObject *__pyx_v_wvals = 0;
  PyArrayObject *__pyx_v_cm = 0;
  Py_buffer __pyx_bstruct_cm;
  Py_ssize_t __pyx_bstride_0_cm = 0;
  Py_ssize_t __pyx_bstride_1_cm = 0;
  Py_ssize_t __pyx_bshape_0_cm = 0;
  Py_ssize_t __pyx_bshape_1_cm = 0;
  Py_buffer __pyx_bstruct_pvals;
  Py_ssize_t __pyx_bstride_0_pvals = 0;
  Py_ssize_t __pyx_bstride_1_pvals = 0;
  Py_ssize_t __pyx_bshape_0_pvals = 0;
  Py_ssize_t __pyx_bshape_1_pvals = 0;
  Py_buffer __pyx_bstruct_wvals;
  Py_ssize_t __pyx_bstride_0_wvals = 0;
  Py_ssize_t __pyx_bstride_1_wvals = 0;
  Py_ssize_t __pyx_bshape_0_wvals = 0;
  Py_ssize_t __pyx_bshape_1_wvals = 0;
  Py_buffer __pyx_bstruct_start_index;
  Py_ssize_t __pyx_bstride_0_start_index = 0;
  Py_ssize_t __pyx_bshape_0_start_index = 0;
  PyObject *__pyx_r = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__level,&__pyx_n_s__start_index,&__pyx_n_s__pvals,&__pyx_n_s__wvals,&__pyx_n_s__cm,0};
  __Pyx_RefNannySetupContext("add_grid_to_tree");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__level);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start_index);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_grid_to_tree", 1, 5, 5, 1); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pvals);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_grid_to_tree", 1, 5, 5, 2); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__wvals);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_grid_to_tree", 1, 5, 5, 3); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cm);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("add_grid_to_tree", 1, 5, 5, 4); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "add_grid_to_tree") < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_level = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_level == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_start_index = ((PyArrayObject *)values[1]);
    __pyx_v_pvals = ((PyArrayObject *)values[2]);
    __pyx_v_wvals = ((PyArrayObject *)values[3]);
    __pyx_v_cm = ((PyArrayObject *)values[4]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_level = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_level == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_start_index = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 1));
    __pyx_v_pvals = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 2));
    __pyx_v_wvals = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 3));
    __pyx_v_cm = ((PyArrayObject *)PyTuple_GET_ITEM(__pyx_args, 4));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("add_grid_to_tree", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.QuadTree.add_grid_to_tree");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_bstruct_start_index.buf = NULL;
  __pyx_bstruct_pvals.buf = NULL;
  __pyx_bstruct_wvals.buf = NULL;
  __pyx_bstruct_cm.buf = NULL;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_start_index), __pyx_ptype_5numpy_ndarray, 1, "start_index", 0))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pvals), __pyx_ptype_5numpy_ndarray, 1, "pvals", 0))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_wvals), __pyx_ptype_5numpy_ndarray, 1, "wvals", 0))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cm), __pyx_ptype_5numpy_ndarray, 1, "cm", 0))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_start_index, (PyObject*)__pyx_v_start_index, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_start_index = __pyx_bstruct_start_index.strides[0];
  __pyx_bshape_0_start_index = __pyx_bstruct_start_index.shape[0];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_pvals, (PyObject*)__pyx_v_pvals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_pvals = __pyx_bstruct_pvals.strides[0]; __pyx_bstride_1_pvals = __pyx_bstruct_pvals.strides[1];
  __pyx_bshape_0_pvals = __pyx_bstruct_pvals.shape[0]; __pyx_bshape_1_pvals = __pyx_bstruct_pvals.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_wvals, (PyObject*)__pyx_v_wvals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_wvals = __pyx_bstruct_wvals.strides[0]; __pyx_bstride_1_wvals = __pyx_bstruct_wvals.strides[1];
  __pyx_bshape_0_wvals = __pyx_bstruct_wvals.shape[0]; __pyx_bshape_1_wvals = __pyx_bstruct_wvals.shape[1];
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_cm, (PyObject*)__pyx_v_cm, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int32_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_bstride_0_cm = __pyx_bstruct_cm.strides[0]; __pyx_bstride_1_cm = __pyx_bstruct_cm.strides[1];
  __pyx_bshape_0_cm = __pyx_bstruct_cm.shape[0]; __pyx_bshape_1_cm = __pyx_bstruct_cm.shape[1];

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_cm);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pvals);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_wvals);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_start_index);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.QuadTree.add_grid_to_tree");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_cm);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_pvals);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_wvals);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_start_index);
  __pyx_L2:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":189
 *     @cython.boundscheck(False)
 *     @cython.wraparound(False)
 *     def get_all_from_level(self, int level, int count_only = 0):             # <<<<<<<<<<<<<<
 *         cdef int i, j
 *         cdef int total = 0
 */

static PyObject *__pyx_pf_2yt_9amr_utils_8QuadTree_get_all_from_level(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_2yt_9amr_utils_8QuadTree_get_all_from_level(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_level;
  int __pyx_v_count_only;
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_total;
  PyObject *__pyx_v_vals;
  PyArrayObject *__pyx_v_npos;
  PyArrayObject *__pyx_v_nvals;
  PyArrayObject *__pyx_v_nwvals;
  __pyx_t_5numpy_int64_t __pyx_v_curpos;
  __pyx_t_5numpy_int64_t *__pyx_v_pdata;
  __pyx_t_5numpy_float64_t *__pyx_v_vdata;
  __pyx_t_5numpy_float64_t *__pyx_v_wdata;
  Py_buffer __pyx_bstruct_nwvals;
  Py_ssize_t __pyx_bstride_0_nwvals = 0;
  Py_ssize_t __pyx_bshape_0_nwvals = 0;
  Py_buffer __pyx_bstruct_nvals;
  Py_ssize_t __pyx_bstride_0_nvals = 0;
  Py_ssize_t __pyx_bstride_1_nvals = 0;
  Py_ssize_t __pyx_bshape_0_nvals = 0;
  Py_ssize_t __pyx_bshape_1_nvals = 0;
  Py_buffer __pyx_bstruct_npos;
  Py_ssize_t __pyx_bstride_0_npos = 0;
  Py_ssize_t __pyx_bstride_1_npos = 0;
  Py_ssize_t __pyx_bshape_0_npos = 0;
  Py_ssize_t __pyx_bshape_1_npos = 0;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __pyx_t_5numpy_int64_t __pyx_t_2;
  int __pyx_t_3;
  __pyx_t_5numpy_int64_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyArrayObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyArrayObject *__pyx_t_13 = NULL;
  PyArrayObject *__pyx_t_14 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__level,&__pyx_n_s__count_only,0};
  __Pyx_RefNannySetupContext("get_all_from_level");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__level);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      if (kw_args > 1) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__count_only);
        if (unlikely(value)) { values[1] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "get_all_from_level") < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_level = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_level == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    if (values[1]) {
      __pyx_v_count_only = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_count_only == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    } else {
      __pyx_v_count_only = ((int)0);
    }
  } else {
    __pyx_v_count_only = ((int)0);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_count_only = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_count_only == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      case  1: __pyx_v_level = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_level == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_all_from_level", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[10]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("yt.amr_utils.QuadTree.get_all_from_level");
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_vals = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_npos = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_nvals = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_nwvals = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_bstruct_npos.buf = NULL;
  __pyx_bstruct_nvals.buf = NULL;
  __pyx_bstruct_nwvals.buf = NULL;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":191
 *     def get_all_from_level(self, int level, int count_only = 0):
 *         cdef int i, j
 *         cdef int total = 0             # <<<<<<<<<<<<<<
 *         vals = []
 *         for i in range(self.top_grid_dims[0]):
 */
  __pyx_v_total = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":192
 *         cdef int i, j
 *         cdef int total = 0
 *         vals = []             # <<<<<<<<<<<<<<
 *         for i in range(self.top_grid_dims[0]):
 *             for j in range(self.top_grid_dims[1]):
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_DECREF(__pyx_v_vals);
  __pyx_v_vals = ((PyObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":193
 *         cdef int total = 0
 *         vals = []
 *         for i in range(self.top_grid_dims[0]):             # <<<<<<<<<<<<<<
 *             for j in range(self.top_grid_dims[1]):
 *                 total += self.count_at_level(self.root_nodes[i][j], level)
 */
  __pyx_t_2 = (((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->top_grid_dims[0]);
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":194
 *         vals = []
 *         for i in range(self.top_grid_dims[0]):
 *             for j in range(self.top_grid_dims[1]):             # <<<<<<<<<<<<<<
 *                 total += self.count_at_level(self.root_nodes[i][j], level)
 *         if count_only: return total
 */
    __pyx_t_4 = (((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->top_grid_dims[1]);
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_j = __pyx_t_5;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":195
 *         for i in range(self.top_grid_dims[0]):
 *             for j in range(self.top_grid_dims[1]):
 *                 total += self.count_at_level(self.root_nodes[i][j], level)             # <<<<<<<<<<<<<<
 *         if count_only: return total
 *         # Allocate our array
 */
      __pyx_v_total += ((struct __pyx_vtabstruct_2yt_9amr_utils_QuadTree *)((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->__pyx_vtab)->count_at_level(((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self), ((((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->root_nodes[__pyx_v_i])[__pyx_v_j]), __pyx_v_level);
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":196
 *             for j in range(self.top_grid_dims[1]):
 *                 total += self.count_at_level(self.root_nodes[i][j], level)
 *         if count_only: return total             # <<<<<<<<<<<<<<
 *         # Allocate our array
 *         cdef np.ndarray[np.int64_t, ndim=2] npos
 */
  __pyx_t_3 = __pyx_v_count_only;
  if (__pyx_t_3) {
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_1 = PyInt_FromLong(__pyx_v_total); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_r = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":201
 *         cdef np.ndarray[np.float64_t, ndim=2] nvals
 *         cdef np.ndarray[np.float64_t, ndim=1] nwvals
 *         npos = np.zeros( (total, 2), dtype='int64')             # <<<<<<<<<<<<<<
 *         nvals = np.zeros( (total, self.nvals), dtype='float64')
 *         nwvals = np.zeros( total, dtype='float64')
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyInt_FromLong(__pyx_v_total); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_2);
  __Pyx_GIVEREF(__pyx_int_2);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
  if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)__pyx_n_s__int64)) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = PyEval_CallObjectWithKeywords(__pyx_t_6, __pyx_t_1, ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_npos);
    __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_npos, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_3 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_npos, (PyObject*)__pyx_v_npos, &__Pyx_TypeInfo_nn___pyx_t_5numpy_int64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_bstride_0_npos = __pyx_bstruct_npos.strides[0]; __pyx_bstride_1_npos = __pyx_bstruct_npos.strides[1];
    __pyx_bshape_0_npos = __pyx_bstruct_npos.shape[0]; __pyx_bshape_1_npos = __pyx_bstruct_npos.shape[1];
    if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_9 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_v_npos));
  __pyx_v_npos = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":202
 *         cdef np.ndarray[np.float64_t, ndim=1] nwvals
 *         npos = np.zeros( (total, 2), dtype='int64')
 *         nvals = np.zeros( (total, self.nvals), dtype='float64')             # <<<<<<<<<<<<<<
 *         nwvals = np.zeros( total, dtype='float64')
 *         cdef np.int64_t curpos = 0
 */
  __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__zeros); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyInt_FromLong(__pyx_v_total); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->nvals); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_8 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)__pyx_n_s__float64)) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = PyEval_CallObjectWithKeywords(__pyx_t_7, __pyx_t_1, ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_13 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_nvals);
    __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_nvals, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_3 < 0)) {
      PyErr_Fetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_nvals, (PyObject*)__pyx_v_nvals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
      }
    }
    __pyx_bstride_0_nvals = __pyx_bstruct_nvals.strides[0]; __pyx_bstride_1_nvals = __pyx_bstruct_nvals.strides[1];
    __pyx_bshape_0_nvals = __pyx_bstruct_nvals.shape[0]; __pyx_bshape_1_nvals = __pyx_bstruct_nvals.shape[1];
    if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_13 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_v_nvals));
  __pyx_v_nvals = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":203
 *         npos = np.zeros( (total, 2), dtype='int64')
 *         nvals = np.zeros( (total, self.nvals), dtype='float64')
 *         nwvals = np.zeros( total, dtype='float64')             # <<<<<<<<<<<<<<
 *         cdef np.int64_t curpos = 0
 *         cdef np.int64_t *pdata = <np.int64_t *> npos.data
 */
  __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__zeros); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyInt_FromLong(__pyx_v_total); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_8));
  if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__dtype), ((PyObject *)__pyx_n_s__float64)) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = PyEval_CallObjectWithKeywords(__pyx_t_6, __pyx_t_1, ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_7);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_nwvals);
    __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_nwvals, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_3 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_nwvals, (PyObject*)__pyx_v_nwvals, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
      }
    }
    __pyx_bstride_0_nwvals = __pyx_bstruct_nwvals.strides[0];
    __pyx_bshape_0_nwvals = __pyx_bstruct_nwvals.shape[0];
    if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_14 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_v_nwvals));
  __pyx_v_nwvals = ((PyArrayObject *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":204
 *         nvals = np.zeros( (total, self.nvals), dtype='float64')
 *         nwvals = np.zeros( total, dtype='float64')
 *         cdef np.int64_t curpos = 0             # <<<<<<<<<<<<<<
 *         cdef np.int64_t *pdata = <np.int64_t *> npos.data
 *         cdef np.float64_t *vdata = <np.float64_t *> nvals.data
 */
  __pyx_v_curpos = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":205
 *         nwvals = np.zeros( total, dtype='float64')
 *         cdef np.int64_t curpos = 0
 *         cdef np.int64_t *pdata = <np.int64_t *> npos.data             # <<<<<<<<<<<<<<
 *         cdef np.float64_t *vdata = <np.float64_t *> nvals.data
 *         cdef np.float64_t *wdata = <np.float64_t *> nwvals.data
 */
  __pyx_v_pdata = ((__pyx_t_5numpy_int64_t *)__pyx_v_npos->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":206
 *         cdef np.int64_t curpos = 0
 *         cdef np.int64_t *pdata = <np.int64_t *> npos.data
 *         cdef np.float64_t *vdata = <np.float64_t *> nvals.data             # <<<<<<<<<<<<<<
 *         cdef np.float64_t *wdata = <np.float64_t *> nwvals.data
 *         for i in range(self.top_grid_dims[0]):
 */
  __pyx_v_vdata = ((__pyx_t_5numpy_float64_t *)__pyx_v_nvals->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":207
 *         cdef np.int64_t *pdata = <np.int64_t *> npos.data
 *         cdef np.float64_t *vdata = <np.float64_t *> nvals.data
 *         cdef np.float64_t *wdata = <np.float64_t *> nwvals.data             # <<<<<<<<<<<<<<
 *         for i in range(self.top_grid_dims[0]):
 *             for j in range(self.top_grid_dims[1]):
 */
  __pyx_v_wdata = ((__pyx_t_5numpy_float64_t *)__pyx_v_nwvals->data);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":208
 *         cdef np.float64_t *vdata = <np.float64_t *> nvals.data
 *         cdef np.float64_t *wdata = <np.float64_t *> nwvals.data
 *         for i in range(self.top_grid_dims[0]):             # <<<<<<<<<<<<<<
 *             for j in range(self.top_grid_dims[1]):
 *                 curpos += self.fill_from_level(self.root_nodes[i][j],
 */
  __pyx_t_2 = (((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->top_grid_dims[0]);
  for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":209
 *         cdef np.float64_t *wdata = <np.float64_t *> nwvals.data
 *         for i in range(self.top_grid_dims[0]):
 *             for j in range(self.top_grid_dims[1]):             # <<<<<<<<<<<<<<
 *                 curpos += self.fill_from_level(self.root_nodes[i][j],
 *                     level, curpos, pdata, vdata, wdata)
 */
    __pyx_t_4 = (((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->top_grid_dims[1]);
    for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      __pyx_v_j = __pyx_t_5;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":211
 *             for j in range(self.top_grid_dims[1]):
 *                 curpos += self.fill_from_level(self.root_nodes[i][j],
 *                     level, curpos, pdata, vdata, wdata)             # <<<<<<<<<<<<<<
 *         return npos, nvals, nwvals
 * 
 */
      __pyx_v_curpos += ((struct __pyx_vtabstruct_2yt_9amr_utils_QuadTree *)((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->__pyx_vtab)->fill_from_level(((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self), ((((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->root_nodes[__pyx_v_i])[__pyx_v_j]), __pyx_v_level, __pyx_v_curpos, __pyx_v_pdata, __pyx_v_vdata, __pyx_v_wdata);
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":212
 *                 curpos += self.fill_from_level(self.root_nodes[i][j],
 *                     level, curpos, pdata, vdata, wdata)
 *         return npos, nvals, nwvals             # <<<<<<<<<<<<<<
 * 
 *     cdef int count_at_level(self, QuadTreeNode *node, int level):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(((PyObject *)__pyx_v_npos));
  PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_npos));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_npos));
  __Pyx_INCREF(((PyObject *)__pyx_v_nvals));
  PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_v_nvals));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_nvals));
  __Pyx_INCREF(((PyObject *)__pyx_v_nwvals));
  PyTuple_SET_ITEM(__pyx_t_7, 2, ((PyObject *)__pyx_v_nwvals));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_nwvals));
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_nwvals);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_nvals);
    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_npos);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("yt.amr_utils.QuadTree.get_all_from_level");
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_nwvals);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_nvals);
  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_npos);
  __pyx_L2:;
  __Pyx_DECREF(__pyx_v_vals);
  __Pyx_DECREF((PyObject *)__pyx_v_npos);
  __Pyx_DECREF((PyObject *)__pyx_v_nvals);
  __Pyx_DECREF((PyObject *)__pyx_v_nwvals);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":214
 *         return npos, nvals, nwvals
 * 
 *     cdef int count_at_level(self, QuadTreeNode *node, int level):             # <<<<<<<<<<<<<<
 *         cdef int i, j
 *         # We only really return a non-zero, calculated value if we are at the
 */

static  int __pyx_f_2yt_9amr_utils_8QuadTree_count_at_level(struct __pyx_obj_2yt_9amr_utils_QuadTree *__pyx_v_self, struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_v_node, int __pyx_v_level) {
  int __pyx_v_i;
  int __pyx_v_j;
  int __pyx_v_count;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("count_at_level");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":218
 *         # We only really return a non-zero, calculated value if we are at the
 *         # level in question.
 *         if node.level == level:             # <<<<<<<<<<<<<<
 *             # We return 1 if there are no finer points at this level and zero
 *             # if there are
 */
  __pyx_t_1 = (__pyx_v_node->level == __pyx_v_level);
  if (__pyx_t_1) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":221
 *             # We return 1 if there are no finer points at this level and zero
 *             # if there are
 *             return (node.children[0][0] == NULL)             # <<<<<<<<<<<<<<
 *         if node.children[0][0] == NULL: return 0
 *         cdef int count = 0
 */
    __pyx_r = (((__pyx_v_node->children[0])[0]) == NULL);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":222
 *             # if there are
 *             return (node.children[0][0] == NULL)
 *         if node.children[0][0] == NULL: return 0             # <<<<<<<<<<<<<<
 *         cdef int count = 0
 *         for i in range(2):
 */
  __pyx_t_1 = (((__pyx_v_node->children[0])[0]) == NULL);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":223
 *             return (node.children[0][0] == NULL)
 *         if node.children[0][0] == NULL: return 0
 *         cdef int count = 0             # <<<<<<<<<<<<<<
 *         for i in range(2):
 *             for j in range(2):
 */
  __pyx_v_count = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":224
 *         if node.children[0][0] == NULL: return 0
 *         cdef int count = 0
 *         for i in range(2):             # <<<<<<<<<<<<<<
 *             for j in range(2):
 *                 count += self.count_at_level(node.children[i][j], level)
 */
  for (__pyx_t_2 = 0; __pyx_t_2 < 2; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":225
 *         cdef int count = 0
 *         for i in range(2):
 *             for j in range(2):             # <<<<<<<<<<<<<<
 *                 count += self.count_at_level(node.children[i][j], level)
 *         return count
 */
    for (__pyx_t_3 = 0; __pyx_t_3 < 2; __pyx_t_3+=1) {
      __pyx_v_j = __pyx_t_3;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":226
 *         for i in range(2):
 *             for j in range(2):
 *                 count += self.count_at_level(node.children[i][j], level)             # <<<<<<<<<<<<<<
 *         return count
 * 
 */
      __pyx_v_count += ((struct __pyx_vtabstruct_2yt_9amr_utils_QuadTree *)__pyx_v_self->__pyx_vtab)->count_at_level(__pyx_v_self, ((__pyx_v_node->children[__pyx_v_i])[__pyx_v_j]), __pyx_v_level);
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":227
 *             for j in range(2):
 *                 count += self.count_at_level(node.children[i][j], level)
 *         return count             # <<<<<<<<<<<<<<
 * 
 *     cdef int fill_from_level(self, QuadTreeNode *node, int level,
 */
  __pyx_r = __pyx_v_count;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":229
 *         return count
 * 
 *     cdef int fill_from_level(self, QuadTreeNode *node, int level,             # <<<<<<<<<<<<<<
 *                               np.int64_t curpos,
 *                               np.int64_t *pdata,
 */

static  int __pyx_f_2yt_9amr_utils_8QuadTree_fill_from_level(struct __pyx_obj_2yt_9amr_utils_QuadTree *__pyx_v_self, struct __pyx_t_2yt_9amr_utils_QuadTreeNode *__pyx_v_node, int __pyx_v_level, __pyx_t_5numpy_int64_t __pyx_v_curpos, __pyx_t_5numpy_int64_t *__pyx_v_pdata, __pyx_t_5numpy_float64_t *__pyx_v_vdata, __pyx_t_5numpy_float64_t *__pyx_v_wdata) {
  int __pyx_v_i;
  int __pyx_v_j;
  __pyx_t_5numpy_int64_t __pyx_v_added;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("fill_from_level");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":235
 *                               np.float64_t *wdata):
 *         cdef int i, j
 *         if node.level == level:             # <<<<<<<<<<<<<<
 *             if node.children[0][0] != NULL: return 0
 *             for i in range(self.nvals):
 */
  __pyx_t_1 = (__pyx_v_node->level == __pyx_v_level);
  if (__pyx_t_1) {

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":236
 *         cdef int i, j
 *         if node.level == level:
 *             if node.children[0][0] != NULL: return 0             # <<<<<<<<<<<<<<
 *             for i in range(self.nvals):
 *                 vdata[self.nvals * curpos + i] = node.val[i]
 */
    __pyx_t_1 = (((__pyx_v_node->children[0])[0]) != NULL);
    if (__pyx_t_1) {
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":237
 *         if node.level == level:
 *             if node.children[0][0] != NULL: return 0
 *             for i in range(self.nvals):             # <<<<<<<<<<<<<<
 *                 vdata[self.nvals * curpos + i] = node.val[i]
 *             wdata[curpos] = node.weight_val
 */
    __pyx_t_2 = __pyx_v_self->nvals;
    for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
      __pyx_v_i = __pyx_t_3;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":238
 *             if node.children[0][0] != NULL: return 0
 *             for i in range(self.nvals):
 *                 vdata[self.nvals * curpos + i] = node.val[i]             # <<<<<<<<<<<<<<
 *             wdata[curpos] = node.weight_val
 *             pdata[curpos * 2] = node.pos[0]
 */
      (__pyx_v_vdata[((__pyx_v_self->nvals * __pyx_v_curpos) + __pyx_v_i)]) = (__pyx_v_node->val[__pyx_v_i]);
    }

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":239
 *             for i in range(self.nvals):
 *                 vdata[self.nvals * curpos + i] = node.val[i]
 *             wdata[curpos] = node.weight_val             # <<<<<<<<<<<<<<
 *             pdata[curpos * 2] = node.pos[0]
 *             pdata[curpos * 2 + 1] = node.pos[1]
 */
    (__pyx_v_wdata[__pyx_v_curpos]) = __pyx_v_node->weight_val;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":240
 *                 vdata[self.nvals * curpos + i] = node.val[i]
 *             wdata[curpos] = node.weight_val
 *             pdata[curpos * 2] = node.pos[0]             # <<<<<<<<<<<<<<
 *             pdata[curpos * 2 + 1] = node.pos[1]
 *             return 1
 */
    (__pyx_v_pdata[(__pyx_v_curpos * 2)]) = (__pyx_v_node->pos[0]);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":241
 *             wdata[curpos] = node.weight_val
 *             pdata[curpos * 2] = node.pos[0]
 *             pdata[curpos * 2 + 1] = node.pos[1]             # <<<<<<<<<<<<<<
 *             return 1
 *         if node.children[0][0] == NULL: return 0
 */
    (__pyx_v_pdata[((__pyx_v_curpos * 2) + 1)]) = (__pyx_v_node->pos[1]);

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":242
 *             pdata[curpos * 2] = node.pos[0]
 *             pdata[curpos * 2 + 1] = node.pos[1]
 *             return 1             # <<<<<<<<<<<<<<
 *         if node.children[0][0] == NULL: return 0
 *         cdef np.int64_t added = 0
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":243
 *             pdata[curpos * 2 + 1] = node.pos[1]
 *             return 1
 *         if node.children[0][0] == NULL: return 0             # <<<<<<<<<<<<<<
 *         cdef np.int64_t added = 0
 *         for i in range(2):
 */
  __pyx_t_1 = (((__pyx_v_node->children[0])[0]) == NULL);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":244
 *             return 1
 *         if node.children[0][0] == NULL: return 0
 *         cdef np.int64_t added = 0             # <<<<<<<<<<<<<<
 *         for i in range(2):
 *             for j in range(2):
 */
  __pyx_v_added = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":245
 *         if node.children[0][0] == NULL: return 0
 *         cdef np.int64_t added = 0
 *         for i in range(2):             # <<<<<<<<<<<<<<
 *             for j in range(2):
 *                 added += self.fill_from_level(node.children[i][j],
 */
  for (__pyx_t_2 = 0; __pyx_t_2 < 2; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":246
 *         cdef np.int64_t added = 0
 *         for i in range(2):
 *             for j in range(2):             # <<<<<<<<<<<<<<
 *                 added += self.fill_from_level(node.children[i][j],
 *                         level, curpos + added, pdata, vdata, wdata)
 */
    for (__pyx_t_3 = 0; __pyx_t_3 < 2; __pyx_t_3+=1) {
      __pyx_v_j = __pyx_t_3;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":248
 *             for j in range(2):
 *                 added += self.fill_from_level(node.children[i][j],
 *                         level, curpos + added, pdata, vdata, wdata)             # <<<<<<<<<<<<<<
 *         return added
 * 
 */
      __pyx_v_added += ((struct __pyx_vtabstruct_2yt_9amr_utils_QuadTree *)__pyx_v_self->__pyx_vtab)->fill_from_level(__pyx_v_self, ((__pyx_v_node->children[__pyx_v_i])[__pyx_v_j]), __pyx_v_level, (__pyx_v_curpos + __pyx_v_added), __pyx_v_pdata, __pyx_v_vdata, __pyx_v_wdata);
    }
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":249
 *                 added += self.fill_from_level(node.children[i][j],
 *                         level, curpos + added, pdata, vdata, wdata)
 *         return added             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_r = __pyx_v_added;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":251
 *         return added
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         cdef int i, j
 *         for i in range(self.top_grid_dims[0]):
 */

static void __pyx_pf_2yt_9amr_utils_8QuadTree___dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_2yt_9amr_utils_8QuadTree___dealloc__(PyObject *__pyx_v_self) {
  int __pyx_v_i;
  int __pyx_v_j;
  __pyx_t_5numpy_int64_t __pyx_t_1;
  int __pyx_t_2;
  __pyx_t_5numpy_int64_t __pyx_t_3;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("__dealloc__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":253
 *     def __dealloc__(self):
 *         cdef int i, j
 *         for i in range(self.top_grid_dims[0]):             # <<<<<<<<<<<<<<
 *             for j in range(self.top_grid_dims[1]):
 *                 QTN_free(self.root_nodes[i][j])
 */
  __pyx_t_1 = (((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->top_grid_dims[0]);
  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
    __pyx_v_i = __pyx_t_2;

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":254
 *         cdef int i, j
 *         for i in range(self.top_grid_dims[0]):
 *             for j in range(self.top_grid_dims[1]):             # <<<<<<<<<<<<<<
 *                 QTN_free(self.root_nodes[i][j])
 *             free(self.root_nodes[i])
 */
    __pyx_t_3 = (((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->top_grid_dims[1]);
    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
      __pyx_v_j = __pyx_t_4;

      /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":255
 *         for i in range(self.top_grid_dims[0]):
 *             for j in range(self.top_grid_dims[1]):
 *                 QTN_free(self.root_nodes[i][j])             # <<<<<<<<<<<<<<
 *             free(self.root_nodes[i])
 *         free(self.root_nodes)
 */
      __pyx_f_2yt_9amr_utils_QTN_free(((((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->root_nodes[__pyx_v_i])[__pyx_v_j]));
    }

    /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":256
 *             for j in range(self.top_grid_dims[1]):
 *                 QTN_free(self.root_nodes[i][j])
 *             free(self.root_nodes[i])             # <<<<<<<<<<<<<<
 *         free(self.root_nodes)
 */
    free((((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->root_nodes[__pyx_v_i]));
  }

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":257
 *                 QTN_free(self.root_nodes[i][j])
 *             free(self.root_nodes[i])
 *         free(self.root_nodes)             # <<<<<<<<<<<<<<
 */
  free(((struct __pyx_obj_2yt_9amr_utils_QuadTree *)__pyx_v_self)->root_nodes);

  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
}

/* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":187
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_v_copy_shape;
  int __pyx_v_i;
  int __pyx_v_ndim;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  int __pyx_v_t;
  char *__pyx_v_f;
  PyArray_Descr *__pyx_v_descr = 0;
  int __pyx_v_offset;
  int __pyx_v_hasfields;
  int __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  char *__pyx_t_9;
  __Pyx_RefNannySetupContext("__getbuffer__");
  if (__pyx_v_info == NULL) return 0;
  __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(__pyx_v_info->obj);
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":193
 *             # of flags
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 */
  __pyx_v_endian_detector = 1;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":194
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 * 
 *             ndim = PyArray_NDIM(self)
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":196
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 *             ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_v_ndim = PyArray_NDIM(((PyArrayObject *)__pyx_v_self));

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":198
 *             ndim = PyArray_NDIM(self)
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 copy_shape = 1
 *             else:
 */
  __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
  if (__pyx_t_1) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":199
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 copy_shape = 1             # <<<<<<<<<<<<<<
 *             else:
 *                 copy_shape = 0
 */
    __pyx_v_copy_shape = 1;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":201
 *                 copy_shape = 1
 *             else:
 *                 copy_shape = 0             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 */
    __pyx_v_copy_shape = 0;
  }
  __pyx_L5:;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":203
 *                 copy_shape = 0
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  __pyx_t_1 = ((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS);
  if (__pyx_t_1) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":204
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 */
    __pyx_t_2 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_C_CONTIGUOUS));
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":205
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_kp_u_7));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_u_7));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_7));
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[11]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":207
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  __pyx_t_3 = ((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS);
  if (__pyx_t_3) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":208
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 */
    __pyx_t_1 = (!PyArray_CHKFLAGS(((PyArrayObject *)__pyx_v_self), NPY_F_CONTIGUOUS));
    __pyx_t_2 = __pyx_t_1;
  } else {
    __pyx_t_2 = __pyx_t_3;
  }
  if (__pyx_t_2) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":209
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(((PyObject *)__pyx_kp_u_8));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_u_8));
    __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_8));
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[11]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":211
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
 *             info.ndim = ndim
 *             if copy_shape:
 */
  __pyx_v_info->buf = PyArray_DATA(((PyArrayObject *)__pyx_v_self));

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":212
 * 
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim             # <<<<<<<<<<<<<<
 *             if copy_shape:
 *                 # Allocate new buffer for strides and shape info. This is allocated
 */
  __pyx_v_info->ndim = __pyx_v_ndim;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":213
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim
 *             if copy_shape:             # <<<<<<<<<<<<<<
 *                 # Allocate new buffer for strides and shape info. This is allocated
 *                 # as one block, strides first.
 */
  __pyx_t_6 = __pyx_v_copy_shape;
  if (__pyx_t_6) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":216
 *                 # Allocate new buffer for strides and shape info. This is allocated
 *                 # as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)             # <<<<<<<<<<<<<<
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 */
    __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * __pyx_v_ndim) * 2)));

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":217
 *                 # as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)
 *                 info.shape = info.strides + ndim             # <<<<<<<<<<<<<<
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 */
    __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":218
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2)
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):             # <<<<<<<<<<<<<<
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 */
    __pyx_t_6 = __pyx_v_ndim;
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
      __pyx_v_i = __pyx_t_7;

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":219
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]             # <<<<<<<<<<<<<<
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 */
      (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]);

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":220
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]             # <<<<<<<<<<<<<<
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 */
      (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(((PyArrayObject *)__pyx_v_self))[__pyx_v_i]);
    }
    goto __pyx_L8;
  }
  /*else*/ {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":222
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 */
    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(((PyArrayObject *)__pyx_v_self)));

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":223
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)             # <<<<<<<<<<<<<<
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 */
    __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(((PyArrayObject *)__pyx_v_self)));
  }
  __pyx_L8:;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":224
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 */
  __pyx_v_info->suboffsets = NULL;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":225
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)             # <<<<<<<<<<<<<<
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 * 
 */
  __pyx_v_info->itemsize = PyArray_ITEMSIZE(((PyArrayObject *)__pyx_v_self));

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":226
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)             # <<<<<<<<<<<<<<
 * 
 *             cdef int t
 */
  __pyx_v_info->readonly = (!PyArray_ISWRITEABLE(((PyArrayObject *)__pyx_v_self)));

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":229
 * 
 *             cdef int t
 *             cdef char* f = NULL             # <<<<<<<<<<<<<<
 *             cdef dtype descr = self.descr
 *             cdef list stack
 */
  __pyx_v_f = NULL;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":230
 *             cdef int t
 *             cdef char* f = NULL
 *             cdef dtype descr = self.descr             # <<<<<<<<<<<<<<
 *             cdef list stack
 *             cdef int offset
 */
  __Pyx_INCREF(((PyObject *)((PyArrayObject *)__pyx_v_self)->descr));
  __pyx_v_descr = ((PyArrayObject *)__pyx_v_self)->descr;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":234
 *             cdef int offset
 * 
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields and not copy_shape:
 */
  __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":236
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)
 * 
 *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
 *                 # do not call releasebuffer
 *                 info.obj = None
 */
  __pyx_t_2 = (!__pyx_v_hasfields);
  if (__pyx_t_2) {
    __pyx_t_3 = (!__pyx_v_copy_shape);
    __pyx_t_1 = __pyx_t_3;
  } else {
    __pyx_t_1 = __pyx_t_2;
  }
  if (__pyx_t_1) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":238
 *             if not hasfields and not copy_shape:
 *                 # do not call releasebuffer
 *                 info.obj = None             # <<<<<<<<<<<<<<
 *             else:
 *                 # need to call releasebuffer
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = Py_None;
    goto __pyx_L11;
  }
  /*else*/ {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":241
 *             else:
 *                 # need to call releasebuffer
 *                 info.obj = self             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields:
 */
    __Pyx_INCREF(__pyx_v_self);
    __Pyx_GIVEREF(__pyx_v_self);
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = __pyx_v_self;
  }
  __pyx_L11:;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":243
 *                 info.obj = self
 * 
 *             if not hasfields:             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == '>' and little_endian) or
 */
  __pyx_t_1 = (!__pyx_v_hasfields);
  if (__pyx_t_1) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":244
 * 
 *             if not hasfields:
 *                 t = descr.type_num             # <<<<<<<<<<<<<<
 *                 if ((descr.byteorder == '>' and little_endian) or
 *                     (descr.byteorder == '<' and not little_endian)):
 */
    __pyx_v_t = __pyx_v_descr->type_num;

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":245
 *             if not hasfields:
 *                 t = descr.type_num
 *                 if ((descr.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == '<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_1 = (__pyx_v_descr->byteorder == '>');
    if (__pyx_t_1) {
      __pyx_t_2 = __pyx_v_little_endian;
    } else {
      __pyx_t_2 = __pyx_t_1;
    }
    if (!__pyx_t_2) {

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":246
 *                 t = descr.type_num
 *                 if ((descr.byteorder == '>' and little_endian) or
 *                     (descr.byteorder == '<' and not little_endian)):             # <<<<<<<<<<<<<<
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 */
      __pyx_t_1 = (__pyx_v_descr->byteorder == '<');
      if (__pyx_t_1) {
        __pyx_t_3 = (!__pyx_v_little_endian);
        __pyx_t_8 = __pyx_t_3;
      } else {
        __pyx_t_8 = __pyx_t_1;
      }
      __pyx_t_1 = __pyx_t_8;
    } else {
      __pyx_t_1 = __pyx_t_2;
    }
    if (__pyx_t_1) {

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":247
 *                 if ((descr.byteorder == '>' and little_endian) or
 *                     (descr.byteorder == '<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(((PyObject *)__pyx_kp_u_9));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_u_9));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_9));
      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[11]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L13;
    }
    __pyx_L13:;

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":248
 *                     (descr.byteorder == '<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_BYTE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__b;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":249
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_UBYTE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__B;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":250
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_SHORT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__h;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":251
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_USHORT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__H;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":252
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_INT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__i;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":253
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_UINT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__I;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":254
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_LONG);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__l;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":255
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_ULONG);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__L;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":256
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_LONGLONG);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__q;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":257
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_ULONGLONG);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__Q;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":258
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_FLOAT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__f;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":259
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_DOUBLE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__d;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":260
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_LONGDOUBLE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__g;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":261
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_CFLOAT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__Zf;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":262
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"
 */
    __pyx_t_1 = (__pyx_v_t == NPY_CDOUBLE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__Zd;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":263
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 */
    __pyx_t_1 = (__pyx_v_t == NPY_CLONGDOUBLE);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__Zg;
      goto __pyx_L14;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":264
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
    __pyx_t_1 = (__pyx_v_t == NPY_OBJECT);
    if (__pyx_t_1) {
      __pyx_v_f = __pyx_k__O;
      goto __pyx_L14;
    }
    /*else*/ {

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":266
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *                 info.format = f
 *                 return
 */
      __pyx_t_5 = PyInt_FromLong(__pyx_v_t); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_10), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_4, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      {__pyx_filename = __pyx_f[11]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L14:;

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":267
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f             # <<<<<<<<<<<<<<
 *                 return
 *             else:
 */
    __pyx_v_info->format = __pyx_v_f;

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":268
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f
 *                 return             # <<<<<<<<<<<<<<
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L12;
  }
  /*else*/ {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":270
 *                 return
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)             # <<<<<<<<<<<<<<
 *                 info.format[0] = '^' # Native data types, manual alignment
 *                 offset = 0
 */
    __pyx_v_info->format = ((char *)malloc(255));

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":271
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = '^' # Native data types, manual alignment             # <<<<<<<<<<<<<<
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,
 */
    (__pyx_v_info->format[0]) = '^';

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":272
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = '^' # Native data types, manual alignment
 *                 offset = 0             # <<<<<<<<<<<<<<
 *                 f = _util_dtypestring(descr, info.format + 1,
 *                                       info.format + _buffer_format_string_len,
 */
    __pyx_v_offset = 0;

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":275
 *                 f = _util_dtypestring(descr, info.format + 1,
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)             # <<<<<<<<<<<<<<
 *                 f[0] = 0 # Terminate format string
 * 
 */
    __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_f = __pyx_t_9;

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":276
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 *                 f[0] = 0 # Terminate format string             # <<<<<<<<<<<<<<
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 */
    (__pyx_v_f[0]) = 0;
  }
  __pyx_L12:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__");
  __pyx_r = -1;
  __Pyx_GOTREF(__pyx_v_info->obj);
  __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_descr);
  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":278
 *                 f[0] = 0 # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static void __pyx_pf_5numpy_7ndarray___releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__releasebuffer__");
  __Pyx_INCREF((PyObject *)__pyx_v_self);

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":279
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_t_1 = PyArray_HASFIELDS(((PyArrayObject *)__pyx_v_self));
  if (__pyx_t_1) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":280
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)             # <<<<<<<<<<<<<<
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)
 */
    free(__pyx_v_info->format);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":281
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.strides)
 *                 # info.shape was stored after info.strides in the same block
 */
  __pyx_t_1 = ((sizeof(npy_intp)) != (sizeof(Py_ssize_t)));
  if (__pyx_t_1) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":282
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)             # <<<<<<<<<<<<<<
 *                 # info.shape was stored after info.strides in the same block
 * 
 */
    free(__pyx_v_info->strides);
    goto __pyx_L6;
  }
  __pyx_L6:;

  __Pyx_DECREF((PyObject *)__pyx_v_self);
  __Pyx_RefNannyFinishContext();
}

/* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":755
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew1");

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":756
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":758
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew2");

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":759
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":761
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew3");

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":762
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":764
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew4");

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":765
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":767
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew5");

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":768
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":770
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
  PyArray_Descr *__pyx_v_child;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  PyObject *__pyx_v_fields;
  PyObject *__pyx_v_childname;
  PyObject *__pyx_v_new_offset;
  PyObject *__pyx_v_t;
  char *__pyx_r;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  char *__pyx_t_10;
  __Pyx_RefNannySetupContext("_util_dtypestring");
  __Pyx_INCREF((PyObject *)__pyx_v_descr);
  __pyx_v_child = ((PyArray_Descr *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_fields = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_childname = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_new_offset = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_t = Py_None; __Pyx_INCREF(Py_None);

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":777
 *     cdef int delta_offset
 *     cdef tuple i
 *     cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 *     cdef tuple fields
 */
  __pyx_v_endian_detector = 1;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":778
 *     cdef tuple i
 *     cdef int endian_detector = 1
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 *     cdef tuple fields
 * 
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":781
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  if (likely(((PyObject *)__pyx_v_descr->names) != Py_None)) {
    __pyx_t_1 = 0; __pyx_t_2 = ((PyObject *)__pyx_v_descr->names); __Pyx_INCREF(__pyx_t_2);
  } else {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  for (;;) {
    if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
    __Pyx_DECREF(__pyx_v_childname);
    __pyx_v_childname = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":782
 * 
 *     for childname in descr.names:
 *         fields = descr.fields[childname]             # <<<<<<<<<<<<<<
 *         child, new_offset = fields
 * 
 */
    __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_fields));
    __pyx_v_fields = ((PyObject *)__pyx_t_3);
    __pyx_t_3 = 0;

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":783
 *     for childname in descr.names:
 *         fields = descr.fields[childname]
 *         child, new_offset = fields             # <<<<<<<<<<<<<<
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:
 */
    if (likely(((PyObject *)__pyx_v_fields) != Py_None) && likely(PyTuple_GET_SIZE(((PyObject *)__pyx_v_fields)) == 2)) {
      PyObject* tuple = ((PyObject *)__pyx_v_fields);
      __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3);
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_4 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_v_child));
      __pyx_v_child = ((PyArray_Descr *)__pyx_t_3);
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_v_new_offset);
      __pyx_v_new_offset = __pyx_t_4;
      __pyx_t_4 = 0;
    } else {
      __Pyx_UnpackTupleError(((PyObject *)__pyx_v_fields), 2);
      {__pyx_filename = __pyx_f[11]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":785
 *         child, new_offset = fields
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    __pyx_t_4 = PyInt_FromLong((__pyx_v_end - __pyx_v_f)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_15, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_6) {

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":786
 * 
 *         if (end - f) - (new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == '>' and little_endian) or
 */
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(((PyObject *)__pyx_kp_u_11));
      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_u_11));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_11));
      __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[11]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":788
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == '>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == '<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_6 = (__pyx_v_child->byteorder == '>');
    if (__pyx_t_6) {
      __pyx_t_7 = __pyx_v_little_endian;
    } else {
      __pyx_t_7 = __pyx_t_6;
    }
    if (!__pyx_t_7) {

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":789
 * 
 *         if ((child.byteorder == '>' and little_endian) or
 *             (child.byteorder == '<' and not little_endian)):             # <<<<<<<<<<<<<<
 *             raise ValueError(u"Non-native byte order not supported")
 *             # One could encode it in the format string and have Cython
 */
      __pyx_t_6 = (__pyx_v_child->byteorder == '<');
      if (__pyx_t_6) {
        __pyx_t_8 = (!__pyx_v_little_endian);
        __pyx_t_9 = __pyx_t_8;
      } else {
        __pyx_t_9 = __pyx_t_6;
      }
      __pyx_t_6 = __pyx_t_9;
    } else {
      __pyx_t_6 = __pyx_t_7;
    }
    if (__pyx_t_6) {

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":790
 *         if ((child.byteorder == '>' and little_endian) or
 *             (child.byteorder == '<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_kp_u_9));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_u_9));
      __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_9));
      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[11]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":800
 * 
 *         # Output padding bytes
 *         while offset[0] < new_offset:             # <<<<<<<<<<<<<<
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 */
    while (1) {
      __pyx_t_5 = PyInt_FromLong((__pyx_v_offset[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_new_offset, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!__pyx_t_6) break;

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":801
 *         # Output padding bytes
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte             # <<<<<<<<<<<<<<
 *             f += 1
 *             offset[0] += 1
 */
      (__pyx_v_f[0]) = 120;

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":802
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte
 *             f += 1             # <<<<<<<<<<<<<<
 *             offset[0] += 1
 * 
 */
      __pyx_v_f += 1;

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":803
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 *             offset[0] += 1             # <<<<<<<<<<<<<<
 * 
 *         offset[0] += child.itemsize
 */
      (__pyx_v_offset[0]) += 1;
    }

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":805
 *             offset[0] += 1
 * 
 *         offset[0] += child.itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not PyDataType_HASFIELDS(child):
 */
    (__pyx_v_offset[0]) += __pyx_v_child->elsize;

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":807
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
    __pyx_t_6 = (!PyDataType_HASFIELDS(__pyx_v_child));
    if (__pyx_t_6) {

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":808
 * 
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num             # <<<<<<<<<<<<<<
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")
 */
      __pyx_t_3 = PyInt_FromLong(__pyx_v_child->type_num); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_v_t);
      __pyx_v_t = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":809
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(u"Format string allocated too short.")
 * 
 */
      __pyx_t_6 = ((__pyx_v_end - __pyx_v_f) < 5);
      if (__pyx_t_6) {

        /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":810
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(((PyObject *)__pyx_kp_u_12));
        PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_u_12));
        __Pyx_GIVEREF(((PyObject *)__pyx_kp_u_12));
        __pyx_t_5 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_Raise(__pyx_t_5, 0, 0);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        {__pyx_filename = __pyx_f[11]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        goto __pyx_L10;
      }
      __pyx_L10:;

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":813
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 98;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":814
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"             # <<<<<<<<<<<<<<
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 66;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":815
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"             # <<<<<<<<<<<<<<
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 104;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":816
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"             # <<<<<<<<<<<<<<
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 72;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":817
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 105;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":818
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 73;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":819
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 108;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":820
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 76;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":821
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 113;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":822
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 81;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":823
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"             # <<<<<<<<<<<<<<
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 102;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":824
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 */
      __pyx_t_3 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 100;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":825
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"             # <<<<<<<<<<<<<<
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 */
      __pyx_t_5 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 103;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":826
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf             # <<<<<<<<<<<<<<
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 */
      __pyx_t_3 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 102;
        __pyx_v_f += 1;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":827
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd             # <<<<<<<<<<<<<<
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 */
      __pyx_t_5 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 100;
        __pyx_v_f += 1;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":828
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg             # <<<<<<<<<<<<<<
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 */
      __pyx_t_3 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 103;
        __pyx_v_f += 1;
        goto __pyx_L11;
      }

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":829
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      __pyx_t_5 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 79;
        goto __pyx_L11;
      }
      /*else*/ {

        /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":831
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *             f += 1
 *         else:
 */
        __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_u_10), __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        {__pyx_filename = __pyx_f[11]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L11:;

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":832
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *             f += 1             # <<<<<<<<<<<<<<
 *         else:
 *             # Cython ignores struct boundary information ("T{...}"),
 */
      __pyx_v_f += 1;
      goto __pyx_L9;
    }
    /*else*/ {

      /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":836
 *             # Cython ignores struct boundary information ("T{...}"),
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)             # <<<<<<<<<<<<<<
 *     return f
 * 
 */
      __pyx_t_10 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_f = __pyx_t_10;
    }
    __pyx_L9:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":837
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)
 *     return f             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_f;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("numpy._util_dtypestring");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_child);
  __Pyx_DECREF(__pyx_v_fields);
  __Pyx_DECREF(__pyx_v_childname);
  __Pyx_DECREF(__pyx_v_new_offset);
  __Pyx_DECREF(__pyx_v_t);
  __Pyx_DECREF((PyObject *)__pyx_v_descr);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":952
 * 
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *      cdef PyObject* baseptr
 *      if base is None:
 */

static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
  PyObject *__pyx_v_baseptr;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("set_array_base");
  __Pyx_INCREF((PyObject *)__pyx_v_arr);
  __Pyx_INCREF(__pyx_v_base);

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":954
 * cdef inline void set_array_base(ndarray arr, object base):
 *      cdef PyObject* baseptr
 *      if base is None:             # <<<<<<<<<<<<<<
 *          baseptr = NULL
 *      else:
 */
  __pyx_t_1 = (__pyx_v_base == Py_None);
  if (__pyx_t_1) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":955
 *      cdef PyObject* baseptr
 *      if base is None:
 *          baseptr = NULL             # <<<<<<<<<<<<<<
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 */
    __pyx_v_baseptr = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":957
 *          baseptr = NULL
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!             # <<<<<<<<<<<<<<
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 */
    Py_INCREF(__pyx_v_base);

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":958
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base             # <<<<<<<<<<<<<<
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr
 */
    __pyx_v_baseptr = ((PyObject *)__pyx_v_base);
  }
  __pyx_L3:;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":959
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)             # <<<<<<<<<<<<<<
 *      arr.base = baseptr
 * 
 */
  Py_XDECREF(__pyx_v_arr->base);

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":960
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr             # <<<<<<<<<<<<<<
 * 
 * cdef inline object get_array_base(ndarray arr):
 */
  __pyx_v_arr->base = __pyx_v_baseptr;

  __Pyx_DECREF((PyObject *)__pyx_v_arr);
  __Pyx_DECREF(__pyx_v_base);
  __Pyx_RefNannyFinishContext();
}

/* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":962
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("get_array_base");
  __Pyx_INCREF((PyObject *)__pyx_v_arr);

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":963
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  __pyx_t_1 = (__pyx_v_arr->base == NULL);
  if (__pyx_t_1) {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":964
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     else:
 *         return <object>arr.base
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/numpy.pxd":966
 *         return None
 *     else:
 *         return <object>arr.base             # <<<<<<<<<<<<<<
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_arr->base));
    __pyx_r = ((PyObject *)__pyx_v_arr->base);
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_arr);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_tp_new_2yt_9amr_utils_position(PyTypeObject *t, PyObject *a, PyObject *k) {
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  if (__pyx_pf_2yt_9amr_utils_8position___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_2yt_9amr_utils_position(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static struct PyMethodDef __pyx_methods_2yt_9amr_utils_position[] = {
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_2yt_9amr_utils_position[] = {
  {(char *)"output_pos", T_INT, offsetof(struct __pyx_obj_2yt_9amr_utils_position, output_pos), 0, 0},
  {(char *)"refined_pos", T_INT, offsetof(struct __pyx_obj_2yt_9amr_utils_position, refined_pos), 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_position = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION >= 3
  0, /*reserved*/
  #else
  0, /*nb_long*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_position = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_position = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_position = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_2yt_9amr_utils_position = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("yt.amr_utils.position"), /*tp_name*/
  sizeof(struct __pyx_obj_2yt_9amr_utils_position), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_2yt_9amr_utils_position, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_position, /*tp_as_number*/
  &__pyx_tp_as_sequence_position, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_position, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_position, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_2yt_9amr_utils_position, /*tp_methods*/
  __pyx_members_2yt_9amr_utils_position, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_2yt_9amr_utils_position, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_2yt_9amr_utils_OctreeGrid(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_2yt_9amr_utils_OctreeGrid *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)o);
  p->child_indices = Py_None; Py_INCREF(Py_None);
  p->fields = Py_None; Py_INCREF(Py_None);
  p->left_edges = Py_None; Py_INCREF(Py_None);
  p->dimensions = Py_None; Py_INCREF(Py_None);
  p->dx = Py_None; Py_INCREF(Py_None);
  if (__pyx_pf_2yt_9amr_utils_10OctreeGrid___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_2yt_9amr_utils_OctreeGrid(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_OctreeGrid *p = (struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)o;
  Py_XDECREF(p->child_indices);
  Py_XDECREF(p->fields);
  Py_XDECREF(p->left_edges);
  Py_XDECREF(p->dimensions);
  Py_XDECREF(p->dx);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_2yt_9amr_utils_OctreeGrid(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_2yt_9amr_utils_OctreeGrid *p = (struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)o;
  if (p->child_indices) {
    e = (*v)(p->child_indices, a); if (e) return e;
  }
  if (p->fields) {
    e = (*v)(p->fields, a); if (e) return e;
  }
  if (p->left_edges) {
    e = (*v)(p->left_edges, a); if (e) return e;
  }
  if (p->dimensions) {
    e = (*v)(p->dimensions, a); if (e) return e;
  }
  if (p->dx) {
    e = (*v)(p->dx, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_2yt_9amr_utils_OctreeGrid(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_OctreeGrid *p = (struct __pyx_obj_2yt_9amr_utils_OctreeGrid *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->child_indices);
  p->child_indices = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->fields);
  p->fields = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->left_edges);
  p->left_edges = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->dimensions);
  p->dimensions = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->dx);
  p->dx = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_2yt_9amr_utils_OctreeGrid[] = {
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_2yt_9amr_utils_OctreeGrid[] = {
  {(char *)"child_indices", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_OctreeGrid, child_indices), 0, 0},
  {(char *)"fields", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_OctreeGrid, fields), 0, 0},
  {(char *)"left_edges", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_OctreeGrid, left_edges), 0, 0},
  {(char *)"dimensions", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_OctreeGrid, dimensions), 0, 0},
  {(char *)"dx", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_OctreeGrid, dx), 0, 0},
  {(char *)"level", T_INT, offsetof(struct __pyx_obj_2yt_9amr_utils_OctreeGrid, level), 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_OctreeGrid = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION >= 3
  0, /*reserved*/
  #else
  0, /*nb_long*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_OctreeGrid = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_OctreeGrid = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_OctreeGrid = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_2yt_9amr_utils_OctreeGrid = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("yt.amr_utils.OctreeGrid"), /*tp_name*/
  sizeof(struct __pyx_obj_2yt_9amr_utils_OctreeGrid), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_2yt_9amr_utils_OctreeGrid, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_OctreeGrid, /*tp_as_number*/
  &__pyx_tp_as_sequence_OctreeGrid, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_OctreeGrid, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_OctreeGrid, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_2yt_9amr_utils_OctreeGrid, /*tp_traverse*/
  __pyx_tp_clear_2yt_9amr_utils_OctreeGrid, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_2yt_9amr_utils_OctreeGrid, /*tp_methods*/
  __pyx_members_2yt_9amr_utils_OctreeGrid, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_2yt_9amr_utils_OctreeGrid, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyObject *__pyx_tp_new_2yt_9amr_utils_OctreeGridList(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_2yt_9amr_utils_OctreeGridList *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)o);
  p->grids = Py_None; Py_INCREF(Py_None);
  if (__pyx_pf_2yt_9amr_utils_14OctreeGridList___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_2yt_9amr_utils_OctreeGridList(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_OctreeGridList *p = (struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)o;
  Py_XDECREF(p->grids);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_2yt_9amr_utils_OctreeGridList(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_2yt_9amr_utils_OctreeGridList *p = (struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)o;
  if (p->grids) {
    e = (*v)(p->grids, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_2yt_9amr_utils_OctreeGridList(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_OctreeGridList *p = (struct __pyx_obj_2yt_9amr_utils_OctreeGridList *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->grids);
  p->grids = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_2yt_9amr_utils_OctreeGridList(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static struct PyMethodDef __pyx_methods_2yt_9amr_utils_OctreeGridList[] = {
  {__Pyx_NAMESTR("__getitem__"), (PyCFunction)__pyx_pf_2yt_9amr_utils_14OctreeGridList___getitem__, METH_O|METH_COEXIST, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_2yt_9amr_utils_OctreeGridList[] = {
  {(char *)"grids", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_OctreeGridList, grids), 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_OctreeGridList = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION >= 3
  0, /*reserved*/
  #else
  0, /*nb_long*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_OctreeGridList = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_2yt_9amr_utils_OctreeGridList, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_OctreeGridList = {
  0, /*mp_length*/
  __pyx_pf_2yt_9amr_utils_14OctreeGridList___getitem__, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_OctreeGridList = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_2yt_9amr_utils_OctreeGridList = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("yt.amr_utils.OctreeGridList"), /*tp_name*/
  sizeof(struct __pyx_obj_2yt_9amr_utils_OctreeGridList), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_2yt_9amr_utils_OctreeGridList, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_OctreeGridList, /*tp_as_number*/
  &__pyx_tp_as_sequence_OctreeGridList, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_OctreeGridList, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_OctreeGridList, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_2yt_9amr_utils_OctreeGridList, /*tp_traverse*/
  __pyx_tp_clear_2yt_9amr_utils_OctreeGridList, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_2yt_9amr_utils_OctreeGridList, /*tp_methods*/
  __pyx_members_2yt_9amr_utils_OctreeGridList, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_2yt_9amr_utils_OctreeGridList, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_2yt_9amr_utils_VectorPlane __pyx_vtable_2yt_9amr_utils_VectorPlane;

static PyObject *__pyx_tp_new_2yt_9amr_utils_VectorPlane(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_2yt_9amr_utils_VectorPlane *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_2yt_9amr_utils_VectorPlane *)o);
  p->__pyx_vtab = __pyx_vtabptr_2yt_9amr_utils_VectorPlane;
  p->avp_pos = Py_None; Py_INCREF(Py_None);
  p->avp_dir = Py_None; Py_INCREF(Py_None);
  p->acenter = Py_None; Py_INCREF(Py_None);
  p->aimage = Py_None; Py_INCREF(Py_None);
  p->ax_vec = Py_None; Py_INCREF(Py_None);
  p->ay_vec = Py_None; Py_INCREF(Py_None);
  if (__pyx_pf_2yt_9amr_utils_11VectorPlane___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_2yt_9amr_utils_VectorPlane(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_VectorPlane *p = (struct __pyx_obj_2yt_9amr_utils_VectorPlane *)o;
  Py_XDECREF(p->avp_pos);
  Py_XDECREF(p->avp_dir);
  Py_XDECREF(p->acenter);
  Py_XDECREF(p->aimage);
  Py_XDECREF(p->ax_vec);
  Py_XDECREF(p->ay_vec);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_2yt_9amr_utils_VectorPlane(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_2yt_9amr_utils_VectorPlane *p = (struct __pyx_obj_2yt_9amr_utils_VectorPlane *)o;
  if (p->avp_pos) {
    e = (*v)(p->avp_pos, a); if (e) return e;
  }
  if (p->avp_dir) {
    e = (*v)(p->avp_dir, a); if (e) return e;
  }
  if (p->acenter) {
    e = (*v)(p->acenter, a); if (e) return e;
  }
  if (p->aimage) {
    e = (*v)(p->aimage, a); if (e) return e;
  }
  if (p->ax_vec) {
    e = (*v)(p->ax_vec, a); if (e) return e;
  }
  if (p->ay_vec) {
    e = (*v)(p->ay_vec, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_2yt_9amr_utils_VectorPlane(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_VectorPlane *p = (struct __pyx_obj_2yt_9amr_utils_VectorPlane *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->avp_pos);
  p->avp_pos = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->avp_dir);
  p->avp_dir = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->acenter);
  p->acenter = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->aimage);
  p->aimage = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->ax_vec);
  p->ax_vec = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->ay_vec);
  p->ay_vec = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_2yt_9amr_utils_VectorPlane[] = {
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_2yt_9amr_utils_VectorPlane[] = {
  {(char *)"avp_pos", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_VectorPlane, avp_pos), 0, 0},
  {(char *)"avp_dir", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_VectorPlane, avp_dir), 0, 0},
  {(char *)"acenter", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_VectorPlane, acenter), 0, 0},
  {(char *)"aimage", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_VectorPlane, aimage), 0, 0},
  {(char *)"ax_vec", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_VectorPlane, ax_vec), 0, 0},
  {(char *)"ay_vec", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_VectorPlane, ay_vec), 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_VectorPlane = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION >= 3
  0, /*reserved*/
  #else
  0, /*nb_long*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_VectorPlane = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_VectorPlane = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_VectorPlane = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_2yt_9amr_utils_VectorPlane = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("yt.amr_utils.VectorPlane"), /*tp_name*/
  sizeof(struct __pyx_obj_2yt_9amr_utils_VectorPlane), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_2yt_9amr_utils_VectorPlane, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_VectorPlane, /*tp_as_number*/
  &__pyx_tp_as_sequence_VectorPlane, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_VectorPlane, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_VectorPlane, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_2yt_9amr_utils_VectorPlane, /*tp_traverse*/
  __pyx_tp_clear_2yt_9amr_utils_VectorPlane, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_2yt_9amr_utils_VectorPlane, /*tp_methods*/
  __pyx_members_2yt_9amr_utils_VectorPlane, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_2yt_9amr_utils_VectorPlane, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_2yt_9amr_utils_TransferFunctionProxy __pyx_vtable_2yt_9amr_utils_TransferFunctionProxy;

static PyObject *__pyx_tp_new_2yt_9amr_utils_TransferFunctionProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)o);
  p->__pyx_vtab = __pyx_vtabptr_2yt_9amr_utils_TransferFunctionProxy;
  p->tf_obj = Py_None; Py_INCREF(Py_None);
  p->my_field_tables = Py_None; Py_INCREF(Py_None);
  if (__pyx_pf_2yt_9amr_utils_21TransferFunctionProxy___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_2yt_9amr_utils_TransferFunctionProxy(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *p = (struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)o;
  Py_XDECREF(p->tf_obj);
  Py_XDECREF(p->my_field_tables);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_2yt_9amr_utils_TransferFunctionProxy(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *p = (struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)o;
  if (p->tf_obj) {
    e = (*v)(p->tf_obj, a); if (e) return e;
  }
  if (p->my_field_tables) {
    e = (*v)(p->my_field_tables, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_2yt_9amr_utils_TransferFunctionProxy(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *p = (struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->tf_obj);
  p->tf_obj = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->my_field_tables);
  p->my_field_tables = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_2yt_9amr_utils_TransferFunctionProxy[] = {
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_2yt_9amr_utils_TransferFunctionProxy[] = {
  {(char *)"ns", T_INT, offsetof(struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy, ns), 0, 0},
  {(char *)"tf_obj", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy, tf_obj), 0, 0},
  {(char *)"my_field_tables", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy, my_field_tables), 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_TransferFunctionProxy = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION >= 3
  0, /*reserved*/
  #else
  0, /*nb_long*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_TransferFunctionProxy = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_TransferFunctionProxy = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_TransferFunctionProxy = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_2yt_9amr_utils_TransferFunctionProxy = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("yt.amr_utils.TransferFunctionProxy"), /*tp_name*/
  sizeof(struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_2yt_9amr_utils_TransferFunctionProxy, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_TransferFunctionProxy, /*tp_as_number*/
  &__pyx_tp_as_sequence_TransferFunctionProxy, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_TransferFunctionProxy, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_TransferFunctionProxy, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_2yt_9amr_utils_TransferFunctionProxy, /*tp_traverse*/
  __pyx_tp_clear_2yt_9amr_utils_TransferFunctionProxy, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_2yt_9amr_utils_TransferFunctionProxy, /*tp_methods*/
  __pyx_members_2yt_9amr_utils_TransferFunctionProxy, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_2yt_9amr_utils_TransferFunctionProxy, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_2yt_9amr_utils_PartitionedGrid __pyx_vtable_2yt_9amr_utils_PartitionedGrid;

static PyObject *__pyx_tp_new_2yt_9amr_utils_PartitionedGrid(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)o);
  p->__pyx_vtab = __pyx_vtabptr_2yt_9amr_utils_PartitionedGrid;
  p->my_data = Py_None; Py_INCREF(Py_None);
  p->LeftEdge = Py_None; Py_INCREF(Py_None);
  p->RightEdge = Py_None; Py_INCREF(Py_None);
  if (__pyx_pf_2yt_9amr_utils_15PartitionedGrid___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_2yt_9amr_utils_PartitionedGrid(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *p = (struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)o;
  Py_XDECREF(p->my_data);
  Py_XDECREF(p->LeftEdge);
  Py_XDECREF(p->RightEdge);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_2yt_9amr_utils_PartitionedGrid(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *p = (struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)o;
  if (p->my_data) {
    e = (*v)(p->my_data, a); if (e) return e;
  }
  if (p->LeftEdge) {
    e = (*v)(p->LeftEdge, a); if (e) return e;
  }
  if (p->RightEdge) {
    e = (*v)(p->RightEdge, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_2yt_9amr_utils_PartitionedGrid(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *p = (struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->my_data);
  p->my_data = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->LeftEdge);
  p->LeftEdge = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->RightEdge);
  p->RightEdge = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_2yt_9amr_utils_PartitionedGrid[] = {
  {__Pyx_NAMESTR("cast_plane"), (PyCFunction)__pyx_pf_2yt_9amr_utils_15PartitionedGrid_cast_plane, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_2yt_9amr_utils_PartitionedGrid[] = {
  {(char *)"my_data", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid, my_data), 0, 0},
  {(char *)"LeftEdge", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid, LeftEdge), 0, 0},
  {(char *)"RightEdge", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid, RightEdge), 0, 0},
  {(char *)"parent_grid_id", T_INT, offsetof(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid, parent_grid_id), 0, 0},
  {(char *)"n_fields", T_INT, offsetof(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid, n_fields), 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_PartitionedGrid = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION >= 3
  0, /*reserved*/
  #else
  0, /*nb_long*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_PartitionedGrid = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_PartitionedGrid = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_PartitionedGrid = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_2yt_9amr_utils_PartitionedGrid = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("yt.amr_utils.PartitionedGrid"), /*tp_name*/
  sizeof(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_2yt_9amr_utils_PartitionedGrid, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_PartitionedGrid, /*tp_as_number*/
  &__pyx_tp_as_sequence_PartitionedGrid, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_PartitionedGrid, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_PartitionedGrid, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_2yt_9amr_utils_PartitionedGrid, /*tp_traverse*/
  __pyx_tp_clear_2yt_9amr_utils_PartitionedGrid, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_2yt_9amr_utils_PartitionedGrid, /*tp_methods*/
  __pyx_members_2yt_9amr_utils_PartitionedGrid, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_2yt_9amr_utils_PartitionedGrid, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_2yt_9amr_utils_GridFace __pyx_vtable_2yt_9amr_utils_GridFace;

static PyObject *__pyx_tp_new_2yt_9amr_utils_GridFace(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_2yt_9amr_utils_GridFace *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_2yt_9amr_utils_GridFace *)o);
  p->__pyx_vtab = __pyx_vtabptr_2yt_9amr_utils_GridFace;
  return o;
}

static void __pyx_tp_dealloc_2yt_9amr_utils_GridFace(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static struct PyMethodDef __pyx_methods_2yt_9amr_utils_GridFace[] = {
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_2yt_9amr_utils_GridFace[] = {
  {(char *)"coord", __Pyx_T_FLOATING(npy_float64), offsetof(struct __pyx_obj_2yt_9amr_utils_GridFace, coord), 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_GridFace = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION >= 3
  0, /*reserved*/
  #else
  0, /*nb_long*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_GridFace = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_GridFace = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_GridFace = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_2yt_9amr_utils_GridFace = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("yt.amr_utils.GridFace"), /*tp_name*/
  sizeof(struct __pyx_obj_2yt_9amr_utils_GridFace), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_2yt_9amr_utils_GridFace, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_GridFace, /*tp_as_number*/
  &__pyx_tp_as_sequence_GridFace, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_GridFace, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_GridFace, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_2yt_9amr_utils_GridFace, /*tp_methods*/
  __pyx_members_2yt_9amr_utils_GridFace, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_2yt_9amr_utils_8GridFace___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_2yt_9amr_utils_GridFace, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_2yt_9amr_utils_ProtoPrism __pyx_vtable_2yt_9amr_utils_ProtoPrism;

static PyObject *__pyx_tp_new_2yt_9amr_utils_ProtoPrism(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_2yt_9amr_utils_ProtoPrism *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)o);
  p->__pyx_vtab = __pyx_vtabptr_2yt_9amr_utils_ProtoPrism;
  p->LeftEdge = Py_None; Py_INCREF(Py_None);
  p->RightEdge = Py_None; Py_INCREF(Py_None);
  p->subgrid_faces = Py_None; Py_INCREF(Py_None);
  if (__pyx_pf_2yt_9amr_utils_10ProtoPrism___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_2yt_9amr_utils_ProtoPrism(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_ProtoPrism *p = (struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)o;
  Py_XDECREF(p->LeftEdge);
  Py_XDECREF(p->RightEdge);
  Py_XDECREF(p->subgrid_faces);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_2yt_9amr_utils_ProtoPrism(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_2yt_9amr_utils_ProtoPrism *p = (struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)o;
  if (p->LeftEdge) {
    e = (*v)(p->LeftEdge, a); if (e) return e;
  }
  if (p->RightEdge) {
    e = (*v)(p->RightEdge, a); if (e) return e;
  }
  if (p->subgrid_faces) {
    e = (*v)(p->subgrid_faces, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_2yt_9amr_utils_ProtoPrism(PyObject *o) {
  struct __pyx_obj_2yt_9amr_utils_ProtoPrism *p = (struct __pyx_obj_2yt_9amr_utils_ProtoPrism *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->LeftEdge);
  p->LeftEdge = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->RightEdge);
  p->RightEdge = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->subgrid_faces);
  p->subgrid_faces = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static struct PyMethodDef __pyx_methods_2yt_9amr_utils_ProtoPrism[] = {
  {__Pyx_NAMESTR("sweep"), (PyCFunction)__pyx_pf_2yt_9amr_utils_10ProtoPrism_sweep, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("get_brick"), (PyCFunction)__pyx_pf_2yt_9amr_utils_10ProtoPrism_get_brick, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyMemberDef __pyx_members_2yt_9amr_utils_ProtoPrism[] = {
  {(char *)"LeftEdge", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_ProtoPrism, LeftEdge), 0, 0},
  {(char *)"RightEdge", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_ProtoPrism, RightEdge), 0, 0},
  {(char *)"subgrid_faces", T_OBJECT, offsetof(struct __pyx_obj_2yt_9amr_utils_ProtoPrism, subgrid_faces), 0, 0},
  {(char *)"parent_grid_id", T_INT, offsetof(struct __pyx_obj_2yt_9amr_utils_ProtoPrism, parent_grid_id), 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_ProtoPrism = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION >= 3
  0, /*reserved*/
  #else
  0, /*nb_long*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_ProtoPrism = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_ProtoPrism = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_ProtoPrism = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_2yt_9amr_utils_ProtoPrism = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("yt.amr_utils.ProtoPrism"), /*tp_name*/
  sizeof(struct __pyx_obj_2yt_9amr_utils_ProtoPrism), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_2yt_9amr_utils_ProtoPrism, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_ProtoPrism, /*tp_as_number*/
  &__pyx_tp_as_sequence_ProtoPrism, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_ProtoPrism, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_ProtoPrism, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_2yt_9amr_utils_ProtoPrism, /*tp_traverse*/
  __pyx_tp_clear_2yt_9amr_utils_ProtoPrism, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_2yt_9amr_utils_ProtoPrism, /*tp_methods*/
  __pyx_members_2yt_9amr_utils_ProtoPrism, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_2yt_9amr_utils_ProtoPrism, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_2yt_9amr_utils_QuadTree __pyx_vtable_2yt_9amr_utils_QuadTree;

static PyObject *__pyx_tp_new_2yt_9amr_utils_QuadTree(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_2yt_9amr_utils_QuadTree *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_2yt_9amr_utils_QuadTree *)o);
  p->__pyx_vtab = __pyx_vtabptr_2yt_9amr_utils_QuadTree;
  if (__pyx_pf_2yt_9amr_utils_8QuadTree___cinit__(o, a, k) < 0) {
    Py_DECREF(o); o = 0;
  }
  return o;
}

static void __pyx_tp_dealloc_2yt_9amr_utils_QuadTree(PyObject *o) {
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_2yt_9amr_utils_8QuadTree___dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  (*Py_TYPE(o)->tp_free)(o);
}

static struct PyMethodDef __pyx_methods_2yt_9amr_utils_QuadTree[] = {
  {__Pyx_NAMESTR("add_array_to_tree"), (PyCFunction)__pyx_pf_2yt_9amr_utils_8QuadTree_add_array_to_tree, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("add_grid_to_tree"), (PyCFunction)__pyx_pf_2yt_9amr_utils_8QuadTree_add_grid_to_tree, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("get_all_from_level"), (PyCFunction)__pyx_pf_2yt_9amr_utils_8QuadTree_get_all_from_level, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_QuadTree = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION >= 3
  0, /*reserved*/
  #else
  0, /*nb_long*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_QuadTree = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_QuadTree = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_QuadTree = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

PyTypeObject __pyx_type_2yt_9amr_utils_QuadTree = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("yt.amr_utils.QuadTree"), /*tp_name*/
  sizeof(struct __pyx_obj_2yt_9amr_utils_QuadTree), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_2yt_9amr_utils_QuadTree, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  0, /*tp_repr*/
  &__pyx_tp_as_number_QuadTree, /*tp_as_number*/
  &__pyx_tp_as_sequence_QuadTree, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_QuadTree, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_QuadTree, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_2yt_9amr_utils_QuadTree, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_2yt_9amr_utils_QuadTree, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static struct PyMethodDef __pyx_methods[] = {
  {__Pyx_NAMESTR("RecurseOctreeDepthFirst"), (PyCFunction)__pyx_pf_2yt_9amr_utils_RecurseOctreeDepthFirst, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("RecurseOctreeByLevels"), (PyCFunction)__pyx_pf_2yt_9amr_utils_RecurseOctreeByLevels, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("UnilinearlyInterpolate"), (PyCFunction)__pyx_pf_2yt_9amr_utils_UnilinearlyInterpolate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("BilinearlyInterpolate"), (PyCFunction)__pyx_pf_2yt_9amr_utils_BilinearlyInterpolate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("TrilinearlyInterpolate"), (PyCFunction)__pyx_pf_2yt_9amr_utils_TrilinearlyInterpolate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("planar_points_in_volume"), (PyCFunction)__pyx_pf_2yt_9amr_utils_planar_points_in_volume, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("grid_points_in_volume"), (PyCFunction)__pyx_pf_2yt_9amr_utils_grid_points_in_volume, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("find_grids_in_inclined_box"), (PyCFunction)__pyx_pf_2yt_9amr_utils_find_grids_in_inclined_box, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("Transfer3D"), (PyCFunction)__pyx_pf_2yt_9amr_utils_Transfer3D, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_2yt_9amr_utils_Transfer3D)},
  {__Pyx_NAMESTR("TransferShells"), (PyCFunction)__pyx_pf_2yt_9amr_utils_TransferShells, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_2yt_9amr_utils_TransferShells)},
  {__Pyx_NAMESTR("Transfer1D"), (PyCFunction)__pyx_pf_2yt_9amr_utils_Transfer1D, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("VoxelTraversal"), (PyCFunction)__pyx_pf_2yt_9amr_utils_VoxelTraversal, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("PlaneVoxelIntegration"), (PyCFunction)__pyx_pf_2yt_9amr_utils_PlaneVoxelIntegration, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("integrate_ray"), (PyCFunction)__pyx_pf_2yt_9amr_utils_integrate_ray, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("CICDeposit_3"), (PyCFunction)__pyx_pf_2yt_9amr_utils_CICDeposit_3, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("construct_boundary_relationships"), (PyCFunction)__pyx_pf_2yt_9amr_utils_construct_boundary_relationships, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("identify_field_neighbors"), (PyCFunction)__pyx_pf_2yt_9amr_utils_identify_field_neighbors, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("extract_identified_contours"), (PyCFunction)__pyx_pf_2yt_9amr_utils_extract_identified_contours, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("write_png"), (PyCFunction)__pyx_pf_2yt_9amr_utils_write_png, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("add_points_to_image"), (PyCFunction)__pyx_pf_2yt_9amr_utils_add_points_to_image, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("read_tiger_section"), (PyCFunction)__pyx_pf_2yt_9amr_utils_read_tiger_section, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("amr_utils"),
    __Pyx_DOCSTR(__pyx_k_13), /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 1},
  {&__pyx_kp_u_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 1, 0, 0},
  {&__pyx_kp_u_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 1, 0, 0},
  {&__pyx_kp_u_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 1, 0, 0},
  {&__pyx_kp_u_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 1, 0, 0},
  {&__pyx_kp_u_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 1, 0, 0},
  {&__pyx_n_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 1},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_u_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 1, 0, 0},
  {&__pyx_kp_u_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 1, 0, 0},
  {&__pyx_kp_u_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 1, 0, 0},
  {&__pyx_n_s__Channel, __pyx_k__Channel, sizeof(__pyx_k__Channel), 0, 0, 1, 1},
  {&__pyx_n_s__F, __pyx_k__F, sizeof(__pyx_k__F), 0, 0, 1, 1},
  {&__pyx_n_s__LeftEdge, __pyx_k__LeftEdge, sizeof(__pyx_k__LeftEdge), 0, 0, 1, 1},
  {&__pyx_n_s__RightEdge, __pyx_k__RightEdge, sizeof(__pyx_k__RightEdge), 0, 0, 1, 1},
  {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
  {&__pyx_n_s__Transfer3D, __pyx_k__Transfer3D, sizeof(__pyx_k__Transfer3D), 0, 0, 1, 1},
  {&__pyx_n_s__TransferShells, __pyx_k__TransferShells, sizeof(__pyx_k__TransferShells), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
  {&__pyx_n_s__acenter, __pyx_k__acenter, sizeof(__pyx_k__acenter), 0, 0, 1, 1},
  {&__pyx_n_s__add_to_position, __pyx_k__add_to_position, sizeof(__pyx_k__add_to_position), 0, 0, 1, 1},
  {&__pyx_n_s__aimage, __pyx_k__aimage, sizeof(__pyx_k__aimage), 0, 0, 1, 1},
  {&__pyx_n_s__alpha, __pyx_k__alpha, sizeof(__pyx_k__alpha), 0, 0, 1, 1},
  {&__pyx_n_s__avp_dir, __pyx_k__avp_dir, sizeof(__pyx_k__avp_dir), 0, 0, 1, 1},
  {&__pyx_n_s__avp_pos, __pyx_k__avp_pos, sizeof(__pyx_k__avp_pos), 0, 0, 1, 1},
  {&__pyx_n_s__ax_vec, __pyx_k__ax_vec, sizeof(__pyx_k__ax_vec), 0, 0, 1, 1},
  {&__pyx_n_s__ay_vec, __pyx_k__ay_vec, sizeof(__pyx_k__ay_vec), 0, 0, 1, 1},
  {&__pyx_n_s__base, __pyx_k__base, sizeof(__pyx_k__base), 0, 0, 1, 1},
  {&__pyx_n_s__blue, __pyx_k__blue, sizeof(__pyx_k__blue), 0, 0, 1, 1},
  {&__pyx_n_s__bounds, __pyx_k__bounds, sizeof(__pyx_k__bounds), 0, 0, 1, 1},
  {&__pyx_n_s__box_center, __pyx_k__box_center, sizeof(__pyx_k__box_center), 0, 0, 1, 1},
  {&__pyx_n_s__box_lengths, __pyx_k__box_lengths, sizeof(__pyx_k__box_lengths), 0, 0, 1, 1},
  {&__pyx_n_s__box_origin, __pyx_k__box_origin, sizeof(__pyx_k__box_origin), 0, 0, 1, 1},
  {&__pyx_n_s__box_vectors, __pyx_k__box_vectors, sizeof(__pyx_k__box_vectors), 0, 0, 1, 1},
  {&__pyx_n_s__break_first, __pyx_k__break_first, sizeof(__pyx_k__break_first), 0, 0, 1, 1},
  {&__pyx_n_s__buf, __pyx_k__buf, sizeof(__pyx_k__buf), 0, 0, 1, 1},
  {&__pyx_n_s__buffer, __pyx_k__buffer, sizeof(__pyx_k__buffer), 0, 0, 1, 1},
  {&__pyx_n_s__byteorder, __pyx_k__byteorder, sizeof(__pyx_k__byteorder), 0, 0, 1, 1},
  {&__pyx_n_s__calculate_extent, __pyx_k__calculate_extent, sizeof(__pyx_k__calculate_extent), 0, 0, 1, 1},
  {&__pyx_n_s__cellSize, __pyx_k__cellSize, sizeof(__pyx_k__cellSize), 0, 0, 1, 1},
  {&__pyx_n_s__center, __pyx_k__center, sizeof(__pyx_k__center), 0, 0, 1, 1},
  {&__pyx_n_s__child_indices, __pyx_k__child_indices, sizeof(__pyx_k__child_indices), 0, 0, 1, 1},
  {&__pyx_n_s__child_mask, __pyx_k__child_mask, sizeof(__pyx_k__child_mask), 0, 0, 1, 1},
  {&__pyx_n_s__children, __pyx_k__children, sizeof(__pyx_k__children), 0, 0, 1, 1},
  {&__pyx_n_s__cm, __pyx_k__cm, sizeof(__pyx_k__cm), 0, 0, 1, 1},
  {&__pyx_n_s__coord, __pyx_k__coord, sizeof(__pyx_k__coord), 0, 0, 1, 1},
  {&__pyx_n_s__copy, __pyx_k__copy, sizeof(__pyx_k__copy), 0, 0, 1, 1},
  {&__pyx_n_s__copy_back, __pyx_k__copy_back, sizeof(__pyx_k__copy_back), 0, 0, 1, 1},
  {&__pyx_n_s__copy_into, __pyx_k__copy_into, sizeof(__pyx_k__copy_into), 0, 0, 1, 1},
  {&__pyx_n_s__corners, __pyx_k__corners, sizeof(__pyx_k__corners), 0, 0, 1, 1},
  {&__pyx_n_s__count_at_level, __pyx_k__count_at_level, sizeof(__pyx_k__count_at_level), 0, 0, 1, 1},
  {&__pyx_n_s__count_only, __pyx_k__count_only, sizeof(__pyx_k__count_only), 0, 0, 1, 1},
  {&__pyx_n_s__curpos, __pyx_k__curpos, sizeof(__pyx_k__curpos), 0, 0, 1, 1},
  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
  {&__pyx_n_s__dbin, __pyx_k__dbin, sizeof(__pyx_k__dbin), 0, 0, 1, 1},
  {&__pyx_n_s__dds, __pyx_k__dds, sizeof(__pyx_k__dds), 0, 0, 1, 1},
  {&__pyx_n_s__descr, __pyx_k__descr, sizeof(__pyx_k__descr), 0, 0, 1, 1},
  {&__pyx_n_s__dimensions, __pyx_k__dimensions, sizeof(__pyx_k__dimensions), 0, 0, 1, 1},
  {&__pyx_n_s__dims, __pyx_k__dims, sizeof(__pyx_k__dims), 0, 0, 1, 1},
  {&__pyx_n_s__direction, __pyx_k__direction, sizeof(__pyx_k__direction), 0, 0, 1, 1},
  {&__pyx_n_s__dpi, __pyx_k__dpi, sizeof(__pyx_k__dpi), 0, 0, 1, 1},
  {&__pyx_n_s__dtype, __pyx_k__dtype, sizeof(__pyx_k__dtype), 0, 0, 1, 1},
  {&__pyx_n_s__dvs, __pyx_k__dvs, sizeof(__pyx_k__dvs), 0, 0, 1, 1},
  {&__pyx_n_s__dx, __pyx_k__dx, sizeof(__pyx_k__dx), 0, 0, 1, 1},
  {&__pyx_n_s__dy, __pyx_k__dy, sizeof(__pyx_k__dy), 0, 0, 1, 1},
  {&__pyx_n_s__dz, __pyx_k__dz, sizeof(__pyx_k__dz), 0, 0, 1, 1},
  {&__pyx_n_s__e, __pyx_k__e, sizeof(__pyx_k__e), 0, 0, 1, 1},
  {&__pyx_n_s__empty, __pyx_k__empty, sizeof(__pyx_k__empty), 0, 0, 1, 1},
  {&__pyx_n_s__eval_transfer, __pyx_k__eval_transfer, sizeof(__pyx_k__eval_transfer), 0, 0, 1, 1},
  {&__pyx_n_s__field, __pyx_k__field, sizeof(__pyx_k__field), 0, 0, 1, 1},
  {&__pyx_n_s__field_id, __pyx_k__field_id, sizeof(__pyx_k__field_id), 0, 0, 1, 1},
  {&__pyx_n_s__field_ids, __pyx_k__field_ids, sizeof(__pyx_k__field_ids), 0, 0, 1, 1},
  {&__pyx_n_s__field_table_ids, __pyx_k__field_table_ids, sizeof(__pyx_k__field_table_ids), 0, 0, 1, 1},
  {&__pyx_n_s__field_tables, __pyx_k__field_tables, sizeof(__pyx_k__field_tables), 0, 0, 1, 1},
  {&__pyx_n_s__fields, __pyx_k__fields, sizeof(__pyx_k__fields), 0, 0, 1, 1},
  {&__pyx_n_s__filename, __pyx_k__filename, sizeof(__pyx_k__filename), 0, 0, 1, 1},
  {&__pyx_n_s__fill_from_level, __pyx_k__fill_from_level, sizeof(__pyx_k__fill_from_level), 0, 0, 1, 1},
  {&__pyx_n_s__find_on_root_level, __pyx_k__find_on_root_level, sizeof(__pyx_k__find_on_root_level), 0, 0, 1, 1},
  {&__pyx_n_s__float32, __pyx_k__float32, sizeof(__pyx_k__float32), 0, 0, 1, 1},
  {&__pyx_n_s__float64, __pyx_k__float64, sizeof(__pyx_k__float64), 0, 0, 1, 1},
  {&__pyx_n_s__floor, __pyx_k__floor, sizeof(__pyx_k__floor), 0, 0, 1, 1},
  {&__pyx_n_s__fn, __pyx_k__fn, sizeof(__pyx_k__fn), 0, 0, 1, 1},
  {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
  {&__pyx_n_s__genealogy, __pyx_k__genealogy, sizeof(__pyx_k__genealogy), 0, 0, 1, 1},
  {&__pyx_n_s__get_start_stop, __pyx_k__get_start_stop, sizeof(__pyx_k__get_start_stop), 0, 0, 1, 1},
  {&__pyx_n_s__gi, __pyx_k__gi, sizeof(__pyx_k__gi), 0, 0, 1, 1},
  {&__pyx_n_s__gray, __pyx_k__gray, sizeof(__pyx_k__gray), 0, 0, 1, 1},
  {&__pyx_n_s__green, __pyx_k__green, sizeof(__pyx_k__green), 0, 0, 1, 1},
  {&__pyx_n_s__grid, __pyx_k__grid, sizeof(__pyx_k__grid), 0, 0, 1, 1},
  {&__pyx_n_s__gridDimension, __pyx_k__gridDimension, sizeof(__pyx_k__gridDimension), 0, 0, 1, 1},
  {&__pyx_n_s__grid_dds, __pyx_k__grid_dds, sizeof(__pyx_k__grid_dds), 0, 0, 1, 1},
  {&__pyx_n_s__grid_dt, __pyx_k__grid_dt, sizeof(__pyx_k__grid_dt), 0, 0, 1, 1},
  {&__pyx_n_s__grid_left_edge, __pyx_k__grid_left_edge, sizeof(__pyx_k__grid_left_edge), 0, 0, 1, 1},
  {&__pyx_n_s__grid_left_edges, __pyx_k__grid_left_edges, sizeof(__pyx_k__grid_left_edges), 0, 0, 1, 1},
  {&__pyx_n_s__grid_mask, __pyx_k__grid_mask, sizeof(__pyx_k__grid_mask), 0, 0, 1, 1},
  {&__pyx_n_s__grid_right_edge, __pyx_k__grid_right_edge, sizeof(__pyx_k__grid_right_edge), 0, 0, 1, 1},
  {&__pyx_n_s__grid_right_edges, __pyx_k__grid_right_edges, sizeof(__pyx_k__grid_right_edges), 0, 0, 1, 1},
  {&__pyx_n_s__grid_t, __pyx_k__grid_t, sizeof(__pyx_k__grid_t), 0, 0, 1, 1},
  {&__pyx_n_s__grids, __pyx_k__grids, sizeof(__pyx_k__grids), 0, 0, 1, 1},
  {&__pyx_n_s__i_f, __pyx_k__i_f, sizeof(__pyx_k__i_f), 0, 0, 1, 1},
  {&__pyx_n_s__i_i, __pyx_k__i_i, sizeof(__pyx_k__i_i), 0, 0, 1, 1},
  {&__pyx_n_s__i_s, __pyx_k__i_s, sizeof(__pyx_k__i_s), 0, 0, 1, 1},
  {&__pyx_n_s__idbin, __pyx_k__idbin, sizeof(__pyx_k__idbin), 0, 0, 1, 1},
  {&__pyx_n_s__idds, __pyx_k__idds, sizeof(__pyx_k__idds), 0, 0, 1, 1},
  {&__pyx_n_s__im_strides, __pyx_k__im_strides, sizeof(__pyx_k__im_strides), 0, 0, 1, 1},
  {&__pyx_n_s__image, __pyx_k__image, sizeof(__pyx_k__image), 0, 0, 1, 1},
  {&__pyx_n_s__imax, __pyx_k__imax, sizeof(__pyx_k__imax), 0, 0, 1, 1},
  {&__pyx_n_s__imin, __pyx_k__imin, sizeof(__pyx_k__imin), 0, 0, 1, 1},
  {&__pyx_n_s__ind, __pyx_k__ind, sizeof(__pyx_k__ind), 0, 0, 1, 1},
  {&__pyx_n_s__int32, __pyx_k__int32, sizeof(__pyx_k__int32), 0, 0, 1, 1},
  {&__pyx_n_s__int64, __pyx_k__int64, sizeof(__pyx_k__int64), 0, 0, 1, 1},
  {&__pyx_n_s__int8, __pyx_k__int8, sizeof(__pyx_k__int8), 0, 0, 1, 1},
  {&__pyx_n_s__integrate_ray, __pyx_k__integrate_ray, sizeof(__pyx_k__integrate_ray), 0, 0, 1, 1},
  {&__pyx_n_s__istorage, __pyx_k__istorage, sizeof(__pyx_k__istorage), 0, 0, 1, 1},
  {&__pyx_n_s__istride, __pyx_k__istride, sizeof(__pyx_k__istride), 0, 0, 1, 1},
  {&__pyx_n_s__itemsize, __pyx_k__itemsize, sizeof(__pyx_k__itemsize), 0, 0, 1, 1},
  {&__pyx_n_s__j_f, __pyx_k__j_f, sizeof(__pyx_k__j_f), 0, 0, 1, 1},
  {&__pyx_n_s__j_i, __pyx_k__j_i, sizeof(__pyx_k__j_i), 0, 0, 1, 1},
  {&__pyx_n_s__jmax, __pyx_k__jmax, sizeof(__pyx_k__jmax), 0, 0, 1, 1},
  {&__pyx_n_s__jmin, __pyx_k__jmin, sizeof(__pyx_k__jmin), 0, 0, 1, 1},
  {&__pyx_n_s__joins, __pyx_k__joins, sizeof(__pyx_k__joins), 0, 0, 1, 1},
  {&__pyx_n_s__jstride, __pyx_k__jstride, sizeof(__pyx_k__jstride), 0, 0, 1, 1},
  {&__pyx_n_s__k_f, __pyx_k__k_f, sizeof(__pyx_k__k_f), 0, 0, 1, 1},
  {&__pyx_n_s__k_i, __pyx_k__k_i, sizeof(__pyx_k__k_i), 0, 0, 1, 1},
  {&__pyx_n_s__kmax, __pyx_k__kmax, sizeof(__pyx_k__kmax), 0, 0, 1, 1},
  {&__pyx_n_s__kmin, __pyx_k__kmin, sizeof(__pyx_k__kmin), 0, 0, 1, 1},
  {&__pyx_n_s__left, __pyx_k__left, sizeof(__pyx_k__left), 0, 0, 1, 1},
  {&__pyx_n_s__leftEdge, __pyx_k__leftEdge, sizeof(__pyx_k__leftEdge), 0, 0, 1, 1},
  {&__pyx_n_s__left_edge, __pyx_k__left_edge, sizeof(__pyx_k__left_edge), 0, 0, 1, 1},
  {&__pyx_n_s__left_edges, __pyx_k__left_edges, sizeof(__pyx_k__left_edges), 0, 0, 1, 1},
  {&__pyx_n_s__level, __pyx_k__level, sizeof(__pyx_k__level), 0, 0, 1, 1},
  {&__pyx_n_s__mask, __pyx_k__mask, sizeof(__pyx_k__mask), 0, 0, 1, 1},
  {&__pyx_n_s__mass, __pyx_k__mass, sizeof(__pyx_k__mass), 0, 0, 1, 1},
  {&__pyx_n_s__max_ind, __pyx_k__max_ind, sizeof(__pyx_k__max_ind), 0, 0, 1, 1},
  {&__pyx_n_s__my_data, __pyx_k__my_data, sizeof(__pyx_k__my_data), 0, 0, 1, 1},
  {&__pyx_n_s__my_field_tables, __pyx_k__my_field_tables, sizeof(__pyx_k__my_field_tables), 0, 0, 1, 1},
  {&__pyx_n_s__n_field_tables, __pyx_k__n_field_tables, sizeof(__pyx_k__n_field_tables), 0, 0, 1, 1},
  {&__pyx_n_s__n_fields, __pyx_k__n_fields, sizeof(__pyx_k__n_fields), 0, 0, 1, 1},
  {&__pyx_n_s__names, __pyx_k__names, sizeof(__pyx_k__names), 0, 0, 1, 1},
  {&__pyx_n_s__nbins, __pyx_k__nbins, sizeof(__pyx_k__nbins), 0, 0, 1, 1},
  {&__pyx_n_s__ndim, __pyx_k__ndim, sizeof(__pyx_k__ndim), 0, 0, 1, 1},
  {&__pyx_n_s__np, __pyx_k__np, sizeof(__pyx_k__np), 0, 0, 1, 1},
  {&__pyx_n_s__npositions, __pyx_k__npositions, sizeof(__pyx_k__npositions), 0, 0, 1, 1},
  {&__pyx_n_s__ns, __pyx_k__ns, sizeof(__pyx_k__ns), 0, 0, 1, 1},
  {&__pyx_n_s__nshells, __pyx_k__nshells, sizeof(__pyx_k__nshells), 0, 0, 1, 1},
  {&__pyx_n_s__numpy, __pyx_k__numpy, sizeof(__pyx_k__numpy), 0, 0, 1, 1},
  {&__pyx_n_s__nv, __pyx_k__nv, sizeof(__pyx_k__nv), 0, 0, 1, 1},
  {&__pyx_n_s__nvals, __pyx_k__nvals, sizeof(__pyx_k__nvals), 0, 0, 1, 1},
  {&__pyx_n_s__o_s, __pyx_k__o_s, sizeof(__pyx_k__o_s), 0, 0, 1, 1},
  {&__pyx_n_s__obj, __pyx_k__obj, sizeof(__pyx_k__obj), 0, 0, 1, 1},
  {&__pyx_n_s__offset, __pyx_k__offset, sizeof(__pyx_k__offset), 0, 0, 1, 1},
  {&__pyx_n_s__order, __pyx_k__order, sizeof(__pyx_k__order), 0, 0, 1, 1},
  {&__pyx_n_s__output, __pyx_k__output, sizeof(__pyx_k__output), 0, 0, 1, 1},
  {&__pyx_n_s__output_pos, __pyx_k__output_pos, sizeof(__pyx_k__output_pos), 0, 0, 1, 1},
  {&__pyx_n_s__parent_grid_id, __pyx_k__parent_grid_id, sizeof(__pyx_k__parent_grid_id), 0, 0, 1, 1},
  {&__pyx_n_s__pass_through, __pyx_k__pass_through, sizeof(__pyx_k__pass_through), 0, 0, 1, 1},
  {&__pyx_n_s__pdx, __pyx_k__pdx, sizeof(__pyx_k__pdx), 0, 0, 1, 1},
  {&__pyx_n_s__pdy, __pyx_k__pdy, sizeof(__pyx_k__pdy), 0, 0, 1, 1},
  {&__pyx_n_s__pmask, __pyx_k__pmask, sizeof(__pyx_k__pmask), 0, 0, 1, 1},
  {&__pyx_n_s__po2, __pyx_k__po2, sizeof(__pyx_k__po2), 0, 0, 1, 1},
  {&__pyx_n_s__points, __pyx_k__points, sizeof(__pyx_k__points), 0, 0, 1, 1},
  {&__pyx_n_s__pos, __pyx_k__pos, sizeof(__pyx_k__pos), 0, 0, 1, 1},
  {&__pyx_n_s__posx, __pyx_k__posx, sizeof(__pyx_k__posx), 0, 0, 1, 1},
  {&__pyx_n_s__posy, __pyx_k__posy, sizeof(__pyx_k__posy), 0, 0, 1, 1},
  {&__pyx_n_s__posz, __pyx_k__posz, sizeof(__pyx_k__posz), 0, 0, 1, 1},
  {&__pyx_n_s__proj_overlap, __pyx_k__proj_overlap, sizeof(__pyx_k__proj_overlap), 0, 0, 1, 1},
  {&__pyx_n_s__pv, __pyx_k__pv, sizeof(__pyx_k__pv), 0, 0, 1, 1},
  {&__pyx_n_s__pvals, __pyx_k__pvals, sizeof(__pyx_k__pvals), 0, 0, 1, 1},
  {&__pyx_n_s__pweight_vals, __pyx_k__pweight_vals, sizeof(__pyx_k__pweight_vals), 0, 0, 1, 1},
  {&__pyx_n_s__px, __pyx_k__px, sizeof(__pyx_k__px), 0, 0, 1, 1},
  {&__pyx_n_s__pxs, __pyx_k__pxs, sizeof(__pyx_k__pxs), 0, 0, 1, 1},
  {&__pyx_n_s__py, __pyx_k__py, sizeof(__pyx_k__py), 0, 0, 1, 1},
  {&__pyx_n_s__pys, __pyx_k__pys, sizeof(__pyx_k__pys), 0, 0, 1, 1},
  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
  {&__pyx_n_s__readonly, __pyx_k__readonly, sizeof(__pyx_k__readonly), 0, 0, 1, 1},
  {&__pyx_n_s__red, __pyx_k__red, sizeof(__pyx_k__red), 0, 0, 1, 1},
  {&__pyx_n_s__refined, __pyx_k__refined, sizeof(__pyx_k__refined), 0, 0, 1, 1},
  {&__pyx_n_s__refined_pos, __pyx_k__refined_pos, sizeof(__pyx_k__refined_pos), 0, 0, 1, 1},
  {&__pyx_n_s__right_edge, __pyx_k__right_edge, sizeof(__pyx_k__right_edge), 0, 0, 1, 1},
  {&__pyx_n_s__root_nodes, __pyx_k__root_nodes, sizeof(__pyx_k__root_nodes), 0, 0, 1, 1},
  {&__pyx_n_s__root_size, __pyx_k__root_size, sizeof(__pyx_k__root_size), 0, 0, 1, 1},
  {&__pyx_n_s__rot_mat, __pyx_k__rot_mat, sizeof(__pyx_k__rot_mat), 0, 0, 1, 1},
  {&__pyx_n_s__sample_values, __pyx_k__sample_values, sizeof(__pyx_k__sample_values), 0, 0, 1, 1},
  {&__pyx_n_s__shape, __pyx_k__shape, sizeof(__pyx_k__shape), 0, 0, 1, 1},
  {&__pyx_n_s__shells, __pyx_k__shells, sizeof(__pyx_k__shells), 0, 0, 1, 1},
  {&__pyx_n_s__slab_size, __pyx_k__slab_size, sizeof(__pyx_k__slab_size), 0, 0, 1, 1},
  {&__pyx_n_s__slab_start, __pyx_k__slab_start, sizeof(__pyx_k__slab_start), 0, 0, 1, 1},
  {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
  {&__pyx_n_s__stack, __pyx_k__stack, sizeof(__pyx_k__stack), 0, 0, 1, 1},
  {&__pyx_n_s__start_index, __pyx_k__start_index, sizeof(__pyx_k__start_index), 0, 0, 1, 1},
  {&__pyx_n_s__strides, __pyx_k__strides, sizeof(__pyx_k__strides), 0, 0, 1, 1},
  {&__pyx_n_s__subgrid_faces, __pyx_k__subgrid_faces, sizeof(__pyx_k__subgrid_faces), 0, 0, 1, 1},
  {&__pyx_n_s__suboffsets, __pyx_k__suboffsets, sizeof(__pyx_k__suboffsets), 0, 0, 1, 1},
  {&__pyx_n_s__sweep, __pyx_k__sweep, sizeof(__pyx_k__sweep), 0, 0, 1, 1},
  {&__pyx_n_s__table, __pyx_k__table, sizeof(__pyx_k__table), 0, 0, 1, 1},
  {&__pyx_n_s__tables, __pyx_k__tables, sizeof(__pyx_k__tables), 0, 0, 1, 1},
  {&__pyx_n_s__tf, __pyx_k__tf, sizeof(__pyx_k__tf), 0, 0, 1, 1},
  {&__pyx_n_s__tf_obj, __pyx_k__tf_obj, sizeof(__pyx_k__tf_obj), 0, 0, 1, 1},
  {&__pyx_n_s__top_grid_dims, __pyx_k__top_grid_dims, sizeof(__pyx_k__top_grid_dims), 0, 0, 1, 1},
  {&__pyx_n_s__type_num, __pyx_k__type_num, sizeof(__pyx_k__type_num), 0, 0, 1, 1},
  {&__pyx_n_s__u, __pyx_k__u, sizeof(__pyx_k__u), 0, 0, 1, 1},
  {&__pyx_n_s__ug, __pyx_k__ug, sizeof(__pyx_k__ug), 0, 0, 1, 1},
  {&__pyx_n_s__v, __pyx_k__v, sizeof(__pyx_k__v), 0, 0, 1, 1},
  {&__pyx_n_s__val, __pyx_k__val, sizeof(__pyx_k__val), 0, 0, 1, 1},
  {&__pyx_n_s__values, __pyx_k__values, sizeof(__pyx_k__values), 0, 0, 1, 1},
  {&__pyx_n_s__vd_strides, __pyx_k__vd_strides, sizeof(__pyx_k__vd_strides), 0, 0, 1, 1},
  {&__pyx_n_s__vp, __pyx_k__vp, sizeof(__pyx_k__vp), 0, 0, 1, 1},
  {&__pyx_n_s__vp_dir, __pyx_k__vp_dir, sizeof(__pyx_k__vp_dir), 0, 0, 1, 1},
  {&__pyx_n_s__vp_pos, __pyx_k__vp_pos, sizeof(__pyx_k__vp_pos), 0, 0, 1, 1},
  {&__pyx_n_s__vp_strides, __pyx_k__vp_strides, sizeof(__pyx_k__vp_strides), 0, 0, 1, 1},
  {&__pyx_n_s__weight_field_id, __pyx_k__weight_field_id, sizeof(__pyx_k__weight_field_id), 0, 0, 1, 1},
  {&__pyx_n_s__weight_field_ids, __pyx_k__weight_field_ids, sizeof(__pyx_k__weight_field_ids), 0, 0, 1, 1},
  {&__pyx_n_s__weight_table_id, __pyx_k__weight_table_id, sizeof(__pyx_k__weight_table_id), 0, 0, 1, 1},
  {&__pyx_n_s__weight_table_ids, __pyx_k__weight_table_ids, sizeof(__pyx_k__weight_table_ids), 0, 0, 1, 1},
  {&__pyx_n_s__weight_val, __pyx_k__weight_val, sizeof(__pyx_k__weight_val), 0, 0, 1, 1},
  {&__pyx_n_s__wvals, __pyx_k__wvals, sizeof(__pyx_k__wvals), 0, 0, 1, 1},
  {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1},
  {&__pyx_n_s__x_bins, __pyx_k__x_bins, sizeof(__pyx_k__x_bins), 0, 0, 1, 1},
  {&__pyx_n_s__x_bounds, __pyx_k__x_bounds, sizeof(__pyx_k__x_bounds), 0, 0, 1, 1},
  {&__pyx_n_s__x_is, __pyx_k__x_is, sizeof(__pyx_k__x_is), 0, 0, 1, 1},
  {&__pyx_n_s__x_vals, __pyx_k__x_vals, sizeof(__pyx_k__x_vals), 0, 0, 1, 1},
  {&__pyx_n_s__x_vec, __pyx_k__x_vec, sizeof(__pyx_k__x_vec), 0, 0, 1, 1},
  {&__pyx_n_s__xrange, __pyx_k__xrange, sizeof(__pyx_k__xrange), 0, 0, 1, 1},
  {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1},
  {&__pyx_n_s__y_bins, __pyx_k__y_bins, sizeof(__pyx_k__y_bins), 0, 0, 1, 1},
  {&__pyx_n_s__y_is, __pyx_k__y_is, sizeof(__pyx_k__y_is), 0, 0, 1, 1},
  {&__pyx_n_s__y_vals, __pyx_k__y_vals, sizeof(__pyx_k__y_vals), 0, 0, 1, 1},
  {&__pyx_n_s__y_vec, __pyx_k__y_vec, sizeof(__pyx_k__y_vec), 0, 0, 1, 1},
  {&__pyx_n_s__z, __pyx_k__z, sizeof(__pyx_k__z), 0, 0, 1, 1},
  {&__pyx_n_s__z_bins, __pyx_k__z_bins, sizeof(__pyx_k__z_bins), 0, 0, 1, 1},
  {&__pyx_n_s__z_is, __pyx_k__z_is, sizeof(__pyx_k__z_is), 0, 0, 1, 1},
  {&__pyx_n_s__z_vals, __pyx_k__z_vals, sizeof(__pyx_k__z_vals), 0, 0, 1, 1},
  {&__pyx_n_s__zeros, __pyx_k__zeros, sizeof(__pyx_k__zeros), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION >= 3
  __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #else
  __pyx_builtin_xrange = __Pyx_GetName(__pyx_b, __pyx_n_s__xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitGlobals(void) {
  #if PY_VERSION_HEX < 0x02040000
  if (unlikely(__Pyx_Py23SetsImport() < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initamr_utils(void); /*proto*/
PyMODINIT_FUNC initamr_utils(void)
#else
PyMODINIT_FUNC PyInit_amr_utils(void); /*proto*/
PyMODINIT_FUNC PyInit_amr_utils(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  #if CYTHON_REFNANNY
  void* __pyx_refnanny = NULL;
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_amr_utils(void)", __LINE__, __FILE__);
  #endif
  __pyx_init_filenames();
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION < 3
  __pyx_empty_bytes = PyString_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #else
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("amr_utils"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_13), 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_yt__amr_utils) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  if (PyType_Ready(&__pyx_type_2yt_9amr_utils_position) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "position", (PyObject *)&__pyx_type_2yt_9amr_utils_position) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_2yt_9amr_utils_position = &__pyx_type_2yt_9amr_utils_position;
  if (PyType_Ready(&__pyx_type_2yt_9amr_utils_OctreeGrid) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "OctreeGrid", (PyObject *)&__pyx_type_2yt_9amr_utils_OctreeGrid) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_2yt_9amr_utils_OctreeGrid = &__pyx_type_2yt_9amr_utils_OctreeGrid;
  if (PyType_Ready(&__pyx_type_2yt_9amr_utils_OctreeGridList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "OctreeGridList", (PyObject *)&__pyx_type_2yt_9amr_utils_OctreeGridList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_2yt_9amr_utils_OctreeGridList = &__pyx_type_2yt_9amr_utils_OctreeGridList;
  __pyx_vtabptr_2yt_9amr_utils_VectorPlane = &__pyx_vtable_2yt_9amr_utils_VectorPlane;
  #if PY_MAJOR_VERSION >= 3
  __pyx_vtable_2yt_9amr_utils_VectorPlane.get_start_stop = (void (*)(struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *, int *))__pyx_f_2yt_9amr_utils_11VectorPlane_get_start_stop;
  __pyx_vtable_2yt_9amr_utils_VectorPlane.copy_into = (void (*)(struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, int, int, int, int *))__pyx_f_2yt_9amr_utils_11VectorPlane_copy_into;
  __pyx_vtable_2yt_9amr_utils_VectorPlane.copy_back = (void (*)(struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, int, int, int, int *))__pyx_f_2yt_9amr_utils_11VectorPlane_copy_back;
  #else
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_VectorPlane.get_start_stop = (void(*)(void))__pyx_f_2yt_9amr_utils_11VectorPlane_get_start_stop;
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_VectorPlane.copy_into = (void(*)(void))__pyx_f_2yt_9amr_utils_11VectorPlane_copy_into;
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_VectorPlane.copy_back = (void(*)(void))__pyx_f_2yt_9amr_utils_11VectorPlane_copy_back;
  #endif
  if (PyType_Ready(&__pyx_type_2yt_9amr_utils_VectorPlane) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_2yt_9amr_utils_VectorPlane.tp_dict, __pyx_vtabptr_2yt_9amr_utils_VectorPlane) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "VectorPlane", (PyObject *)&__pyx_type_2yt_9amr_utils_VectorPlane) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_2yt_9amr_utils_VectorPlane = &__pyx_type_2yt_9amr_utils_VectorPlane;
  __pyx_vtabptr_2yt_9amr_utils_TransferFunctionProxy = &__pyx_vtable_2yt_9amr_utils_TransferFunctionProxy;
  #if PY_MAJOR_VERSION >= 3
  __pyx_vtable_2yt_9amr_utils_TransferFunctionProxy.eval_transfer = (void (*)(struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *))__pyx_f_2yt_9amr_utils_21TransferFunctionProxy_eval_transfer;
  #else
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_TransferFunctionProxy.eval_transfer = (void(*)(void))__pyx_f_2yt_9amr_utils_21TransferFunctionProxy_eval_transfer;
  #endif
  if (PyType_Ready(&__pyx_type_2yt_9amr_utils_TransferFunctionProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_2yt_9amr_utils_TransferFunctionProxy.tp_dict, __pyx_vtabptr_2yt_9amr_utils_TransferFunctionProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "TransferFunctionProxy", (PyObject *)&__pyx_type_2yt_9amr_utils_TransferFunctionProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_2yt_9amr_utils_TransferFunctionProxy = &__pyx_type_2yt_9amr_utils_TransferFunctionProxy;
  __pyx_vtabptr_2yt_9amr_utils_PartitionedGrid = &__pyx_vtable_2yt_9amr_utils_PartitionedGrid;
  #if PY_MAJOR_VERSION >= 3
  __pyx_vtable_2yt_9amr_utils_PartitionedGrid.calculate_extent = (void (*)(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *, struct __pyx_obj_2yt_9amr_utils_VectorPlane *, __pyx_t_5numpy_float64_t *))__pyx_f_2yt_9amr_utils_15PartitionedGrid_calculate_extent;
  __pyx_vtable_2yt_9amr_utils_PartitionedGrid.integrate_ray = (int (*)(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *))__pyx_f_2yt_9amr_utils_15PartitionedGrid_integrate_ray;
  __pyx_vtable_2yt_9amr_utils_PartitionedGrid.sample_values = (void (*)(struct __pyx_obj_2yt_9amr_utils_PartitionedGrid *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t, __pyx_t_5numpy_float64_t, int *, __pyx_t_5numpy_float64_t *, struct __pyx_obj_2yt_9amr_utils_TransferFunctionProxy *))__pyx_f_2yt_9amr_utils_15PartitionedGrid_sample_values;
  #else
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_PartitionedGrid.calculate_extent = (void(*)(void))__pyx_f_2yt_9amr_utils_15PartitionedGrid_calculate_extent;
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_PartitionedGrid.integrate_ray = (void(*)(void))__pyx_f_2yt_9amr_utils_15PartitionedGrid_integrate_ray;
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_PartitionedGrid.sample_values = (void(*)(void))__pyx_f_2yt_9amr_utils_15PartitionedGrid_sample_values;
  #endif
  if (PyType_Ready(&__pyx_type_2yt_9amr_utils_PartitionedGrid) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_2yt_9amr_utils_PartitionedGrid.tp_dict, __pyx_vtabptr_2yt_9amr_utils_PartitionedGrid) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "PartitionedGrid", (PyObject *)&__pyx_type_2yt_9amr_utils_PartitionedGrid) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_2yt_9amr_utils_PartitionedGrid = &__pyx_type_2yt_9amr_utils_PartitionedGrid;
  __pyx_vtabptr_2yt_9amr_utils_GridFace = &__pyx_vtable_2yt_9amr_utils_GridFace;
  #if PY_MAJOR_VERSION >= 3
  __pyx_vtable_2yt_9amr_utils_GridFace.proj_overlap = (int (*)(struct __pyx_obj_2yt_9amr_utils_GridFace *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *))__pyx_f_2yt_9amr_utils_8GridFace_proj_overlap;
  #else
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_GridFace.proj_overlap = (void(*)(void))__pyx_f_2yt_9amr_utils_8GridFace_proj_overlap;
  #endif
  if (PyType_Ready(&__pyx_type_2yt_9amr_utils_GridFace) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_2yt_9amr_utils_GridFace.tp_dict, __pyx_vtabptr_2yt_9amr_utils_GridFace) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "GridFace", (PyObject *)&__pyx_type_2yt_9amr_utils_GridFace) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_2yt_9amr_utils_GridFace = &__pyx_type_2yt_9amr_utils_GridFace;
  __pyx_vtabptr_2yt_9amr_utils_ProtoPrism = &__pyx_vtable_2yt_9amr_utils_ProtoPrism;
  #if PY_MAJOR_VERSION >= 3
  __pyx_vtable_2yt_9amr_utils_ProtoPrism.split = (PyObject *(*)(struct __pyx_obj_2yt_9amr_utils_ProtoPrism *, __pyx_t_5numpy_float64_t *, int))__pyx_f_2yt_9amr_utils_10ProtoPrism_split;
  #else
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_ProtoPrism.split = (void(*)(void))__pyx_f_2yt_9amr_utils_10ProtoPrism_split;
  #endif
  if (PyType_Ready(&__pyx_type_2yt_9amr_utils_ProtoPrism) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_2yt_9amr_utils_ProtoPrism.tp_dict, __pyx_vtabptr_2yt_9amr_utils_ProtoPrism) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "ProtoPrism", (PyObject *)&__pyx_type_2yt_9amr_utils_ProtoPrism) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_2yt_9amr_utils_ProtoPrism = &__pyx_type_2yt_9amr_utils_ProtoPrism;
  __pyx_vtabptr_2yt_9amr_utils_QuadTree = &__pyx_vtable_2yt_9amr_utils_QuadTree;
  #if PY_MAJOR_VERSION >= 3
  __pyx_vtable_2yt_9amr_utils_QuadTree.add_to_position = (void (*)(struct __pyx_obj_2yt_9amr_utils_QuadTree *, int, __pyx_t_5numpy_int64_t *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t))__pyx_f_2yt_9amr_utils_8QuadTree_add_to_position;
  __pyx_vtable_2yt_9amr_utils_QuadTree.find_on_root_level = (struct __pyx_t_2yt_9amr_utils_QuadTreeNode *(*)(struct __pyx_obj_2yt_9amr_utils_QuadTree *, __pyx_t_5numpy_int64_t *, int))__pyx_f_2yt_9amr_utils_8QuadTree_find_on_root_level;
  __pyx_vtable_2yt_9amr_utils_QuadTree.count_at_level = (int (*)(struct __pyx_obj_2yt_9amr_utils_QuadTree *, struct __pyx_t_2yt_9amr_utils_QuadTreeNode *, int))__pyx_f_2yt_9amr_utils_8QuadTree_count_at_level;
  __pyx_vtable_2yt_9amr_utils_QuadTree.fill_from_level = (int (*)(struct __pyx_obj_2yt_9amr_utils_QuadTree *, struct __pyx_t_2yt_9amr_utils_QuadTreeNode *, int, __pyx_t_5numpy_int64_t, __pyx_t_5numpy_int64_t *, __pyx_t_5numpy_float64_t *, __pyx_t_5numpy_float64_t *))__pyx_f_2yt_9amr_utils_8QuadTree_fill_from_level;
  #else
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_QuadTree.add_to_position = (void(*)(void))__pyx_f_2yt_9amr_utils_8QuadTree_add_to_position;
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_QuadTree.find_on_root_level = (void(*)(void))__pyx_f_2yt_9amr_utils_8QuadTree_find_on_root_level;
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_QuadTree.count_at_level = (void(*)(void))__pyx_f_2yt_9amr_utils_8QuadTree_count_at_level;
  *(void(**)(void))&__pyx_vtable_2yt_9amr_utils_QuadTree.fill_from_level = (void(*)(void))__pyx_f_2yt_9amr_utils_8QuadTree_fill_from_level;
  #endif
  if (PyType_Ready(&__pyx_type_2yt_9amr_utils_QuadTree) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_2yt_9amr_utils_QuadTree.tp_dict, __pyx_vtabptr_2yt_9amr_utils_QuadTree) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "QuadTree", (PyObject *)&__pyx_type_2yt_9amr_utils_QuadTree) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_2yt_9amr_utils_QuadTree = &__pyx_type_2yt_9amr_utils_QuadTree;
  /*--- Type import code ---*/
  __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "/Users/matthewturk/Development/yt/trunk/yt/amr_utils.pyx":32
 * 
 * # Set up some imports
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * cimport cython
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/DepthFirstOctree.pyx":26
 * """
 * 
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * cimport cython
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/Interpolators.pyx":1
 * """             # <<<<<<<<<<<<<<
 * Simple interpolators
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/PointsInVolume.pyx":27
 * 
 * 
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * cimport cython
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/RayIntegrators.pyx":26
 * """
 * 
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * cimport cython
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/VolumeIntegrator.pyx":1
 * """             # <<<<<<<<<<<<<<
 * Simple integrators for the radiative transfer equation
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/ContourFinding.pyx":26
 * """
 * 
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * cimport cython
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/png_writer.pyx":1
 * """             # <<<<<<<<<<<<<<
 * A light interface to libpng
 * 
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/fortran_reader.pyx":26
 * """
 * 
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * cimport cython
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/_amr_utils/QuadTree.pyx":27
 * 
 * 
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * # Double up here for def'd functions
 */
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__numpy), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/matthewturk/Development/yt/trunk/yt/amr_utils.pyx":1
 * """             # <<<<<<<<<<<<<<
 * Container file to hold all our Cython routines.  This is to avoid problems with
 * static linking.
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Transfer3D); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__");
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_14), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TransferShells); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__");
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_15), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Cython/Includes/stdlib.pxd":2
 * 
 * cdef extern from "stdlib.h" nogil:             # <<<<<<<<<<<<<<
 *     void free(void *ptr)
 *     void *malloc(size_t size)
 */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  if (__pyx_m) {
    __Pyx_AddTraceback("init yt.amr_utils");
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init yt.amr_utils");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

static const char *__pyx_filenames[] = {
  "DepthFirstOctree.pyx",
  "PointsInVolume.pyx",
  "VolumeIntegrator.pyx",
  "Interpolators.pyx",
  "RayIntegrators.pyx",
  "CICDeposit.pyx",
  "ContourFinding.pyx",
  "amr_utils.pyx",
  "png_writer.pyx",
  "fortran_reader.pyx",
  "QuadTree.pyx",
  "numpy.pxd",
};

/* Runtime support code */

static void __pyx_init_filenames(void) {
  __pyx_f = __pyx_filenames;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *number, *more_or_less;

    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    number = (num_expected == 1) ? "" : "s";
    PyErr_Format(PyExc_TypeError,
        #if PY_VERSION_HEX < 0x02050000
            "%s() takes %s %d positional argument%s (%d given)",
        #else
            "%s() takes %s %zd positional argument%s (%zd given)",
        #endif
        func_name, more_or_less, num_expected, number, num_found);
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #else
        if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
        #endif
            goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;

    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
  unsigned int n = 1;
  return *(unsigned char*)(&n) != 0;
}

typedef struct {
  __Pyx_StructField root;
  __Pyx_BufFmt_StackElem* head;
  size_t fmt_offset;
  int new_count, enc_count;
  int is_complex;
  char enc_type;
  char packmode;
} __Pyx_BufFmt_Context;

static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type) {
  stack[0].field = &ctx->root;
  stack[0].parent_offset = 0;
  ctx->root.type = type;
  ctx->root.name = "buffer dtype";
  ctx->root.offset = 0;
  ctx->head = stack;
  ctx->head->field = &ctx->root;
  ctx->fmt_offset = 0;
  ctx->head->parent_offset = 0;
  ctx->packmode = '@';
  ctx->new_count = 1;
  ctx->enc_count = 0;
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  while (type->typegroup == 'S') {
    ++ctx->head;
    ctx->head->field = type->fields;
    ctx->head->parent_offset = 0;
    type = type->fields->type;
  }
}

static int __Pyx_BufFmt_ParseNumber(const char** ts) {
    int count;
    const char* t = *ts;
    if (*t < '0' || *t > '9') {
      return -1;
    } else {
        count = *t++ - '0';
        while (*t >= '0' && *t < '9') {
            count *= 10;
            count += *t++ - '0';
        }
    }
    *ts = t;
    return count;
}

static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
  char msg[] = {ch, 0};
  PyErr_Format(PyExc_ValueError, "Unexpected format string character: '%s'", msg);
}

static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
  switch (ch) {
    case 'b': return "'char'";
    case 'B': return "'unsigned char'";
    case 'h': return "'short'";
    case 'H': return "'unsigned short'";
    case 'i': return "'int'";
    case 'I': return "'unsigned int'";
    case 'l': return "'long'";
    case 'L': return "'unsigned long'";
    case 'q': return "'long long'";
    case 'Q': return "'unsigned long long'";
    case 'f': return (is_complex ? "'complex float'" : "'float'");
    case 'd': return (is_complex ? "'complex double'" : "'double'");
    case 'g': return (is_complex ? "'complex long double'" : "'long double'");
    case 'T': return "a struct";
    case 'O': return "Python object";
    case 'P': return "a pointer";
    case 0: return "end";
    default: return "unparseable format string";
  }
}

static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': return 1;
    case 'h': case 'H': return 2;
    case 'i': case 'I': case 'l': case 'L': return 4;
    case 'q': case 'Q': return 8;
    case 'f': return (is_complex ? 8 : 4);
    case 'd': return (is_complex ? 16 : 8);
    case 'g': {
      PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
      return 0;
    }
    case 'O': case 'P': return sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}

static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
  switch (ch) {
    case 'c': case 'b': case 'B': return 1;
    case 'h': case 'H': return sizeof(short);
    case 'i': case 'I': return sizeof(int);
    case 'l': case 'L': return sizeof(long);
    #ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(PY_LONG_LONG);
    #endif
    case 'f': return sizeof(float) * (is_complex ? 2 : 1);
    case 'd': return sizeof(double) * (is_complex ? 2 : 1);
    case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
    case 'O': case 'P': return sizeof(void*);
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }    
  }
}

typedef struct { char c; short x; } __Pyx_st_short;
typedef struct { char c; int x; } __Pyx_st_int;
typedef struct { char c; long x; } __Pyx_st_long;
typedef struct { char c; float x; } __Pyx_st_float;
typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_s_long_long;
#endif

static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': return 1;
    case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_s_long_long) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}

static size_t __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
  switch (ch) {
    case 'c': case 'b': case 'h': case 'i': case 'l': case 'q': return 'I';
    case 'B': case 'H': case 'I': case 'L': case 'Q': return 'U';
    case 'f': case 'd': case 'g': return (is_complex ? 'C' : 'R');
    case 'O': return 'O';
    case 'P': return 'P';
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }    
  }
}

static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
  if (ctx->head == NULL || ctx->head->field == &ctx->root) {
    const char* expected;
    const char* quote;
    if (ctx->head == NULL) {
      expected = "end";
      quote = "";
    } else {
      expected = ctx->head->field->type->name;
      quote = "'";
    }
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected %s%s%s but got %s",
                 quote, expected, quote,
                 __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
  } else {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_StructField* parent = (ctx->head - 1)->field;
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
                 field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
                 parent->type->name, field->name);
  }
}

static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
  char group;
  size_t size, offset;
  if (ctx->enc_type == 0) return 0;
  group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
  do {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_TypeInfo* type = field->type;
  
    if (ctx->packmode == '@' || ctx->packmode == '^') {
      size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
    } else {
      size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
    }
    if (ctx->packmode == '@') {
      int align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
      int align_mod_offset;
      if (align_at == 0) return -1;
      align_mod_offset = ctx->fmt_offset % align_at;
      if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
    }

    if (type->size != size || type->typegroup != group) {
      if (type->typegroup == 'C' && type->fields != NULL) {
        /* special case -- treat as struct rather than complex number */
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        ++ctx->head;
        ctx->head->field = type->fields;
        ctx->head->parent_offset = parent_offset;
        continue;
      }
    
      __Pyx_BufFmt_RaiseExpected(ctx);
      return -1;
    }

    offset = ctx->head->parent_offset + field->offset;
    if (ctx->fmt_offset != offset) {
      PyErr_Format(PyExc_ValueError,
                   "Buffer dtype mismatch; next field is at offset %"PY_FORMAT_SIZE_T"d "
                   "but %"PY_FORMAT_SIZE_T"d expected", ctx->fmt_offset, offset);
      return -1;
    }

    ctx->fmt_offset += size;
  
    --ctx->enc_count; /* Consume from buffer string */

    /* Done checking, move to next field, pushing or popping struct stack if needed */
    while (1) {
      if (field == &ctx->root) {
        ctx->head = NULL;
        if (ctx->enc_count != 0) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
        }
        break; /* breaks both loops as ctx->enc_count == 0 */
      }
      ctx->head->field = ++field;
      if (field->type == NULL) {
        --ctx->head;
        field = ctx->head->field;
        continue;
      } else if (field->type->typegroup == 'S') {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        if (field->type->fields->type == NULL) continue; /* empty struct */
        field = field->type->fields;
        ++ctx->head;
        ctx->head->field = field;
        ctx->head->parent_offset = parent_offset;
        break;
      } else {
        break;
      }
    }
  } while (ctx->enc_count);
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  return 0;    
}

static int __Pyx_BufFmt_FirstPack(__Pyx_BufFmt_Context* ctx) {
  if (ctx->enc_type != 0 || ctx->packmode != '@') {
    PyErr_SetString(PyExc_ValueError, "Buffer packing mode currently only allowed at beginning of format string (this is a defect)");
    return -1;
  }
  return 0;
}

static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
  int got_Z = 0;
  while (1) {
    switch(*ts) {
      case 0:
        if (ctx->enc_type != 0 && ctx->head == NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        if (ctx->head != NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        return ts;
      case ' ':
      case 10:
      case 13:
        ++ts;
        break;
      case '<':
        if (!__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
          return NULL;
        }
        if (__Pyx_BufFmt_FirstPack(ctx) == -1) return NULL;
        ctx->packmode = '=';
        ++ts;
        break;
      case '>':
      case '!':
        if (__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
          return NULL;
        }
        if (__Pyx_BufFmt_FirstPack(ctx) == -1) return NULL;
        ctx->packmode = '=';
        ++ts;
        break;
      case '=':
      case '@':
      case '^':
        if (__Pyx_BufFmt_FirstPack(ctx) == -1) return NULL;
        ctx->packmode = *ts++;
        break;
      case 'T': /* substruct */
        {
          int i;
          const char* ts_after_sub;
          int struct_count = ctx->new_count;
          ctx->new_count = 1;
          ++ts;
          if (*ts != '{') {
            PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
            return NULL;
          }
          ++ts;
          ts_after_sub = ts;
          for (i = 0; i != struct_count; ++i) {
            ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
            if (!ts_after_sub) return NULL;
          }
          ts = ts_after_sub;
        }
        break;
      case '}': /* end of substruct; either repeat or move on */
        ++ts;
        return ts;
      case 'x':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->fmt_offset += ctx->new_count;
        ctx->new_count = 1;
        ctx->enc_count = 0;
        ctx->enc_type = 0;
        ++ts;
        break;
      case 'Z':
        got_Z = 1;
        ++ts;
        if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
          __Pyx_BufFmt_RaiseUnexpectedChar('Z');
          return NULL;
        }        /* fall through */
      case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
      case 'l': case 'L': case 'q': case 'Q':
      case 'f': case 'd': case 'g':
      case 'O':
        if (ctx->enc_type == *ts && got_Z == ctx->is_complex) {
          /* Continue pooling same type */
          ctx->enc_count += ctx->new_count;
        } else {
          /* New type */
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_count = ctx->new_count;
          ctx->enc_type = *ts;
          ctx->is_complex = got_Z;
        }
        ++ts;
        ctx->new_count = 1;
        got_Z = 0;
        break;
      default:
        {
          ctx->new_count = __Pyx_BufFmt_ParseNumber(&ts);
          if (ctx->new_count == -1) { /* First char was not a digit */
            char msg[2] = { *ts, 0 };
            PyErr_Format(PyExc_ValueError,
                         "Does not understand character buffer dtype format string ('%s')", msg);
            return NULL;
          }
        }
      
    }
  }
}

static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
  buf->buf = NULL;
  buf->obj = NULL;
  buf->strides = __Pyx_zeros;
  buf->shape = __Pyx_zeros;
  buf->suboffsets = __Pyx_minusones;
}

static int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack) {
  if (obj == Py_None) {
    __Pyx_ZeroBuffer(buf);
    return 0;
  }
  buf->buf = NULL;
  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
  if (buf->ndim != nd) {
    PyErr_Format(PyExc_ValueError,
                 "Buffer has wrong number of dimensions (expected %d, got %d)",
                 nd, buf->ndim);
    goto fail;
  }
  if (!cast) {
    __Pyx_BufFmt_Context ctx;
    __Pyx_BufFmt_Init(&ctx, stack, dtype);
    if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
  }
  if ((unsigned)buf->itemsize != dtype->size) {
    PyErr_Format(PyExc_ValueError,
      "Item size of buffer (%"PY_FORMAT_SIZE_T"d byte%s) does not match size of '%s' (%"PY_FORMAT_SIZE_T"d byte%s)",
      buf->itemsize, (buf->itemsize > 1) ? "s" : "",
      dtype->name,
      dtype->size, (dtype->size > 1) ? "s" : "");
    goto fail;
  }
  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
  return 0;
fail:;
  __Pyx_ZeroBuffer(buf);
  return -1;
}

static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  if (info->buf == NULL) return;
  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  __Pyx_ReleaseBuffer(info);
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();

    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;

    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}



static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static void __Pyx_RaiseBufferFallbackError(void) {
  PyErr_Format(PyExc_ValueError,
     "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
}

static void __Pyx_RaiseBufferIndexError(int axis) {
  PyErr_Format(PyExc_IndexError,
     "Out of bounds on buffer access (axis %d)", axis);
}


static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
        #if PY_VERSION_HEX < 0x02050000
                 "need more than %d value%s to unpack", (int)index,
        #else
                 "need more than %zd value%s to unpack", index,
        #endif
                 (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void) {
    PyErr_SetString(PyExc_ValueError, "too many values to unpack");
}

static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
    PyObject *item;
    if (!(item = PyIter_Next(iter))) {
        if (!PyErr_Occurred()) {
            __Pyx_RaiseNeedMoreValuesError(index);
        }
    }
    return item;
}

static int __Pyx_EndUnpack(PyObject *iter) {
    PyObject *item;
    if ((item = PyIter_Next(iter))) {
        Py_DECREF(item);
        __Pyx_RaiseTooManyValuesError();
        return -1;
    }
    else if (!PyErr_Occurred())
        return 0;
    else
        return -1;
}


static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
    if (t == Py_None) {
      __Pyx_RaiseNoneNotIterableError();
    } else if (PyTuple_GET_SIZE(t) < index) {
      __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
    } else {
      __Pyx_RaiseTooManyValuesError();
    }
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
  #if PY_VERSION_HEX >= 0x02060000
  if (Py_TYPE(obj)->tp_flags & Py_TPFLAGS_HAVE_NEWBUFFER)
      return PyObject_GetBuffer(obj, view, flags);
  #endif
  if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pf_5numpy_7ndarray___getbuffer__(obj, view, flags);
  else {
  PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
  return -1;
    }
}

static void __Pyx_ReleaseBuffer(Py_buffer *view) {
  PyObject* obj = view->obj;
  if (obj) {
if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) __pyx_pf_5numpy_7ndarray___releasebuffer__(obj, view);
    Py_DECREF(obj);
    view->obj = NULL;
  }
}

#endif

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *__import__ = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    __import__ = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!__import__)
        goto bad;
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    module = PyObject_CallFunctionObjArgs(__import__,
        name, global_dict, empty_dict, list, NULL);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(__import__);
    Py_XDECREF(empty_dict);
    return module;
}

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_intp(npy_intp val) {
    const npy_intp neg_one = (npy_intp)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(npy_intp) <  sizeof(long)) {
        return PyInt_FromLong((long)val);
    } else if (sizeof(npy_intp) == sizeof(long)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else { /* (sizeof(npy_intp) > sizeof(long)) */
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    }
}

static CYTHON_INLINE npy_int32 __Pyx_PyInt_from_py_npy_int32(PyObject* x) {
    const npy_int32 neg_one = (npy_int32)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(npy_int32) == sizeof(char)) {
        if (is_unsigned)
            return (npy_int32)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (npy_int32)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(npy_int32) == sizeof(short)) {
        if (is_unsigned)
            return (npy_int32)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (npy_int32)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(npy_int32) == sizeof(int)) {
        if (is_unsigned)
            return (npy_int32)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (npy_int32)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(npy_int32) == sizeof(long)) {
        if (is_unsigned)
            return (npy_int32)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (npy_int32)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(npy_int32) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (npy_int32)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (npy_int32)__Pyx_PyInt_AsSignedLongLong(x);
#if 0
    } else if (sizeof(npy_int32) > sizeof(short) &&
               sizeof(npy_int32) < sizeof(int)) { /*  __int32 ILP64 ? */
        if (is_unsigned)
            return (npy_int32)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (npy_int32)__Pyx_PyInt_AsSignedInt(x);
#endif
    }
    PyErr_SetString(PyExc_TypeError, "npy_int32");
    return (npy_int32)-1;
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_int32(npy_int32 val) {
    const npy_int32 neg_one = (npy_int32)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(npy_int32) <  sizeof(long)) {
        return PyInt_FromLong((long)val);
    } else if (sizeof(npy_int32) == sizeof(long)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else { /* (sizeof(npy_int32) > sizeof(long)) */
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    }
}

#if PY_MAJOR_VERSION < 3
static PyObject *__Pyx_GetStdout(void) {
    PyObject *f = PySys_GetObject((char *)"stdout");
    if (!f) {
        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
    }
    return f;
}

static int __Pyx_Print(PyObject *arg_tuple, int newline) {
    PyObject *f;
    PyObject* v;
    int i;

    if (!(f = __Pyx_GetStdout()))
        return -1;
    for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
        if (PyFile_SoftSpace(f, 1)) {
            if (PyFile_WriteString(" ", f) < 0)
                return -1;
        }
        v = PyTuple_GET_ITEM(arg_tuple, i);
        if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
            return -1;
        if (PyString_Check(v)) {
            char *s = PyString_AsString(v);
            Py_ssize_t len = PyString_Size(v);
            if (len > 0 &&
                isspace(Py_CHARMASK(s[len-1])) &&
                s[len-1] != ' ')
                    PyFile_SoftSpace(f, 0);
        }
    }
    if (newline) {
        if (PyFile_WriteString("\n", f) < 0)
            return -1;
        PyFile_SoftSpace(f, 0);
    }
    return 0;
}

#else /* Python 3 has a print function */

static int __Pyx_Print(PyObject *arg_tuple, int newline) {
    PyObject* kwargs = 0;
    PyObject* result = 0;
    PyObject* end_string;
    if (!__pyx_print) {
        __pyx_print = __Pyx_GetAttrString(__pyx_b, "print");
        if (!__pyx_print)
            return -1;
    }
    if (!newline) {
        if (!__pyx_print_kwargs) {
            __pyx_print_kwargs = PyDict_New();
            if (!__pyx_print_kwargs)
                return -1;
            end_string = PyUnicode_FromStringAndSize(" ", 1);
            if (!end_string)
                return -1;
            if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) {
                Py_DECREF(end_string);
                return -1;
            }
            Py_DECREF(end_string);
        }
        kwargs = __pyx_print_kwargs;
    }
    result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
    if (!result)
        return -1;
    Py_DECREF(result);
    return 0;
}

#endif

static CYTHON_INLINE npy_int64 __Pyx_PyInt_from_py_npy_int64(PyObject* x) {
    const npy_int64 neg_one = (npy_int64)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(npy_int64) == sizeof(char)) {
        if (is_unsigned)
            return (npy_int64)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (npy_int64)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(npy_int64) == sizeof(short)) {
        if (is_unsigned)
            return (npy_int64)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (npy_int64)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(npy_int64) == sizeof(int)) {
        if (is_unsigned)
            return (npy_int64)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (npy_int64)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(npy_int64) == sizeof(long)) {
        if (is_unsigned)
            return (npy_int64)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (npy_int64)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(npy_int64) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (npy_int64)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (npy_int64)__Pyx_PyInt_AsSignedLongLong(x);
#if 0
    } else if (sizeof(npy_int64) > sizeof(short) &&
               sizeof(npy_int64) < sizeof(int)) { /*  __int32 ILP64 ? */
        if (is_unsigned)
            return (npy_int64)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (npy_int64)__Pyx_PyInt_AsSignedInt(x);
#endif
    }
    PyErr_SetString(PyExc_TypeError, "npy_int64");
    return (npy_int64)-1;
}

#if PY_MAJOR_VERSION < 3

static int __Pyx_PrintOne(PyObject *o) {
    PyObject *f;
    if (!(f = __Pyx_GetStdout()))
        return -1;
    if (PyFile_SoftSpace(f, 0)) {
        if (PyFile_WriteString(" ", f) < 0)
            return -1;
    }
    if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
        return -1;
    if (PyFile_WriteString("\n", f) < 0)
        return -1;
    return 0;
    /* the line below is just to avoid compiler
     * compiler warnings about unused functions */
    return __Pyx_Print(NULL, 0);
}

#else /* Python 3 has a print function */

static int __Pyx_PrintOne(PyObject *o) {
    int res;
    PyObject* arg_tuple = PyTuple_New(1);
    if (unlikely(!arg_tuple))
        return -1;
    Py_INCREF(o);
    PyTuple_SET_ITEM(arg_tuple, 0, o);
    res = __Pyx_Print(arg_tuple, 1);
    Py_DECREF(arg_tuple);
    return res;
}

#endif

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(type);
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }

    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

#else /* Python 3+ */

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;

    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (!PyExceptionClass_Check(type)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }

    PyErr_SetObject(type, value);

    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }

bad:
    return;
}
#endif

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_int64(npy_int64 val) {
    const npy_int64 neg_one = (npy_int64)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(npy_int64) <  sizeof(long)) {
        return PyInt_FromLong((long)val);
    } else if (sizeof(npy_int64) == sizeof(long)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else { /* (sizeof(npy_int64) > sizeof(long)) */
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    }
}

static CYTHON_INLINE png_uint_32 __Pyx_PyInt_from_py_png_uint_32(PyObject* x) {
    const png_uint_32 neg_one = (png_uint_32)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(png_uint_32) == sizeof(char)) {
        if (is_unsigned)
            return (png_uint_32)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (png_uint_32)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(png_uint_32) == sizeof(short)) {
        if (is_unsigned)
            return (png_uint_32)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (png_uint_32)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(png_uint_32) == sizeof(int)) {
        if (is_unsigned)
            return (png_uint_32)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (png_uint_32)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(png_uint_32) == sizeof(long)) {
        if (is_unsigned)
            return (png_uint_32)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (png_uint_32)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(png_uint_32) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (png_uint_32)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (png_uint_32)__Pyx_PyInt_AsSignedLongLong(x);
#if 0
    } else if (sizeof(png_uint_32) > sizeof(short) &&
               sizeof(png_uint_32) < sizeof(int)) { /*  __int32 ILP64 ? */
        if (is_unsigned)
            return (png_uint_32)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (png_uint_32)__Pyx_PyInt_AsSignedInt(x);
#endif
    }
    PyErr_SetString(PyExc_TypeError, "png_uint_32");
    return (png_uint_32)-1;
}

static CYTHON_INLINE long __Pyx_pow_long(long b, long e) {
    long t = b;
    switch (e) {
        case 3:
            t *= b;
        case 2:
            t *= b;
        case 1:
            return t;
        case 0:
            return 1;
    }
    if (unlikely(e<0)) return 0;
    t = 1;
    while (likely(e)) {
        t *= (b * (e&1)) | ((~e)&1);    /* 1 or b */
        b *= b;
        e >>= 1;
    }
    return t;
}

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return ::std::complex< float >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return x + y*(__pyx_t_float_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      __pyx_t_float_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        float denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
/*
    static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) {
#if HAVE_HYPOT
        return hypotf(z.real, z.imag);
#else
        return sqrtf(z.real*z.real + z.imag*z.imag);
#endif
    }
*/
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return ::std::complex< double >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return x + y*(__pyx_t_double_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      __pyx_t_double_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        double denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
/*
    static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) {
#if HAVE_HYPOT
        return hypot(z.real, z.imag);
#else
        return sqrt(z.real*z.real + z.imag*z.imag);
#endif
    }
*/
#endif

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static void __Pyx_WriteUnraisable(const char *name) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX < 0x03010000
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#else
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    long size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];

    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(class_name);
    #else
    py_name = PyUnicode_FromString(class_name);
    #endif
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError, 
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning), 
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        PyErr_WarnEx(NULL, warning, 0);
    }
    else if (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError, 
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;

    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(name);
    #else
    py_name = PyUnicode_FromString(name);
    #endif
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   if (x == Py_True) return 1;
   else if ((x == Py_False) | (x == Py_None)) return 0;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
