@@ -1326,7 +1326,7 @@ void cntr_del(Csite *site)
13261326
13271327
13281328/* Build a list of XY 2-D arrays, shape (N,2), to which a list of K arrays
1329- is concatenated concatenated . */
1329+ is concatenated. */
13301330static PyObject *
13311331build_cntr_list_v2 (long * np , double * xp , double * yp , short * kp ,
13321332 int nparts , long ntotal )
@@ -1653,6 +1653,29 @@ Cntr_trace(Cntr *self, PyObject *args, PyObject *kwds)
16531653 return cntr_trace (self -> site , levels , nlevels , nchunk );
16541654}
16551655
1656+ /* The following will not normally be called. It is experimental,
1657+ and intended for future debugging. It may go away at any time.
1658+ */
1659+ static PyObject *
1660+ Cntr_get_cdata (Cntr * self )
1661+ {
1662+ PyArrayObject * Cdata ;
1663+ npy_intp dims [2 ];
1664+ int i , j ;
1665+ int ni , nj ;
1666+
1667+ dims [0 ] = ni = self -> site -> imax ;
1668+ dims [1 ] = nj = self -> site -> jmax ;
1669+
1670+ Cdata = (PyArrayObject * ) PyArray_SimpleNew (2 , dims , PyArray_SHORT );
1671+ for (j = 0 ; j < nj ; j ++ )
1672+ for (i = 0 ; i < ni ; i ++ )
1673+ Cdata -> data [j + i * nj ] = self -> site -> data [i + j * ni ];
1674+ /* output is C-order, input is F-order */
1675+ /* for now we are ignoring the last ni+1 values */
1676+ return (PyObject * )Cdata ;
1677+ }
1678+
16561679static PyMethodDef Cntr_methods [] = {
16571680 {"trace" , (PyCFunction )Cntr_trace , METH_VARARGS | METH_KEYWORDS ,
16581681 "Return a list of contour line segments or polygons.\n\n"
@@ -1665,6 +1688,12 @@ static PyMethodDef Cntr_methods[] = {
16651688 " Optional argument: nchunk; approximate number of grid points\n"
16661689 " per chunk. 0 (default) for no chunking.\n"
16671690 },
1691+ {"get_cdata" , (PyCFunction )Cntr_get_cdata , METH_NOARGS ,
1692+ "Returns a copy of the mesh array with contour calculation codes.\n\n"
1693+ "Experimental and incomplete; we are not returning quite all of\n"
1694+ "the array.\n"
1695+ "Don't call this unless you are exploring the dark recesses of cntr.c\n"
1696+ },
16681697 {0 , 0 , 0 , 0 } /* Sentinel */
16691698};
16701699
0 commit comments