Cython: urs_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: urs_ext.c

    +001: #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;

     002: import cython

     003: from libc.stdlib cimport malloc, free

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

    +005: 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;

     006: cimport numpy as np

     007:

     008: # declare the interface to the C code

     009: cdef extern from "urs.c":

     010:   float** _read_mux2(int numSrc, char** muxFileNameArray, float* weights, double* params, int* number_of_stations, long* permutation, int verbose)

     011:

    +012: def read_mux2(int numSrc,\

    /* Python wrapper */
    static PyObject *__pyx_pw_5anuga_4file_7urs_ext_1read_mux2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_5anuga_4file_7urs_ext_1read_mux2 = {"read_mux2", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5anuga_4file_7urs_ext_1read_mux2, METH_VARARGS|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_5anuga_4file_7urs_ext_1read_mux2(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      int __pyx_v_numSrc;
      PyObject *__pyx_v_filenames = 0;
      PyArrayObject *__pyx_v_pyweights = 0;
      PyArrayObject *__pyx_v_file_params = 0;
      PyArrayObject *__pyx_v_permutation = 0;
      int __pyx_v_verbose;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("read_mux2 (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_numSrc,&__pyx_n_s_filenames,&__pyx_n_s_pyweights,&__pyx_n_s_file_params,&__pyx_n_s_permutation,&__pyx_n_s_verbose,0};
        PyObject* values[6] = {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  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_numSrc)) != 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_filenames)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("read_mux2", 1, 6, 6, 1); __PYX_ERR(0, 12, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyweights)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("read_mux2", 1, 6, 6, 2); __PYX_ERR(0, 12, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  3:
            if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_file_params)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("read_mux2", 1, 6, 6, 3); __PYX_ERR(0, 12, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  4:
            if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_permutation)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("read_mux2", 1, 6, 6, 4); __PYX_ERR(0, 12, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  5:
            if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_verbose)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("read_mux2", 1, 6, 6, 5); __PYX_ERR(0, 12, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_mux2") < 0)) __PYX_ERR(0, 12, __pyx_L3_error)
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 6) {
          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);
        }
        __pyx_v_numSrc = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_numSrc == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 12, __pyx_L3_error)
        __pyx_v_filenames = ((PyObject*)values[1]);
        __pyx_v_pyweights = ((PyArrayObject *)values[2]);
        __pyx_v_file_params = ((PyArrayObject *)values[3]);
        __pyx_v_permutation = ((PyArrayObject *)values[4]);
        __pyx_v_verbose = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_verbose == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 17, __pyx_L3_error)
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("read_mux2", 1, 6, 6, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 12, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("anuga.file.urs_ext.read_mux2", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_filenames), (&PyList_Type), 1, "filenames", 1))) __PYX_ERR(0, 13, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pyweights), __pyx_ptype_5numpy_ndarray, 0, "pyweights", 0))) __PYX_ERR(0, 14, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_file_params), __pyx_ptype_5numpy_ndarray, 0, "file_params", 0))) __PYX_ERR(0, 15, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_permutation), __pyx_ptype_5numpy_ndarray, 0, "permutation", 0))) __PYX_ERR(0, 16, __pyx_L1_error)
      __pyx_r = __pyx_pf_5anuga_4file_7urs_ext_read_mux2(__pyx_self, __pyx_v_numSrc, __pyx_v_filenames, __pyx_v_pyweights, __pyx_v_file_params, __pyx_v_permutation, __pyx_v_verbose);
      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_4file_7urs_ext_read_mux2(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_numSrc, PyObject *__pyx_v_filenames, PyArrayObject *__pyx_v_pyweights, PyArrayObject *__pyx_v_file_params, PyArrayObject *__pyx_v_permutation, int __pyx_v_verbose) {
      char **__pyx_v_muxFileNameArray;
      float **__pyx_v_cdata;
      float *__pyx_v_weights;
      int __pyx_v_dimensions[2];
      CYTHON_UNUSED int __pyx_v_total_number_of_stations;
      int __pyx_v_number_of_selected_stations;
      int __pyx_v_nt;
      CYTHON_UNUSED double __pyx_v_dt;
      int __pyx_v_i;
      int __pyx_v_j;
      int __pyx_v_start_tstep;
      int __pyx_v_finish_tstep;
      int __pyx_v_it;
      int __pyx_v_time;
      int __pyx_v_num_ts;
      int __pyx_v_POFFSET;
      PyArrayObject *__pyx_v_pydata = 0;
      PyArrayObject *__pyx_v_tmp_perm = 0;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_file_params;
      __Pyx_Buffer __pyx_pybuffer_file_params;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_permutation;
      __Pyx_Buffer __pyx_pybuffer_permutation;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_pydata;
      __Pyx_Buffer __pyx_pybuffer_pydata;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_pyweights;
      __Pyx_Buffer __pyx_pybuffer_pyweights;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_tmp_perm;
      __Pyx_Buffer __pyx_pybuffer_tmp_perm;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("read_mux2", 0);
      __Pyx_INCREF((PyObject *)__pyx_v_permutation);
      __pyx_pybuffer_pydata.pybuffer.buf = NULL;
      __pyx_pybuffer_pydata.refcount = 0;
      __pyx_pybuffernd_pydata.data = NULL;
      __pyx_pybuffernd_pydata.rcbuffer = &__pyx_pybuffer_pydata;
      __pyx_pybuffer_tmp_perm.pybuffer.buf = NULL;
      __pyx_pybuffer_tmp_perm.refcount = 0;
      __pyx_pybuffernd_tmp_perm.data = NULL;
      __pyx_pybuffernd_tmp_perm.rcbuffer = &__pyx_pybuffer_tmp_perm;
      __pyx_pybuffer_pyweights.pybuffer.buf = NULL;
      __pyx_pybuffer_pyweights.refcount = 0;
      __pyx_pybuffernd_pyweights.data = NULL;
      __pyx_pybuffernd_pyweights.rcbuffer = &__pyx_pybuffer_pyweights;
      __pyx_pybuffer_file_params.pybuffer.buf = NULL;
      __pyx_pybuffer_file_params.refcount = 0;
      __pyx_pybuffernd_file_params.data = NULL;
      __pyx_pybuffernd_file_params.rcbuffer = &__pyx_pybuffer_file_params;
      __pyx_pybuffer_permutation.pybuffer.buf = NULL;
      __pyx_pybuffer_permutation.refcount = 0;
      __pyx_pybuffernd_permutation.data = NULL;
      __pyx_pybuffernd_permutation.rcbuffer = &__pyx_pybuffer_permutation;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pyweights.rcbuffer->pybuffer, (PyObject*)__pyx_v_pyweights, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 12, __pyx_L1_error)
      }
      __pyx_pybuffernd_pyweights.diminfo[0].strides = __pyx_pybuffernd_pyweights.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pyweights.diminfo[0].shape = __pyx_pybuffernd_pyweights.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_file_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_file_params, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 12, __pyx_L1_error)
      }
      __pyx_pybuffernd_file_params.diminfo[0].strides = __pyx_pybuffernd_file_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_file_params.diminfo[0].shape = __pyx_pybuffernd_file_params.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_permutation.rcbuffer->pybuffer, (PyObject*)__pyx_v_permutation, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 12, __pyx_L1_error)
      }
      __pyx_pybuffernd_permutation.diminfo[0].strides = __pyx_pybuffernd_permutation.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_permutation.diminfo[0].shape = __pyx_pybuffernd_permutation.rcbuffer->pybuffer.shape[0];
    /* … */
      /* function exit code */
      __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_6);
      { 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_file_params.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_permutation.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pydata.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pyweights.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp_perm.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("anuga.file.urs_ext.read_mux2", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_file_params.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_permutation.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pydata.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pyweights.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp_perm.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_pydata);
      __Pyx_XDECREF((PyObject *)__pyx_v_tmp_perm);
      __Pyx_XDECREF((PyObject *)__pyx_v_permutation);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__3 = PyTuple_Pack(24, __pyx_n_s_numSrc, __pyx_n_s_filenames, __pyx_n_s_pyweights, __pyx_n_s_file_params, __pyx_n_s_permutation, __pyx_n_s_verbose, __pyx_n_s_muxFileNameArray, __pyx_n_s_cdata, __pyx_n_s_weights, __pyx_n_s_dimensions, __pyx_n_s_total_number_of_stations, __pyx_n_s_number_of_selected_stations, __pyx_n_s_nt, __pyx_n_s_dt, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_start_tstep, __pyx_n_s_finish_tstep, __pyx_n_s_it, __pyx_n_s_time, __pyx_n_s_num_ts, __pyx_n_s_POFFSET, __pyx_n_s_pydata, __pyx_n_s_tmp_perm); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 12, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__3);
      __Pyx_GIVEREF(__pyx_tuple__3);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5anuga_4file_7urs_ext_1read_mux2, NULL, __pyx_n_s_anuga_file_urs_ext); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_mux2, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     013:               list filenames,\

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

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

     016:               np.ndarray[long, ndim=1, mode="c"] permutation not None,\

     017:               int verbose):

     018:   # Make sure filenames are cast as str().encode(). This will work in both Python2 and Python3 (Ole)

     019:

     020:   cdef char** muxFileNameArray

     021:   cdef float** cdata

     022:   cdef float* weights

     023:   cdef int dimensions[2]

     024:   cdef int total_number_of_stations

     025:   cdef int number_of_selected_stations

     026:   cdef int nt

     027:   cdef double dt

     028:   cdef int i, j, start_tstep, finish_tstep, it, time, num_ts

    +029:   cdef int POFFSET = 5

      __pyx_v_POFFSET = 5;

     030:   cdef np.ndarray[double, ndim=2, mode="c"] pydata

     031:   cdef np.ndarray[long, ndim=1, mode="c"] tmp_perm

     032:

    +033:   tmp_perm = np.array([0],int)

      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 33, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyList_SET_ITEM(__pyx_t_2, 0, __pyx_int_0);
      __pyx_t_4 = NULL;
      __pyx_t_5 = 0;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
          __pyx_t_5 = 1;
        }
      }
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, ((PyObject *)(&PyInt_Type))};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, ((PyObject *)(&PyInt_Type))};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 33, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__pyx_t_4) {
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
        }
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_2);
        __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
        __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
        PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, ((PyObject *)(&PyInt_Type)));
        __pyx_t_2 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 33, __pyx_L1_error)
      __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp_perm.rcbuffer->pybuffer);
        __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp_perm.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_5 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp_perm.rcbuffer->pybuffer, (PyObject*)__pyx_v_tmp_perm, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          }
          __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0;
        }
        __pyx_pybuffernd_tmp_perm.diminfo[0].strides = __pyx_pybuffernd_tmp_perm.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tmp_perm.diminfo[0].shape = __pyx_pybuffernd_tmp_perm.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 33, __pyx_L1_error)
      }
      __pyx_t_7 = 0;
      __pyx_v_tmp_perm = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

     034:

    +035:   assert len(filenames) > 0, "empty lists not allowed"

      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        if (unlikely(__pyx_v_filenames == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
          __PYX_ERR(0, 35, __pyx_L1_error)
        }
        __pyx_t_11 = PyList_GET_SIZE(__pyx_v_filenames); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 35, __pyx_L1_error)
        if (unlikely(!((__pyx_t_11 > 0) != 0))) {
          PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_empty_lists_not_allowed);
          __PYX_ERR(0, 35, __pyx_L1_error)
        }
      }
      #endif

     036:

    +037:   assert len(filenames) == pyweights.shape[0], "Must specify one weight for each filename"

      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        if (unlikely(__pyx_v_filenames == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
          __PYX_ERR(0, 37, __pyx_L1_error)
        }
        __pyx_t_11 = PyList_GET_SIZE(__pyx_v_filenames); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 37, __pyx_L1_error)
        if (unlikely(!((__pyx_t_11 == (__pyx_v_pyweights->dimensions[0])) != 0))) {
          PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Must_specify_one_weight_for_each);
          __PYX_ERR(0, 37, __pyx_L1_error)
        }
      }
      #endif

     038:

    +039:   muxFileNameArray = <char** > malloc(numSrc * sizeof(char*))

      __pyx_v_muxFileNameArray = ((char **)malloc((__pyx_v_numSrc * (sizeof(char *)))));

    +040:   assert muxFileNameArray != NULL, "ERROR: Memory for muxFileNameArray could not be allocated."

      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        if (unlikely(!((__pyx_v_muxFileNameArray != NULL) != 0))) {
          PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_ERROR_Memory_for_muxFileNameArra);
          __PYX_ERR(0, 40, __pyx_L1_error)
        }
      }
      #endif

     041:

    +042:   for i in xrange(numSrc):

      __pyx_t_5 = __pyx_v_numSrc;
      __pyx_t_12 = __pyx_t_5;
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

     043:     #assert isinstance(filenames[i], basestring), "filename not a string"  # Nor should it be ;-)

     044:     #print(filenames[i], type(filenames[i]))

    +045:     muxFileNameArray[i] = filenames[i]

        if (unlikely(__pyx_v_filenames == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
          __PYX_ERR(0, 45, __pyx_L1_error)
        }
        __pyx_t_14 = __Pyx_PyObject_AsWritableString(PyList_GET_ITEM(__pyx_v_filenames, __pyx_v_i)); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) __PYX_ERR(0, 45, __pyx_L1_error)
        (__pyx_v_muxFileNameArray[__pyx_v_i]) = __pyx_t_14;
      }

     046:

    +047:   weights = <float* > malloc(numSrc * sizeof(float))

      __pyx_v_weights = ((float *)malloc((__pyx_v_numSrc * (sizeof(float)))));

    +048:   assert weights != NULL, "ERROR: Memory for weights could not be allocated."

      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        if (unlikely(!((__pyx_v_weights != NULL) != 0))) {
          PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_ERROR_Memory_for_weights_could_n);
          __PYX_ERR(0, 48, __pyx_L1_error)
        }
      }
      #endif

     049:

    +050:   for i in xrange(numSrc):

      __pyx_t_5 = __pyx_v_numSrc;
      __pyx_t_12 = __pyx_t_5;
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

    +051:     weights[i] = pyweights[i]

        __pyx_t_15 = __pyx_v_i;
        (__pyx_v_weights[__pyx_v_i]) = (*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_pyweights.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_pyweights.diminfo[0].strides));
      }

     052:

    +053:   number_of_selected_stations = permutation.shape[0]

      __pyx_v_number_of_selected_stations = (__pyx_v_permutation->dimensions[0]);

     054:

    +055:   if number_of_selected_stations == 0:

      __pyx_t_16 = ((__pyx_v_number_of_selected_stations == 0) != 0);
      if (__pyx_t_16) {
    /* … */
      }

    +056:     permutation = tmp_perm

        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_permutation.rcbuffer->pybuffer);
          __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_permutation.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_tmp_perm), &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack);
          if (unlikely(__pyx_t_5 < 0)) {
            PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_permutation.rcbuffer->pybuffer, (PyObject*)__pyx_v_permutation, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
            }
            __pyx_t_10 = __pyx_t_9 = __pyx_t_8 = 0;
          }
          __pyx_pybuffernd_permutation.diminfo[0].strides = __pyx_pybuffernd_permutation.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_permutation.diminfo[0].shape = __pyx_pybuffernd_permutation.rcbuffer->pybuffer.shape[0];
          if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 56, __pyx_L1_error)
        }
        __Pyx_INCREF(((PyObject *)__pyx_v_tmp_perm));
        __Pyx_DECREF_SET(__pyx_v_permutation, ((PyArrayObject *)__pyx_v_tmp_perm));

     057:

    +058:   cdata = _read_mux2(numSrc,\

      __pyx_v_cdata = _read_mux2(__pyx_v_numSrc, __pyx_v_muxFileNameArray, __pyx_v_weights, (&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_file_params.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_file_params.diminfo[0].strides))), (&__pyx_v_number_of_selected_stations), (&(*__Pyx_BufPtrCContig1d(long *, __pyx_pybuffernd_permutation.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_permutation.diminfo[0].strides))), __pyx_v_verbose);

     059: 		     muxFileNameArray,\

     060:                      weights,\

    +061:                      &file_params[0],\

      __pyx_t_15 = 0;

     062:                      &number_of_selected_stations,\

    +063:                      &permutation[0],\

      __pyx_t_17 = 0;

     064:                      verbose)

     065:

    +066:   assert cdata != NULL, "No STS_DATA returned"

      #ifndef CYTHON_WITHOUT_ASSERTIONS
      if (unlikely(!Py_OptimizeFlag)) {
        if (unlikely(!((__pyx_v_cdata != NULL) != 0))) {
          PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_No_STS_DATA_returned);
          __PYX_ERR(0, 66, __pyx_L1_error)
        }
      }
      #endif

     067:

    +068:   total_number_of_stations = int(file_params[0])

      __pyx_t_17 = 0;
      __pyx_v_total_number_of_stations = ((int)(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_file_params.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_file_params.diminfo[0].strides)));

    +069:   dt = file_params[1]

      __pyx_t_17 = 1;
      __pyx_v_dt = (*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_file_params.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_file_params.diminfo[0].strides));

    +070:   nt = int(file_params[2])

      __pyx_t_17 = 2;
      __pyx_v_nt = ((int)(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_file_params.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_file_params.diminfo[0].strides)));

     071:

     072:   # Find min and max start times of all gauges

    +073:   start_tstep = nt + 1

      __pyx_v_start_tstep = (__pyx_v_nt + 1);

    +074:   finish_tstep = -1

      __pyx_v_finish_tstep = -1;

    +075:   for i in xrange(number_of_selected_stations):

      __pyx_t_5 = __pyx_v_number_of_selected_stations;
      __pyx_t_12 = __pyx_t_5;
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

    +076:     if int(cdata[i][nt + 3]) < start_tstep:

        __pyx_t_1 = __Pyx_PyInt_FromDouble(((__pyx_v_cdata[__pyx_v_i])[(__pyx_v_nt + 3)])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_start_tstep); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 76, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(0, 76, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__pyx_t_16) {
    /* … */
        }

    +077:       start_tstep = int(cdata[i][nt + 3])

          __pyx_v_start_tstep = ((int)((__pyx_v_cdata[__pyx_v_i])[(__pyx_v_nt + 3)]));

    +078:     if int(cdata[i][nt + 4]) > finish_tstep:

        __pyx_t_6 = __Pyx_PyInt_FromDouble(((__pyx_v_cdata[__pyx_v_i])[(__pyx_v_nt + 4)])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 78, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_finish_tstep); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = PyObject_RichCompare(__pyx_t_6, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(0, 78, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_16) {
    /* … */
        }
      }

    +079:       finish_tstep = int(cdata[i][nt + 4])

          __pyx_v_finish_tstep = ((int)((__pyx_v_cdata[__pyx_v_i])[(__pyx_v_nt + 4)]));

     080:

    +081:   if start_tstep > nt or finish_tstep < 0:

      __pyx_t_18 = ((__pyx_v_start_tstep > __pyx_v_nt) != 0);
      if (!__pyx_t_18) {
      } else {
        __pyx_t_16 = __pyx_t_18;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_18 = ((__pyx_v_finish_tstep < 0) != 0);
      __pyx_t_16 = __pyx_t_18;
      __pyx_L13_bool_binop_done:;
      if (__pyx_t_16) {
    /* … */
      }

    +082:     print "ERROR: Gauge data has incorrect start and finish times:"

        if (__Pyx_PrintOne(0, __pyx_kp_s_ERROR_Gauge_data_has_incorrect_s) < 0) __PYX_ERR(0, 82, __pyx_L1_error)

    +083:     print "   start_tstep = %d, max_number_of_steps = %d" % (start_tstep, nt)

        __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_start_tstep); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_nt); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 83, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
        __pyx_t_1 = 0;
        __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_start_tstep_d_max_number_of_ste, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__Pyx_PrintOne(0, __pyx_t_3) < 0) __PYX_ERR(0, 83, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    +084:     print "   finish_tstep = %d, min_number_of_steps = %d" % (finish_tstep, 0)

        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_finish_tstep); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 84, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_0);
        __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_finish_tstep_d_min_number_of_st, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__Pyx_PrintOne(0, __pyx_t_3) < 0) __PYX_ERR(0, 84, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     085:

    +086:     assert start_tstep <= nt and finish_tstep >= 0, "Incorrect start and finish times"

        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          __pyx_t_18 = ((__pyx_v_start_tstep <= __pyx_v_nt) != 0);
          if (__pyx_t_18) {
          } else {
            __pyx_t_16 = __pyx_t_18;
            goto __pyx_L15_bool_binop_done;
          }
          __pyx_t_18 = ((__pyx_v_finish_tstep >= 0) != 0);
          __pyx_t_16 = __pyx_t_18;
          __pyx_L15_bool_binop_done:;
          if (unlikely(!__pyx_t_16)) {
            PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_Incorrect_start_and_finish_times);
            __PYX_ERR(0, 86, __pyx_L1_error)
          }
        }
        #endif

     087:

    +088:     free(weights)

        free(__pyx_v_weights);

    +089:     free(muxFileNameArray)

        free(__pyx_v_muxFileNameArray);

     090:

    +091:     for i in xrange(number_of_selected_stations):

        __pyx_t_5 = __pyx_v_number_of_selected_stations;
        __pyx_t_12 = __pyx_t_5;
        for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
          __pyx_v_i = __pyx_t_13;

    +092:       free(cdata[i])

          free((__pyx_v_cdata[__pyx_v_i]));
        }

    +093:     free(cdata)

        free(__pyx_v_cdata);

     094:

    +095:   if start_tstep >= finish_tstep:

      __pyx_t_16 = ((__pyx_v_start_tstep >= __pyx_v_finish_tstep) != 0);
      if (__pyx_t_16) {
    /* … */
      }

    +096:     assert start_tstep < finish_tstep, "ERROR: Gauge data has non-positive length"

        #ifndef CYTHON_WITHOUT_ASSERTIONS
        if (unlikely(!Py_OptimizeFlag)) {
          if (unlikely(!((__pyx_v_start_tstep < __pyx_v_finish_tstep) != 0))) {
            PyErr_SetObject(PyExc_AssertionError, __pyx_kp_s_ERROR_Gauge_data_has_non_positiv);
            __PYX_ERR(0, 96, __pyx_L1_error)
          }
        }
        #endif

    +097:     free(weights)

        free(__pyx_v_weights);

    +098:     free(muxFileNameArray)

        free(__pyx_v_muxFileNameArray);

    +099:     for i in xrange(number_of_selected_stations):

        __pyx_t_5 = __pyx_v_number_of_selected_stations;
        __pyx_t_12 = __pyx_t_5;
        for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
          __pyx_v_i = __pyx_t_13;

    +100:       free(cdata[i])

          free((__pyx_v_cdata[__pyx_v_i]));
        }

    +101:     free(cdata)

        free(__pyx_v_cdata);

     102:

    +103:   num_ts = finish_tstep - start_tstep + 1

      __pyx_v_num_ts = ((__pyx_v_finish_tstep - __pyx_v_start_tstep) + 1);

    +104:   dimensions[0] = number_of_selected_stations

      (__pyx_v_dimensions[0]) = __pyx_v_number_of_selected_stations;

    +105:   dimensions[1] = num_ts + POFFSET

      (__pyx_v_dimensions[1]) = (__pyx_v_num_ts + __pyx_v_POFFSET);

     106:

     107:   # Each gauge begins and ends recording at different times. When a gauge is

     108:   # not recording but at least one other gauge is.

     109:   # Pad the non recording gauge array with zeros.

    +110:   pydata = np.zeros((dimensions[0],dimensions[1]),dtype=float)

      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_dimensions[0])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_dimensions[1])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
      __pyx_t_3 = 0;
      __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 110, __pyx_L1_error)
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 110, __pyx_L1_error)
      __pyx_t_19 = ((PyArrayObject *)__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pydata.rcbuffer->pybuffer);
        __pyx_t_5 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pydata.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_5 < 0)) {
          PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pydata.rcbuffer->pybuffer, (PyObject*)__pyx_v_pydata, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
          }
          __pyx_t_8 = __pyx_t_9 = __pyx_t_10 = 0;
        }
        __pyx_pybuffernd_pydata.diminfo[0].strides = __pyx_pybuffernd_pydata.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pydata.diminfo[0].shape = __pyx_pybuffernd_pydata.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pydata.diminfo[1].strides = __pyx_pybuffernd_pydata.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pydata.diminfo[1].shape = __pyx_pybuffernd_pydata.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 110, __pyx_L1_error)
      }
      __pyx_t_19 = 0;
      __pyx_v_pydata = ((PyArrayObject *)__pyx_t_3);
      __pyx_t_3 = 0;

    +111:   for i in xrange(number_of_selected_stations):

      __pyx_t_5 = __pyx_v_number_of_selected_stations;
      __pyx_t_12 = __pyx_t_5;
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

    +112:     time = 0

        __pyx_v_time = 0;

    +113:     for it in xrange(finish_tstep):

        __pyx_t_20 = __pyx_v_finish_tstep;
        __pyx_t_21 = __pyx_t_20;
        for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
          __pyx_v_it = __pyx_t_22;

    +114:       if it + 1 >= start_tstep and it + 1 <= finish_tstep:

          __pyx_t_18 = (((__pyx_v_it + 1) >= __pyx_v_start_tstep) != 0);
          if (__pyx_t_18) {
          } else {
            __pyx_t_16 = __pyx_t_18;
            goto __pyx_L27_bool_binop_done;
          }
          __pyx_t_18 = (((__pyx_v_it + 1) <= __pyx_v_finish_tstep) != 0);
          __pyx_t_16 = __pyx_t_18;
          __pyx_L27_bool_binop_done:;
          if (__pyx_t_16) {
    /* … */
          }
        }

    +115:         if it + 1 <= int(cdata[i][nt + 4]):

            __pyx_t_3 = __Pyx_PyInt_From_long((__pyx_v_it + 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_2 = __Pyx_PyInt_FromDouble(((__pyx_v_cdata[__pyx_v_i])[(__pyx_v_nt + 4)])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_16 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(0, 115, __pyx_L1_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (__pyx_t_16) {
    /* … */
            }

    +116:           pydata[i,time] = cdata[i][it]

              __pyx_t_17 = __pyx_v_i;
              __pyx_t_15 = __pyx_v_time;
              *__Pyx_BufPtrCContig2d(double *, __pyx_pybuffernd_pydata.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_pydata.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_pydata.diminfo[1].strides) = ((__pyx_v_cdata[__pyx_v_i])[__pyx_v_it]);

    +117:         time += 1

            __pyx_v_time = (__pyx_v_time + 1);

    +118:     for j in xrange(POFFSET):

        __pyx_t_20 = __pyx_v_POFFSET;
        __pyx_t_21 = __pyx_t_20;
        for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {
          __pyx_v_j = __pyx_t_22;

    +119:       pydata[i,num_ts + j] = cdata[i][nt + j]

          __pyx_t_15 = __pyx_v_i;
          __pyx_t_17 = (__pyx_v_num_ts + __pyx_v_j);
          *__Pyx_BufPtrCContig2d(double *, __pyx_pybuffernd_pydata.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_pydata.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_pydata.diminfo[1].strides) = ((__pyx_v_cdata[__pyx_v_i])[(__pyx_v_nt + __pyx_v_j)]);
        }
      }

     120:

    +121:   free(weights)

      free(__pyx_v_weights);

    +122:   free(muxFileNameArray)

      free(__pyx_v_muxFileNameArray);

    +123:   for i in xrange(number_of_selected_stations):

      __pyx_t_5 = __pyx_v_number_of_selected_stations;
      __pyx_t_12 = __pyx_t_5;
      for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
        __pyx_v_i = __pyx_t_13;

    +124:     free(cdata[i])

        free((__pyx_v_cdata[__pyx_v_i]));
      }

    +125:   free(cdata)

      free(__pyx_v_cdata);

     126:

    +127:   return pydata

      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(((PyObject *)__pyx_v_pydata));
      __pyx_r = ((PyObject *)__pyx_v_pydata);
      goto __pyx_L0;

     128:

     129: