Skip to content

Commit

Permalink
Merge pull request #19 from leiyangleon/geogrid_runinfo_radar_update
Browse files Browse the repository at this point in the history
update the testGeogrid 'runinfo' output with those extracted from the Geogrid c++ source code
  • Loading branch information
leiyangleon authored Mar 17, 2021
2 parents ef6be08 + c9d4e16 commit f5cc354
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 7 deletions.
22 changes: 21 additions & 1 deletion geo_autoRIFT/geogrid/Geogrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ def geogrid(self):

##Run
geogrid.geogrid_Py(self._geogrid)

##Get parameters
self.getState()

##Clean up
self.finalize()
Expand Down Expand Up @@ -213,14 +216,23 @@ def getIncidenceAngle(self, zrange=[-200,4000]):

self.incidenceAngle = np.mean(thetas)


def getDEM(self, bbox):
'''
Look up database and return values.
'''

return "", "", "", "", ""

def getState(self):
from components.contrib.geo_autoRIFT.geogrid import geogrid

self.pOff = geogrid.getXOff_Py(self._geogrid)
self.lOff = geogrid.getYOff_Py(self._geogrid)
self.pCount = geogrid.getXCount_Py(self._geogrid)
self.lCount = geogrid.getYCount_Py(self._geogrid)
self.X_res = geogrid.getXPixelSize_Py(self._geogrid)
self.Y_res = geogrid.getYPixelSize_Py(self._geogrid)

