def check_distance(self): cat = self.cat0 cat["D_Z"] = cat["Redshift_Cosmological"].map(lambda x: z2d(x, h=1.0, wm=self.wm)) cat["colour"] = cat["Johnson_B_Apparent"] - cat["Johnson_R_Apparent"] cat["K Correction"] = cat.apply(apply_kcor, axis=1) cat["DM"] = cat["Johnson_B_Apparent"] - cat["Johnson_B_Absolute"] - cat["K Correction"] cat["D Lum"] = cat["DM"].map(lambda x: math.pow(10, 0.2 * x + 1) / 1.0e6) cat["D_M"] = cat.apply(self.make_d_m(), axis=1) cat["Diff"] = cat.apply(calc_diff, axis=1) stats = cat["Diff"].describe() logger.info("Stats:\n{0}".format(stats)) logger.debug("First 10:\n{0}".format(cat.head(10))) if abs(stats["mean"]) > self.job_params.MAX_MEAN_DIFFERENCE: logger.error("Mean difference {0} exceeds {1}".format(stats["mean"], self.job_params.MAX_MEAN_DIFFERENCE)) if abs(stats["max"]) > self.job_params.MAX_MAX_DIFFERENCE: logger.error("Max difference {0} exceeds {1}".format(stats["max"], self.job_params.MAX_MAX_DIFFERENCE)) if abs(stats["mean"]) < self.job_params.MIN_MEAN_DIFFERENCE: logger.error( "Mean difference {0} is less than {1}".format(stats["mean"], self.job_params.MIN_MEAN_DIFFERENCE) ) if abs(stats["max"]) < self.job_params.MIN_MAX_DIFFERENCE: logger.error("Max difference {0} is less than {1}".format(stats["max"], self.job_params.MIN_MAX_DIFFERENCE)) return
header = data.readline() headers = header.split(csv_delimiter) ids = {} for field in required_fields: if required_fields[field] in headers: ids[field] = headers.index(required_fields[field]) if len(ids) != len(required_fields): print "can't find all required fields in the catalogue." sys.exit() print " z(TAO) d(TAO) d(z) d(DM) diff %" for i in range(0,n): line = data.readline() values = line.split(csv_delimiter) z = float(values[ids['z']]) d = float(values[ids['d']]) b_abs = float(values[ids['b_abs']]) b_app = float(values[ids['b_app']]) r_app = float(values[ids['r_app']]) d_z = z2d(z, 1) # [Mpc/h] color = b_app - r_app k_corr = calc_kcor('B', z, 'B - Rc', color) dm = b_app - b_abs - k_corr # distance modulus d_lum = math.pow(10, 0.2*dm + 1)/1e6 # luminosity distance [Mpc] d_m = h*d_lum/(1+z) # co-moving distance [Mpc/h] diff = 100*d_m/d - 100; # % print "%e\t%e\t%e\t%e\t%.2f" % (z, d, d_z, d_m, diff)