コード例 #1
0
ファイル: skyMap.py プロジェクト: sudeepdas/SpecKPack-
def plotSensitivity(sm):
    """Histogram the sensitivity in all pixels"""

    data = sm.sensmap.data.ravel()
    dummy = pylab.hist(data, 75, [25, 100], fc="red")
    pylab.xlabel("Sensitivity in $\mathrm{\mu}$K$_{\mathrm{cmb}}$-arcmin")
    pylab.ylabel("Pixels")
    pylab.title("Pixel sensitivity distribution derived from hit map")
    pylab.text(90, 400000, "Mean: %.3f uK" % data[data < 100].mean(), ha="right")
    pylab.text(90, 370000, "Median: %.3f uK" % numpy.median(data[data < 100]), ha="right")
    pylab.text(90, 340000, "RMS: %.3f uK" % data[data < 100].std(), ha="right")
    utils.saveAndShow("sensitivity_histogram.png")
コード例 #2
0
ファイル: skyMap.py プロジェクト: sudeepdas/SpecKPack-
def plotSky_das(
    map, boxRAs=None, boxDecs=None, colorMapName="jet", show=True, colorBar=True, cutLevels=[-200, 200], **kwargs
):

    ip = ImagePlot(
        map.data, map.wcs, colorMapName=colorMapName, cutLevels=cutLevels, axesFontFamily="sans-serif", **kwargs
    )

    if boxRAs != None:
        print "boxRAs", boxRAs
        assert len(boxRAs) == len(boxDecs)
        ip.addPlotBoxes(boxRAs, boxDecs, "patches", color="black", width=1.5)

    pylab.ylabel("Dec.")

    if colorBar:
        cb = pylab.colorbar(orientation="horizontal", shrink=0.8, aspect=80, pad=0.375)
    if show:
        utils.saveAndShow()
    return ip
コード例 #3
0
ファイル: skyMap.py プロジェクト: sudeepdas/SpecKPack-
def plotValues(sm):
    """Histogram the data (temperature) values in the filtered map and difference map"""

    ax = pylab.subplot(111)

    x0, y0 = sm.map.skyToPix(102.70, -55.263)
    x1, y1 = sm.map.skyToPix(12.00, -51.0854)
    print x0, x1, y0, y1

    data = sm.diff.data[y0:y1, x0:x1].ravel()
    hist = pylab.hist(data, 200, [-400, 400], histtype="step", ec="red", axes=ax)
    pylab.text(100, 55000, "Values in CMB microK:")
    pylab.text(350, 50000, "Diff mean = %6.2f" % data.mean(), ha="right", color="red")
    pylab.text(350, 45000, "Diff rms  = %6.2f" % data.std(), ha="right", color="red")

    data = sm.fmap.data[y0:y1, x0:x1].ravel()
    hist = pylab.hist(data, 200, [-400, 400], histtype="step", ec="green", axes=ax)
    pylab.text(350, 40000, "Data mean = %6.2f" % data.mean(), ha="right", color="green")
    pylab.text(350, 35000, "Data rms  = %6.2f" % data.std(), ha="right", color="green")

    utils.saveAndShow("pixel_histogram.png")
コード例 #4
0
ファイル: skyMap.py プロジェクト: sudeepdas/SpecKPack-
def plotSky(map, boxes=True, colorMapName="jet", show=True, colorBar=True, cutLevels=[-200, 200], **kwargs):

    ip = ImagePlot(
        map.data, map.wcs, colorMapName=colorMapName, cutLevels=cutLevels, axesFontFamily="sans-serif", **kwargs
    )

    if boxes:
        RAs = []
        Decs = []
        dra = (102.700630 - 12.007338) / 13.0
        for i in range(13):
            RAs.append([12.07338 + dra * i, 12.07338 + dra * (i + 1)])
            Decs.append([-55.263018, -51.085420])
        ip.addPlotBoxes(RAs, Decs, "patches", color="black", width=1.5)

    pylab.ylabel("Dec.")

    if colorBar:
        cb = pylab.colorbar(orientation="horizontal", shrink=0.8, aspect=80, pad=0.375)
    if show:
        utils.saveAndShow()
    return ip
