Exemple #1
0
    def showmatch(self, show=False, verbose=True):
        """
		A plot of the transformed stars and the candidate quad
		"""
        if self.ok == False:
            return
        if verbose:
            print "Plotting match ..."
        import matplotlib.pyplot as plt
        #import matplotlib.patches
        #import matplotlib.collections

        plt.figure(figsize=(10, 10))

        # The ref in black
        a = star.listtoarray(self.ref.starlist, full=True)
        plt.scatter(a[:, 0], a[:, 1], s=2.0, color="black")
        a = star.listtoarray(self.refmatchstars, full=True)
        plt.scatter(a[:, 0], a[:, 1], s=10.0, color="black")

        # The ukn in red
        a = star.listtoarray(self.trans.applystarlist(self.ukn.starlist),
                             full=True)
        plt.scatter(a[:, 0], a[:, 1], s=2.0, color="red")
        a = star.listtoarray(self.trans.applystarlist(self.uknmatchstars),
                             full=True)
        plt.scatter(a[:, 0], a[:, 1], s=6.0, color="red")

        # The quad

        polycorners = star.listtoarray(self.cand["refquad"].stars)
        polycorners = imgcat.ccworder(polycorners)
        plt.fill(polycorners[:, 0],
                 polycorners[:, 1],
                 alpha=0.1,
                 ec="none",
                 color="red")

        plt.xlim(self.ref.xlim)
        plt.ylim(self.ref.ylim)
        plt.title("Match of %s" % (str(self.ukn.name)))
        plt.xlabel("ref x")
        plt.ylabel("ref y")
        ax = plt.gca()
        ax.set_aspect('equal', 'datalim')

        if show:
            plt.show()
        else:
            if not os.path.isdir("alipy_visu"):
                os.makedirs("alipy_visu")
            plt.savefig(
                os.path.join("alipy_visu", self.ukn.name + "_match.png"))
Exemple #2
0
    def showquads(self, show=False, flux=True, verbose=True):
        """
		Uses matplotlib to write/show the quads.
		"""
        if verbose:
            print "Plotting quads ..."

        import matplotlib.pyplot as plt
        #import matplotlib.patches
        #import matplotlib.collections

        plt.figure(figsize=(10, 10))

        if len(self.starlist) >= 2:
            a = star.listtoarray(self.starlist, full=True)
            if flux:
                f = np.log10(a[:, 2])
                fmax = np.max(f)
                fmin = np.min(f)
                f = 1.0 + 8.0 * (f - fmin) / (fmax - fmin)
                plt.scatter(a[:, 0], a[:, 1], s=f, color="black")
            else:
                plt.plot(a[:, 0],
                         a[:, 1],
                         marker=",",
                         ls="none",
                         color="black")

        if len(self.quadlist) != 0:
            for quad in self.quadlist:
                polycorners = star.listtoarray(quad.stars)
                polycorners = ccworder(polycorners)
                plt.fill(polycorners[:, 0],
                         polycorners[:, 1],
                         alpha=0.03,
                         ec="none")

        plt.xlim(self.xlim)
        plt.ylim(self.ylim)
        plt.title(str(self))
        plt.xlabel("x")
        plt.ylabel("y")
        ax = plt.gca()
        ax.set_aspect('equal', 'datalim')

        if show:
            plt.show()
        else:
            if not os.path.isdir("alipy_visu"):
                os.makedirs("alipy_visu")
            plt.savefig(os.path.join("alipy_visu", self.name + "_quads.png"))
