SuperDARN / pydarn

Python library for visualizing SuperDARN Data
GNU Lesser General Public License v3.0
31 stars 11 forks source link

BUG: Issue plotting Infinity for GSMR Range Estimation - Help needed for further dev in MUSIC code #268

Closed carleyjmartin closed 2 years ago

carleyjmartin commented 2 years ago

BUG

For further development, it is requested that we remove the line that removes infinite values from coordinates.py

y0inx = np.min(np.where(np.isfinite(beam_corners_lats[:,0]))[0])

As these values cause issues with plotting further down the line.

We need a solution where this line is removed/amended and the size of the return beam_corners_lats, beam_corners_lons is the size of the fan, but does not affect the plotting later on. Any ideas welcome!

@w2naf @francistee26 please add anything that you think would be helpful to know!

Priority

Urgent only as it is required for further development, and is a failure in usage if removed.

Information

python version: OS: matplotlib version:

Example of the bug

Error output when plotting a fan plot with 'range_estimation': RangeEstimation.GSMR with the line in the code removed:

Traceback (most recent call last):
  File "/Users/carley/Documents/testing_code/test_music.py", line 30, in <module>
    pydarn.Fan.plot_fan(sps_fitacf_data, colorbar=True, **kwargs1)
  File "/Users/carley/Documents/testing_code/venv-music1/lib/python3.9/site-packages/pydarn/plotting/fan.py", line 320, in plot_fan
    ax.pcolormesh(thetas, rs,
  File "/Users/carley/Documents/testing_code/venv-music1/lib/python3.9/site-packages/matplotlib/__init__.py", line 1412, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/Users/carley/Documents/testing_code/venv-music1/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 6058, in pcolormesh
    X, Y, C, shading = self._pcolorargs('pcolormesh', *args,
  File "/Users/carley/Documents/testing_code/venv-music1/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 5533, in _pcolorargs
    raise ValueError(
ValueError: x and y arguments to pcolormesh cannot have non-finite values or be of type numpy.ma.core.MaskedArray with masked values

Attempts

No attempts made.

Potential Solution(s)

It's possible we set the values to NaN instead of infinity, and then the pcolormesh can deal with that? We cannot use a masked array as ground scatter is already in the masked array. Remember this line is in two of the functions in coordinates.py and needs to work for both.

carleyjmartin commented 2 years ago

Check out the branch named ehn/music_setup for an idea. Used the keyword idea in coordinates.py but made some new modules and a method that will get the data required without having to go through any plotting. I've set it all up so that really you can just add the methods for the algorithm in there, and I've made a plotting specific module where we can add the plotting methods for the interpolated data and probability density functions for wave numbers (not done, just left place holders, possible we can just use the RTP with specific options for the interpolated data). Anyway, there's some peripherals like a new warning for using options meant for music only and set up the init file for new modules.

carleyjmartin commented 2 years ago

Closing as I don't think outside help is needed for this problem any more, the problem is technically solved and work on integration is ongoing.