Exemple #1
0
    def __init__(self, file_name=CMR_path):
        """
        initial the color magnitude data

        :param file_name: file name of the color magnitude data
        :returns: Cmr class with property data array [z,griz ...]
        """
        try:
            self.data = np.loadtxt(file_name)
        except IOError:
            warning("Fail to open cmr file: {0:s}".format(file_name))
            exit(1)
Exemple #2
0
    def get_magnitude(self, zid, band):
        """
        get the magnitude of given redshift and band

        :param zid: redshift row to return
        :param band: color band: [griz]
        :returns: [z,griz ...]
        """
        try:
            mid = CMR_BANDS[band] + np.arange(0, CMR_NL, len(CMR_BANDS), np.dtype("I4")) + 1
            return self.data[zid, mid]
        except NameError:
            warning("wrong color band: {0:s}".format(band))
        except IndexError:
            warning("wrong number of L*")
Exemple #3
0
    def update_method(self, catalog, method):
        """
        Update the method in database based on catalog

        :param catalog: catalog name contains ID which is detected by method, "all" will set method to 1 for all
        :param method: method want to update to 1
        """
        if method not in P_method:
            warning("Wrong method name")
            exit()
        if catalog == "all":
            self.cur.execute("UPDATE {0:s} SET {1:s} = 1".format(self.table, method))
        else:
            cid = np.loadtxt(catalog, dtype=int)
            for i in cid:
                self.cur.execute("UPDATE {0:s} SET {1:s} = 1 WHERE id = ?".format(self.table, method), (cid,))
        self.conn.commit()
Exemple #4
0
    def fit_pz(self, ax, color, fit_x=0):
        """
        fit the P(z) data for given color

        :param ax: axis to plot
        :param color: detection color
        :param fit_x: 0 for fix x, 1 for fit x
        """
        if self.method is None:
            warning("error! no method defined")
            return [0, 0]

        self.color = color
        self.fit_x = fit_x
        x = self.pz[self.method][color][:, 0]
        y = self.pz[self.method][color][:, 1]
        if fit_x == 0:
            fit = axplot.g3g(x, y, n_sigma=NSIGMA)
        else:
            fit = axplot.g3gf(x, y, n_sigma=NSIGMA)
        y = np.max(y) * np.exp(-(x - fit[0]) ** 2 / 2. / fit[1] ** 2)
        ax.plot(x, y, '--')
        self.fit_result = fit