Exemple #1
0
    def printsefdinfo (self):
        raras = self.raras
        solution = self.solution
        saps = self.saps
        n = len (saps)
        maxant = util.apAnt (saps[-1]) + 1

        msefds = np.empty (n)
        pstds = np.empty (n)
        antcounts = np.zeros (maxant)
        antprods = np.ones (maxant)

        for i in xrange (n):
            info = raras[i]
            # TODO later: we're ignoring the RARA weighting
            # sqrt (2 * 102.4 khz * 10 s)
            sefd = 1431 * solution[i] * info[1]
            msefds[i] = sefd.mean ()
            pstds[i] = 100. * sefd.std () / msefds[i]

            ant = util.apAnt (saps[i])
            antcounts[ant] += 1
            antprods[ant] *= msefds[i]

        w = np.where (antcounts == 2)[0]
        if w.size == 0:
            bestant = -1
        else:
            bestant = w[np.argmin (antprods[w])]

        mmarks = ['     |     '] * n
        smarks = ['     |     '] * n

        sm = np.argsort (msefds)
        ss = np.argsort (pstds)

        for i in xrange (5):
            mmarks[sm[i]] = ' ' * i + '*' + ' ' * (4 - i) + '|     '
            mmarks[sm[-1 - i]] = '     |' + ' ' * (4 - i) + '*' + ' ' * i
            smarks[ss[i]] = ' ' * i + '*' + ' ' * (4 - i) + '|     '
            smarks[ss[-1 - i]] = '     |' + ' ' * (4 - i) + '*' + ' ' * i

        print 'instrument:', self.instr
        print
        print '%4s %7s %5s %13s %13s' % ('AP', 'SEFD', 'Var.', 'SEFD Rank',
                                         'Var. Rank')

        for i in xrange (n):
            print '%4s %7.0f %4.1f%% [%s] [%s]' % \
                (util.fmtAP (saps[i]), msefds[i], pstds[i], mmarks[i], smarks[i])

        print
        print 'Median (mean SEFD):', np.median (msefds)
        print '       Equiv. TSys:', np.median (msefds) / 153.

        if bestant < 0:
            print 'No dual-pol antennas'
        else:
            print 'Best dual-pol antenna:', bestant
Exemple #2
0
    def printsefdinfo(self):
        raras = self.raras
        solution = self.solution
        saps = self.saps
        n = len(saps)
        maxant = util.apAnt(saps[-1]) + 1

        msefds = np.empty(n)
        pstds = np.empty(n)
        antcounts = np.zeros(maxant)
        antprods = np.ones(maxant)

        for i in xrange(n):
            info = raras[i]
            # TODO later: we're ignoring the RARA weighting
            # sqrt (2 * 102.4 khz * 10 s)
            sefd = 1431 * solution[i] * info[1]
            msefds[i] = sefd.mean()
            pstds[i] = 100. * sefd.std() / msefds[i]

            ant = util.apAnt(saps[i])
            antcounts[ant] += 1
            antprods[ant] *= msefds[i]

        w = np.where(antcounts == 2)[0]
        if w.size == 0:
            bestant = -1
        else:
            bestant = w[np.argmin(antprods[w])]

        mmarks = ['     |     '] * n
        smarks = ['     |     '] * n

        sm = np.argsort(msefds)
        ss = np.argsort(pstds)

        for i in xrange(5):
            mmarks[sm[i]] = ' ' * i + '*' + ' ' * (4 - i) + '|     '
            mmarks[sm[-1 - i]] = '     |' + ' ' * (4 - i) + '*' + ' ' * i
            smarks[ss[i]] = ' ' * i + '*' + ' ' * (4 - i) + '|     '
            smarks[ss[-1 - i]] = '     |' + ' ' * (4 - i) + '*' + ' ' * i

        print 'instrument:', self.instr
        print
        print '%4s %7s %5s %13s %13s' % ('AP', 'SEFD', 'Var.', 'SEFD Rank',
                                         'Var. Rank')

        for i in xrange(n):
            print '%4s %7.0f %4.1f%% [%s] [%s]' % \
                (util.fmtAP (saps[i]), msefds[i], pstds[i], mmarks[i], smarks[i])

        print
        print 'Median (mean SEFD):', np.median(msefds)
        print '       Equiv. TSys:', np.median(msefds) / 153.

        if bestant < 0:
            print 'No dual-pol antennas'
        else:
            print 'Best dual-pol antenna:', bestant
