kenfus / radiospectra

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

Header missing in CallistoSpectrogram #13

Open anawas opened 2 years ago

anawas commented 2 years ago

When creating a CallistoSpectrogram with

spec = CallistoSpectrogram.read("SWISS-Landschlacht_20220815_143000_62.fit.gz")

the following works:

print(type(spec.get_header())
Output: <class 'astropy.io.fits.header.Header'>

But when I call

start = datetime.datetime(2022, 8, 15, 14, 30)
end = datetime.datetime(2022, 8, 15, 14, 35)
spec2 = CallistoSpectrogram.from_range("SWISS-Landschlacht", start.isoformat(), end.isoformat())
print(type(spec2.get_header())

I get an exception:

Traceback (most recent call last):
  File "/Volumes/VMs/astrophysics/raumschiff/radiospectra/test.py", line 10, in <module>
    print(spec2.get_header())
  File "/Volumes/VMs/astrophysics/raumschiff/radiospectra/radiospectra/sources/callisto.py", line 244, in get_header
    header = self.header.copy()
AttributeError: 'NoneType' object has no attribute 'copy'

This indicates that there is no header in the spec2. Therefore, I cannot write the spectrogram to disk:

spec2.save("test.fit.gz")

Traceback (most recent call last):
  File "/Volumes/VMs/astrophysics/raumschiff/radiospectra/test.py", line 10, in <module>
    spec2.save("test.fit.gz")
  File "/Volumes/VMs/astrophysics/raumschiff/radiospectra/radiospectra/sources/callisto.py", line 180, in save
    main_header = self.get_header()
  File "/Volumes/VMs/astrophysics/raumschiff/radiospectra/radiospectra/sources/callisto.py", line 244, in get_header
    header = self.header.copy()
AttributeError: 'NoneType' object has no attribute 'copy'
anawas commented 2 years ago

The problem seems to be in function combine_frequencies() in module spectrogram.py. A new CallistoSpectrogram is created on line 1757. But the parameters of the function call do not include the header nor the axes_header. I think a fix is to copy the header from one of the spectrograms and adjust it once we run through all the settings an come back to one single CallistoSpectrogram instance.