Exemplo n.º 1
0
def tui_checkabs (args):
    import omega as om

    if len (args) != 1:
        util.die ('usage: <datfile>')

    nc = NoiseCal ()
    nc.load (args[0])

    saps = nc.saps
    sqbps = nc.sqbps
    vals = nc.bpdata[:,1]
    uncerts = nc.bpdata[:,2]**-0.5
    modelvals = nc.bpdata[:,3] * nc.svals
    muncerts = nc.suncerts * nc.bpdata[:,3]

    pg = om.quickPager ([])

    for idx in xrange (len (saps)):
        w = np.where ((sqbps[:,0] == idx) | (sqbps[:,1] == idx))

        p = om.quickXYErr (vals[w], modelvals[w], muncerts[w],
                           util.fmtAP (saps[idx]), lines=False)
        p.setLabels ('Measured variance (Jy²)', 'Modeled variance (Jy²)')
        pg.send (p)

    pg.done ()
    return 0
Exemplo n.º 2
0
    def plot (self, modelx, dlines=False, xmin=None, xmax=None,
              ymin=None, ymax=None, **kwargs):
        """This assumes that `data` is 1D and that `mfunc` takes one argument that
        should be treated as the X variable."""

        import omega as om

        modelx = np.asarray (modelx)
        if modelx.shape != self.data.shape:
            raise ValueError ('modelx and data arrays must have same shape')

        modely = self.mfunc (modelx)
        sigmas = self.invsigma**-1 # TODO: handle invsigma = 0

        vb = om.layout.VBox (2)
        vb.pData = om.quickXYErr (modelx, self.data, sigmas,
                                  'Data', lines=dlines, **kwargs)

        vb[0] = vb.pData
        vb[0].addXY (modelx, modely, 'Model')
        vb[0].setYLabel ('Y')
        vb[0].rebound (False, True)
        vb[0].setBounds (xmin, xmax, ymin, ymax)

        vb[1] = vb.pResid = om.RectPlot ()
        vb[1].defaultField.xaxis = vb[1].defaultField.xaxis
        vb[1].addXYErr (modelx, self.resids, sigmas, None, lines=False)
        vb[1].setLabels ('X', 'Residuals')
        vb[1].rebound (False, True)
        # ignore Y values since residuals are on different scale:
        vb[1].setBounds (xmin, xmax)

        vb.setWeight (0, 3)
        return vb
Exemplo n.º 3
0
def tui_checkabs(args):
    import omega as om

    if len(args) != 1:
        util.die('usage: <datfile>')

    nc = NoiseCal()
    nc.load(args[0])

    saps = nc.saps
    sqbps = nc.sqbps
    vals = nc.bpdata[:, 1]
    uncerts = nc.bpdata[:, 2]**-0.5
    modelvals = nc.bpdata[:, 3] * nc.svals
    muncerts = nc.suncerts * nc.bpdata[:, 3]

    pg = om.quickPager([])

    for idx in xrange(len(saps)):
        w = np.where((sqbps[:, 0] == idx) | (sqbps[:, 1] == idx))

        p = om.quickXYErr(vals[w],
                          modelvals[w],
                          muncerts[w],
                          util.fmtAP(saps[idx]),
                          lines=False)
        p.setLabels('Measured variance (Jy²)', 'Modeled variance (Jy²)')
        pg.send(p)

    pg.done()
    return 0
Exemplo n.º 4
0
    def plot(self,
             modelx,
             dlines=False,
             xmin=None,
             xmax=None,
             ymin=None,
             ymax=None,
             **kwargs):
        """Plot the data and model (requires `omega`).

        This assumes that `data` is 1D and that `mfunc` takes one argument
        that should be treated as the X variable.

        """
        import omega as om

        modelx = np.asarray(modelx)
        if modelx.shape != self.data.shape:
            raise ValueError('modelx and data arrays must have same shape')

        modely = self.mfunc(modelx)
        sigmas = self.invsigma**-1  # TODO: handle invsigma = 0

        vb = om.layout.VBox(2)
        vb.pData = om.quickXYErr(modelx,
                                 self.data,
                                 sigmas,
                                 'Data',
                                 lines=dlines,
                                 **kwargs)

        vb[0] = vb.pData
        vb[0].addXY(modelx, modely, 'Model')
        vb[0].setYLabel('Y')
        vb[0].rebound(False, True)
        vb[0].setBounds(xmin, xmax, ymin, ymax)

        vb[1] = vb.pResid = om.RectPlot()
        vb[1].defaultField.xaxis = vb[1].defaultField.xaxis
        vb[1].addXYErr(modelx, self.resids, sigmas, None, lines=False)
        vb[1].setLabels('X', 'Residuals')
        vb[1].rebound(False, True)
        # ignore Y values since residuals are on different scale:
        vb[1].setBounds(xmin, xmax)

        vb.setWeight(0, 3)
        return vb
