Issue #197 - merging gridslice changes into git thinclient branch.

Former-commit-id: ae1bd95af06f6413ff17b73b290fda3ab8a13b29
This commit is contained in:
Bryan Kowal 2012-01-23 13:40:59 -06:00
parent cf4d56d0a0
commit a48a3094f0
8 changed files with 637 additions and 341 deletions

View file

@ -1,341 +1,365 @@
/*****************************************************************************************
* COPYRIGHT (c), 2009, RAYTHEON COMPANY
* ALL RIGHTS RESERVED, An Unpublished Work
*
* RAYTHEON PROPRIETARY
* If the end user is not the U.S. Government or any agency thereof, use
* or disclosure of data contained in this source code file is subject to
* the proprietary restrictions set forth in the Master Rights File.
*
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
* If the end user is the U.S. Government or any agency thereof, this source
* code is provided to the U.S. Government with Government Purpose Rights.
* Use or disclosure of data contained in this source code file is subject to
* the "Government Purpose Rights" restriction in the Master Rights File.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* Use or disclosure of data contained in this source code file is subject to
* the export restrictions set forth in the Master Rights File.
******************************************************************************************/
/*
* Python module that utilizes the AWIPSI sliceConvert functions to offer
* slicing capability to numpy arrays.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 11/17/09 3580 brockwoo Initial Creation
*
* </pre>
*
* @author brockwoo
* @version 1
*/
#include <Python.h>
#include <stdio.h>
#include <string.h>
#include "numpy/arrayobject.h"
#include "sliceConvert.h"
static PyObject *GridSliceError;
static int dimensions(PyObject * array) {
int returnValue = 0;
int aDim = PyArray_NDIM(array);
if (aDim == 3) {
returnValue |= 4; // 2d arrays
} else if (aDim == 2) {
npy_intp * aDimList = PyArray_DIMS(array);
if (aDimList[0] == 1) {
returnValue |= 1; //linear array
}
} else {
returnValue |= 8; // Unsupported
}
return returnValue;
}
static PyObject * defineNumpySlice(PyObject *self, PyObject* args)
/* float ** vc3d, float ** param3d, int mnx,
int nx, int ny, int nz, float param, int sense, float * vc2d) */{
PyObject * vc;
PyObject * param;
//int mx = 0;
int nx = 0;
int ny = 0;
int nz = 0;
float targetLevel;
int sense;
if (!PyArg_ParseTuple(args, "OOfi", &vc, &param, &targetLevel, &sense)) {
return NULL;
}
int vu = dimensions(vc);
int pu = dimensions(param);
int uniformity = (vu | pu);
if ((uniformity >> 3) == 1) {
PyErr_SetString(GridSliceError,
"One of the numpy arrays passed cannot be used for slicing.");
return NULL;
}
npy_intp * vdimList = PyArray_DIMS(vc);
npy_intp * pdimList = PyArray_DIMS(param);
float * vc2d = 0;
if (uniformity == 4) { // two cubes
if (vdimList[0] != pdimList[0] || vdimList[1] != pdimList[1]
|| vdimList[2] != pdimList[2]) {
PyErr_SetString(GridSliceError,
"Dimensions are different between cubes. Calculation cannot be done.");
return NULL;
}
nz = vdimList[0];
ny = vdimList[1];
nx = vdimList[2];
float ** vc3d = (float**) malloc(nz * sizeof(float*));
float ** param3d = (float**) malloc(nz * sizeof(float*));
vc2d = (float*) malloc(nx * ny * sizeof(float));
int levelCount = 0;
for (levelCount = 0; levelCount < nz; levelCount++) {
vc3d[levelCount] = (float *) PyArray_GETPTR1(vc, levelCount);
param3d[levelCount] = (float *) PyArray_GETPTR1(param, levelCount);
}
defineSlice(vc3d, param3d, nx, nx, ny, nz, targetLevel, sense, vc2d);
free(vc3d);
free(param3d);
} else if (uniformity < 4 || uniformity == 5) { // one cube and one constant or two constants
int vnz = (vu == 4) ? vdimList[0] : vdimList[1];
int pnz = (pu == 4) ? pdimList[0] : pdimList[1];
int vny = (vu == 4) ? vdimList[1] : 0;
int pny = (pu == 4) ? pdimList[1] : 0;
int vnx = (vu == 4) ? vdimList[2] : 0;
int pnx = (pu == 4) ? pdimList[2] : 0;
if (vnz != pnz) {
PyErr_SetString(GridSliceError,
"Dimensions are different between the arrays. Calculation cannot be done.");
return NULL;
}
nz = vnz;
ny = vny >= pny ? vny : pny;
nx = vnx >= pnx ? vnx : pnx;
float ** vc3d = (float**) malloc(nz * sizeof(float*));
float ** param3d = (float**) malloc(nz * sizeof(float*));
vc2d = (float*) malloc(nx * ny * sizeof(float));
int * vc3dDim = (int*) malloc(nz * sizeof(int));
int * param3dDim = (int*) malloc(nz * sizeof(int));
int levelCount = 0;
for (levelCount = 0; levelCount < nz; levelCount++) {
if (vu == 4) {
vc3d[levelCount] = (float *) PyArray_GETPTR1(vc, levelCount);
vc3dDim[levelCount] = 2;
} else {
vc3d[levelCount] = (float *) PyArray_GETPTR2(vc, 0, levelCount);
vc3dDim[levelCount] = 0;
}
if (pu == 4) {
param3d[levelCount]
= (float *) PyArray_GETPTR1(param, levelCount);
param3dDim[levelCount] = 2;
} else {
param3d[levelCount]
= (float *) PyArray_GETPTR2(param, 0, levelCount);
param3dDim[levelCount] = 0;
}
}
defineSliceD(vc3d, vc3dDim, param3d, param3dDim, nx, nx, ny, nz,
targetLevel, sense, vc2d);
free(vc3d);
free(param3d);
free(vc3dDim);
free(param3dDim);
}
if (vc2d) {
PyObject * pyVc2d;
npy_intp dimSize[2];
dimSize[0] = ny;
dimSize[1] = nx;
pyVc2d = PyArray_SimpleNew(2, dimSize, NPY_FLOAT);
memcpy(((PyArrayObject *) pyVc2d)->data, vc2d, nx * ny * sizeof(float));
free(vc2d);
return pyVc2d;
} else {
PyErr_SetString(
GridSliceError,
"The result grid returned was empty. Please check your initial data and try again.");
return NULL;
}
}
static PyObject * createNumpySlice(PyObject *self, PyObject* args)
/*float ** vc3d, float * vc2d,
float ** slice3d, int mnx, int nx, int ny, int nz, int sense,
float * slice)*/{
PyObject * vc;
PyObject * s3d;
//int mx = 0;
int nx = 0;
int ny = 0;
int nz = 0;
PyObject * targetLevel;
int sense;
int hyb = DOINTERP;
if (!PyArg_ParseTuple(args, "OOOi|i", &vc, &s3d, &targetLevel, &sense, &hyb)) {
return NULL;
}
int vu = dimensions(vc);
int su = dimensions(s3d);
int uniformity = (vu | su);
npy_intp * vdimList = PyArray_DIMS(vc);
npy_intp * sdimList = PyArray_DIMS(s3d);
float * slice = 0;
if (uniformity == 4) {
if (vdimList[0] != sdimList[0] || vdimList[1] != sdimList[1]
|| vdimList[2] != sdimList[2]) {
PyErr_SetString(GridSliceError,
"Dimensions are different between cubes. Calculation cannot be done.");
return NULL;
}
nz = vdimList[0];
ny = vdimList[1];
nx = vdimList[2];
float ** vc3d = (float**) malloc(nz * sizeof(float*));
float ** slice3d = (float**) malloc(nz * sizeof(float*));
slice = (float*) malloc(nx * ny * sizeof(float));
int levelCount = 0;
float * vc2d = (float *) PyArray_GETPTR1(targetLevel, 0);
for (levelCount = 0; levelCount < nz; levelCount++) {
vc3d[levelCount] = (float *) PyArray_GETPTR1(vc, levelCount);
slice3d[levelCount] = (float *) PyArray_GETPTR1(s3d, levelCount);
}
if (hyb == DOINTERP) {
createSlice(vc3d, vc2d, slice3d, nx, nx, ny, nz, sense, slice);
} else {
sampleSlice(vc3d, vc2d, slice3d, nx, nx, ny, nz, sense, hyb, slice);
}
free(vc3d);
free(slice3d);
} else if (vu < 4 && su == 4) { // one cube and one constant or two constants
int vnz = (vu == 4) ? vdimList[0] : vdimList[1];
if (vnz != sdimList[0]) {
PyErr_SetString(GridSliceError,
"Dimensions are different between the arrays. Calculation cannot be done.");
return NULL;
}
nz = sdimList[0];
ny = sdimList[1];
nx = sdimList[2];
float ** vc3d = (float**) malloc(nz * sizeof(float*));
float ** slice3d = (float**) malloc(nz * sizeof(float*));
int * vc3dDim = (int*) malloc(nz * sizeof(int));
slice = (float*) malloc(nx * ny * sizeof(float));
int levelCount = 0;
for (levelCount = 0; levelCount < nz; levelCount++) {
if (vu == 4) {
vc3d[levelCount] = (float *) PyArray_GETPTR1(vc, levelCount);
vc3dDim[levelCount] = 2;
} else {
vc3d[levelCount] = (float *) PyArray_GETPTR2(vc, 0, levelCount);
vc3dDim[levelCount] = 0;
}
slice3d[levelCount] = (float *) PyArray_GETPTR1(s3d, levelCount);
}
float * vc2d = (float *) PyArray_GETPTR1(targetLevel, 0);
if (hyb == DOINTERP) {
createSliceD(vc3d, vc3dDim, vc2d, 2, slice3d, nx, nx, ny, nz, sense, slice);
} else {
sampleSliceD(vc3d, vc3dDim, vc2d, 2, slice3d, nx, nx, ny, nz, sense, hyb, slice);
}
free(vc3d);
free(slice3d);
free(vc3dDim);
}
if (slice) {
PyObject * pyVc2d;
npy_intp dimSize[2];
dimSize[0] = ny;
dimSize[1] = nx;
pyVc2d = PyArray_SimpleNew(2, dimSize, NPY_FLOAT);
memcpy(((PyArrayObject *) pyVc2d)->data, slice, nx * ny * sizeof(float));
free(slice);
return pyVc2d;
} else {
PyErr_SetString(
GridSliceError,
"The result grid returned was empty. Please check your initial data and try again.");
return NULL;
}
return NULL;
}
static PyObject * createNumpySliceD(PyObject *self, PyObject* args)
/*float ** vc3d, int * dim3, float * vc2d,
int dim2, float ** slice3d, int mnx, int nx, int ny, int nz, int sense,
float * slice)*/{
return NULL;
}
static PyObject * sampleNumpySlice(PyObject *self, PyObject* args)
/*float ** vc3d, float * vc2d,
float ** slice3d, int mnx, int nx, int ny, int nz, int sense, int hyb,
float * slice)*/{
return NULL;
}
static PyObject * sampleNumpySliceD(PyObject *self, PyObject* args)
/*float ** vc3d, int * dim3, float * vc2d,
int dim2, float ** slice3d, int mnx, int nx, int ny, int nz, int sense,
int hyb, float * slice)*/{
return NULL;
}
static PyObject * defineNumpySlices(PyObject *self, PyObject* args)
/*float * vc3d, int senseA, float * param3d,
int senseB, int nx, int ny, int nz, float * paramC, int nc, float * vcC)*/{
return NULL;
}
static PyObject * createNumpySlices(PyObject *self, PyObject* args)
/*float * vc3d, float * param3d, int sense,
int nx, int ny, int nz, float * vcC, int nc, float * paramC)*/{
return NULL;
}
static PyMethodDef gridslice_methods[] = { { "defineNumpySlice",
defineNumpySlice, METH_VARARGS, "Description to be decided." }, {
"createNumpySlice", createNumpySlice, METH_VARARGS,
"Description to be decided." }, { "createNumpySliceD",
createNumpySliceD, METH_VARARGS, "Description to be decided." }, {
"sampleNumpySlice", sampleNumpySlice, METH_VARARGS,
"Description to be decided." }, { "sampleNumpySliceD",
sampleNumpySliceD, METH_VARARGS, "Description to be decided." }, {
"defineNumpySlices", defineNumpySlices, METH_VARARGS,
"Description to be decided." }, { "createNumpySlices",
createNumpySlices, METH_VARARGS, "Description to be decided." }, {
NULL, NULL, 0, NULL } /* sentinel */
};
void initgridslice(void) {
PyObject *m;
import_array();
PyImport_AddModule("gridslice");
m = Py_InitModule("gridslice", gridslice_methods);
GridSliceError = PyErr_NewException("gridslice.error", NULL, NULL);
Py_INCREF(GridSliceError);
PyModule_AddObject(m, "error", GridSliceError);
}
/*****************************************************************************************
* COPYRIGHT (c), 2009, RAYTHEON COMPANY
* ALL RIGHTS RESERVED, An Unpublished Work
*
* RAYTHEON PROPRIETARY
* If the end user is not the U.S. Government or any agency thereof, use
* or disclosure of data contained in this source code file is subject to
* the proprietary restrictions set forth in the Master Rights File.
*
* U.S. GOVERNMENT PURPOSE RIGHTS NOTICE
* If the end user is the U.S. Government or any agency thereof, this source
* code is provided to the U.S. Government with Government Purpose Rights.
* Use or disclosure of data contained in this source code file is subject to
* the "Government Purpose Rights" restriction in the Master Rights File.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* Use or disclosure of data contained in this source code file is subject to
* the export restrictions set forth in the Master Rights File.
******************************************************************************************/
/*
* Python module that utilizes the AWIPSI sliceConvert functions to offer
* slicing capability to numpy arrays.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 11/17/09 3580 brockwoo Initial Creation
*
* </pre>
*
* @author brockwoo
* @version 1
*/
#include <Python.h>
#include <stdio.h>
#include <string.h>
#include "numpy/arrayobject.h"
#include "sliceConvert.h"
static PyObject *GridSliceError;
static int dimensions(PyObject * array) {
int returnValue = 0;
int aDim = PyArray_NDIM(array);
if (aDim == 3) {
returnValue |= 4; // 2d arrays
} else if (aDim == 2) {
npy_int * aDimList = PyArray_DIMS(array);
if (aDimList[0] == 1) {
returnValue |= 1; //linear array
}
} else {
returnValue |= 8; // Unsupported
}
return returnValue;
}
static PyObject * defineNumpySlice(PyObject *self, PyObject* args)
/* float ** vc3d, float ** param3d, int mnx,
int nx, int ny, int nz, float param, int sense, float * vc2d) */{
PyObject * vc;
PyObject * param;
//int mx = 0;
int nx = 0;
int ny = 0;
int nz = 0;
float targetLevel;
int sense;
int vu, pu, uniformity;
float * vc2d;
float ** vc3d;
int * vc3dDim;
float ** param3d;
int * param3dDim;
int levelCount;
int vnz, pnz, vny , pny , vnx , pnx;
int dimSize[2];
npy_int * vdimList;
npy_int * pdimList;
if (!PyArg_ParseTuple(args, "OOfi", &vc, &param, &targetLevel, &sense)) {
return NULL;
}
vu = dimensions(vc);
pu = dimensions(param);
uniformity = (vu | pu);
if ((uniformity >> 3) == 1) {
PyErr_SetString(GridSliceError,
"One of the numpy arrays passed cannot be used for slicing.");
return NULL;
}
vdimList = PyArray_DIMS(vc);
pdimList = PyArray_DIMS(param);
vc2d = 0;
if (uniformity == 4) { // two cubes
if (vdimList[0] != pdimList[0] || vdimList[1] != pdimList[1]
|| vdimList[2] != pdimList[2]) {
PyErr_SetString(GridSliceError,
"Dimensions are different between cubes. Calculation cannot be done.");
return NULL;
}
nz = vdimList[0];
ny = vdimList[1];
nx = vdimList[2];
vc3d = (float**) malloc(nz * sizeof(float*));
param3d = (float**) malloc(nz * sizeof(float*));
vc2d = (float*) malloc(nx * ny * sizeof(float));
levelCount = 0;
for (levelCount = 0; levelCount < nz; levelCount++) {
vc3d[levelCount] = (float *) PyArray_GETPTR1(vc, levelCount);
param3d[levelCount] = (float *) PyArray_GETPTR1(param, levelCount);
}
defineSlice(vc3d, param3d, nx, nx, ny, nz, targetLevel, sense, vc2d);
free(vc3d);
free(param3d);
} else if (uniformity < 4 || uniformity == 5) { // one cube and one constant or two constants
vnz = (vu == 4) ? vdimList[0] : vdimList[1];
pnz = (pu == 4) ? pdimList[0] : pdimList[1];
vny = (vu == 4) ? vdimList[1] : 0;
pny = (pu == 4) ? pdimList[1] : 0;
vnx = (vu == 4) ? vdimList[2] : 0;
pnx = (pu == 4) ? pdimList[2] : 0;
if (vnz != pnz) {
PyErr_SetString(GridSliceError,
"Dimensions are different between the arrays. Calculation cannot be done.");
return NULL;
}
nz = vnz;
ny = vny >= pny ? vny : pny;
nx = vnx >= pnx ? vnx : pnx;
vc3d = (float**) malloc(nz * sizeof(float*));
param3d = (float**) malloc(nz * sizeof(float*));
vc2d = (float*) malloc(nx * ny * sizeof(float));
vc3dDim = (int*) malloc(nz * sizeof(int));
param3dDim = (int*) malloc(nz * sizeof(int));
levelCount = 0;
for (levelCount = 0; levelCount < nz; levelCount++) {
if (vu == 4) {
vc3d[levelCount] = (float *) PyArray_GETPTR1(vc, levelCount);
vc3dDim[levelCount] = 2;
} else {
vc3d[levelCount] = (float *) PyArray_GETPTR2(vc, 0, levelCount);
vc3dDim[levelCount] = 0;
}
if (pu == 4) {
param3d[levelCount]
= (float *) PyArray_GETPTR1(param, levelCount);
param3dDim[levelCount] = 2;
} else {
param3d[levelCount]
= (float *) PyArray_GETPTR2(param, 0, levelCount);
param3dDim[levelCount] = 0;
}
}
defineSliceD(vc3d, vc3dDim, param3d, param3dDim, nx, nx, ny, nz,
targetLevel, sense, vc2d);
free(vc3d);
free(param3d);
free(vc3dDim);
free(param3dDim);
}
if (vc2d) {
PyObject * pyVc2d;
dimSize[0] = ny;
dimSize[1] = nx;
pyVc2d = PyArray_SimpleNew(2, dimSize, NPY_FLOAT);
memcpy(((PyArrayObject *) pyVc2d)->data, vc2d, nx * ny * sizeof(float));
free(vc2d);
return pyVc2d;
} else {
PyErr_SetString(
GridSliceError,
"The result grid returned was empty. Please check your initial data and try again.");
return NULL;
}
}
static PyObject * createNumpySlice(PyObject *self, PyObject* args)
/*float ** vc3d, float * vc2d,
float ** slice3d, int mnx, int nx, int ny, int nz, int sense,
float * slice)*/{
PyObject * vc;
PyObject * s3d;
//int mx = 0;
int nx = 0;
int ny = 0;
int nz = 0;
PyObject * targetLevel;
int sense;
int hyb = DOINTERP;
int vu;
int su;
int uniformity;
int vnz;
float * slice = 0;
float ** vc3d ;
float ** slice3d;
int * vc3dDim ;
int levelCount;
float * vc2d ;
int dimSize[2];
npy_int * vdimList;
npy_int * sdimList;
if (!PyArg_ParseTuple(args, "OOOi|i", &vc, &s3d, &targetLevel, &sense, &hyb)) {
return NULL;
}
vu = dimensions(vc);
su = dimensions(s3d);
uniformity = (vu | su);
vdimList = PyArray_DIMS(vc);
sdimList = PyArray_DIMS(s3d);
if (uniformity == 4) {
if (vdimList[0] != sdimList[0] || vdimList[1] != sdimList[1]
|| vdimList[2] != sdimList[2]) {
PyErr_SetString(GridSliceError,
"Dimensions are different between cubes. Calculation cannot be done.");
return NULL;
}
nz = vdimList[0];
ny = vdimList[1];
nx = vdimList[2];
vc3d = (float**) malloc(nz * sizeof(float*));
slice3d = (float**) malloc(nz * sizeof(float*));
slice = (float*) malloc(nx * ny * sizeof(float));
levelCount = 0;
vc2d = (float *) PyArray_GETPTR1(targetLevel, 0);
for (levelCount = 0; levelCount < nz; levelCount++) {
vc3d[levelCount] = (float *) PyArray_GETPTR1(vc, levelCount);
slice3d[levelCount] = (float *) PyArray_GETPTR1(s3d, levelCount);
}
if (hyb == DOINTERP) {
createSlice(vc3d, vc2d, slice3d, nx, nx, ny, nz, sense, slice);
} else {
sampleSlice(vc3d, vc2d, slice3d, nx, nx, ny, nz, sense, hyb, slice);
}
free(vc3d);
free(slice3d);
} else if (vu < 4 && su == 4) { // one cube and one constant or two constants
vnz = (vu == 4) ? vdimList[0] : vdimList[1];
if (vnz != sdimList[0]) {
PyErr_SetString(GridSliceError,
"Dimensions are different between the arrays. Calculation cannot be done.");
return NULL;
}
nz = sdimList[0];
ny = sdimList[1];
nx = sdimList[2];
vc3d = (float**) malloc(nz * sizeof(float*));
slice3d = (float**) malloc(nz * sizeof(float*));
vc3dDim = (int*) malloc(nz * sizeof(int));
slice = (float*) malloc(nx * ny * sizeof(float));
levelCount = 0;
for (levelCount = 0; levelCount < nz; levelCount++) {
if (vu == 4) {
vc3d[levelCount] = (float *) PyArray_GETPTR1(vc, levelCount);
vc3dDim[levelCount] = 2;
} else {
vc3d[levelCount] = (float *) PyArray_GETPTR2(vc, 0, levelCount);
vc3dDim[levelCount] = 0;
}
slice3d[levelCount] = (float *) PyArray_GETPTR1(s3d, levelCount);
}
vc2d = (float *) PyArray_GETPTR1(targetLevel, 0);
if (hyb == DOINTERP) {
createSliceD(vc3d, vc3dDim, vc2d, 2, slice3d, nx, nx, ny, nz, sense, slice);
} else {
sampleSliceD(vc3d, vc3dDim, vc2d, 2, slice3d, nx, nx, ny, nz, sense, hyb, slice);
}
free(vc3d);
free(slice3d);
free(vc3dDim);
}
if (slice) {
PyObject * pyVc2d;
dimSize[0] = ny;
dimSize[1] = nx;
pyVc2d = PyArray_SimpleNew(2, dimSize, NPY_FLOAT);
memcpy(((PyArrayObject *) pyVc2d)->data, slice, nx * ny * sizeof(float));
free(slice);
return pyVc2d;
} else {
PyErr_SetString(
GridSliceError,
"The result grid returned was empty. Please check your initial data and try again.");
return NULL;
}
return NULL;
}
static PyObject * createNumpySliceD(PyObject *self, PyObject* args)
/*float ** vc3d, int * dim3, float * vc2d,
int dim2, float ** slice3d, int mnx, int nx, int ny, int nz, int sense,
float * slice)*/{
return NULL;
}
static PyObject * sampleNumpySlice(PyObject *self, PyObject* args)
/*float ** vc3d, float * vc2d,
float ** slice3d, int mnx, int nx, int ny, int nz, int sense, int hyb,
float * slice)*/{
return NULL;
}
static PyObject * sampleNumpySliceD(PyObject *self, PyObject* args)
/*float ** vc3d, int * dim3, float * vc2d,
int dim2, float ** slice3d, int mnx, int nx, int ny, int nz, int sense,
int hyb, float * slice)*/{
return NULL;
}
static PyObject * defineNumpySlices(PyObject *self, PyObject* args)
/*float * vc3d, int senseA, float * param3d,
int senseB, int nx, int ny, int nz, float * paramC, int nc, float * vcC)*/{
return NULL;
}
static PyObject * createNumpySlices(PyObject *self, PyObject* args)
/*float * vc3d, float * param3d, int sense,
int nx, int ny, int nz, float * vcC, int nc, float * paramC)*/{
return NULL;
}
static PyMethodDef gridslice_methods[] = { { "defineNumpySlice",
defineNumpySlice, METH_VARARGS, "Description to be decided." }, {
"createNumpySlice", createNumpySlice, METH_VARARGS,
"Description to be decided." }, { "createNumpySliceD",
createNumpySliceD, METH_VARARGS, "Description to be decided." }, {
"sampleNumpySlice", sampleNumpySlice, METH_VARARGS,
"Description to be decided." }, { "sampleNumpySliceD",
sampleNumpySliceD, METH_VARARGS, "Description to be decided." }, {
"defineNumpySlices", defineNumpySlices, METH_VARARGS,
"Description to be decided." }, { "createNumpySlices",
createNumpySlices, METH_VARARGS, "Description to be decided." }, {
NULL, NULL, 0, NULL } /* sentinel */
};
void initgridslice(void) {
PyObject *m;
import_array();
PyImport_AddModule("gridslice");
m = Py_InitModule("gridslice", gridslice_methods);
GridSliceError = PyErr_NewException("gridslice.error", NULL, NULL);
Py_INCREF(GridSliceError);
PyModule_AddObject(m, "error", GridSliceError);
}

