Esempio n. 1
0
        if t != tprev:
            # New time 
            l += 1
            tprev = t
            if l == 600:
                break
        if len(data.nonzero()[0]) == nf:
            out[ibl[i,j],:,l,k] = data[data.nonzero()]
    return out, freq

import copy
import spectrogram_fit as sp
from util import Time

trange = Time(['2015-06-21 01:26:00','2015-06-21 01:46:00'])
s = sp.Spectrogram(trange)
s.fidx = [0,213]
tsys, std = s.get_median_data()

out,fghz = readXdata('/data1/IDB/IDB20150621012612')
out2,f = readXdata('/data1/IDB/IDB20150621013612')
out = concatenate((out,out2),2)
pcal = angle(out[:,:,550,:])
acal = abs(out[:,:,550,:])
calout = copy.copy(out)
# Calibrate for time 550, just before the peak of the flare.
for i in range(1200):
    calout[:,:,i,:] = calout[:,:,i,:]*(cos(pcal)-1j*sin(pcal))/acal

# Normalize to the total power spectrum at the same time, with reference
# to the shortest baseline (preserves the relative amplitudes on various
Esempio n. 2
0
def show_selfcalibrated(index, trange, plot='multipanel', antennas=0):
    #for index, choose a time when the flare starting, with a large slope.
    #the options for plot are 'multipanel' , 'saturation' , and 'uncalibrated'
    #antennas controls which pair the saturation plot shows.

    data = get_trange_files(trange)
    IDBdata, uvw, freq, times = get_X_data(data)

    s = sp.Spectrogram(trange)
    s.fidx = [0, IDBdata.shape[2]]
    tsys, std = s.get_median_data()

    pcal = np.angle(IDBdata[:, :, :, index])
    acal = abs(IDBdata[:, :, :, index])
    calout = copy.copy(IDBdata)
    # Calibrate for time 'index', just before the initial peak of the flare.
    for i in range(IDBdata.shape[3]):
        calout[:, :, :,
               i] = calout[:, :, :,
                           i] * (np.cos(pcal) - 1j * np.sin(pcal)) / acal
    # Normalize to the total power spectrum at the same time, with reference
    # to the shortest baseline (preserves the relative amplitudes on various
    # baselines and polarizations.
    norm = abs(calout[:, :, :, index])
    for i in range(12):
        for j in range(2):
            norm[i, j, :] = tsys[:, index] * abs(calout[i, j, :, index]) / abs(
                calout[0, 0, :, index])
    for i in range(IDBdata.shape[3]):
        calout[:, :, :, i] = calout[:, :, :, i] * norm
    if plot == 'multipanel':
        # Multi-panel Plot
        f, ax = plt.subplots(4, 5)
        sbl = ['1-2', '1-3', '1-4', '2-3', '2-4', '3-4', '5-7', '5-8', '7-8']
        for i, ibl in enumerate([0, 1, 2, 3, 4, 5, 7, 8, 11]):
            if (i > 4):
                ax[2, i % 5].imshow(abs(calout[ibl, 0, 50:, :]))
                ax[2, i % 5].text(100, 10, sbl[i] + ' Amp', color='white')
                ax[3, i % 5].imshow(np.angle(calout[ibl, 0, 50:, :]))
                ax[3, i % 5].text(100, 10, sbl[i] + ' Phase')
            else:
                ax[0, i % 5].imshow(abs(calout[ibl, 0, 50:, :]))
                ax[0, i % 5].text(100, 10, sbl[i] + ' Amp', color='white')
                ax[1, i % 5].imshow(np.angle(calout[ibl, 0, 50:, :]))
                ax[1, i % 5].text(100, 10, sbl[i] + ' Phase')
            ax[2, 4].imshow(tsys[50:, :])
            ax[2, 4].text(100, 10, 'Total Power', color='white')
            plt.subplots_adjust(left=0.02,
                                bottom=0.03,
                                right=0.99,
                                top=0.97,
                                wspace=0.20,
                                hspace=0.20)
    else:
        if plot == 'saturation':
            # Saturation Plot
            ants_ = 'Ants ' + str(antennas + 1) + '-' + str(antennas + 2)
            plt.figure()
            plt.plot(tsys[IDBdata.shape[2] - 110, :],
                     abs(calout[antennas, 0, IDBdata.shape[2] - 110, :]),
                     '.',
                     label=str(freq[IDBdata.shape[2] - 110])[:5] + ' GHz')
            plt.plot(tsys[IDBdata.shape[2] - 60, :],
                     abs(calout[antennas, 0, IDBdata.shape[2] - 60, :]),
                     '.',
                     label=str(freq[IDBdata.shape[2] - 60])[:5] + ' GHz')
            plt.plot(tsys[IDBdata.shape[2] - 10, :],
                     abs(calout[antennas, 0, IDBdata.shape[2] - 10, :]),
                     '.',
                     label=str(freq[IDBdata.shape[2] - 10])[:5] + ' GHz')
            plt.xlabel('Total Power [sfu]')
            plt.ylabel('Correlated Power (' + ants_ + ') [sfu]')
            plt.legend(loc='lower right')
        else:
            if plot == 'uncalibrated':
                #"uncalibrated"
                f, ax = plt.subplots(4, 5)
                sbl = [
                    '1-2', '1-3', '1-4', '2-3', '2-4', '3-4', '5-7', '5-8',
                    '7-8'
                ]
                for i, ibl in enumerate([0, 1, 2, 3, 4, 5, 7, 8, 11]):
                    if (i > 4):
                        ax[2, i % 5].imshow(abs(IDBdata[ibl, 0, 50:, :]))
                        ax[2, i % 5].text(100,
                                          10,
                                          sbl[i] + ' Amp',
                                          color='white')
                        ax[3, i % 5].imshow(np.angle(IDBdata[ibl, 0, 50:, :]))
                        ax[3, i % 5].text(100, 10, sbl[i] + ' Phase')
                    else:
                        ax[0, i % 5].imshow(abs(IDBdata[ibl, 0, 50:, :]))
                        ax[0, i % 5].text(100,
                                          10,
                                          sbl[i] + ' Amp',
                                          color='white')
                        ax[1, i % 5].imshow(np.angle(IDBdata[ibl, 0, 50:, :]))
                        ax[1, i % 5].text(100, 10, sbl[i] + ' Phase')
                ax[2, 4].imshow(tsys[50:, :])
                ax[2, 4].text(100, 10, 'Total Power', color='white')
                plt.subplots_adjust(left=0.02,
                                    bottom=0.03,
                                    right=0.99,
                                    top=0.97,
                                    wspace=0.20,
                                    hspace=0.20)
            else:
                print 'please choose valid plot type'