Exemplo n.º 5
0
    def plot (self, dlines=False, densemodel=True, xmin=None, xmax=None,
              ymin=None, ymax=None, mxmin=None, mxmax=None, **kwargs):
        import omega as om

        if not densemodel:
            modx = self.x
            mody = self.modely
        else:
            if mxmin is None:
                mxmin = self.x.min ()
            if mxmax is None:
                mxmax = self.x.max ()
            modx = np.linspace (mxmin, mxmax, 400)
            mody = self.modelfunc (modx)

        sigmas = self.invsigma**-1 # TODO: handle invsigma = 0

        vb = om.layout.VBox (2)
        vb.pData = om.quickXYErr (self.x, self.y, sigmas,
                                  'Data', lines=dlines, **kwargs)

        vb[0] = vb.pData
        vb[0].addXY (modx, mody, 'Model')
        vb[0].setYLabel ('Y')
        vb[0].rebound (False, True)
        vb[0].setBounds (xmin, xmax, ymin, ymax)

        vb[1] = vb.pResid = om.RectPlot ()
        vb[1].defaultField.xaxis = vb[1].defaultField.xaxis
        vb[1].addXYErr (self.x, self.resids, sigmas, None, lines=False)
        vb[1].setLabels ('X', 'Residuals')
        vb[1].rebound (False, True)
        # ignore Y values since residuals are on different scale:
        vb[1].setBounds (xmin, xmax)

        vb.setWeight (0, 3)
        return vb
Exemplo n.º 6
0
    def report (self, cfg):
        import omega as om
        import omega.gtk3
        from pwkit import ndshow_gtk3

        self.all_aps = np.sort (list (self.all_aps))
        self.all_bps = sorted (self.all_bps)
        self.all_times = np.sort (list (self.all_times))

        # Antpols by DDID, time:
        data = []
        descs = []

        for ddid, stats in self.ap_time_stats_by_ddid.iteritems ():
            mean, scat = postproc (stats.finish (self.all_times, self.all_aps))
            data.append (mean / scat)
            descs.append ('DDID %d' % ddid)

        print ('Viewing X axis: antpol; Y axis: time; iteration: DDID (~= spwid) ...')
        ndshow_gtk3.cycle (data, descs, run_main=True)

        # Antpols by DDID, freq:
        data = []
        descs = []

        for ddid, stats in self.ap_spec_stats_by_ddid.iteritems ():
            mean, scat = postproc (stats.finish (self.all_aps))
            data.append (mean / scat)
            descs.append ('DDID %d' % ddid)

        print ('Viewing X axis: frequency; Y axis: antpol; iteration: DDID ...')
        ndshow_gtk3.cycle (data, descs, run_main=True)

        # Antpols by DDID
        p = om.RectPlot ()

        for ddid, stats in self.ap_stats_by_ddid.iteritems ():
            ok, mean, scat = postproc_mask (stats.finish (self.all_aps))
            p.addXYErr (np.arange (len (self.all_aps))[ok], mean, scat, 'DDID %d' % ddid)

        p.setBounds (-0.5, len (self.all_aps) - 0.5)
        p.setLabels ('Antpol number', 'Mean closure phase (rad)')
        p.addHLine (0, keyText=None, zheight=-1)
        print ('Viewing everything grouped by antpol ...')
        p.show ()

        # Basepols by DDID
        data = []
        descs = []
        tostatuses = []

        def bpgrid_status (pol1, pol2, ants, yx):
            i, j = [int (_) for _ in np.floor (yx + 0.5)]
            if i < 0 or j < 0 or i >= ants.size or j >= ants.size:
                return ''

            ni = self._getname (ants[i])
            nj = self._getname (ants[j])

            if i <= j:
                return '%s-%s %s' % (ni, nj, util.pol_names[pol1])
            return '%s-%s %s' % (nj, ni, util.pol_names[pol2])

        for ddid, stats in self.bp_stats_by_ddid.iteritems ():
            mean, scat = postproc (stats.finish (self.all_bps))
            nmean = mean / scat
            from itertools import izip
            pol1, pol2, ants, grid = grid_bp_data (self.all_bps,
                                                   izip (self.all_bps, nmean))
            data.append (grid)
            descs.append ('DDID %d' % ddid)
            tostatuses.append (lambda yx: bpgrid_status (pol1, pol2, ants, yx))

        print ('Viewing X axis: antpol1; Y axis: antpol2; iteration: DDID ...')
        ndshow_gtk3.cycle (data, descs, tostatuses=tostatuses, run_main=True)

        # Everything by time
        ok, mean, scat = postproc_mask (self.global_stats_by_time.finish (self.all_times))
        stimes = self.all_times[ok] / 86400
        st0 = int (np.floor (stimes.min ()))
        stimes -= st0
        p = om.quickXYErr (stimes, mean, scat)
        p.addHLine (0, keyText=None, zheight=-1)
        p.setLabels ('MJD - %d' % st0, 'Mean closure phase (rad)')
        print ('Viewing everything grouped by time ...')
        p.show ()