Exemple #3
0
        def record (self, state):
            inp = state.inp
            track = self.track
            systemps = self.systemps
            prefactor = self.prefactor
            bps = self.bps
            bpfactors = self.bpfactors

            if track is None:
               track = inp.makeVarTracker ().track ('systemp', 'sdf', 'inttime')
               self.track = track

            if track.updated ():
                nants = inp.getVarInt ('nants')
                systemps = self.systemps = inp.getVarFloat ('systemp', nants)
                nspect = inp.getVarInt ('nspect')
                sdf = inp.getVarDouble ('sdf', nspect)
                if nspect > 1:
                    sdf = sdf[0]
                inttime = inp.getVarFloat ('inttime')
                prefactor = self.prefactor = 2 * inttime * sdf * 1e9

            if bpfactors is None or bpfactors.size != state.nbp:
                bpfactors = self.bpfactors = np.empty (state.nbp)
                bps = self.bps = np.empty ((state.nbp, 2), dtype=np.int)

            ap1, ap2 = mir2bp (inp, state.preamble)

            if ap1 == ap2:
                # Autocorrelation! Get the RARA (raw autocorrelation
                # RMS amplitude)
                w = np.where (state.flags)[0]
                if w.size == 0:
                    self.raras.pop (ap1, 0)
                else:
                    self.raras[ap1] = np.sqrt ((state.data.real[w]**2).mean ())

            # Get the factor that will go in front of the RARAs for
            # jyperk computations. Do this for autocorrs too because
            # there's no reason not to.

            if state.instr not in self.byinstr:
                raise Exception ('need information for instrument ' +
                                 state.instr)

            byap, default = self.byinstr[state.instr]
            cal1 = byap.get (ap1, default)
            cal2 = byap.get (ap2, default)
            ant1, ant2 = apAnt (ap1), apAnt (ap2)
            tsys1, tsys2 = systemps[ant1 - 1], systemps[ant2 - 1]

            bpindex = state.bpindex
            bps[bpindex,0] = ap1
            bps[bpindex,1] = ap2
            bpfactors[bpindex] = prefactor * cal1 * cal2 / (tsys1 * tsys2)
Exemple #4
0
        def record(self, state):
            inp = state.inp
            track = self.track
            systemps = self.systemps
            prefactor = self.prefactor
            bps = self.bps
            bpfactors = self.bpfactors

            if track is None:
                track = inp.makeVarTracker().track('systemp', 'sdf', 'inttime')
                self.track = track

            if track.updated():
                nants = inp.getVarInt('nants')
                systemps = self.systemps = inp.getVarFloat('systemp', nants)
                nspect = inp.getVarInt('nspect')
                sdf = inp.getVarDouble('sdf', nspect)
                if nspect > 1:
                    sdf = sdf[0]
                inttime = inp.getVarFloat('inttime')
                prefactor = self.prefactor = 2 * inttime * sdf * 1e9

            if bpfactors is None or bpfactors.size != state.nbp:
                bpfactors = self.bpfactors = np.empty(state.nbp)
                bps = self.bps = np.empty((state.nbp, 2), dtype=np.int)

            ap1, ap2 = mir2bp(inp, state.preamble)

            if ap1 == ap2:
                # Autocorrelation! Get the RARA (raw autocorrelation
                # RMS amplitude)
                w = np.where(state.flags)[0]
                if w.size == 0:
                    self.raras.pop(ap1, 0)
                else:
                    self.raras[ap1] = np.sqrt((state.data.real[w]**2).mean())

            # Get the factor that will go in front of the RARAs for
            # jyperk computations. Do this for autocorrs too because
            # there's no reason not to.

            if state.instr not in self.byinstr:
                raise Exception('need information for instrument ' +
                                state.instr)

            byap, default = self.byinstr[state.instr]
            cal1 = byap.get(ap1, default)
            cal2 = byap.get(ap2, default)
            ant1, ant2 = apAnt(ap1), apAnt(ap2)
            tsys1, tsys2 = systemps[ant1 - 1], systemps[ant2 - 1]

            bpindex = state.bpindex
            bps[bpindex, 0] = ap1
            bps[bpindex, 1] = ap2
            bpfactors[bpindex] = prefactor * cal1 * cal2 / (tsys1 * tsys2)