Exemple #3
0
    def showmatch(self, show=False, verbose=True):
        """
        A plot of the transformed stars and the candidate quad
        """
        if self.ok == False:
            return
        if verbose:
            print("Plotting match ...")
        import matplotlib.pyplot as plt
        # import matplotlib.patches
        # import matplotlib.collections

        plt.figure(figsize=(10, 10))

        # The ref in black
        a = star.listtoarray(self.ref.starlist, full=True)
        plt.scatter(a[:, 0], a[:, 1], s=2.0, color="black")
        a = star.listtoarray(self.refmatchstars, full=True)
        plt.scatter(a[:, 0], a[:, 1], s=10.0, color="black")

        # The ukn in red
        a = star.listtoarray(
            self.trans.applystarlist(self.ukn.starlist), full=True)
        plt.scatter(a[:, 0], a[:, 1], s=2.0, color="red")
        a = star.listtoarray(
            self.trans.applystarlist(self.uknmatchstars), full=True)
        plt.scatter(a[:, 0], a[:, 1], s=6.0, color="red")

        # The quad

        polycorners = star.listtoarray(self.cand["refquad"].stars)
        polycorners = imgcat.ccworder(polycorners)
        plt.fill(polycorners[:, 0], polycorners[
                 :, 1], alpha=0.1, ec="none", color="red")

        plt.xlim(self.ref.xlim)
        plt.ylim(self.ref.ylim)
        plt.title("Match of %s" % (str(self.ukn.name)))
        plt.xlabel("ref x")
        plt.ylabel("ref y")
        ax = plt.gca()
        ax.set_aspect('equal', 'datalim')

        if show:
            plt.show()
        else:
            if not os.path.isdir("alipy_visu"):
                os.makedirs("alipy_visu")
            plt.savefig(
                os.path.join("alipy_visu", self.ukn.name + "_match.png"))
Exemple #4
0
    def showquads(self, show=False, flux=True, verbose=True):
        """
        Uses matplotlib to write/show the quads.
        """
        if verbose:
            print("Plotting quads ...")

        import matplotlib.pyplot as plt

        # import matplotlib.patches
        # import matplotlib.collections

        plt.figure(figsize=(10, 10))

        if len(self.starlist) >= 2:
            a = star.listtoarray(self.starlist, full=True)
            if flux:
                f = np.log10(a[:, 2])
                fmax = np.max(f)
                fmin = np.min(f)
                f = 1.0 + 8.0 * (f - fmin) / (fmax - fmin)
                plt.scatter(a[:, 0], a[:, 1], s=f, color="black")
            else:
                plt.plot(a[:, 0], a[:, 1], marker=",", ls="none", color="black")

        if len(self.quadlist) != 0:
            for quad in self.quadlist:
                polycorners = star.listtoarray(quad.stars)
                polycorners = ccworder(polycorners)
                plt.fill(polycorners[:, 0], polycorners[:, 1], alpha=0.03, ec="none")

        plt.xlim(self.xlim)
        plt.ylim(self.ylim)
        plt.title(str(self))
        plt.xlabel("x")
        plt.ylabel("y")
        ax = plt.gca()
        ax.set_aspect("equal", "datalim")

        if show:
            plt.show()
        else:
            if not os.path.isdir("alipy_visu"):
                os.makedirs("alipy_visu")
            plt.savefig(os.path.join("alipy_visu", self.name + "_quads.png"))
Exemple #5
0
	def calcfluxratio(self, verbose=True):
		"""
		Computes a very simple median flux ratio between the images.
		The purpose is simply to get a crude guess, for images with e.g. different exposure times.
		Given that we have these corresponding star lists in hand, this is trivial to do once findtrans was run.
		"""
		assert len(self.uknmatchstars) == len(self.refmatchstars)
		if len(self.refmatchstars) == 0:
			if verbose:
				print "No matching stars to compute flux ratio !"
			return
		
		reffluxes = star.listtoarray(self.refmatchstars, full=True)[:,2]
		uknfluxes = star.listtoarray(self.uknmatchstars, full=True)[:,2]
		fluxratios = reffluxes / uknfluxes
		
		self.medfluxratio = float(np.median(fluxratios))
		self.stdfluxratio = float(np.std(fluxratios))
		
		if verbose:
			print "Computed flux ratio from %i matches : median %.2f, std %.2f" % (len(reffluxes), self.medfluxratio, self.stdfluxratio)