kenfus / radiospectra

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

Exception occured #16

Open anawas opened 1 year ago

anawas commented 1 year ago

When processing instrument GLASGOW for event from 2022/08/03 10:15 to 2022/08/03 10:19 I get the following exception:

Traceback (most recent call last):
  File "/Volumes/VMs/astrophysics/raumschiff/burstextractor/burstlist.py", line 94, in extract_burst
    interesting = s.in_interval(event_start, event_end)
  File "/Users/andreas/miniforge3/envs/ecallisto/lib/python3.9/site-packages/radiospectra-0.3.1.dev151+gc1bb19c-py3.9.egg/radiospectra/spectrogram.py", line 1837, in in_interval
    return self[:, start:end]
  File "/Users/andreas/miniforge3/envs/ecallisto/lib/python3.9/site-packages/radiospectra-0.3.1.dev151+gc1bb19c-py3.9.egg/radiospectra/spectrogram.py", line 694, in __getitem__
    return self._slice(key[0], key[1])
  File "/Users/andreas/miniforge3/envs/ecallisto/lib/python3.9/site-packages/radiospectra-0.3.1.dev151+gc1bb19c-py3.9.egg/radiospectra/spectrogram.py", line 360, in _slice
    data = self.data[y_range, x_range]
  File "/Users/andreas/miniforge3/envs/ecallisto/lib/python3.9/site-packages/numpy/ma/core.py", line 3222, in __getitem__
    dout = self.data[indx]
TypeError: slice indices must be integers or None or have an __index__ method
anawas commented 1 year ago

Seems to be a problem with interval boundary, because the start minute is set to 15. If I set the start time to 2022/08/03 10:14, everything works. Not sure if it is an issue. You can work around it by adjusting the time accordingly before calling in_interval().

arielespinosa commented 1 year ago

Seems to be a problem with interval boundary, because the start minute is set to 15. If I set the start time to 2022/08/03 10:14, everything works. Not sure if it is an issue. You can work around it by adjusting the time accordingly before calling in_interval().

HI @anawas. We check it already and seems like it works image

Can you provide us more info if you get the same error trying to read the file as I show you in the image below?

anawas commented 1 year ago

Executing your code lines works perfectly. But I see that my description of the problem was inaccurate - sorry about that. The exception occurs if I execute the following lines:

start = datetime.datetime(2022, 8, 3, 10, 15)
end = datetime.datetime(2022, 8, 3, 10, 19)
spec = CallistoSpectrogram.from_range("GLASGOW", start, end)
cutout = spec.in_interval("10:15", "10:19")

This is a common use case when I extract the bursts from the spectrogram. The lower and upper time boundaries are calculated by a script. It reads the event time from the original burst list and adds +/- 2 minutes. When I use start = datetime.datetime(2022, 8, 3, 10, 14) instead anything works fine.

Suggested workaround Check if time boundaries are time.minutes % 15 == 0. If so, adjust boundaries by -1 minutes.