コード例 #5
0
ファイル: skyMap.py プロジェクト: sudeepdas/SpecKPack-
    def filter(self, minEll=300, deltaEll=400, maxEll=12000, plotFilter=False, plotMap=False, valueRange=[-250, 250]):
        """Apply a filter that rises as sin^2 in the given ell band.
        The 0.50 point is at minEll.  The full width is deltaEll.
        A separate Gaussian low-pass filter falls to 60% at maxEll.
        """

        ell = numpy.arange(0, 20000, 10.0)
        lowestEll = minEll - 0.5 * deltaEll
        Fell = numpy.sin(numpy.pi / 2 * (ell - lowestEll) / (deltaEll)) ** 2
        Fell[ell < minEll - 0.5 * deltaEll] = 0.0
        Fell[ell > minEll + 0.5 * deltaEll] = 1.0
        Fell *= numpy.exp(-0.5 * (ell / maxEll) ** 2)

        if plotFilter:
            pylab.clf()
            pylab.plot(ell, Fell)
            pylab.xlim([10, 20000])
            pylab.semilogx()
            utils.saveAndShow()
            print "The filters are plotted"

        self.fmap = filterFromList(self.map, [ell, Fell])
        print "The map is filtered now"

        if plotMap:
            plotSky(self.fmap, boxes=True)
        self.ftwoway = [filterFromList(m, [ell, Fell]) for m in self.twoway]

        if plotMap:
            pylab.clf()
            self.ftwoway[0].plot(
                valueRange=valueRange,
                colBarOrient="horizontal",
                colorMapName="copper",
                axesLabels="sexagesimal",
                RATickSteps="auto",
            )
            utils.saveAndShow()
            pylab.clf()
            self.ftwoway[1].plot(
                valueRange=valueRange,
                colBarOrient="horizontal",
                colorMapName="copper",
                axesLabels="sexagesimal",
                RATickSteps="auto",
            )
            utils.saveAndShow()
コード例 #6
0
ファイル: skyMap.py プロジェクト: sudeepdas/SpecKPack-
    def compute_variance(self, minHits=2000, plot=False):
        """Compute the average variance across the map of temperature times sqrt(N)
        for N hits in each pixel.  Given this number V, we can convert the hit map
        (of N) to a sensitivity map (of sqrt(V/N))."""

        # Make 1d vectors of map, weights
        if self.diff:
            mv = self.diff.data.ravel()
            wv = self.wt.data.ravel()
        else:
            mv = self.fmap.data.ravel()
            wv = self.wt.data.ravel()
        mv = mv[wv > minHits]
        wv = wv[wv > minHits]

        tn = numpy.sqrt(wv) * mv
        contents, bins, _ignore = pylab.hist(tn, 150, [-2e5, 2e5], fc="gold")

        # Estimate a gaussian by the moments
        mu = tn.mean()
        sig = tn.std()
        y0 = contents.max()
        binctr = 0.5 * (bins[1:] + bins[:-1])

        print "Moments    mu, sig: ", mu, sig
        if plot:
            pylab.plot(binctr, y0 * numpy.exp(-0.5 * ((binctr - mu) / sig) ** 2), "red")

        # Estimate a different gaussian by the 16, 84 %ile points
        h = numpy.cumsum(contents) * 1.0
        h /= h[-1]
        f = scipy.interpolate.interp1d(h, binctr)
        p16 = f(0.1587)  # The -1 sigma point on a Gaussian
        p84 = f(0.8413)  # The +1 sigma point on a Gaussian
        sig = 0.5 * (p84 - p16)
        median = f(0.5)
        print "Percentile mu, sig: ", median, sig
        if plot:
            pylab.plot(binctr, y0 * numpy.exp(-0.5 * ((binctr - median) / sig) ** 2), "blue")

        print "The raw one-hit variance is %.5g, or sqrt(V)=%.2f" % (sig ** 2, sig)
        size_arcmin = numpy.sqrt(self.fmap.pixScaleX * self.fmap.pixScaleY) * 180 / numpy.pi * 60.0
        sig *= size_arcmin
        self.StdDevHit = sig
        print "The calibrated one-hit std dev is sqrt(V)=%.2f uK-arcmin" % sig
        if plot:
            utils.saveAndShow()

        self.sensmap = self.wt.copy()
        self.sensmap.data[self.sensmap.data < 100] = 100
        self.sensmap.data = self.StdDevHit / numpy.sqrt(self.sensmap.data)

        if plot:
            pylab.clf()
            self.sensmap.plot(
                valueRange=[25, 75],
                colBarOrient="horizontal",
                colorMapName="hot",
                axesLabels="sexagesimal",
                RATickSteps="auto",
            )
            utils.saveAndShow()