Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeogridOptical.py Divide by zero error in search range creation if slope is not specified #20

Closed
forrestfwilliams opened this issue Mar 18, 2021 · 2 comments

Comments

@forrestfwilliams
Copy link
Contributor

If testGeogrid_ISCE.py is run with search range files but not slope files, a divide by zero error occurs. Looking at lines 565-576 of GeogridOptical.py:

if (self.dhdxname != ""):
    normal = -slp / np.linalg.norm(slp)
else:
    normal = np.array([0., 0., 0.])

if (self.vxname != ""):
    vel[2] = -(vel[0]*normal[0]+vel[1]*normal[1])/normal[2]

if (self.srxname != ""):
    schrng1[2] = -(schrng1[0]*normal[0]+schrng1[1]*normal[1])/normal[2]
    schrng2[2] = -(schrng2[0]*normal[0]+schrng2[1]*normal[1])/normal[2]

If self.dhdxname is not specified, the normal vector is set to an array of zeroes, which results in divide by zero errors at lines 575 and 576 if self.srxname is specified. Must slope always be specified if the search range option is used?

@leiyangleon
Copy link
Collaborator

@forrestfwilliams thanks for the question. We really need to update the documentation which is outdated. Geogrid can be used with several combination of input files. The possible combinations can be found here. When certain conditions are met, corresponding output variables will be written to a file (e.g. window_*.tif) otherwise, they will be discarded. For your particular question, yes, slope must be provided in order for search range to be outputted, which is enforced by this check. If only search range is provided without slope, although you might see warnings of divide by zero, the program runs through without crashing, i.e. other variables are outputted properly but search range just won't be written to a file because it is meaningless (divide by zero).

The math behind this can be found in this paper. Refer to Eq 4 (derivation in Appendix A) that converts between velocity (and search range of velocity that is also in unit of m/yr) and pixel offset (and search range in the number of pixels).

So, slope is is a must-have for Geogrid to generate search range. However, it is strictly required for radar images with range/azimuth geometry; for optical images, both DEM and slope can be all-zero-value images.

@forrestfwilliams
Copy link
Contributor Author

forrestfwilliams commented Mar 19, 2021

Thank you for this explanation @leiyangleon. I am happy for this issue to be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants