kenfus / radiospectra

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

AttributeError: 'list' object has no attribute 't_delt' #18

Open anawas opened 2 years ago

anawas commented 2 years ago

When reading some spectrograms I get the following exception:

Traceback (most recent call last):
  File "/Volumes/VMs/astrophysics/raumschiff/burstextractor/burstlist.py", line 97, in extract_burst
    s = CallistoSpectrogram.from_range(
  File "/Volumes/VMs/astrophysics/raumschiff/radiospectra-ids/radiospectra/radiospectra/sources/callisto.py", line 528, in from_range
    spec = cls.combine_frequencies(
  File "/Volumes/VMs/astrophysics/raumschiff/radiospectra-ids/radiospectra/radiospectra/spectrogram.py", line 1714, in combine_frequencies
    specs = cls.intersect_time(specs)
  File "/Volumes/VMs/astrophysics/raumschiff/radiospectra-ids/radiospectra/radiospectra/spectrogram.py", line 1689, in intersect_time
    delt = min(sp.t_delt for sp in specs)
  File "/Volumes/VMs/astrophysics/raumschiff/radiospectra-ids/radiospectra/radiospectra/spectrogram.py", line 1689, in <genexpr>
    delt = min(sp.t_delt for sp in specs)
AttributeError: 'list' object has no attribute 't_delt'

How to reproduce

start = datetime.datetime(2022,8,2, 13, 59)
end = datetime.datetime(2022,8,2,14,3)
spec = CallistoSpectrogram.from_range("SPAIN-PERALEJOS", start, end)

Works for

start = datetime.datetime(2022,8,2, 22, 9)
end = datetime.datetime(2022,8,2,22,13)
spec = CallistoSpectrogram.from_range("ROSWELL-NM", start, end)
kenfus commented 2 years ago

I am able to reproduce this! Will look at it

kenfus commented 2 years ago

Ok, what I have figured out thus far:

For some reason, data = list(map(cls.from_url, urls)) for "SPAIN-PERALEJOS" has duplicate freq_axis.

Then this part of the code: freq_buckets[tuple(elem.freq_axis)].append(elem) in callisto.py and the use the append function causes in the dictionary freq_buckets to have a list with length bigger than 0 per key. In the function combine_frequencies then the mentioned error is casted because of course delt = min(sp.t_delt for sp in specs) does not work if specs is a list of a list instead of just a list because a list does not have the property t_delt, only a element in the list of the list.

The masked arrays in data are also different per identical key, so I am unsure how to fix this. Maybe it's a problem in the source data?

Also, in the newest version of radiospectra from sunpy, both functions work and don't throw an error. I would suggest to close this and work on putting our stuff in the version of radiospectra of sunpy?

arielespinosa commented 2 years ago

@kenfus add in the class LinearSpectogram, in the begining of intersect_time() function this line and problem solved

specs = [item if type(item) != list else item[0] for item in specs]