cgrima / subradar

Tools for subsurface radar processing
MIT License
3 stars 3 forks source link

Assorted improvements and testing code #7

Closed gregoryng closed 11 months ago

gregoryng commented 1 year ago

For your consideration, here are some assorted style improvements. There is one change that is sort of a bug but that likely would never be encountered.

I wrote a script that exercises all of the code. It is in my usual style to try to figure out if we can run every line of code with all combinations of options. That's in 8a84eb57a1e0d60e6c056bec5a828738665c75d0.

No real urgency but just wanted to have this available for you to merge/rebase in case you start working on it later.

cgrima commented 1 year ago

Ah, that's good to know, thanks!

gregoryng commented 1 year ago

Hi Cyril, this pull request can be merged in; everything works as well as it did before or better.

But FYI, there are still a few known issues with some code that you probably never ran before (which you are welcome to fix at a later point).

Basically there are some weightings that don't quite work:

(ve_rsr1) freeze.ig.utexas.edu 97% ./test_subradar1.py                                                   [10/416]
............../subradar/utils.py:178: RuntimeWarning: divide by zero encountered in true_divide
  W = 1./Pxx
../subradar/utils.py:178: RuntimeWarning: invalid value encountered in true_divide
  W = 1./Pxx
../subradar/utils.py:190: RuntimeWarning: invalid value encountered in multiply
  cc = np.abs(scipy.fft.ifft(Pxy * W ))#[1:]
../subradar/utils.py:180: RuntimeWarning: divide by zero encountered in true_divide
  W = 1./np.sqrt(Pxx * Pyy)
../subradar/utils.py:180: RuntimeWarning: invalid value encountered in true_divide
  W = 1./np.sqrt(Pxx * Pyy)
../subradar/utils.py:182: RuntimeWarning: divide by zero encountered in true_divide
  W = 1./np.abs(Pxy)
..../subradar/surface.py:98: RuntimeWarning: invalid value encountered in true_divide
  c = signal[idx]/noise
....
======================================================================
ERROR: test_gcc (__main__.TestSurface) (weight='wiener')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/utig5/ngg/data/202308_rsr/subradar/tests/./test_subradar1.py", line 139, in test_gcc
    info = sr.surface.gcc(self.rdg, weight=method)
  File "../subradar/surface.py", line 176, in gcc
    _ = utils.gcc(rdg[:, i], rdg[:, i+1], **kwargs)
  File "../subradar/utils.py", line 190, in gcc
    cc = np.abs(scipy.fft.ifft(Pxy * W ))#[1:]
ValueError: operands could not be broadcast together with shapes (2000,) (501,)
======================================================================
ERROR: test_gcc (__main__.TestSurface) (weight='ml')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/utig5/ngg/data/202308_rsr/subradar/tests/./test_subradar1.py", line 139, in test_gcc
    info = sr.surface.gcc(self.rdg, weight=method)
  File "../subradar/surface.py", line 176, in gcc
    _ = utils.gcc(rdg[:, i], rdg[:, i+1], **kwargs)
  File "../subradar/utils.py", line 185, in gcc
    W =  K / np.abs(Pxy)
ValueError: operands could not be broadcast together with shapes (501,) (2000,)

----------------------------------------------------------------------
Ran 19 tests in 10.380s