View file

@ -0,0 +1,90 @@
@echo OFF
REM This script will compile a Windows version of the gridslice library.
REM In order to compile the gridslice library, you will need to have
REM Microsoft Visual C++ 2008 installed and the AWIPS II Runtime Environment.
REM This script assumes that Microsoft Visual Studio has been installed in the
REM standard location - in the Program Files directory.
REM
REM This script should work on both a 32-bit and a 64-bit Windows 7
REM installation.
SET CONTAINING_DIR=%~dp0
REM Determine what our architecture is.
SET REG_EXE=
SET PROGRAM_FILES_DIR=
IF "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
GOTO OS_64_BIT
) ELSE (
IF "%PROCESSOR_ARCHITECTURE%" == "x86" (
GOTO OS_32_BIT
) ELSE (
echo "ERROR: Unrecognized Architecture."
PAUSE
)
)
REM Set the Program Files location based on the architecture.
:OS_32_BIT
SET PROGRAM_FILES_DIR=%ProgramFiles%
SET REG_EXE=C:\Windows\System32\reg.exe
GOTO ARCH_KNOWN
:OS_64_BIT
SET PROGRAM_FILES_DIR=%ProgramFiles(x86)%
SET REG_EXE=C:\Windows\SysWOW64\reg.exe
GOTO ARCH_KNOWN
:ARCH_KNOWN
REM Determine where AWIPS II Python has been installed.
SET A2_PYTHON_REG="HKLM\Software\Raytheon\Runtime Environment\AWIPS II Python"
%REG_EXE% QUERY %A2_PYTHON_REG% /v PythonInstallDirectory > NUL 2>&1
IF ERRORLEVEL 1 (
echo ENVIRONMENT ERROR - Unable to find AWIPS II Python.
PAUSE && EXIT 1
)
FOR /F "tokens=2* delims= " %%A IN (
'%REG_EXE% QUERY %A2_PYTHON_REG% /v PythonInstallDirectory'
) DO (
SET PythonInstallDirectory=%%B
)
REM Visual Studio 2008 is Version 9.0 of Microsoft Visual Studio.
SET MVS_VERSION=Microsoft Visual Studio 9.0
REM Use the MS Visual Studion vcvarsall.bat utility to prepare
REM the environment for this build.
REM Until further notice, we assume the build is 32-bit.
cd "%PROGRAM_FILES_DIR%\%MVS_VERSION%\VC"
CALL vcvarsall.bat x86
IF NOT ERRORLEVEL 0 (
echo ERROR: Unable to prepare the environment.
PAUSE && EXIT 1
)
cd "%CONTAINING_DIR%"
REM Compile gridslice
cl.exe /LD "%CONTAINING_DIR%..\sliceConvert.c" ^
"%CONTAINING_DIR%..\gridslice.c" ^
-I"%PythonInstallDirectory%\Lib\site-packages\numpy\core\include" ^
-I"%PythonInstallDirectory%\include" ^
"%PythonInstallDirectory%\libs\python27.lib" ^
/link/out:gridslice.pyd /EXPORT:initgridslice
if ERRORLEVEL 1 (
echo ERROR: The gridslice compile has failed.
PAUSE
)
REM Move the build artifacts to the build directory.
IF NOT EXIST "%CONTAINING_DIR%build" (
MKDIR "%CONTAINING_DIR%build"
)
MOVE /Y "%CONTAINING_DIR%sliceConvert*" ^
"%CONTAINING_DIR%build"
MOVE /Y "%CONTAINING_DIR%gridslice*" ^
"%CONTAINING_DIR%build"
echo.
echo.
echo The gridslice compile was successful.
PAUSE

