|
From: <js...@us...> - 2008-07-22 11:12:54
|
Revision: 5808
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5808&view=rev
Author: jswhit
Date: 2008-07-22 11:12:50 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
initial checkin of natgrid toolkit.
Added Paths:
-----------
trunk/toolkits/natgrid/
trunk/toolkits/natgrid/Copyright.txt
trunk/toolkits/natgrid/README
trunk/toolkits/natgrid/lib/
trunk/toolkits/natgrid/lib/mpl_toolkits/
trunk/toolkits/natgrid/lib/mpl_toolkits/__init__.py
trunk/toolkits/natgrid/lib/mpl_toolkits/natgrid/
trunk/toolkits/natgrid/lib/mpl_toolkits/natgrid/__init__.py
trunk/toolkits/natgrid/setup.py
trunk/toolkits/natgrid/setupegg.py
trunk/toolkits/natgrid/src/
trunk/toolkits/natgrid/src/_natgrid.c
trunk/toolkits/natgrid/src/_natgrid.pyx
trunk/toolkits/natgrid/src/natgrid.c
trunk/toolkits/natgrid/src/natgridd.c
trunk/toolkits/natgrid/src/natgrids.c
trunk/toolkits/natgrid/src/nnchead.h
trunk/toolkits/natgrid/src/nncheadd.h
trunk/toolkits/natgrid/src/nncheads.h
trunk/toolkits/natgrid/src/nncrunch.c
trunk/toolkits/natgrid/src/nncrunchd.c
trunk/toolkits/natgrid/src/nncrunchs.c
trunk/toolkits/natgrid/src/nnerror.c
trunk/toolkits/natgrid/src/nnexver.h
trunk/toolkits/natgrid/src/nnghead.h
trunk/toolkits/natgrid/src/nngheadd.h
trunk/toolkits/natgrid/src/nngheads.h
trunk/toolkits/natgrid/src/nnmhead.h
trunk/toolkits/natgrid/src/nntpvrs.h
trunk/toolkits/natgrid/src/nntypes.h
trunk/toolkits/natgrid/src/nnuhead.h
trunk/toolkits/natgrid/src/nnuheadd.h
trunk/toolkits/natgrid/src/nnuheads.h
trunk/toolkits/natgrid/src/nnuser.c
trunk/toolkits/natgrid/src/nnuserd.c
trunk/toolkits/natgrid/src/nnusers.c
trunk/toolkits/natgrid/test.py
Added: trunk/toolkits/natgrid/Copyright.txt
===================================================================
--- trunk/toolkits/natgrid/Copyright.txt (rev 0)
+++ trunk/toolkits/natgrid/Copyright.txt 2008-07-22 11:12:50 UTC (rev 5808)
@@ -0,0 +1,37 @@
+NCL - UNIX Version 5.0.0
+Copyright (C) 2007
+University Corporation for Atmospheric Research
+
+NCL Source Code License
+
+Copyright (c) 2007 University Corporation for Atmospheric Research
+(UCAR). All rights reserved. Developed by NCAR's Computational and
+Information Systems Laboratory, UCAR, www.cisl.ucar.edu, with the
+following contributions:
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+Neither the names of NCAR's Computational and Information Systems
+Laboratory, the University Corporation for Atmospheric Research, nor
+the names of its contributors may be used to endorse or promote
+products derived from this Software without specific prior written
+permission.
+
+Redistributions of source code must retain the above copyright
+notice, this list of conditions, and the disclaimer below.
+
+Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions, and the disclaimer below in the
+documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+SOFTWARE.
Added: trunk/toolkits/natgrid/README
===================================================================
--- trunk/toolkits/natgrid/README (rev 0)
+++ trunk/toolkits/natgrid/README 2008-07-22 11:12:50 UTC (rev 5808)
@@ -0,0 +1,35 @@
+Python interface to NCAR natgrid library
+(http://www.ncarg.ucar.edu//ngmath/natgrid/nnhome.html).
+
+When installed, will be used by the matplotlib.mlab griddata function.
+
+Not otherwise intended for public consumption.
+
+*LICENSE*
+
+NCAR natgrid source code licensed under the terms given in Copyright.txt,
+except for code in the file src/nncrunch.c, which is based on code written and
+copyrighted (C) by Dave Watson. Dr. Watson retains the copyright to his
+original code.
+
+The Python interface (src/_natgrid.pyx and src/_natgrid.c) are made available
+under the following license:
+
+copyright (c) 2007 by Jeffrey Whitaker.
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notices appear in all copies and that
+both the copyright notices and this permission notice appear in
+supporting documentation.
+THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+*Contact*
+
+Jeff Whitaker <jeffrey.s.whitaker@noaa,gov>
Added: trunk/toolkits/natgrid/lib/mpl_toolkits/__init__.py
===================================================================
--- trunk/toolkits/natgrid/lib/mpl_toolkits/__init__.py (rev 0)
+++ trunk/toolkits/natgrid/lib/mpl_toolkits/__init__.py 2008-07-22 11:12:50 UTC (rev 5808)
@@ -0,0 +1,4 @@
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ pass # must not have setuptools
Added: trunk/toolkits/natgrid/setup.py
===================================================================
--- trunk/toolkits/natgrid/setup.py (rev 0)
+++ trunk/toolkits/natgrid/setup.py 2008-07-22 11:12:50 UTC (rev 5808)
@@ -0,0 +1,27 @@
+import glob
+from distutils.core import setup, Extension
+deps = glob.glob('src/*.c')
+packages = ['mpl_toolkits','mpl_toolkits.natgrid']
+package_dirs = {'':'lib'}
+extensions = [Extension("mpl_toolkits.natgrid._natgrid",deps,include_dirs = ['src'],)]
+setup(
+ name = "natgrid",
+ version = "0.1",
+ description = "Python interface to NCAR natgrid library",
+ url = "http://matplotlib.sourceforge.net/toolkits.html",
+ download_url = "http://sourceforge.net/projects/matplotlib",
+ author = "Jeff Whitaker",
+ author_email = "jef...@no...",
+ platforms = ["any"],
+ license = "Restricted",
+ keywords = ["python","plotting","plots","graphs","charts","GIS","mapping","map projections","maps"],
+ classifiers = ["Development Status :: 4 - Beta",
+ "Intended Audience :: Science/Research",
+ "License :: OSI Approved",
+ "Topic :: Scientific/Engineering :: Visualization",
+ "Topic :: Software Development :: Libraries :: Python Modules",
+ "Operating System :: OS Independent"],
+ packages = packages,
+ package_dir = package_dirs,
+ ext_modules = extensions,
+ )
Added: trunk/toolkits/natgrid/setupegg.py
===================================================================
--- trunk/toolkits/natgrid/setupegg.py (rev 0)
+++ trunk/toolkits/natgrid/setupegg.py 2008-07-22 11:12:50 UTC (rev 5808)
@@ -0,0 +1,8 @@
+"""
+Poor man's setuptools script...
+"""
+
+from setuptools import setup
+execfile('setup.py',
+ {'additional_params' :
+ {'namespace_packages' : ['mpl_toolkits']}})
Added: trunk/toolkits/natgrid/src/_natgrid.c
===================================================================
--- trunk/toolkits/natgrid/src/_natgrid.c (rev 0)
+++ trunk/toolkits/natgrid/src/_natgrid.c 2008-07-22 11:12:50 UTC (rev 5808)
@@ -0,0 +1,1112 @@
+/* Generated by Cython 0.9.6.12 on Sun Jul 20 11:01:12 2008 */
+
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#include "structmember.h"
+#ifndef PY_LONG_LONG
+ #define PY_LONG_LONG LONG_LONG
+#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 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)
+#endif
+#if PY_VERSION_HEX < 0x02040000
+ #define METH_COEXIST 0
+#endif
+#ifndef WIN32
+ #define __stdcall
+ #define __cdecl
+#endif
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+#include <math.h>
+
+
+#ifdef __GNUC__
+#define INLINE __inline__
+#elif _WIN32
+#define INLINE __inline
+#else
+#define INLINE
+#endif
+
+typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/
+typedef struct {PyObject **p; char *s; long n; int is_unicode;} __Pyx_StringTabEntry; /*proto*/
+
+
+
+static int __pyx_skip_dispatch = 0;
+
+
+/* Type Conversion Predeclarations */
+
+#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
+static INLINE int __Pyx_PyObject_IsTrue(PyObject* x);
+static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x);
+static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x);
+static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b);
+
+#define __pyx_PyInt_AsLong(x) (PyInt_CheckExact(x) ? PyInt_AS_LONG(x) : PyInt_AsLong(x))
+#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+
+static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x);
+static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x);
+static INLINE char __pyx_PyInt_char(PyObject* x);
+static INLINE short __pyx_PyInt_short(PyObject* x);
+static INLINE int __pyx_PyInt_int(PyObject* x);
+static INLINE long __pyx_PyInt_long(PyObject* x);
+static INLINE signed char __pyx_PyInt_signed_char(PyObject* x);
+static INLINE signed short __pyx_PyInt_signed_short(PyObject* x);
+static INLINE signed int __pyx_PyInt_signed_int(PyObject* x);
+static INLINE signed long __pyx_PyInt_signed_long(PyObject* x);
+static INLINE long double __pyx_PyInt_long_double(PyObject* 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 int __pyx_lineno;
+static char *__pyx_filename;
+static char **__pyx_f;
+
+static char __pyx_mdoc[] = "\nPyrex wrapper for NCAR natgrid library for interpolation\nof irregularly spaced data to a grid.\n\ncopyright (c) 2007 by Jeffrey Whitaker.\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notices appear in all copies and that\nboth the copyright notices and this permission notice appear in\nsupporting documentation.\nTHE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO\nEVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR\nCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF\nUSE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n";
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
+static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+
+static void __Pyx_AddTraceback(char *funcname); /*proto*/
+
+/* Declarations from _natgrid */
+
+__PYX_EXTERN_C DL_EXPORT(void) c_nnseti(char *, int); /*proto*/
+__PYX_EXTERN_C DL_EXPORT(double) *c_natgridd(int, double *, double *, double *, int, int, double *, double *, int *); /*proto*/
+__PYX_EXTERN_C DL_EXPORT(void) c_nnsetr(char *, float); /*proto*/
+
+
+/* Implementation of _natgrid */
+
+/* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":32
+ * char *PyString_AsString(object)
+ *
+ * def seti(name, value): # <<<<<<<<<<<<<<
+ * cdef char *pnam
+ * cdef int ival
+ */
+
+static PyObject *__pyx_pf_8_natgrid_seti(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_8_natgrid_seti(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_name = 0;
+ PyObject *__pyx_v_value = 0;
+ char *__pyx_v_pnam;
+ int __pyx_v_ival;
+ PyObject *__pyx_r;
+ char *__pyx_1;
+ int __pyx_2;
+ static char *__pyx_argnames[] = {"name","value",0};
+ if (likely(!__pyx_kwds) && likely(PyTuple_GET_SIZE(__pyx_args) == 2)) {
+ __pyx_v_name = PyTuple_GET_ITEM(__pyx_args, 0);
+ __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 1);
+ }
+ else {
+ if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_name, &__pyx_v_value))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; goto __pyx_L2;}
+ }
+ goto __pyx_L3;
+ __pyx_L2:;
+ return NULL;
+ __pyx_L3:;
+ Py_INCREF(__pyx_v_name);
+ Py_INCREF(__pyx_v_value);
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":35
+ * cdef char *pnam
+ * cdef int ival
+ * pnam = name; ival = value # <<<<<<<<<<<<<<
+ * c_nnseti(pnam, ival)
+ *
+ */
+ __pyx_1 = PyString_AsString(__pyx_v_name); if (unlikely((!__pyx_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;}
+ __pyx_v_pnam = __pyx_1;
+ __pyx_2 = __pyx_PyInt_int(__pyx_v_value); if (unlikely((__pyx_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; goto __pyx_L1;}
+ __pyx_v_ival = __pyx_2;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":36
+ * cdef int ival
+ * pnam = name; ival = value
+ * c_nnseti(pnam, ival) # <<<<<<<<<<<<<<
+ *
+ * def setr(name, value):
+ */
+ c_nnseti(__pyx_v_pnam, __pyx_v_ival);
+
+ __pyx_r = Py_None; Py_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1:;
+ __Pyx_AddTraceback("_natgrid.seti");
+ __pyx_r = NULL;
+ __pyx_L0:;
+ Py_DECREF(__pyx_v_name);
+ Py_DECREF(__pyx_v_value);
+ return __pyx_r;
+}
+
+/* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":38
+ * c_nnseti(pnam, ival)
+ *
+ * def setr(name, value): # <<<<<<<<<<<<<<
+ * cdef char *pnam
+ * cdef float fval
+ */
+
+static PyObject *__pyx_pf_8_natgrid_setr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_8_natgrid_setr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_name = 0;
+ PyObject *__pyx_v_value = 0;
+ char *__pyx_v_pnam;
+ float __pyx_v_fval;
+ PyObject *__pyx_r;
+ char *__pyx_1;
+ float __pyx_2;
+ static char *__pyx_argnames[] = {"name","value",0};
+ if (likely(!__pyx_kwds) && likely(PyTuple_GET_SIZE(__pyx_args) == 2)) {
+ __pyx_v_name = PyTuple_GET_ITEM(__pyx_args, 0);
+ __pyx_v_value = PyTuple_GET_ITEM(__pyx_args, 1);
+ }
+ else {
+ if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_name, &__pyx_v_value))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; goto __pyx_L2;}
+ }
+ goto __pyx_L3;
+ __pyx_L2:;
+ return NULL;
+ __pyx_L3:;
+ Py_INCREF(__pyx_v_name);
+ Py_INCREF(__pyx_v_value);
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":41
+ * cdef char *pnam
+ * cdef float fval
+ * pnam = name; fval = value # <<<<<<<<<<<<<<
+ * c_nnsetr(pnam, fval)
+ *
+ */
+ __pyx_1 = PyString_AsString(__pyx_v_name); if (unlikely((!__pyx_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; goto __pyx_L1;}
+ __pyx_v_pnam = __pyx_1;
+ __pyx_2 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; goto __pyx_L1;}
+ __pyx_v_fval = __pyx_2;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":42
+ * cdef float fval
+ * pnam = name; fval = value
+ * c_nnsetr(pnam, fval) # <<<<<<<<<<<<<<
+ *
+ * def natgridd(x, y, z, xo, yo, zo):
+ */
+ c_nnsetr(__pyx_v_pnam, __pyx_v_fval);
+
+ __pyx_r = Py_None; Py_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1:;
+ __Pyx_AddTraceback("_natgrid.setr");
+ __pyx_r = NULL;
+ __pyx_L0:;
+ Py_DECREF(__pyx_v_name);
+ Py_DECREF(__pyx_v_value);
+ return __pyx_r;
+}
+
+/* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":44
+ * c_nnsetr(pnam, fval)
+ *
+ * def natgridd(x, y, z, xo, yo, zo): # <<<<<<<<<<<<<<
+ * cdef int npnts, numxout, numyout, ier
+ * cdef Py_ssize_t buflenx, bufleny, buflenz, buflenxo, buflenyo, buflenzo
+ */
+
+static PyObject *__pyx_n_RuntimeError;
+
+static PyObject *__pyx_k_1p;
+static PyObject *__pyx_k_2p;
+static PyObject *__pyx_k_3p;
+static PyObject *__pyx_k_4p;
+static PyObject *__pyx_k_5p;
+static PyObject *__pyx_k_6p;
+static PyObject *__pyx_k_7p;
+
+static PyObject *__pyx_builtin_RuntimeError;
+
+static char __pyx_k_1[] = "error getting buffer for x";
+static char __pyx_k_2[] = "error getting buffer for y";
+static char __pyx_k_3[] = "error getting buffer for z";
+static char __pyx_k_4[] = "error getting buffer for x";
+static char __pyx_k_5[] = "error getting buffer for y";
+static char __pyx_k_6[] = "error getting buffer for z";
+static char __pyx_k_7[] = "error in natgridd - ier =";
+
+static PyObject *__pyx_pf_8_natgrid_natgridd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_8_natgrid_natgridd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_x = 0;
+ PyObject *__pyx_v_y = 0;
+ PyObject *__pyx_v_z = 0;
+ PyObject *__pyx_v_xo = 0;
+ PyObject *__pyx_v_yo = 0;
+ PyObject *__pyx_v_zo = 0;
+ int __pyx_v_npnts;
+ int __pyx_v_numxout;
+ int __pyx_v_numyout;
+ int __pyx_v_ier;
+ Py_ssize_t __pyx_v_buflenx;
+ Py_ssize_t __pyx_v_bufleny;
+ Py_ssize_t __pyx_v_buflenz;
+ Py_ssize_t __pyx_v_buflenxo;
+ Py_ssize_t __pyx_v_buflenyo;
+ Py_ssize_t __pyx_v_buflenzo;
+ void *__pyx_v_xp;
+ void *__pyx_v_yp;
+ void *__pyx_v_zp;
+ void *__pyx_v_xop;
+ void *__pyx_v_yop;
+ void *__pyx_v_zop;
+ double *__pyx_v_xd;
+ double *__pyx_v_yd;
+ double *__pyx_v_zd;
+ double *__pyx_v_xod;
+ double *__pyx_v_yod;
+ double *__pyx_v_zod;
+ double *__pyx_v_out;
+ PyObject *__pyx_v_i;
+ PyObject *__pyx_r;
+ Py_ssize_t __pyx_1 = 0;
+ int __pyx_2;
+ PyObject *__pyx_3 = 0;
+ PyObject *__pyx_4 = 0;
+ long __pyx_5;
+ Py_ssize_t __pyx_6 = 0;
+ Py_ssize_t __pyx_7 = 0;
+ static char *__pyx_argnames[] = {"x","y","z","xo","yo","zo",0};
+ if (likely(!__pyx_kwds) && likely(PyTuple_GET_SIZE(__pyx_args) == 6)) {
+ __pyx_v_x = PyTuple_GET_ITEM(__pyx_args, 0);
+ __pyx_v_y = PyTuple_GET_ITEM(__pyx_args, 1);
+ __pyx_v_z = PyTuple_GET_ITEM(__pyx_args, 2);
+ __pyx_v_xo = PyTuple_GET_ITEM(__pyx_args, 3);
+ __pyx_v_yo = PyTuple_GET_ITEM(__pyx_args, 4);
+ __pyx_v_zo = PyTuple_GET_ITEM(__pyx_args, 5);
+ }
+ else {
+ if (unlikely(!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z, &__pyx_v_xo, &__pyx_v_yo, &__pyx_v_zo))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; goto __pyx_L2;}
+ }
+ goto __pyx_L3;
+ __pyx_L2:;
+ return NULL;
+ __pyx_L3:;
+ Py_INCREF(__pyx_v_x);
+ Py_INCREF(__pyx_v_y);
+ Py_INCREF(__pyx_v_z);
+ Py_INCREF(__pyx_v_xo);
+ Py_INCREF(__pyx_v_yo);
+ Py_INCREF(__pyx_v_zo);
+ __pyx_v_i = Py_None; Py_INCREF(Py_None);
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":49
+ * cdef void *xp, *yp, *zp, *xop, *yop, *zop
+ * cdef double *xd, *yd, *zd, *xod, *yod, *zod, *out
+ * npnts = len(x) # <<<<<<<<<<<<<<
+ * numxout = len(xo)
+ * numyout = len(yo)
+ */
+ __pyx_1 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; goto __pyx_L1;}
+ __pyx_v_npnts = __pyx_1;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":50
+ * cdef double *xd, *yd, *zd, *xod, *yod, *zod, *out
+ * npnts = len(x)
+ * numxout = len(xo) # <<<<<<<<<<<<<<
+ * numyout = len(yo)
+ * if PyObject_AsWriteBuffer(x, &xp, &buflenx) <> 0:
+ */
+ __pyx_1 = PyObject_Length(__pyx_v_xo); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; goto __pyx_L1;}
+ __pyx_v_numxout = __pyx_1;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":51
+ * npnts = len(x)
+ * numxout = len(xo)
+ * numyout = len(yo) # <<<<<<<<<<<<<<
+ * if PyObject_AsWriteBuffer(x, &xp, &buflenx) <> 0:
+ * raise RuntimeError('error getting buffer for x')
+ */
+ __pyx_1 = PyObject_Length(__pyx_v_yo); if (unlikely(__pyx_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; goto __pyx_L1;}
+ __pyx_v_numyout = __pyx_1;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":52
+ * numxout = len(xo)
+ * numyout = len(yo)
+ * if PyObject_AsWriteBuffer(x, &xp, &buflenx) <> 0: # <<<<<<<<<<<<<<
+ * raise RuntimeError('error getting buffer for x')
+ * if PyObject_AsWriteBuffer(y, &yp, &bufleny) <> 0:
+ */
+ __pyx_2 = (PyObject_AsWriteBuffer(__pyx_v_x, (&__pyx_v_xp), (&__pyx_v_buflenx)) != 0);
+ if (__pyx_2) {
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":53
+ * numyout = len(yo)
+ * if PyObject_AsWriteBuffer(x, &xp, &buflenx) <> 0:
+ * raise RuntimeError('error getting buffer for x') # <<<<<<<<<<<<<<
+ * if PyObject_AsWriteBuffer(y, &yp, &bufleny) <> 0:
+ * raise RuntimeError('error getting buffer for y')
+ */
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;}
+ Py_INCREF(__pyx_k_1p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k_1p);
+ __pyx_4 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_3, NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;}
+ Py_DECREF(__pyx_3); __pyx_3 = 0;
+ __Pyx_Raise(__pyx_4, 0, 0);
+ Py_DECREF(__pyx_4); __pyx_4 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;}
+ goto __pyx_L4;
+ }
+ __pyx_L4:;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":54
+ * if PyObject_AsWriteBuffer(x, &xp, &buflenx) <> 0:
+ * raise RuntimeError('error getting buffer for x')
+ * if PyObject_AsWriteBuffer(y, &yp, &bufleny) <> 0: # <<<<<<<<<<<<<<
+ * raise RuntimeError('error getting buffer for y')
+ * if PyObject_AsWriteBuffer(z, &zp, &buflenz) <> 0:
+ */
+ __pyx_2 = (PyObject_AsWriteBuffer(__pyx_v_y, (&__pyx_v_yp), (&__pyx_v_bufleny)) != 0);
+ if (__pyx_2) {
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":55
+ * raise RuntimeError('error getting buffer for x')
+ * if PyObject_AsWriteBuffer(y, &yp, &bufleny) <> 0:
+ * raise RuntimeError('error getting buffer for y') # <<<<<<<<<<<<<<
+ * if PyObject_AsWriteBuffer(z, &zp, &buflenz) <> 0:
+ * raise RuntimeError('error getting buffer for z')
+ */
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; goto __pyx_L1;}
+ Py_INCREF(__pyx_k_2p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k_2p);
+ __pyx_4 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_3, NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; goto __pyx_L1;}
+ Py_DECREF(__pyx_3); __pyx_3 = 0;
+ __Pyx_Raise(__pyx_4, 0, 0);
+ Py_DECREF(__pyx_4); __pyx_4 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; goto __pyx_L1;}
+ goto __pyx_L5;
+ }
+ __pyx_L5:;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":56
+ * if PyObject_AsWriteBuffer(y, &yp, &bufleny) <> 0:
+ * raise RuntimeError('error getting buffer for y')
+ * if PyObject_AsWriteBuffer(z, &zp, &buflenz) <> 0: # <<<<<<<<<<<<<<
+ * raise RuntimeError('error getting buffer for z')
+ * xd = <double *>xp
+ */
+ __pyx_2 = (PyObject_AsWriteBuffer(__pyx_v_z, (&__pyx_v_zp), (&__pyx_v_buflenz)) != 0);
+ if (__pyx_2) {
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":57
+ * raise RuntimeError('error getting buffer for y')
+ * if PyObject_AsWriteBuffer(z, &zp, &buflenz) <> 0:
+ * raise RuntimeError('error getting buffer for z') # <<<<<<<<<<<<<<
+ * xd = <double *>xp
+ * yd = <double *>yp
+ */
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;}
+ Py_INCREF(__pyx_k_3p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k_3p);
+ __pyx_4 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_3, NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;}
+ Py_DECREF(__pyx_3); __pyx_3 = 0;
+ __Pyx_Raise(__pyx_4, 0, 0);
+ Py_DECREF(__pyx_4); __pyx_4 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; goto __pyx_L1;}
+ goto __pyx_L6;
+ }
+ __pyx_L6:;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":58
+ * if PyObject_AsWriteBuffer(z, &zp, &buflenz) <> 0:
+ * raise RuntimeError('error getting buffer for z')
+ * xd = <double *>xp # <<<<<<<<<<<<<<
+ * yd = <double *>yp
+ * zd = <double *>zp
+ */
+ __pyx_v_xd = ((double *)__pyx_v_xp);
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":59
+ * raise RuntimeError('error getting buffer for z')
+ * xd = <double *>xp
+ * yd = <double *>yp # <<<<<<<<<<<<<<
+ * zd = <double *>zp
+ * if PyObject_AsWriteBuffer(xo, &xop, &buflenxo) <> 0:
+ */
+ __pyx_v_yd = ((double *)__pyx_v_yp);
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":60
+ * xd = <double *>xp
+ * yd = <double *>yp
+ * zd = <double *>zp # <<<<<<<<<<<<<<
+ * if PyObject_AsWriteBuffer(xo, &xop, &buflenxo) <> 0:
+ * raise RuntimeError('error getting buffer for x')
+ */
+ __pyx_v_zd = ((double *)__pyx_v_zp);
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":61
+ * yd = <double *>yp
+ * zd = <double *>zp
+ * if PyObject_AsWriteBuffer(xo, &xop, &buflenxo) <> 0: # <<<<<<<<<<<<<<
+ * raise RuntimeError('error getting buffer for x')
+ * if PyObject_AsWriteBuffer(yo, &yop, &buflenyo) <> 0:
+ */
+ __pyx_2 = (PyObject_AsWriteBuffer(__pyx_v_xo, (&__pyx_v_xop), (&__pyx_v_buflenxo)) != 0);
+ if (__pyx_2) {
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":62
+ * zd = <double *>zp
+ * if PyObject_AsWriteBuffer(xo, &xop, &buflenxo) <> 0:
+ * raise RuntimeError('error getting buffer for x') # <<<<<<<<<<<<<<
+ * if PyObject_AsWriteBuffer(yo, &yop, &buflenyo) <> 0:
+ * raise RuntimeError('error getting buffer for y')
+ */
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;}
+ Py_INCREF(__pyx_k_4p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k_4p);
+ __pyx_4 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_3, NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;}
+ Py_DECREF(__pyx_3); __pyx_3 = 0;
+ __Pyx_Raise(__pyx_4, 0, 0);
+ Py_DECREF(__pyx_4); __pyx_4 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; goto __pyx_L1;}
+ goto __pyx_L7;
+ }
+ __pyx_L7:;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":63
+ * if PyObject_AsWriteBuffer(xo, &xop, &buflenxo) <> 0:
+ * raise RuntimeError('error getting buffer for x')
+ * if PyObject_AsWriteBuffer(yo, &yop, &buflenyo) <> 0: # <<<<<<<<<<<<<<
+ * raise RuntimeError('error getting buffer for y')
+ * if PyObject_AsWriteBuffer(zo, &zop, &buflenzo) <> 0:
+ */
+ __pyx_2 = (PyObject_AsWriteBuffer(__pyx_v_yo, (&__pyx_v_yop), (&__pyx_v_buflenyo)) != 0);
+ if (__pyx_2) {
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":64
+ * raise RuntimeError('error getting buffer for x')
+ * if PyObject_AsWriteBuffer(yo, &yop, &buflenyo) <> 0:
+ * raise RuntimeError('error getting buffer for y') # <<<<<<<<<<<<<<
+ * if PyObject_AsWriteBuffer(zo, &zop, &buflenzo) <> 0:
+ * raise RuntimeError('error getting buffer for z')
+ */
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
+ Py_INCREF(__pyx_k_5p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k_5p);
+ __pyx_4 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_3, NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
+ Py_DECREF(__pyx_3); __pyx_3 = 0;
+ __Pyx_Raise(__pyx_4, 0, 0);
+ Py_DECREF(__pyx_4); __pyx_4 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; goto __pyx_L1;}
+ goto __pyx_L8;
+ }
+ __pyx_L8:;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":65
+ * if PyObject_AsWriteBuffer(yo, &yop, &buflenyo) <> 0:
+ * raise RuntimeError('error getting buffer for y')
+ * if PyObject_AsWriteBuffer(zo, &zop, &buflenzo) <> 0: # <<<<<<<<<<<<<<
+ * raise RuntimeError('error getting buffer for z')
+ * xod = <double *>xop
+ */
+ __pyx_2 = (PyObject_AsWriteBuffer(__pyx_v_zo, (&__pyx_v_zop), (&__pyx_v_buflenzo)) != 0);
+ if (__pyx_2) {
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":66
+ * raise RuntimeError('error getting buffer for y')
+ * if PyObject_AsWriteBuffer(zo, &zop, &buflenzo) <> 0:
+ * raise RuntimeError('error getting buffer for z') # <<<<<<<<<<<<<<
+ * xod = <double *>xop
+ * yod = <double *>yop
+ */
+ __pyx_3 = PyTuple_New(1); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
+ Py_INCREF(__pyx_k_6p);
+ PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k_6p);
+ __pyx_4 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_3, NULL); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
+ Py_DECREF(__pyx_3); __pyx_3 = 0;
+ __Pyx_Raise(__pyx_4, 0, 0);
+ Py_DECREF(__pyx_4); __pyx_4 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; goto __pyx_L1;}
+ goto __pyx_L9;
+ }
+ __pyx_L9:;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":67
+ * if PyObject_AsWriteBuffer(zo, &zop, &buflenzo) <> 0:
+ * raise RuntimeError('error getting buffer for z')
+ * xod = <double *>xop # <<<<<<<<<<<<<<
+ * yod = <double *>yop
+ * zod = <double *>zop
+ */
+ __pyx_v_xod = ((double *)__pyx_v_xop);
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":68
+ * raise RuntimeError('error getting buffer for z')
+ * xod = <double *>xop
+ * yod = <double *>yop # <<<<<<<<<<<<<<
+ * zod = <double *>zop
+ * # output overwrites zo.
+ */
+ __pyx_v_yod = ((double *)__pyx_v_yop);
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":69
+ * xod = <double *>xop
+ * yod = <double *>yop
+ * zod = <double *>zop # <<<<<<<<<<<<<<
+ * # output overwrites zo.
+ * out = c_natgridd(npnts, yd, xd, zd, numyout, numxout, yod, xod, &ier)
+ */
+ __pyx_v_zod = ((double *)__pyx_v_zop);
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":71
+ * zod = <double *>zop
+ * # output overwrites zo.
+ * out = c_natgridd(npnts, yd, xd, zd, numyout, numxout, yod, xod, &ier) # <<<<<<<<<<<<<<
+ * for i from 0 <= i < buflenzo/8:
+ * zod[i] = out[i]
+ */
+ __pyx_v_out = c_natgridd(__pyx_v_npnts, __pyx_v_yd, __pyx_v_xd, __pyx_v_zd, __pyx_v_numyout, __pyx_v_numxout, __pyx_v_yod, __pyx_v_xod, (&__pyx_v_ier));
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":72
+ * # output overwrites zo.
+ * out = c_natgridd(npnts, yd, xd, zd, numyout, numxout, yod, xod, &ier)
+ * for i from 0 <= i < buflenzo/8: # <<<<<<<<<<<<<<
+ * zod[i] = out[i]
+ * if ier != 0:
+ */
+ __pyx_1 = (__pyx_v_buflenzo / 8);
+ for (__pyx_5 = 0; __pyx_5 < __pyx_1; __pyx_5++) {
+ __pyx_3 = PyInt_FromLong(__pyx_5); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; goto __pyx_L1;}
+ Py_DECREF(__pyx_v_i);
+ __pyx_v_i = __pyx_3;
+ __pyx_3 = 0;
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":73
+ * out = c_natgridd(npnts, yd, xd, zd, numyout, numxout, yod, xod, &ier)
+ * for i from 0 <= i < buflenzo/8:
+ * zod[i] = out[i] # <<<<<<<<<<<<<<
+ * if ier != 0:
+ * raise RuntimeError('error in natgridd - ier ='%ier)
+ */
+ __pyx_6 = __pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; goto __pyx_L1;}
+ __pyx_7 = __pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_7 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; goto __pyx_L1;}
+ (__pyx_v_zod[__pyx_7]) = (__pyx_v_out[__pyx_6]);
+ }
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":74
+ * for i from 0 <= i < buflenzo/8:
+ * zod[i] = out[i]
+ * if ier != 0: # <<<<<<<<<<<<<<
+ * raise RuntimeError('error in natgridd - ier ='%ier)
+ */
+ __pyx_2 = (__pyx_v_ier != 0);
+ if (__pyx_2) {
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":75
+ * zod[i] = out[i]
+ * if ier != 0:
+ * raise RuntimeError('error in natgridd - ier ='%ier) # <<<<<<<<<<<<<<
+ */
+ __pyx_4 = PyInt_FromLong(__pyx_v_ier); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;}
+ __pyx_3 = PyNumber_Remainder(__pyx_k_7p, __pyx_4); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;}
+ Py_DECREF(__pyx_4); __pyx_4 = 0;
+ __pyx_4 = PyTuple_New(1); if (unlikely(!__pyx_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;}
+ PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
+ __pyx_3 = 0;
+ __pyx_3 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_4, NULL); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;}
+ Py_DECREF(__pyx_4); __pyx_4 = 0;
+ __Pyx_Raise(__pyx_3, 0, 0);
+ Py_DECREF(__pyx_3); __pyx_3 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; goto __pyx_L1;}
+ goto __pyx_L12;
+ }
+ __pyx_L12:;
+
+ __pyx_r = Py_None; Py_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1:;
+ Py_XDECREF(__pyx_3);
+ Py_XDECREF(__pyx_4);
+ __Pyx_AddTraceback("_natgrid.natgridd");
+ __pyx_r = NULL;
+ __pyx_L0:;
+ Py_DECREF(__pyx_v_i);
+ Py_DECREF(__pyx_v_x);
+ Py_DECREF(__pyx_v_y);
+ Py_DECREF(__pyx_v_z);
+ Py_DECREF(__pyx_v_xo);
+ Py_DECREF(__pyx_v_yo);
+ Py_DECREF(__pyx_v_zo);
+ return __pyx_r;
+}
+
+static __Pyx_InternTabEntry __pyx_intern_tab[] = {
+ {&__pyx_n_RuntimeError, "RuntimeError"},
+ {0, 0}
+};
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+ {&__pyx_k_1p, __pyx_k_1, sizeof(__pyx_k_1), 0},
+ {&__pyx_k_2p, __pyx_k_2, sizeof(__pyx_k_2), 0},
+ {&__pyx_k_3p, __pyx_k_3, sizeof(__pyx_k_3), 0},
+ {&__pyx_k_4p, __pyx_k_4, sizeof(__pyx_k_4), 0},
+ {&__pyx_k_5p, __pyx_k_5, sizeof(__pyx_k_5), 0},
+ {&__pyx_k_6p, __pyx_k_6, sizeof(__pyx_k_6), 0},
+ {&__pyx_k_7p, __pyx_k_7, sizeof(__pyx_k_7), 0},
+ {0, 0, 0, 0}
+};
+
+static struct PyMethodDef __pyx_methods[] = {
+ {"seti", (PyCFunction)__pyx_pf_8_natgrid_seti, METH_VARARGS|METH_KEYWORDS, 0},
+ {"setr", (PyCFunction)__pyx_pf_8_natgrid_setr, METH_VARARGS|METH_KEYWORDS, 0},
+ {"natgridd", (PyCFunction)__pyx_pf_8_natgrid_natgridd, METH_VARARGS|METH_KEYWORDS, 0},
+ {0, 0, 0, 0}
+};
+
+static void __pyx_init_filenames(void); /*proto*/
+
+PyMODINIT_FUNC init_natgrid(void); /*proto*/
+PyMODINIT_FUNC init_natgrid(void) {
+ /*--- Libary function declarations ---*/
+ __pyx_init_filenames();
+ /*--- Module creation code ---*/
+ __pyx_m = Py_InitModule4("_natgrid", __pyx_methods, __pyx_mdoc, 0, PYTHON_API_VERSION);
+ if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+ __pyx_b = PyImport_AddModule("__builtin__");
+ if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+ if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+ /*--- Intern code ---*/
+ if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+ /*--- String init code ---*/
+ if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
+ /*--- Builtin init code ---*/
+ __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;}
+ __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
+ __pyx_skip_dispatch = 0;
+ /*--- Global init code ---*/
+ /*--- Function export code ---*/
+ /*--- Function import code ---*/
+ /*--- Type init code ---*/
+ /*--- Type import code ---*/
+ /*--- Execution code ---*/
+
+ /* "/Users/jwhitaker/python/matplotlib/lib/natgrid/src/_natgrid.pyx":44
+ * c_nnsetr(pnam, fval)
+ *
+ * def natgridd(x, y, z, xo, yo, zo): # <<<<<<<<<<<<<<
+ * cdef int npnts, numxout, numyout, ier
+ * cdef Py_ssize_t buflenx, bufleny, buflenz, buflenxo, buflenyo, buflenzo
+ */
+ return;
+ __pyx_L1:;
+ __Pyx_AddTraceback("_natgrid");
+}
+
+static char *__pyx_filenames[] = {
+ "_natgrid.pyx",
+};
+
+/* Runtime support code */
+
+static void __pyx_init_filenames(void) {
+ __pyx_f = __pyx_filenames;
+}
+
+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 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 {
+ PyErr_SetString(PyExc_TypeError,
+ "raise: exception must be an old-style class or instance");
+ goto raise_error;
+ }
+ #else
+ type = (PyObject*) type->ob_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
+ }
+ PyErr_Restore(type, value, tb);
+ return;
+raise_error:
+ Py_XDECREF(value);
+ Py_XDECREF(type);
+ Py_XDECREF(tb);
+ return;
+}
+
+static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) {
+ while (t->p) {
+ *t->p = PyString_InternFromString(t->s);
+ if (!*t->p)
+ return -1;
+ ++t;
+ }
+ return 0;
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+ while (t->p) {
+ if (t->is_unicode) {
+ *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
+ } else {
+ *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+ }
+ if (!*t->p)
+ return -1;
+ ++t;
+ }
+ return 0;
+}
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+
+static void __Pyx_AddTraceback(char *funcname) {
+ PyObject *py_srcfile = 0;
+ PyObject *py_funcname = 0;
+ PyObject *py_globals = 0;
+ PyObject *empty_string = 0;
+ PyCodeObject *py_code = 0;
+ PyFrameObject *py_frame = 0;
+
+ py_srcfile = PyString_FromString(__pyx_filename);
+ if (!py_srcfile) goto bad;
+ py_funcname = PyString_FromString(funcname);
+ if (!py_funcname) goto bad;
+ py_globals = PyModule_GetDict(__pyx_m);
+ if (!py_globals) goto bad;
+ empty_string = PyString_FromString("");
+ if (!empty_string) goto bad;
+ py_code = PyCode_New(
+ 0, /*int argcount,*/
+ 0, /*int nlocals,*/
+ 0, /*int stacksize,*/
+ 0, /*int flags,*/
+ empty_string, /*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,*/
+ empty_string /*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(empty_string);
+ Py_XDECREF(py_code);
+ Py_XDECREF(py_frame);
+}
+
+/* Type Conversion Functions */
+
+static 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 INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
+ if (x == Py_True) return 1;
+ else if (x == Py_False) return 0;
+ else return PyObject_IsTrue(x);
+}
+
+static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) {
+ if (PyInt_CheckExact(x)) {
+ return PyInt_AS_LONG(x);
+ }
+ else if (PyLong_CheckExact(x)) {
+ return PyLong_AsLongLong(x);
+ }
+ else {
+ PY_LONG_LONG val;
+ PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
+ val = __pyx_PyInt_AsLongLong(tmp);
+ Py_DECREF(tmp);
+ return val;
+ }
+}
+
+static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
+ if (PyInt_CheckExact(x)) {
+ long val = PyInt_AS_LONG(x);
+ if (unlikely(val < 0)) {
+ PyErr_SetString(PyExc_TypeError, "Negative assignment to unsigned type.");
+ return (unsigned PY_LONG_LONG)-1;
+ }
+ return val;
+ }
+ else if (PyLong_CheckExact(x)) {
+ return PyLong_AsUnsignedLongLong(x);
+ }
+ else {
+ PY_LONG_LONG val;
+ PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
+ val = __pyx_PyInt_AsUnsignedLongLong(tmp);
+ Py_DECREF(tmp);
+ return val;
+ }
+}
+
+
+static INLINE unsigned char __pyx_PyInt_unsigned_char(PyObject* x) {
+ if (sizeof(unsigned char) < sizeof(long)) {
+ long long_val = __pyx_PyInt_AsLong(x);
+ unsigned char val = (unsigned char)long_val;
+ if (unlikely((val != long_val) || (long_val < 0))) {
+ PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned char");
+ return (unsigned char)-1;
+ }
+ return val;
+ }
+ else {
+ return __pyx_PyInt_AsLong(x);
+ }
+}
+
+static INLINE unsigned short __pyx_PyInt_unsigned_short(PyObject* x) {
+ if (sizeof(unsigned short) < sizeof(long)) {
+ long long_val = __pyx_PyInt_AsLong(x);
+ unsigned short val = (unsigned short)long_val;
+ if (unlikely((val != long_val) || (long_val < 0))) {
+ PyErr_SetString(PyExc_OverflowError, "value too large to convert to unsigned short");
+ return (unsigned short)-1;
+ }
+ return val;
+ }
+ else {
+ return __pyx_PyInt_AsLong(x);
+ }
+}
+
+static INLINE char __pyx_PyInt_char(PyObject* x) {
+ if (sizeof(char) < sizeof(long)) {
+ long long_val = __pyx_PyInt_AsLong(x);
+ char val = (char)long_val;
+ if (unlikely((val != long_val) )) {
+ PyErr_SetString(PyExc_OverflowError, "value too large to convert to char");
+ return (char)-1;
+ }
+ return val;
+ }
+ else {
+ return __pyx_PyInt_AsLong(x);
+ }
+}
+
+static INLINE short __pyx_PyInt_short(PyObject* x) {
+ if (sizeof(short) < sizeof(long)) {
+ long long_val = __pyx_PyInt_AsLong(x);
+ short val = (short)long_val;
+ if (unlikely((val != long_val) )) {
+ PyErr_SetString(PyExc_OverflowError, "value too large to convert to short");
+ return (short)-1;
+ }
+ return val;
+ }
+ else {
+ return __pyx_PyInt_AsLong(x);
+ }
+}
+
+static INLINE int __pyx_PyInt_int(PyObject* x) {
+ if (sizeof(int) < sizeof(long)) {
+ long long_val = __pyx_PyInt_AsLong(x);
+ int val = (int)long_val;
+ if (unlikely((val != long_val) )) {
+ PyErr_SetString(PyExc_OverflowError, "value too large to convert to int");
+ return (int)-1;
+ }
+ return val;
+ }
+ else {
+ return __pyx_PyInt_AsLong(x);
+ }
+}
+
+static INLINE long __pyx_PyInt_long(PyObject* x) {
+ if (sizeof(long) < sizeof(long)) {
+ long long_val = __pyx_PyInt_AsLong(x);
+ long val = (long)long_val;
+ if (unlikely((val != long_val) )) {
+ PyErr_SetString(PyExc_OverflowError, "value too large to convert to long");
+ return (long)-1;
+ }
+ return val;
+ }
+ else {
+ return __pyx_PyInt_AsLong(x);
+ }
+}
+
+static INLINE signed char __pyx_PyInt_signed_char(PyObject* x) {
+ if (sizeof(signed char) < sizeof(long)) {
+ long long_val = __pyx_PyInt_AsLong(x);
+ signed char val = (signed char)long_val;
+ if (unlikely((val != long_val) )) {
+ PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed char");
+ return (signed char)-1;
+ }
+ return val;
+ }
+ else {
+ return __pyx_PyInt_AsLong(x);
+ }
+}
+
+static INLINE signed short __pyx_PyInt_signed_short(PyObject* x) {
+ if (sizeof(signed short) < sizeof(long)) {
+ long long_val = __pyx_PyInt_AsLong(x);
+ signed short val = (signed short)long_val;
+ if (unlikely((val != long_val) )) {
+ PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed short");
+ return (signed short)-1;
+ }
+ return val;
+ }
+ else {
+ return __pyx_PyInt_AsLong(x);
+ }
+}
+
+static INLINE signed int __pyx_PyInt_signed_int(PyObject* x) {
+ if (sizeof(signed int) < sizeof(long)) {
+ long long_val = __pyx_PyInt_AsLong(x);
+ signed int val = (signed int)long_val;
+ if (unlikely((val != long_val) )) {
+ PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed int");
+ return (signed int)-1;
+ }
+ return val;
+ }
+ else {
+ return __pyx_PyInt_AsLong(x);
+ }
+}
+
+static INLINE signed long __pyx_PyInt_signed_long(PyObject* x) {
+ if (sizeof(signed long) < sizeof(long)) {
+ long long_val = __pyx_PyInt_AsLong(x);
+ signed long val = (signed long)long_val;
+ if (unlikely((val != long_val) )) {
+ PyErr_SetString(PyExc_OverflowError, "value too large to convert to signed long");
+ return (signed long)-1;
+ }
+ return val;
+ }
+ else {
+ return __pyx_PyInt_AsLong(x);
+ }
+}
+
+static INLINE long double __pyx_PyInt_long_double(PyObject* x) {
+ if (sizeof(long double) < sizeof(long)) {
+ long long_val = __pyx_PyInt_AsLong(x);
+ long double val = (long double)long_val;
+ if (unlikely((val != long_val) )) {
+ PyErr_SetString(PyExc_OverflowError, "value too large to convert to long double");
+ return (long double)-1;
+ }
+ return val;
+ }
+ else {
+ return __pyx_PyInt_AsLong(x);
+ }
+}
Added: trunk/toolkits/natgrid/src/_natgrid.pyx
===================================================================
--- trunk/toolkits/natgrid/src/_natgrid.pyx (rev 0)
+++ trunk/toolkits/natgrid/src/_natgrid.pyx 2008-07-22 11:12:50 UTC (rev 5808)
@@ -0,0 +1,75 @@
+"""
+Pyrex wrapper for NCAR natgrid library for interpolation
+of irregularly spaced data to a grid.
+
+copyright (c) 2007 by Jeffrey Whitaker.
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notices appear in all copies and that
+both the copyright notices and this permission notice appear in
+supporting documentation.
+THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+"""
+
+# Pyrex generates nnint.c from this file, so make changes here
+# and re-create nnint.c with "pyrexc nnint.pyx".
+
+cdef extern void c_nnseti(char *pnam, int ival)
+cdef extern double *c_natgridd(int n, double *x, double *y, double *z, int numxout, int numyout, double *xo, double *yo, int *ier)
+cdef extern void c_nnsetr(char *pnam, float fval)
+
+cdef extern from "Python.h":
+ int PyObject_AsWriteBuffer(object, void **rbuf, Py_ssize_t *len)
+ char *PyString_AsString(object)
+
+def seti(name, value):
+ cdef char *pnam
+ cdef int ival
+ pnam = name; ival = value
+ c_nnseti(pnam, ival)
+
+def setr(name, value):
+ cdef char *pnam
+ cdef float fval
+ pnam = name; fval = value
+ c_nnsetr(pnam, fval)
+
+def natgridd(x, y, z, xo, yo, zo):
+ cdef int npnts, numxout, numyout, ier
+ cdef Py_ssize_t buflenx, bufleny, buflenz, buflenxo, buflenyo, buflenzo
+ cdef void *xp, *yp, *zp, *xop, *yop, *zop
+ cdef double *xd, *yd, *zd, *xod, *yod, *zod, *out
+ npnts = len(x)
+ numxout = len(xo)
+ numyout = len(yo)
+ if PyObject_AsWriteBuffer(x, &xp, &buflenx) <> 0:
+ raise RuntimeError('error getting buffer for x')
+ if PyObject_AsWriteBuffer(y, &yp, &bufleny) <> 0:
+ raise RuntimeError('error getting buffer for y')
+ if PyObject_AsWriteBuffer(z, &zp, &buflenz) <> 0:
+ raise RuntimeError('error getting buffer for z')
+ xd = <double *>xp
+ yd = <double *>yp
+ zd = <double *>zp
+ if PyObject_AsWriteBuffer(xo, &xop, &buflenxo) <> 0:
+ raise RuntimeError('error getting buffer for x')
+ if PyObject_AsWriteBuffer(yo, &yop, &buflenyo) <> 0:
+ raise RuntimeError('error getting buffer for y')
+ if PyObject_AsWriteBuffer(zo, &zop, &buflenzo) <> 0:
+ raise RuntimeError('error getting buffer for z')
+ xod = <double *>xop
+ yod = <double *>yop
+ zod = <double *>zop
+ # output overwrites zo.
+ out = c_natgridd(npnts, yd, xd, zd, numyout, numxout, yod, xod, &ier)
+ for i from 0 <= i < buflenzo/8:
+ zod[i] = out[i]
+ if ier != 0:
+ raise RuntimeError('error in natgridd - ier ='%ier)
Property changes on: trunk/toolkits/natgrid/src/_natgrid.pyx
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/toolkits/natgrid/src/natgrid.c
===================================================================
--- trunk/toolkits/natgrid/src/natgrid.c (rev 0)
+++ trunk/toolkits/natgrid/src/natgrid.c 2008-07-22 11:12:50 UTC (rev 5808)
@@ -0,0 +1,69 @@
+/*
+ * This file contains the settings for most of the
+ * global variables by way of including nnmhead.h .
+ */
+
+#include "nnmhead.h"
+#include "nnghead.h"
+#include "nntypes.h"
+#include "nntpvrs.h"
+#include "nnexver.h"
+
+void Terminate()
+{
+ struct simp *tmp,*tmp0;
+ struct datum *dtmp,*dtmp0;
+ struct neig *ntmp,*ntmp0;
+ struct temp *ttmp,*ttmp0;
+ tmp = rootsimp;
+ while(tmp!=NULL) {
+ tmp0 =tmp->nextsimp;
+ free(tmp);
+ tmp = tmp0;
+ }
+ rootsimp = cursimp = holdsimp = lastsimp = prevsimp = NULL;
+ dtmp = rootdat;
+ while(dtmp!=NULL) {
+ dtmp0 =dtmp->nextdat;
+ free(dtmp);
+ dtmp = dtmp0;
+ }
+ rootdat = curdat = holddat = NULL;
+ ntmp = rootneig;
+ while(ntmp!=NULL) {
+ ntmp0 =ntmp->nextneig;
+ free(ntmp);
+ ntmp = ntmp0;
+ }
+ rootneig = curneig = lastneig = NULL;
+ ttmp = roottemp;
+ while(ttmp!=NULL) {
+ ttmp0 =ttmp->nexttemp;
+ free(ttmp);
+ ttmp = ttmp0;
+ }
+ roottemp = curtemp = lasttemp= prevtemp= NULL;
+
+ if(points!=NULL) {
+ FreeMatrixd(points);
+ points = NULL;
+ }
+ if(joints!=NULL) {
+ FreeMatrixd(joints);
+ joints = NULL;
+ }
+ if(jndx != NULL) {
+ FreeVecti(jndx);
+ jndx = NULL;
+ }
+ if(wts != NULL) {
+ free(wts);
+ }
+ if(nbrs != NULL) {
+ free(nbrs);
+ }
+
+ magx = magx_orig;
+ magy = magy_orig;
+ magz = magz_orig;
+}
Added: trunk/toolkits/natgrid/src/natgridd.c
===================================================================
--- trunk/toolkits/natgrid/src/natgridd.c (rev 0)
+++ trunk/toolkits/natgrid/src/natgridd.c 2008-07-22 11:12:50 UTC (rev 5808)
@@ -0,0 +1,166 @@
+#include "nnghead.h"
+#include "nngheadd.h"
+
+double *c_natgridd(int n, double x[], double y[], double z[],
+ int nxi, int nyi, double xi[], double yi[], int *ier)
+{
+ double **data_out=NULL, *rtrn_val=NULL;
+
+ *ier = 0;
+
+ if (single_point == 0)
+ {
+ asflag = 1;
+ Initialized(n, x, y, nxi, nyi, xi, yi);
+
+ if (ReadDatad(n,x,y,z) != 0)
+ {
+ *ier = error_status;
+ return ( (double *) NULL);
+ }
+ }
+
+ if (adf)
+ {
+ CircOut();
+ if (error_status)
+ {
+ *ier = error_status;
+ return ( (double *) NULL);
+ }
+ }
+ if (igrad)
+ {
+ Gradient();
+ if (error_status)
+ {
+ *ier = error_status;
+ return ( (double *) NULL);
+ }
+ }
+
+ data_out = MakeGridd(nxi, nyi, xi, yi);
+ if (error_status)
+ {
+ if((data_out !=NULL)&&(data_out[0]!=NULL)) {
+ free(data_out[0]);
+ free(data_out);
+ }
+ *ier = error_status;
+ return ( (double *) NULL);
+ }
+
+ if (single_point == 0)
+ {
+ Terminate();
+ }
+
+ horilap = -1.;
+ vertlap = -1.;
+
+ rtrn_val = data_out[0];
+ free(data_out);
+ return (rtrn_val);
+}
+void Initialized(int n, double x[], double y[], int nxi, int nyi,
+ double xi[], double yi[])
+{
+
+ double xil, xir, yib, yit;
+
+/*
+ * Reserve memory for returning natural neighbor indices
+ * and associated weights when requested in single point
+ * mode for linear interpolation.
+ */
+ nbrs = (int *) calloc(n,sizeof(int));
+ wts = (double *) calloc(n,sizeof(double));
+
+ error_status = 0;
+ datcnt = 0;
+ magx_orig = magx;
+ magy_orig = magy;
+ magz_orig = magz;
+ iscale = 0;
+ magx_auto = 1.;
+ magy_auto = 1.;
+ magz_auto = 1.;
+
+/*
+ * Find the limits of the output array.
+ */
+ xstart = armind(nxi, xi);
+ xend = armaxd(nxi, xi);
+ ystart = armind(nyi, yi);
+ yend = armaxd(nyi, yi);
+
+/*
+ * Find the limits of the input array.
+ */
+ xil = armind(n, x);
+ xir = armaxd(n, x);
+ yib = armind(n, y);
+ yit = armaxd(n, y);
+
+/*
+ * As the default (that is, unless horizontal and vertical overlaps
+ * have been specifically set by the user) choose the overlap values
+ * as the smallest values that will make all input data points included
+ * in the overlap region.
+ */
+ if (horilap EQ -1.) {
+ if ( (xstart >= xil) && (xend <= xir) ) {
+ horilap = 1.01 * (((xstart-xil) < (xir-xend)) ?
+ (xir-xend) : (xstart-xil));
+ }
+ else if ( (xstart >= xil) && (xend >= xir) ) {
+ horilap = 1.01 * (xstart-xil);
+ }
+ else if ( (xstart <= xil) && (xend <= xir) ) {
+ horilap = 1.01 * (xir-xend);
+ }
+ else if ( (xstart <= xil) && (xir <= xend) ) {
+ horilap = 0.;
+ }
+ }
+ if (horilap <= EPSILON) {
+ horilap = 0.01 * (xend - xstart);
+ }
+ if (vertlap EQ -1.) {
+ if ( (yib <= ystart) && (yend <= yit) ) {
+ vertlap = 1.01 * (((ystart-yib) < (yit-yend)) ?
+ (yit-yend) : (ystart-yib));
+ }
+ else if ( (ystart <= yib) && (yend <= yit) ) {
+ vertlap = 1.01 * (yit-yend);
+ }
+ else if ( (yib <= ystart) && (yit <= yend) ) {
+ vertlap = 1.01 * (ystart-yib);
+ }
+ else if ( (ystart <= yib) && (yit <= yend) ) {
+ vertlap = 0.;
+ }
+ }
+ if (vertlap <= EPSILON) {
+ vertlap = 0.01 * (yend - ystart);
+ }
+}
+
+double armind(int num, double *x)
+{
+ int i;
+ float amin;
+ amin = x[0];
+ for (i = 1 ; i < num ; i++)
+ if (x[i] < amin) amin = x[i];
+ return(amin);
+}
+double armaxd(int num, double *x)
+{
+ int i;
+ float amax;
+ amax = x[0];
+ for (i = 1 ; i < num ; i++)
+ if (x[i] > amax) amax = x[i];
+ return(amax);
+}
Added: trunk/toolkits/natgrid/src/natgrids.c
===================================================================
--- trunk/toolkits/natgrid/src/natgrids.c (rev 0)
+++ trunk/toolkits/natgrid/src/natgrids.c 2008-07-22 11:12:50 UTC (rev 5808)
@@ -0,0 +1,168 @@
+#include <stdlib.h>
+#include "nnghead.h"
+#include "nngheads.h"
+#include "nnexver.h"
+
+float *c_natgrids(int n, float x[], float y[], float z[],
+ int nxi, int nyi, float xi[], flo...
[truncated message content] |