def process_table(table, epochs, band, blind=True,quiet=True, report=False): print 'Removing large boxes' too_large_rows=np.where(table['stamp_size']>100)[0] table.remove_rows(too_large_rows) print "Lower casing" lowercase(table) lowercase(epochs) print "Sorting and grouping" epochs.sort(["id", "expnum"]) table.sort("identifier") print 'Adding chi2_pixel' chi2 = -2 * table['likelihood'] effective_npix = table['stamp_size']**2 * table['n_exposure'] * (1-table['mean_mask_fraction']) chi2_pixel = chi2 / effective_npix col = astropy.table.Column(name='chi2_pixel', data=chi2_pixel) table.add_column(col) print 'Renaming identifier->coadd_objects_ids' table.rename_column("identifier", "coadd_objects_id") epochs.rename_column('id', 'coadd_objects_id') #print 'NOT NOT NOT NOT NOT NOT NOT Adding extra columns flags' print "adding new columns" extra_columns.add_standard_cols(table) print 'Flagging' #error cuts cuts = cut_data.error_cuts + getattr(cut_data, "error_cuts_%s"%band) flags, fractions = cut_data.compute_flags(table, cuts, verb=not quiet) col = astropy.table.Column(name='error_flag', data=flags) table.add_column(col) if report: print "INFO CUTS" cut_data.report(cuts) #info cuts cuts = cut_data.info_cuts1 + getattr(cut_data, "info_cuts_%s"%band) + cut_data.info_cuts2 flags, fractions = cut_data.compute_flags(table, cuts, verb=not quiet) col = astropy.table.Column(name='info_flag', data=flags) table.add_column(col) if report: print "ERROR CUTS" cut_data.report(cuts) return table, epochs #blinding if blind: print 'Blinding' e1,e2 = blind_catalog.blind_arrays(table['e1'],table['e2']) table['e1'][:] = e1 table['e2'][:] = e2 print "Reticulating splines" return table, epochs
def _prepare_table(self, raw_catalog): """Carries operations to generate a standardized table.""" table = deepcopy(raw_catalog) # make notation for 'ra' and 'dec' standard across code. table.rename_column("RA", "ra") table.rename_column("DEC", "dec") table.rename_column("MAG", "ref_mag") index = np.arange(0, len(table)) # convert ra dec from degrees to arcsec in catalog. table["ra"] *= 3600 table["dec"] *= 3600 size = raw_catalog["flux_radius"] * raw_catalog["PIXEL_SCALE"] table["btk_size"] = size table["btk_index"] = index return table
def _prepare_table(self): table = deepcopy(self._raw_catalog) # make notation for 'ra' and 'dec' standard across code. table.rename_column("RA", "ra") table.rename_column("DEC", "dec") table.rename_column("MAG", "ref_mag") index = np.where(t["IDENT_1"] == self._raw_catalog["IDENT_1"] for t in table) # convert ra dec from degrees to arcsec in catalog. table["ra"] *= 3600 table["dec"] *= 3600 size = self._raw_catalog["flux_radius"] * self._raw_catalog[ "PIXEL_SCALE"] table["btk_size"] = size table["btk_index"] = index # ADds the extra columns to both catalogs just to be sure self._raw_catalog["ref_mag"] = self._raw_catalog["MAG"] self._raw_catalog["btk_size"] = size return table
def lowercase(table): for col in table.colnames[:]: if col!=col.lower(): table.rename_column(col, col.lower())