Commit f729b299 authored by Alexandre Beelen's avatar Alexandre Beelen

Conversion script

parents
from pathlib import Path
from astropy.io import ascii, fits
from astropy.table import Table
from astropy.coordinates import SkyCoord
import astropy.units as u
from regions import CircleSkyRegion, write_ds9
indir = Path('GOODSN/rlsaw')
fitsdir = Path('GOODSN/cat')
regdir = Path('GOODSN/reg')
################################################################################
#
# Greve et al. 2008
#
path = indir / 'Greve2008_tab1.dat'
filename = 'Greve2008'
bibcode = '2008MNRAS.389.1489G'
name = 'Greve et at. 2008'
instrument = 'MAMBO2@IRAM30m'
fwhm = 11.1 * u.arcsec
data = ascii.read(path,
format='fixed_width', comment='#', delimiter=' ', header_start=None, data_start=0,
names=['Name',
'GN_name',
'R.A. (J2000)', 'Dec. (J2000)',
'f1200', 'e1200',
'S/N',
'f1200 (deboosted)', 'e1200 (deboosted)',
'f1.4GHz', 'e1.4GHz', 'offset', 'P'])
for col in [key for key in data.keys() if 'f1200' in key or 'e1200' in key]:
data[col].unit = u.mJy
for col in ['f1.4GHz', 'e1.4GHz']:
data[col].unit = u.uJy
data['offset'].unit = u.arcsec
coords = SkyCoord(data['R.A. (J2000)'], data['Dec. (J2000)'], unit=(u.hourangle, u.deg))
data['_ra'] = coords.ra
data['_dec'] = coords.dec
data.meta['bibcode'] = bibcode
data.meta['name'] = name
data.meta['inst'] = instrument
reg = [CircleSkyRegion(coord, fwhm) for coord in coords]
# Meta is PER region, so no way to include global meta yet
# reg[0].meta = data.meta
write_ds9(reg, regdir / f'{filename}.reg')
data.write(fitsdir / f'{filename}.fits', overwrite=True)
################################################################################
#
# Perera et al. 2008
#
path = indir / 'Perera2008_table1.dat'
filename = 'Perera2008'
bibcode = '2008MNRAS.391.1227P'
name = 'Perera et at. 2008'
instrument = 'AzTEC@JCMT'
fwhm = 18 * u.arcsec
data = ascii.read(path, names=['Source ID', 'R.A. (J2000)', 'Dec. (J2000)',
'f1100', 'e1100', 'S/N',
'f1100 (deboosted)', 'ep1100 (deboosted)', 'em1100 (deboosted)',
'non positive PSF Integral'])
for col in [key for key in data.keys() if 'f1100' in key or 'e1100' in key]:
data[col].unit = u.mJy
coords = SkyCoord(data['R.A. (J2000)'], data['Dec. (J2000)'], unit=(u.hourangle, u.deg))
data['_ra'] = coords.ra
data['_dec'] = coords.dec
data.meta['bibcode'] = bibcode
data.meta['name'] = name
data.meta['inst'] = instrument
reg = [CircleSkyRegion(coord, fwhm) for coord in coords]
write_ds9(reg, regdir / f'{filename}.reg')
data.write(fitsdir / f'{filename}.fits', overwrite=True)
################################################################################
#
# Staguhn et al. 2014
#
path = indir / 'Staguhn2013_tab1_2.dat'
filename = 'Staguhn2014'
bibcode = '2014ApJ...790...77S'
name = 'Staguhn et al 2014'
instrument = 'GISMO@30m'
fwhm = 17.5 * u.arcsec
data = ascii.read(path, names=['ID', 'R.A. (J2000)', 'Dec. (J2000)',
'f2000', 'e2000', 'S/N', 'Confidence [%]', 'N_f',
'f2000 (deboosted Lapi et al.)', 'e2000 (deboosted Lapi et al.)',
'f2000 (deboosted Coppin et al.)', 'e2000 (deboosted Coppin et al.)',
'f2000 (deboosted Bethermin et al.)', 'e2000 (deboosted Bethermin et al.)'])
for col in [key for key in data.keys() if 'f2000' in key or 'e2000' in key]:
data[col].unit = u.mJy
coords = SkyCoord(data['R.A. (J2000)'], data['Dec. (J2000)'], unit=(u.hourangle, u.deg))
data['_ra'] = coords.ra
data['_dec'] = coords.dec
data.meta['bibcode'] = bibcode
data.meta['name'] = name
data.meta['inst'] = instrument
reg = [CircleSkyRegion(coord, fwhm) for coord in coords]
write_ds9(reg, regdir / f'{filename}.reg')
data.write(fitsdir / f'{filename}.fits', overwrite=True)
################################################################################
#
# Geach et al. 2016
#
path = indir / 'S2CLS_CATALOGUE_DR1.FITS'
filename = 'Geach2017'
bibcode = '2017MNRAS.465.1789G'
name = 'Geach et al 2017'
instrument = 'SCUBA-2@JCMT'
fwhm = 14.8 * u.arcsec
data = Table.read(path)
mask = [True if 'GDN' in id else False for id in data['Nickname']]
data = data[mask]
data['S_850_observed'].name = 'f850'
data['delta_S_850_inst'].name = 'e850'
data['detection_SNR'].name = 'SNR'
data['S_850_deboost'].name = 'f850 (deboosted)'
data['delta_S_850_deboost'].name = 'e850 (deboosted)'
coords = SkyCoord(data['RA'], data['Dec'], unit=(u.hourangle, u.deg))
data['_ra'] = coords.ra
data['_dec'] = coords.dec
data.meta['bibcode'] = bibcode
data.meta['name'] = name
data.meta['inst'] = instrument
reg = [CircleSkyRegion(coord, fwhm) for coord in coords]
write_ds9(reg, regdir / f'{filename}.reg')
data.write(fitsdir / f'{filename}.fits', overwrite=True)
################################################################################
#
# Elbaz et al. 2011
#
path = indir / 'GH_GOODS-North_tables_DR1' / 'GH_GOODS-North_tables_DR1.fits'
filename = 'GOODSH_DR1'
bibcode = '2011A&A...533A.119E'
name = 'Elbaz et al. 2011'
instrument = 'IRAC@Spitzer, MIPS@Spitzer, PACS@Herschel, SPIRE@Herschel'
fwhm = 5.6 * u.arcsec # Based on MIPS 24 micron
data = Table.read(path)
for col in [key for key in data.keys() if 'err' in key]:
data[col].name = col.replace('err', 'e')
coords = SkyCoord(data['ra'], data['dec'], unit=(u.deg, u.deg))
data['_ra'] = data['ra']
data['_dec'] = data['dec']
data.meta['bibcode'] = bibcode
data.meta['name'] = name
data.meta['inst'] = instrument
reg = [CircleSkyRegion(coord, fwhm) for coord in coords]
write_ds9(reg, regdir / f'{filename}.reg')
data.write(fitsdir / f'{filename}.fits', overwrite=True)
################################################################################
#
# Oliver et al 2016
#
path = indir / 'GOODS-North_xID250_DR4.fits'
filename = 'HerMes_DR4'
bibcode = ''
name = 'HerMes HELP DR4'
instrument = 'SPIRE@Herschel'
fwhm = 17.9 * u.arcsec # Based on MIPS 24 micron
data = Table.read(path)
data['_ra'] = data['ra']
data['_dec'] = data['dec']
data.meta['bibcode'] = bibcode
data.meta['name'] = name
data.meta['inst'] = instrument
reg = [CircleSkyRegion(coord, fwhm) for coord in coords]
write_ds9(reg, regdir / f'{filename}.reg')
data.write(fitsdir / f'{filename}.fits', overwrite=True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment