Skip to content

Commit

Permalink
Merge pull request #26 from leiyangleon/other_MISC_fixes
Browse files Browse the repository at this point in the history
add dt-varying search range routine
  • Loading branch information
leiyangleon authored Apr 14, 2021
2 parents 58a1760 + dd40b73 commit b8be98d
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 5 deletions.
11 changes: 10 additions & 1 deletion geo_autoRIFT/geogrid/Geogrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ def setState(self):
geogrid.setRangeParameters_Py( self._geogrid, self.startingRange, self.rangePixelSize)
geogrid.setAzimuthParameters_Py( self._geogrid, DTU.seconds_since_midnight(self.sensingStart), self.prf)
geogrid.setRepeatTime_Py(self._geogrid, self.repeatTime)

geogrid.setDtUnity_Py( self._geogrid, self.dt_unity)
geogrid.setMaxFactor_Py( self._geogrid, self.max_factor)
geogrid.setUpperThreshold_Py( self._geogrid, self.upper_thld)
geogrid.setLowerThreshold_Py(self._geogrid, self.lower_thld)

geogrid.setEPSG_Py(self._geogrid, self.epsg)
geogrid.setIncidenceAngle_Py(self._geogrid, self.incidenceAngle)
Expand Down Expand Up @@ -373,7 +378,11 @@ def __init__(self):
self.winro2vxname = None
self.winro2vyname = None


##dt-varying search range rountine parameters
self.dt_unity = 182
self.max_factor = 5
self.upper_thld = 20000
self.lower_thld = 0

##Coordinate system
self.epsg = None
Expand Down
12 changes: 11 additions & 1 deletion geo_autoRIFT/geogrid/GeogridOptical.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,11 @@ def geogrid(self):
vel = np.array([0., 0., 0.])
if (self.srxname != ""):
schrng1 = np.array([srxLine[jj], sryLine[jj], 0.0])
schrng2 = np.array([-srxLine[jj], sryLine[jj], 0.0])
schrng1[0] *= np.max((self.max_factor*((self.dt_unity-1)*self.max_factor+(self.max_factor-1)-(self.max_factor-1)*self.repeatTime/24.0/3600.0)/((self.dt_unity-1)*self.max_factor),1))
schrng1[0] = np.min((np.max((schrng1[0],self.lower_thld)),self.upper_thld))
schrng1[1] *= np.max((self.max_factor*((self.dt_unity-1)*self.max_factor+(self.max_factor-1)-(self.max_factor-1)*self.repeatTime/24.0/3600.0)/((self.dt_unity-1)*self.max_factor),1))
schrng1[1] = np.min((np.max((schrng1[1],self.lower_thld)),self.upper_thld))
schrng2 = np.array([-schrng1[0], schrng1[1], 0.0])
targutm0 = np.array(fwdTrans.TransformPoint(targxyz0[0],targxyz0[1],targxyz0[2]))
xind = np.round((targutm0[0] - self.startingX) / self.XSize) + 1.
yind = np.round((targutm0[1] - self.startingY) / self.YSize) + 1.
Expand Down Expand Up @@ -862,6 +866,12 @@ def __init__(self):
self.winssmname = None
self.winro2vxname = None
self.winro2vyname = None

##dt-varying search range rountine parameters
self.dt_unity = 182
self.max_factor = 5
self.upper_thld = 20000
self.lower_thld = 0

##Coordinate system
self.epsgDem = None
Expand Down
48 changes: 48 additions & 0 deletions geo_autoRIFT/geogrid/bindings/geogridmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,54 @@ PyObject* getYPixelSize(PyObject *self, PyObject *args)
return Py_BuildValue("d",var);
}

PyObject* setDtUnity(PyObject *self, PyObject *args)
{
uint64_t ptr;
double dt_unity;
if (!PyArg_ParseTuple(args, "Kd", &ptr, &dt_unity))
{
return NULL;
}
((geoGrid*)(ptr))->dt_unity = dt_unity;
return Py_BuildValue("i", 0);
}

PyObject* setMaxFactor(PyObject *self, PyObject *args)
{
uint64_t ptr;
double max_factor;
if (!PyArg_ParseTuple(args, "Kd", &ptr, &max_factor))
{
return NULL;
}
((geoGrid*)(ptr))->max_factor = max_factor;
return Py_BuildValue("i", 0);
}

PyObject* setUpperThreshold(PyObject *self, PyObject *args)
{
uint64_t ptr;
double upper_thld;
if (!PyArg_ParseTuple(args, "Kd", &ptr, &upper_thld))
{
return NULL;
}
((geoGrid*)(ptr))->upper_thld = upper_thld;
return Py_BuildValue("i", 0);
}

PyObject* setLowerThreshold(PyObject *self, PyObject *args)
{
uint64_t ptr;
double lower_thld;
if (!PyArg_ParseTuple(args, "Kd", &ptr, &lower_thld))
{
return NULL;
}
((geoGrid*)(ptr))->lower_thld = lower_thld;
return Py_BuildValue("i", 0);
}


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