def setState(self):
'''
Create C object and populate.
Expand Down Expand Up @@ -343,3 +355,11 @@ def __init__(self):
##Pointer to C
self._geogrid = None
self._orbit = None

##parameters for autoRIFT
self.pOff = None
self.lOff = None
self.pCount = None
self.lCount = None
self.X_res = None
self.Y_res = None
84 changes: 84 additions & 0 deletions geo_autoRIFT/geogrid/bindings/geogridmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,90 @@ PyObject* setOrbit(PyObject *self, PyObject *args)
return Py_BuildValue("i", 0);
}

PyObject* getXOff(PyObject *self, PyObject *args)
{
int var;
uint64_t ptr;

if (!PyArg_ParseTuple(args, "K", &ptr))
{
return NULL;
}

var = ((geoGrid*)(ptr))->pOff;
return Py_BuildValue("i",var);
}

PyObject* getYOff(PyObject *self, PyObject *args)
{
int var;
uint64_t ptr;

if (!PyArg_ParseTuple(args, "K", &ptr))
{
return NULL;
}

var = ((geoGrid*)(ptr))->lOff;
return Py_BuildValue("i",var);
}

PyObject* getXCount(PyObject *self, PyObject *args)
{
int var;
uint64_t ptr;

if (!PyArg_ParseTuple(args, "K", &ptr))
{
return NULL;
}

var = ((geoGrid*)(ptr))->pCount;
return Py_BuildValue("i",var);
}

PyObject* getYCount(PyObject *self, PyObject *args)
{
int var;
uint64_t ptr;

if (!PyArg_ParseTuple(args, "K", &ptr))
{
return NULL;
}

var = ((geoGrid*)(ptr))->lCount;
return Py_BuildValue("i",var);
}

PyObject* getXPixelSize(PyObject *self, PyObject *args)
{
double var;
uint64_t ptr;

if (!PyArg_ParseTuple(args, "K", &ptr))
{
return NULL;
}

var = ((geoGrid*)(ptr))->grd_res;
return Py_BuildValue("d",var);
}

PyObject* getYPixelSize(PyObject *self, PyObject *args)
{
double var;
uint64_t ptr;

if (!PyArg_ParseTuple(args, "K", &ptr))
{
return NULL;
}

var = ((geoGrid*)(ptr))->azm_res;
return Py_BuildValue("d",var);
}


PyObject* geogrid(PyObject* self, PyObject* args)
{
Expand Down
2 changes: 2 additions & 0 deletions geo_autoRIFT/geogrid/include/geogrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ struct geoGrid
int lookSide;
int nodata_out;
double incidenceAngle;
int pOff, lOff, pCount, lCount;
double grd_res, azm_res;

//Output file names
std::string pixlinename;
Expand Down
12 changes: 12 additions & 0 deletions geo_autoRIFT/geogrid/include/geogridmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ extern "C"
PyObject * setChipSizeX0(PyObject *, PyObject *);
PyObject * setXLimits(PyObject *, PyObject *);
PyObject * setYLimits(PyObject *, PyObject *);
PyObject * getXPixelSize(PyObject *, PyObject *);
PyObject * getYPixelSize(PyObject *, PyObject *);
PyObject * getXOff(PyObject *, PyObject *);
PyObject * getYOff(PyObject *, PyObject *);
PyObject * getXCount(PyObject *, PyObject *);
PyObject * getYCount(PyObject *, PyObject *);
}

static PyMethodDef geogrid_methods[] =
Expand All @@ -93,6 +99,12 @@ static PyMethodDef geogrid_methods[] =
{"setNodataOut_Py", setNodataOut, METH_VARARGS, " "},
{"setXLimits_Py", setXLimits, METH_VARARGS, " "},
{"setYLimits_Py", setYLimits, METH_VARARGS, " "},
{"getXPixelSize_Py", getXPixelSize, METH_VARARGS, " "},
{"getYPixelSize_Py", getYPixelSize, METH_VARARGS, " "},
{"getXOff_Py", getXOff, METH_VARARGS, " "},
{"getYOff_Py", getYOff, METH_VARARGS, " "},
{"getXCount_Py", getXCount, METH_VARARGS, " "},
{"getYCount_Py", getYCount, METH_VARARGS, " "},
{"setWindowLocationsFilename_Py", setWindowLocationsFilename, METH_VARARGS, " "},
{"setWindowOffsetsFilename_Py", setWindowOffsetsFilename, METH_VARARGS, " "},
{"setWindowSearchRangeFilename_Py", setWindowSearchRangeFilename, METH_VARARGS, " "},
Expand Down
17 changes: 11 additions & 6 deletions geo_autoRIFT/geogrid/src/geogrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,16 @@ void geoGrid::geogrid()


//Get offsets and size to read from DEM
int lOff = std::max( std::floor((ymax - geoTrans[3])/geoTrans[5]), 0.);
int lCount = std::min( std::ceil((ymin - geoTrans[3])/geoTrans[5]), demYSize-1.) - lOff;

int pOff = std::max( std::floor((xmin - geoTrans[0])/geoTrans[1]), 0.);
int pCount = std::min( std::ceil((xmax - geoTrans[0])/geoTrans[1]), demXSize-1.) - pOff;
// int lOff = std::max( std::floor((ymax - geoTrans[3])/geoTrans[5]), 0.);
// int lCount = std::min( std::ceil((ymin - geoTrans[3])/geoTrans[5]), demYSize-1.) - lOff;
//
// int pOff = std::max( std::floor((xmin - geoTrans[0])/geoTrans[1]), 0.);
// int pCount = std::min( std::ceil((xmax - geoTrans[0])/geoTrans[1]), demXSize-1.) - pOff;
lOff = std::max( std::floor((ymax - geoTrans[3])/geoTrans[5]), 0.);
lCount = std::min( std::ceil((ymin - geoTrans[3])/geoTrans[5]), demYSize-1.) - lOff;

pOff = std::max( std::floor((xmin - geoTrans[0])/geoTrans[1]), 0.);
pCount = std::min( std::ceil((xmax - geoTrans[0])/geoTrans[1]), demXSize-1.) - pOff;


std::cout << "Xlimits : " << geoTrans[0] + pOff * geoTrans[1] << " "
Expand Down Expand Up @@ -648,7 +653,7 @@ void geoGrid::geogrid()


// ground range and azimuth pixel size
double grd_res, azm_res;
// double grd_res, azm_res;

// double incang = 38.0*deg2rad;
double incang = incidenceAngle;
Expand Down

0 comments on commit f5cc354

Please sign in to comment.