dlilien / ImpDAR

An impulse radar processor
GNU General Public License v3.0
27 stars 19 forks source link

Fixed a bug in "impdar/lib/migrationlib/mig_python.py". #42

Closed real-Xuan closed 1 year ago

real-Xuan commented 1 year ago

In the code, presently, when the "migrate" function is called, it generates an error as shown below:

… numpy.core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'multiply' output from dtype('float64') to dtype('int16') with casting rule 'same_kind' …

The reason for this problem is that the current code will save the result in dat.data, however, when the result's data type is float64, which cannot be stored in int32.

This pull request fixed the bug mentioned in "impdar/lib/migrationlib/mig_python.py."

dlilien commented 1 year ago

Sorry for the delay. We need to think a bit about how we want to handle this--it is going to be radar-system dependent and I want to figure out what is best here. I actually think it may be best to coerce back to int32 (or really whatever the input was). Any thoughts @benhills?

benhills commented 1 year ago

I think I agree that it should be whatever the input data type was.

Something like:

H,V = np.meshgrid(h,v).astype(dat.data.dtype)
dat.data *= H*V

I also think we should incorporate these into #39 since that is always confusing people who use the kirchoff migration in the tutorial.

I haven't gotten around to addressing all the dependency failures (see #37) although I was planning to do that at one point. I think if we could deal with those and then merge all this together it would be a very useful PR.

dlilien commented 1 year ago

I put a fix on this in @benhills PR #39, which I have now merged. I think that fix is more generic and will still handle this issue. @real-Xuan , if there is still a problem feel free to re-open this, but first check if version 1.1.7 (available on github or pypi) fixes the error.