Binary file not shown.

View file

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gridslice", "gridslice.vcproj", "{60589C73-F65B-44AE-8D8C-DE88B01E6ECE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{60589C73-F65B-44AE-8D8C-DE88B01E6ECE}.Debug|Win32.ActiveCfg = Debug|Win32
{60589C73-F65B-44AE-8D8C-DE88B01E6ECE}.Debug|Win32.Build.0 = Debug|Win32
{60589C73-F65B-44AE-8D8C-DE88B01E6ECE}.Release|Win32.ActiveCfg = Release|Win32
{60589C73-F65B-44AE-8D8C-DE88B01E6ECE}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

View file

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="gridslice"
ProjectGUID="{60589C73-F65B-44AE-8D8C-DE88B01E6ECE}"
RootNamespace="gridslice"
Keyword="MakeFileProj"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="0"
>
<Tool
Name="VCNMakeTool"
BuildCommandLine="cd $(InputDir)..\&#x0D;&#x0A;CALL build.bat"
ReBuildCommandLine=""
CleanCommandLine="cd $(InputDir)..\&#x0D;&#x0A;IF EXIST build (&#x0D;&#x0A; DEL /Q build\*&#x0D;&#x0A; RMDIR build&#x0D;&#x0A;)"
Output=""
PreprocessorDefinitions="WIN32;_DEBUG;"
IncludeSearchPath=""
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies=""
CompileAsManaged=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="0"
>
<Tool
Name="VCNMakeTool"
BuildCommandLine=""
ReBuildCommandLine=""
CleanCommandLine=""
Output=""
PreprocessorDefinitions="WIN32;NDEBUG;"
IncludeSearchPath=""
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies=""
CompileAsManaged=""
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\sliceConvert.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\gridslice.c"
>
</File>
<File
RelativePath="..\..\sliceConvert.c"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioUserFile
ProjectType="Visual C++"
Version="9.00"
ShowAllFiles="true"
>
<Configurations>
<Configuration
Name="Debug|Win32"
>
<DebugSettings
Command="$(TargetPath)"
WorkingDirectory=""
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="ISFL017138"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor=""
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
>
<DebugSettings
Command="$(TargetPath)"
WorkingDirectory=""
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="ISFL017138"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor=""
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
</Configurations>
</VisualStudioUserFile>

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><VisualStudioUserFile ProjectType="Visual C++" Version="9.00" ShowAllFiles="true"></VisualStudioUserFile>