def _format_obs_history(obs_history, field_ids, save_to_disk=None): obs_history = obs_history.loc[obs_history['Field_fieldID'].isin( field_ids)].copy() # Some unit conversion and column renaming obs_history['Ixx_PSF'] = units.fwhm_to_sigma( obs_history['finSeeing'].values)**2.0 obs_history['apFluxErr'] = units.mag_to_flux( obs_history['fiveSigmaDepth'].values - 22.5) / 5.0 obs_history = obs_history.rename( { 'filtSkyBrightness': 'sky', 'obsHistID': 'ccdVisitId' }, axis=1) # Only keep columns we'll need obs_keep_cols = [ 'ccdVisitId', 'Field_fieldID', 'expMJD', 'Ixx_PSF', 'apFluxErr', 'sky', 'filter', ] obs_history = obs_history[obs_keep_cols] if save_to_disk is not None: obs_history.to_csv(save_to_disk, index=False) return obs_history
def _format_truth_catalog(point_neighbors, save_to_disk=None): # Point-source neighbors point_neighbors[['ra', 'dec' ]] = units.deg_to_arcsec(point_neighbors[['ra', 'dec']]) for bp in 'ugrizy': point_neighbors['flux_%s' % bp] = units.mag_to_flux( point_neighbors[bp].values, to_unit='nMgy') if save_to_disk is not None: point_neighbors.to_csv(save_to_disk, index=False) return point_neighbors
def _format_obs_history(obs_history, field, save_to_disk=None): """ Parameters ---------- obs_history : Pandas.DataFrame field : Pandas.DataFrame save_to_disk : str Note ---- We use the dithered RA, Dec and express all positions in arcsec. Returns ------- DataFrame obs_history, formatted with new column conventions and units """ # Join with Field table obs_history = pd.merge(obs_history, field, left_on='Field_fieldID', right_on='fieldID') # Some unit conversion and column renaming # NOTE: OpSim DB defines dithered positions as offset from the field center. obs_history['ditheredRA'] = units.deg_to_arcsec( obs_history['ditheredRA'].values + obs_history['fieldRA'].values) obs_history['ditheredDec'] = units.deg_to_arcsec( obs_history['ditheredDec'].values + obs_history['fieldDec'].values) obs_history['Ixx_PSF'] = units.fwhm_to_sigma( obs_history['finSeeing'].values)**2.0 obs_history['apFluxErr'] = units.mag_to_flux( obs_history['fiveSigmaDepth'].values - 22.5) / 5.0 obs_history = obs_history.rename( { 'filtSkyBrightness': 'sky', 'obsHistID': 'ccdVisitId' }, axis=1) # Only keep columns we'll need obs_keep_cols = [ 'ccdVisitId', 'Field_fieldID', 'expMJD', 'ditheredRA', 'ditheredDec', 'Ixx_PSF', 'apFluxErr', 'sky', 'filter', ] obs_history = obs_history[obs_keep_cols] obs_history['ccdVisitId'] = obs_history['ccdVisitId'].astype(np.int64) if save_to_disk is not None: obs_history.to_csv(save_to_disk, index=False) return obs_history
def _format_extragal_catalog(galaxies, save_to_disk=None): # Unit conversion and column renaming filters = list('ugrizy') galaxies.columns = map(str.lower, galaxies.columns) galaxies[['ra', 'dec']] = units.deg_to_arcsec(galaxies[['ra_true', 'dec_true']]) galaxies['phi_bulge'] = units.e1e2_to_phi( e1=galaxies['ellipticity_1_bulge_true'].values, e2=galaxies['ellipticity_2_bulge_true'].values) galaxies['phi_disk'] = units.e1e2_to_phi( e1=galaxies['ellipticity_1_disk_true'].values, e2=galaxies['ellipticity_2_disk_true'].values) galaxies['disk_to_total_ratio'] = 1.0 - galaxies['bulge_to_total_ratio_i'] for bp in 'ugrizy': galaxies['flux_%s' % bp] = units.mag_to_flux( galaxies['mag_true_%s_lsst' % bp].values, to_unit='nMgy') galaxies['flux_disk_%s' % bp] = galaxies[ 'flux_%s' % bp].values * galaxies['disk_to_total_ratio'].values galaxies['flux_bulge_%s' % bp] = galaxies[ 'flux_%s' % bp].values * galaxies['bulge_to_total_ratio_i'].values for component in ['disk', 'bulge']: galaxies['ra_%s' % component] = galaxies['ra'].values galaxies['dec_%s' % component] = galaxies['dec'].values galaxies['size_circular_%s' % component] = ( galaxies['size_minor_%s_true' % component].values * galaxies['size_%s_true' % component].values)**0.5 galaxies['e_%s' % component] = galaxies['ellipticity_%s_true' % component] # Only keep columns we'll use galaxies_cols_to_keep = ['galaxy_id', 'ra', 'dec'] # 'agn', 'sprinkled', 'star'] galaxies_cols_to_keep += [ 'ra_bulge', 'dec_bulge', 'size_circular_bulge', 'e_bulge', 'phi_bulge' ] galaxies_cols_to_keep += [ 'ra_disk', 'dec_disk', 'size_circular_disk', 'e_disk', 'phi_disk' ] galaxies_cols_to_keep += [ prop + '_' + bp for prop, bp in product(['flux_bulge', 'flux_disk'], filters) ] galaxies = galaxies[galaxies_cols_to_keep] if save_to_disk is not None: galaxies.to_csv(save_to_disk, index=False) return galaxies