kenfus / radiospectra

BSD 2-Clause "Simplified" License
0 stars 2 forks source link

Mean of spectrogram is NaN #17

Closed anawas closed 1 year ago

anawas commented 1 year ago

Sometimes, the mean value of spectrogram data is reported as Nan. In the following case, e.g:

start = datetime.datetime(2022,8,5, 16, 29)
end = datetime.datetime(2022,8,5,16,33)
spec = CallistoSpectrogram.from_range("Arecibo-Observatory", start.isoformat(), end.isoformat())
spec.data.mean()
Output: nan

Why does it matter? I use the mean value in order to adjust the colormap when plotting the spectrogram.

anawas commented 1 year ago

I assume the problem is caused because the mask in the masked_array used is all False:

print(spec.data.sum())
Output: nan

print(spec.data)
Output:
masked_array(
  data=[[124.0, 122.0, 122.0, ..., 122.0, 122.0, 123.0],
        [121.0, 122.0, 121.0, ..., 121.0, 122.0, 121.0],
        [123.0, 122.0, 123.0, ..., 123.0, 122.0, 122.0],
        ...,
        [146.0, 147.0, 147.0, ..., 146.0, 146.0, 145.0],
        [nan, nan, nan, ..., nan, nan, nan],
        [nan, nan, nan, ..., nan, nan, nan]],
  mask=[[False, False, False, ..., False, False, False],
        [False, False, False, ..., False, False, False],
        [False, False, False, ..., False, False, False],
        ...,
        [False, False, False, ..., False, False, False],
        [False, False, False, ..., False, False, False],
        [False, False, False, ..., False, False, False]],
  fill_value=1e+20)
anawas commented 1 year ago

A cannot reproduce this bug after merging the latest commit.