Cython: calc_grid_values_ext.pyx

Generated by Cython 0.29.28

Yellow lines hint at Python interaction.
Click on a line that starts with a "`+`" to see the C code that Cython generated for it.

Raw output: calc_grid_values_ext.c

    +01: #cython: wraparound=False, boundscheck=False, cdivision=True, profile=False, nonecheck=False, overflowcheck=False, cdivision_warnings=False, unraisable_tracebacks=False

      __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     02: import cython

     03:

     04: # import both numpy and the Cython declarations for numpy

    +05: import numpy as np

      __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     06: cimport numpy as np

     07:

     08: # declare the interface to the C code

     09: cdef extern from "calc_grid_values.c":

     10: 	void _calc_grid_values(double* x, double* y, double* norms, int num_vert, long* volumes, int num_tri, double cell_size, int nrow, int ncol, double* vertex_val, double* grid_val)

     11: 	void init_norms(double* x, double* y, double* norms, long* volumes, int num_tri)

     12:

     13:

    +14: def calc_grid_values(int nrow, int ncol,\

    /* Python wrapper */
    static PyObject *__pyx_pw_5anuga_15file_conversion_20calc_grid_values_ext_1calc_grid_values(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_5anuga_15file_conversion_20calc_grid_values_ext_1calc_grid_values = {"calc_grid_values", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5anuga_15file_conversion_20calc_grid_values_ext_1calc_grid_values, METH_VARARGS|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_5anuga_15file_conversion_20calc_grid_values_ext_1calc_grid_values(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      int __pyx_v_nrow;
      int __pyx_v_ncol;
      double __pyx_v_cell_size;
      double __pyx_v_nodata_val;
      PyArrayObject *__pyx_v_x = 0;
      PyArrayObject *__pyx_v_y = 0;
      PyArrayObject *__pyx_v_norms = 0;
      PyArrayObject *__pyx_v_volumes = 0;
      PyArrayObject *__pyx_v_result = 0;
      PyArrayObject *__pyx_v_grid_val = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("calc_grid_values (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_nrow,&__pyx_n_s_ncol,&__pyx_n_s_cell_size,&__pyx_n_s_nodata_val,&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_norms,&__pyx_n_s_volumes,&__pyx_n_s_result,&__pyx_n_s_grid_val,0};
        PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
            CYTHON_FALLTHROUGH;
            case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
            CYTHON_FALLTHROUGH;
            case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
            CYTHON_FALLTHROUGH;
            case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
            CYTHON_FALLTHROUGH;
            case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
            CYTHON_FALLTHROUGH;
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            CYTHON_FALLTHROUGH;
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            CYTHON_FALLTHROUGH;
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_nrow)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_ncol)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("calc_grid_values", 1, 10, 10, 1); __PYX_ERR(0, 14, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cell_size)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("calc_grid_values", 1, 10, 10, 2); __PYX_ERR(0, 14, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  3:
            if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_nodata_val)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("calc_grid_values", 1, 10, 10, 3); __PYX_ERR(0, 14, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  4:
            if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("calc_grid_values", 1, 10, 10, 4); __PYX_ERR(0, 14, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  5:
            if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("calc_grid_values", 1, 10, 10, 5); __PYX_ERR(0, 14, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  6:
            if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_norms)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("calc_grid_values", 1, 10, 10, 6); __PYX_ERR(0, 14, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  7:
            if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_volumes)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("calc_grid_values", 1, 10, 10, 7); __PYX_ERR(0, 14, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  8:
            if (likely((values[8] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_result)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("calc_grid_values", 1, 10, 10, 8); __PYX_ERR(0, 14, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  9:
            if (likely((values[9] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_grid_val)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("calc_grid_values", 1, 10, 10, 9); __PYX_ERR(0, 14, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "calc_grid_values") < 0)) __PYX_ERR(0, 14, __pyx_L3_error)
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 10) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
          values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
          values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
          values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
          values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
          values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
          values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        }
        __pyx_v_nrow = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_nrow == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 14, __pyx_L3_error)
        __pyx_v_ncol = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_ncol == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 14, __pyx_L3_error)
        __pyx_v_cell_size = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_cell_size == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 15, __pyx_L3_error)
        __pyx_v_nodata_val = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_nodata_val == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 16, __pyx_L3_error)
        __pyx_v_x = ((PyArrayObject *)values[4]);
        __pyx_v_y = ((PyArrayObject *)values[5]);
        __pyx_v_norms = ((PyArrayObject *)values[6]);
        __pyx_v_volumes = ((PyArrayObject *)values[7]);
        __pyx_v_result = ((PyArrayObject *)values[8]);
        __pyx_v_grid_val = ((PyArrayObject *)values[9]);
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("calc_grid_values", 1, 10, 10, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 14, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("anuga.file_conversion.calc_grid_values_ext.calc_grid_values", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5numpy_ndarray, 0, "x", 0))) __PYX_ERR(0, 17, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5numpy_ndarray, 0, "y", 0))) __PYX_ERR(0, 18, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_norms), __pyx_ptype_5numpy_ndarray, 0, "norms", 0))) __PYX_ERR(0, 19, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_volumes), __pyx_ptype_5numpy_ndarray, 0, "volumes", 0))) __PYX_ERR(0, 20, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_result), __pyx_ptype_5numpy_ndarray, 0, "result", 0))) __PYX_ERR(0, 21, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_grid_val), __pyx_ptype_5numpy_ndarray, 0, "grid_val", 0))) __PYX_ERR(0, 22, __pyx_L1_error)
      __pyx_r = __pyx_pf_5anuga_15file_conversion_20calc_grid_values_ext_calc_grid_values(__pyx_self, __pyx_v_nrow, __pyx_v_ncol, __pyx_v_cell_size, __pyx_v_nodata_val, __pyx_v_x, __pyx_v_y, __pyx_v_norms, __pyx_v_volumes, __pyx_v_result, __pyx_v_grid_val);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_5anuga_15file_conversion_20calc_grid_values_ext_calc_grid_values(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_nrow, int __pyx_v_ncol, double __pyx_v_cell_size, double __pyx_v_nodata_val, PyArrayObject *__pyx_v_x, PyArrayObject *__pyx_v_y, PyArrayObject *__pyx_v_norms, PyArrayObject *__pyx_v_volumes, PyArrayObject *__pyx_v_result, PyArrayObject *__pyx_v_grid_val) {
      int __pyx_v_i;
      int __pyx_v_num_tri;
      int __pyx_v_num_vert;
      CYTHON_UNUSED int __pyx_v_num_norms;
      CYTHON_UNUSED int __pyx_v_num_grid_val;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_grid_val;
      __Pyx_Buffer __pyx_pybuffer_grid_val;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_norms;
      __Pyx_Buffer __pyx_pybuffer_norms;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_result;
      __Pyx_Buffer __pyx_pybuffer_result;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_volumes;
      __Pyx_Buffer __pyx_pybuffer_volumes;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_x;
      __Pyx_Buffer __pyx_pybuffer_x;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_y;
      __Pyx_Buffer __pyx_pybuffer_y;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("calc_grid_values", 0);
      __pyx_pybuffer_x.pybuffer.buf = NULL;
      __pyx_pybuffer_x.refcount = 0;
      __pyx_pybuffernd_x.data = NULL;
      __pyx_pybuffernd_x.rcbuffer = &__pyx_pybuffer_x;
      __pyx_pybuffer_y.pybuffer.buf = NULL;
      __pyx_pybuffer_y.refcount = 0;
      __pyx_pybuffernd_y.data = NULL;
      __pyx_pybuffernd_y.rcbuffer = &__pyx_pybuffer_y;
      __pyx_pybuffer_norms.pybuffer.buf = NULL;
      __pyx_pybuffer_norms.refcount = 0;
      __pyx_pybuffernd_norms.data = NULL;
      __pyx_pybuffernd_norms.rcbuffer = &__pyx_pybuffer_norms;
      __pyx_pybuffer_volumes.pybuffer.buf = NULL;
      __pyx_pybuffer_volumes.refcount = 0;
      __pyx_pybuffernd_volumes.data = NULL;
      __pyx_pybuffernd_volumes.rcbuffer = &__pyx_pybuffer_volumes;
      __pyx_pybuffer_result.pybuffer.buf = NULL;
      __pyx_pybuffer_result.refcount = 0;
      __pyx_pybuffernd_result.data = NULL;
      __pyx_pybuffernd_result.rcbuffer = &__pyx_pybuffer_result;
      __pyx_pybuffer_grid_val.pybuffer.buf = NULL;
      __pyx_pybuffer_grid_val.refcount = 0;
      __pyx_pybuffernd_grid_val.data = NULL;
      __pyx_pybuffernd_grid_val.rcbuffer = &__pyx_pybuffer_grid_val;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_x.rcbuffer->pybuffer, (PyObject*)__pyx_v_x, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 14, __pyx_L1_error)
      }
      __pyx_pybuffernd_x.diminfo[0].strides = __pyx_pybuffernd_x.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_x.diminfo[0].shape = __pyx_pybuffernd_x.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_y.rcbuffer->pybuffer, (PyObject*)__pyx_v_y, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 14, __pyx_L1_error)
      }
      __pyx_pybuffernd_y.diminfo[0].strides = __pyx_pybuffernd_y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_y.diminfo[0].shape = __pyx_pybuffernd_y.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_norms.rcbuffer->pybuffer, (PyObject*)__pyx_v_norms, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 14, __pyx_L1_error)
      }
      __pyx_pybuffernd_norms.diminfo[0].strides = __pyx_pybuffernd_norms.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_norms.diminfo[0].shape = __pyx_pybuffernd_norms.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_volumes.rcbuffer->pybuffer, (PyObject*)__pyx_v_volumes, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 14, __pyx_L1_error)
      }
      __pyx_pybuffernd_volumes.diminfo[0].strides = __pyx_pybuffernd_volumes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_volumes.diminfo[0].shape = __pyx_pybuffernd_volumes.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_volumes.diminfo[1].strides = __pyx_pybuffernd_volumes.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_volumes.diminfo[1].shape = __pyx_pybuffernd_volumes.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_result.rcbuffer->pybuffer, (PyObject*)__pyx_v_result, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 14, __pyx_L1_error)
      }
      __pyx_pybuffernd_result.diminfo[0].strides = __pyx_pybuffernd_result.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_result.diminfo[0].shape = __pyx_pybuffernd_result.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grid_val.rcbuffer->pybuffer, (PyObject*)__pyx_v_grid_val, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 14, __pyx_L1_error)
      }
      __pyx_pybuffernd_grid_val.diminfo[0].strides = __pyx_pybuffernd_grid_val.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_grid_val.diminfo[0].shape = __pyx_pybuffernd_grid_val.rcbuffer->pybuffer.shape[0];
    /* … */
      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grid_val.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_norms.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_volumes.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("anuga.file_conversion.calc_grid_values_ext.calc_grid_values", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grid_val.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_norms.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_result.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_volumes.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_x.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_y.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__3 = PyTuple_Pack(15, __pyx_n_s_nrow, __pyx_n_s_ncol, __pyx_n_s_cell_size, __pyx_n_s_nodata_val, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_norms, __pyx_n_s_volumes, __pyx_n_s_result, __pyx_n_s_grid_val, __pyx_n_s_i, __pyx_n_s_num_tri, __pyx_n_s_num_vert, __pyx_n_s_num_norms, __pyx_n_s_num_grid_val); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__3);
      __Pyx_GIVEREF(__pyx_tuple__3);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5anuga_15file_conversion_20calc_grid_values_ext_1calc_grid_values, NULL, __pyx_n_s_anuga_file_conversion_calc_grid_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_calc_grid_values, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     15:                     double cell_size,\

     16:                     double nodata_val,\

     17:                     np.ndarray[double, ndim=1, mode="c"] x not None,\

     18:                     np.ndarray[double, ndim=1, mode="c"] y not None,\

     19:                     np.ndarray[double, ndim=1, mode="c"] norms not None,\

     20:                     np.ndarray[long, ndim=2, mode="c"] volumes not None,\

     21:                     np.ndarray[double, ndim=1, mode="c"] result not None,\

     22:                     np.ndarray[double, ndim=1, mode="c"] grid_val not None):

     23:

     24: 	cdef int i, num_tri, num_vert, num_norms, num_grid_val

     25:

    +26: 	num_tri = volumes.shape[0]

      __pyx_v_num_tri = (__pyx_v_volumes->dimensions[0]);

    +27: 	num_vert = x.shape[0]

      __pyx_v_num_vert = (__pyx_v_x->dimensions[0]);

    +28: 	num_norms = norms.shape[0]

      __pyx_v_num_norms = (__pyx_v_norms->dimensions[0]);

    +29: 	num_grid_val = grid_val.shape[0]

      __pyx_v_num_grid_val = (__pyx_v_grid_val->dimensions[0]);

     30:

    +31: 	init_norms(&x[0], &y[0], &norms[0], &volumes[0,0], num_tri)

      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      init_norms((&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_x.diminfo[0].strides))), (&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_y.diminfo[0].strides))), (&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_norms.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_norms.diminfo[0].strides))), (&(*__Pyx_BufPtrCContig2d(long *, __pyx_pybuffernd_volumes.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_volumes.diminfo[0].strides, __pyx_t_5, __pyx_pybuffernd_volumes.diminfo[1].strides))), __pyx_v_num_tri);

     32:

    +33: 	for i in xrange(nrow*ncol):

      __pyx_t_6 = (__pyx_v_nrow * __pyx_v_ncol);
      __pyx_t_7 = __pyx_t_6;
      for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
        __pyx_v_i = __pyx_t_8;

    +34: 		grid_val[i] = nodata_val

        __pyx_t_5 = __pyx_v_i;
        *__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_grid_val.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_grid_val.diminfo[0].strides) = __pyx_v_nodata_val;
      }

     35:

    +36: 	_calc_grid_values(&x[0], &y[0],\

      __pyx_t_5 = 0;
      __pyx_t_4 = 0;
    /* … */
      _calc_grid_values((&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_x.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_x.diminfo[0].strides))), (&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_y.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_y.diminfo[0].strides))), (&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_norms.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_norms.diminfo[0].strides))), __pyx_v_num_vert, (&(*__Pyx_BufPtrCContig2d(long *, __pyx_pybuffernd_volumes.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_volumes.diminfo[0].strides, __pyx_t_1, __pyx_pybuffernd_volumes.diminfo[1].strides))), __pyx_v_num_tri, __pyx_v_cell_size, __pyx_v_nrow, __pyx_v_ncol, (&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_result.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_result.diminfo[0].strides))), (&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_grid_val.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_grid_val.diminfo[0].strides))));

    +37:                     &norms[0],\

      __pyx_t_3 = 0;

     38:                     num_vert,\

    +39:                     &volumes[0,0],\

      __pyx_t_2 = 0;
      __pyx_t_1 = 0;

     40:                     num_tri,\

     41:                     cell_size,\

     42:                     nrow,\

     43:                     ncol,\

    +44:                     &result[0],\

      __pyx_t_9 = 0;

    +45:                     &grid_val[0])

      __pyx_t_10 = 0;