//dt-varying search range rountine parameters
double dt_unity;
double max_factor;
double upper_thld, lower_thld;

//Output file names
std::string pixlinename;
Expand Down
9 changes: 9 additions & 0 deletions geo_autoRIFT/geogrid/include/geogridmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ extern "C"
PyObject * setOrbit(PyObject *, PyObject *);
PyObject * setLookSide(PyObject *, PyObject *);
PyObject * setNodataOut(PyObject *, PyObject *);

PyObject * setDtUnity(PyObject *, PyObject *);
PyObject * setMaxFactor(PyObject *, PyObject *);
PyObject * setUpperThreshold(PyObject*, PyObject *);
PyObject * setLowerThreshold(PyObject *, PyObject *);

PyObject * setWindowLocationsFilename(PyObject *, PyObject *);
PyObject * setWindowOffsetsFilename(PyObject *, PyObject *);
Expand Down Expand Up @@ -99,6 +104,10 @@ static PyMethodDef geogrid_methods[] =
{"setOrbit_Py", setOrbit, METH_VARARGS, " "},
{"setLookSide_Py", setLookSide, METH_VARARGS, " "},
{"setNodataOut_Py", setNodataOut, METH_VARARGS, " "},
{"setDtUnity_Py", setDtUnity, METH_VARARGS, " "},
{"setMaxFactor_Py", setMaxFactor, METH_VARARGS, " "},
{"setUpperThreshold_Py", setUpperThreshold, METH_VARARGS, " "},
{"setLowerThreshold_Py", setLowerThreshold, METH_VARARGS, " "},
{"setXLimits_Py", setXLimits, METH_VARARGS, " "},
{"setYLimits_Py", setYLimits, METH_VARARGS, " "},
{"getXPixelSize_Py", getXPixelSize, METH_VARARGS, " "},
Expand Down
10 changes: 7 additions & 3 deletions geo_autoRIFT/geogrid/src/geogrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,11 +927,15 @@ void geoGrid::geogrid()
{
schrng1[0] = srxLine[jj];
schrng1[1] = sryLine[jj];
schrng2[0] = -srxLine[jj];
schrng2[1] = sryLine[jj];
}

schrng1[0] *= std::max(max_factor*((dt_unity-1)*max_factor+(max_factor-1)-(max_factor-1)*dt/24.0/3600.0)/((dt_unity-1)*max_factor),1.0);
schrng1[0] = std::min(std::max(schrng1[0],lower_thld),upper_thld);
schrng1[1] *= std::max(max_factor*((dt_unity-1)*max_factor+(max_factor-1)-(max_factor-1)*dt/24.0/3600.0)/((dt_unity-1)*max_factor),1.0);
schrng1[1] = std::min(std::max(schrng1[1],lower_thld),upper_thld);

schrng2[0] = -schrng1[0];
schrng2[1] = schrng1[1];
}


//Convert from DEM coordinates to LLH inplace
Expand Down
4 changes: 4 additions & 0 deletions testGeogridOptical.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ def runGeogrid(info, info1, dem, dhdx, dhdy, vx, vy, srx, sry, csminx, csminy, c
obj.ssmname = ssm
obj.winlocname = "window_location.tif"
obj.winoffname = "window_offset.tif"
# obj.max_factor = 10
# obj.dt_unity = 32
# obj.upper_thld = 20000
# obj.lower_thld = 0
obj.winsrname = "window_search_range.tif"
obj.wincsminname = "window_chip_size_min.tif"
obj.wincsmaxname = "window_chip_size_max.tif"
Expand Down
8 changes: 8 additions & 0 deletions testGeogrid_ISCE.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ def runGeogrid(info, info1, dem, dhdx, dhdy, vx, vy, srx, sry, csminx, csminy, c
obj.ssmname = ssm
obj.winlocname = "window_location.tif"
obj.winoffname = "window_offset.tif"
# obj.max_factor = 10
# obj.dt_unity = 5
# obj.upper_thld = 20000
# obj.lower_thld = 0
obj.winsrname = "window_search_range.tif"
obj.wincsminname = "window_chip_size_min.tif"
obj.wincsmaxname = "window_chip_size_max.tif"
Expand Down Expand Up @@ -317,6 +321,10 @@ def runGeogridOptical(info, info1, dem, dhdx, dhdy, vx, vy, srx, sry, csminx, cs
obj.ssmname = ssm
obj.winlocname = "window_location.tif"
obj.winoffname = "window_offset.tif"
# obj.max_factor = 10
# obj.dt_unity = 32
# obj.upper_thld = 20000
# obj.lower_thld = 0
obj.winsrname = "window_search_range.tif"
obj.wincsminname = "window_chip_size_min.tif"
obj.wincsmaxname = "window_chip_size_max.tif"
Expand Down

0 comments on commit b8be98d

Please sign in to comment.