Skip to content

Commit

Permalink
Update spectrogram for other spectrogram in eCallisto archive
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Maloney committed Oct 30, 2021
1 parent 0dfd9b5 commit 645fc5d
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions radiospectra/spectrogram2/spectrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,28 +631,7 @@ def _read_cdf(file):
def _read_fits(file):
hd_pairs = fits.read(file)

if 'e-CALLISTO' in hd_pairs[0].header.get('CONTENT', ''):
data = hd_pairs[0].data
times = hd_pairs[1].data['TIME'].flatten() * u.s
freqs = hd_pairs[1].data['FREQUENCY'].flatten() * u.MHz
start_time = parse_time(hd_pairs[0].header['DATE-OBS']
+ ' ' + hd_pairs[0].header['TIME-OBS'])
end_time = parse_time(hd_pairs[0].header['DATE-END']
+ ' ' + hd_pairs[0].header['TIME-END'])
times = start_time + times
meta = {
'fits_meta': hd_pairs[0].header,
'detector': 'e-CALLISTO',
'instrument': 'e-CALLISTO',
'observatory': hd_pairs[0].header['INSTRUME'],
'start_time': start_time,
'end_time': end_time,
'wavelength': a.Wavelength(freqs.min(), freqs.max()),
'times': times,
'freqs': freqs
}
return data, meta
elif hd_pairs[0].header.get('TELESCOP', '') == 'EOVSA':
if hd_pairs[0].header.get('TELESCOP', '') == 'EOVSA':
times = Time(hd_pairs[2].data['mjd'] + hd_pairs[2].data['time'] / 1000.0 / 86400.,
format='mjd')
freqs = hd_pairs[1].data['sfreq'] * u.GHz
Expand All @@ -673,6 +652,35 @@ def _read_fits(file):
}
return data, meta

# semi standard - spec in primary and time and freq in 1st extension
try:
data = hd_pairs[0].data
times = hd_pairs[1].data['TIME'].flatten() * u.s
freqs = hd_pairs[1].data['FREQUENCY'].flatten() * u.MHz
start_time = parse_time(hd_pairs[0].header['DATE-OBS']
+ ' ' + hd_pairs[0].header['TIME-OBS'])
end_time = parse_time(hd_pairs[0].header['DATE-END']
+ ' ' + hd_pairs[0].header['TIME-END'])
times = start_time + times
meta = {
'fits_meta': hd_pairs[0].header,
'start_time': start_time,
'end_time': end_time,
'wavelength': a.Wavelength(freqs.min(), freqs.max()),
'times': times,
'freqs': freqs,
'instrument': hd_pairs[0].header.get('INSTRUME', ''),
'observatory': hd_pairs[0].header.get('INSTRUME', ''),
'detector': hd_pairs[0].header.get('DETECTOR', ''),
}
if 'e-CALLISTO' in hd_pairs[0].header['CONTENT']:
meta['detector'] = 'e-CALLISTO'
meta['instrument'] = 'e-CALLISTO'

return data, meta
except KeyError:
raise ValueError('Could not load fits file into spectrogram')

@staticmethod
def _read_idl_sav(file, instrument=None):
data = readsav(file)
Expand Down

0 comments on commit 645fc5d

Please sign in to comment.