Exemplo n.º 7
0
    def report(self, cfg):
        import omega as om
        import omega.gtk3
        from pwkit import ndshow_gtk3

        self.all_aps = np.sort(list(self.all_aps))
        self.all_bps = sorted(self.all_bps)
        self.all_times = np.sort(list(self.all_times))

        # Antpols by DDID, time:
        data = []
        descs = []

        for ddid, stats in self.ap_time_stats_by_ddid.items():
            mean, scat = postproc(stats.finish(self.all_times, self.all_aps))
            data.append(mean / scat)
            descs.append('DDID %d' % ddid)

        print(
            'Viewing X axis: antpol; Y axis: time; iteration: DDID (~= spwid) ...'
        )
        ndshow_gtk3.cycle(data, descs, run_main=True)

        # Antpols by DDID, freq:
        data = []
        descs = []

        for ddid, stats in self.ap_spec_stats_by_ddid.items():
            mean, scat = postproc(stats.finish(self.all_aps))
            data.append(mean / scat)
            descs.append('DDID %d' % ddid)

        print('Viewing X axis: frequency; Y axis: antpol; iteration: DDID ...')
        ndshow_gtk3.cycle(data, descs, run_main=True)

        # Antpols by DDID
        p = om.RectPlot()

        for ddid, stats in self.ap_stats_by_ddid.items():
            ok, mean, scat = postproc_mask(stats.finish(self.all_aps))
            p.addXYErr(
                np.arange(len(self.all_aps))[ok], mean, scat, 'DDID %d' % ddid)

        p.setBounds(-0.5, len(self.all_aps) - 0.5)
        p.setLabels('Antpol number', 'Mean closure phase (rad)')
        p.addHLine(0, keyText=None, zheight=-1)
        print('Viewing everything grouped by antpol ...')
        p.show()

        # Basepols by DDID
        data = []
        descs = []
        tostatuses = []

        def bpgrid_status(pol1, pol2, ants, yx):
            i, j = [int(_) for _ in np.floor(yx + 0.5)]
            if i < 0 or j < 0 or i >= ants.size or j >= ants.size:
                return ''

            ni = self._getname(ants[i])
            nj = self._getname(ants[j])

            if i <= j:
                return '%s-%s %s' % (ni, nj, util.pol_names[pol1])
            return '%s-%s %s' % (nj, ni, util.pol_names[pol2])

        for ddid, stats in self.bp_stats_by_ddid.items():
            mean, scat = postproc(stats.finish(self.all_bps))
            nmean = mean / scat
            pol1, pol2, ants, grid = grid_bp_data(self.all_bps,
                                                  zip(self.all_bps, nmean))
            data.append(grid)
            descs.append('DDID %d' % ddid)
            tostatuses.append(lambda yx: bpgrid_status(pol1, pol2, ants, yx))

        print('Viewing X axis: antpol1; Y axis: antpol2; iteration: DDID ...')
        ndshow_gtk3.cycle(data, descs, tostatuses=tostatuses, run_main=True)

        # Everything by time
        ok, mean, scat = postproc_mask(
            self.global_stats_by_time.finish(self.all_times))
        stimes = self.all_times[ok] / 86400
        st0 = int(np.floor(stimes.min()))
        stimes -= st0
        p = om.quickXYErr(stimes, mean, scat)
        p.addHLine(0, keyText=None, zheight=-1)
        p.setLabels('MJD - %d' % st0, 'Mean closure phase (rad)')
        print('Viewing everything grouped by time ...')
        p.show()