Exemple #1
0
def process_options(args):
    opt = adict()
    filename = os.path.abspath(__file__).rsplit('/', 1)[0] + '/default.cfg'
    opt = parse_config(filename)
    if os.path.lexists('./plot.cfg'):
        opt = parse_config('./plot.cfg', opt)

    opt.atom = readatom(molecules=True)

    if opt.Rfwhm is not None:
        if isinstance(opt.Rfwhm, basestring):
            if opt.Rfwhm == 'convolve_with_COS_FOS':
                if convolve_with_COS_FOS is None:
                    raise ValueError('convolve_with_COS_FOS() not available')
                print('Using tailored FWHM for COS/FOS data')
                opt.Rfwhm = 'convolve_with_COS_FOS'
            elif opt.Rfwhm.endswith('fits'):
                print('Reading Resolution FWHM from', opt.Rfwhm)
                res = readtabfits(opt.Rfwhm)
                opt.Rfwhm = res.res / 2.354
            else:
                print('Reading Resolution FWHM from', opt.Rfwhm)
                fh = open(opt.Rfwhm)
                opt.Rfwhm = 1 / 2.354 * np.array([float(r) for r in fh])
                fh.close()
        else:
            opt.Rfwhm = float(opt.Rfwhm)

    if opt.features is not None:
        print('Reading feature list from', opt.features)
        opt.features = readtabfits(opt.features)

    if opt.f26 is not None:
        name = opt.f26
        print('Reading ions and fitting regions from', name)
        opt.f26 = readf26(name)
        opt.f26.filename = name

    if opt.transitions is not None:
        print('Reading transitions from', opt.transitions)
        fh = open(opt.transitions)
        trans = list(fh)
        fh.close()
        temp = []
        for tr in trans:
            tr = tr.strip()
            if tr and not tr.startswith('#'):
                junk = tr.split()
                tr = junk[0] + ' ' + junk[1]
                t = findtrans(tr, atomdat=opt.atom)
                temp.append(dict(name=t[0], wa=t[1][0], tr=t[1]))
        opt.linelist = temp
    else:
        opt.linelist = readtxt(get_data_path() + 'linelists/qsoabs_lines',
                               names='wa,name,select')

    if opt.f26 is None and opt.taulines is not None:
        print('Reading ions from', opt.taulines)
        fh = open(opt.taulines)
        lines = []
        for row in fh:
            if row.lstrip().startswith('#'):
                continue
            items = row.split()
            lines.append([items[0]] + list(map(float, items[1:])))
        fh.close()
        opt.lines = lines

    if opt.show_regions is None:
        opt.show_regions = True

    if hasattr(opt, 'aodname'):
        opt.aod = Table.read(opt.aodname)

    return opt
def read_gal():
    print 'Reading galaxy info'
    M = readtabfits('/home/ntejos/Q0107/catalogs/master20100921.fits')

    deimos = (M.Z_DEIMOS > 1e-3) & (M.ZCONF_DEIMOS > 2)
    gmos   = (M.Z_GMOS   > 1e-3) & (M.ZCONF_GMOS == 'a')
    vimos  = (M.Z_VIMOS  > 1e-3) & (M.ZCONF_VIMOS > 2)
    cfht   = (M.Z_CFHT   > 1e-3) 
    
    isgal = deimos | gmos | vimos | cfht
    print 'N gmos', gmos.sum()
    print 'N vimos', vimos.sum()
    print 'N deimos', deimos.sum()
    print 'N CFHT',cfht.sum()
    print 'total', isgal.sum()
    # correct the VIMOS redshifts to match DEIMOS (add 150 km/s)
    # new correction from gas-galaxy correlation callibration by eye using 1>W>0.5 A. (add 250 km/s)
    zv = M.Z_VIMOS[vimos]
    M.Z_VIMOS[vimos] = zv + (250/Ckms)*(1 + zv)
    # same for GMOS (add 50 km/s)
    # new correction from gas-galaxy correlation callibration by eye using 1>W>0.5 A. (add 100 km/s)
    zg = M.Z_GMOS[gmos]
    M.Z_GMOS[gmos] = zg + (100/Ckms)*(1 + zg)
    # same for DEIMOS (add 0 km/s)
    # new correction from gas-galaxy correlation callibration by eye using 1>W>0.5 A. (add 50 km/s)
    zg = M.Z_DEIMOS[deimos]
    M.Z_DEIMOS[deimos] = zg + (50/Ckms)*(1 + zg)

    # Now consolidate z list, choose z such that deimos > gmos > vimos >
    # cfht
    zg = []
    isd = np.zeros(len(M), bool)
    isv = np.zeros(len(M), bool)
    isg = np.zeros(len(M), bool)
    isc = np.zeros(len(M), bool)
    for i in range(len(M)):
        z = -1
        if deimos[i]:
            z = M.Z_DEIMOS[i]
            isd[i] = 1
        elif gmos[i]:
            z = M.Z_GMOS[i]
            isg[i] = 1
        elif vimos[i]:
            z = M.Z_VIMOS[i]
            isv[i] = 1
        elif cfht[i]:
            z = M.Z_CFHT[i]
            isc[i] = 1
        zg.append(z)

    zg =  np.array(zg)[isgal]
    isd = isd[isgal]
    isv = isv[isgal]
    isg = isg[isgal]
    isc = isc[isgal]

    ra = M[isgal].ALPHA_J2000
    dec = M[isgal].DELTA_J2000
    # index into the master catalogue
    ind = M[isgal].NUMBER - 1
    mag = M[isgal].MAG_AUTO
    template = M[isgal].VIMOS_TEMPLATE
    rec = np.rec.fromarrays([ra,dec,zg,isd,isv,isg,isc,mag,template],
                            names='ra,dec,z,dei,vim,gmos,cfht,mag,template')
    return rec
Exemple #3
0
def process_options(args):
    opt = adict()
    filename = os.path.abspath(__file__).rsplit('/', 1)[0] + '/default.cfg'
    opt = parse_config(filename)
    if os.path.lexists('./plot.cfg'):
        opt = parse_config('./plot.cfg', opt)

    opt.atom = readatom(molecules=True)

    if opt.Rfwhm is not None:
        if isinstance(opt.Rfwhm, basestring):
            if opt.Rfwhm == 'convolve_with_COS_FOS':
                if convolve_with_COS_FOS is None:
                    raise ValueError('convolve_with_COS_FOS() not available')
                print('Using tailored FWHM for COS/FOS data')
                opt.Rfwhm = 'convolve_with_COS_FOS'
            elif opt.Rfwhm.endswith('fits'):
                print('Reading Resolution FWHM from', opt.Rfwhm)
                res = readtabfits(opt.Rfwhm)
                opt.Rfwhm = res.res / 2.354
            else:
                print('Reading Resolution FWHM from', opt.Rfwhm)
                fh = open(opt.Rfwhm)
                opt.Rfwhm = 1 / 2.354 * np.array([float(r) for r in fh])
                fh.close()
        else:
            opt.Rfwhm = float(opt.Rfwhm)

    if opt.features is not None:
        print('Reading feature list from', opt.features)
        opt.features = readtabfits(opt.features)

    if opt.f26 is not None:
        name = opt.f26
        print('Reading ions and fitting regions from', name)
        opt.f26 = readf26(name)
        opt.f26.filename = name

    if opt.transitions is not None:
        print('Reading transitions from', opt.transitions)
        fh = open(opt.transitions)
        trans = list(fh)
        fh.close()
        temp = []
        for tr in trans:
            tr = tr.strip()
            if tr and not tr.startswith('#'):
                junk = tr.split()
                tr = junk[0] + ' ' + junk[1]
                t = findtrans(tr, atomdat=opt.atom)
                temp.append(dict(name=t[0], wa=t[1][0], tr=t[1]))
        opt.linelist = temp
    else:
        opt.linelist = readtxt(get_data_path() + 'linelists/qsoabs_lines',
                        names='wa,name,select')

    if opt.f26 is None and opt.taulines is not None:
        print('Reading ions from', opt.taulines)
        fh = open(opt.taulines)
        lines = []
        for row in fh:
            if row.lstrip().startswith('#'):
                continue
            items = row.split()
            lines.append([items[0]] + list(map(float, items[1:])))
        fh.close()
        opt.lines = lines

    if opt.show_regions is None:
        opt.show_regions = True

    if hasattr(opt, 'aodname'):
        opt.aod = Table.read(opt.aodname)

    return opt
Exemple #4
0
def read_gal():
    print 'Reading galaxy info'
    M = readtabfits('/home/ntejos/Q0107/catalogs/master20100921.fits')

    deimos = (M.Z_DEIMOS > 1e-3) & (M.ZCONF_DEIMOS > 2)
    gmos = (M.Z_GMOS > 1e-3) & (M.ZCONF_GMOS == 'a')
    vimos = (M.Z_VIMOS > 1e-3) & (M.ZCONF_VIMOS > 2)
    cfht = (M.Z_CFHT > 1e-3)

    isgal = deimos | gmos | vimos | cfht
    print 'N gmos', gmos.sum()
    print 'N vimos', vimos.sum()
    print 'N deimos', deimos.sum()
    print 'N CFHT', cfht.sum()
    print 'total', isgal.sum()
    # correct the VIMOS redshifts to match DEIMOS (add 150 km/s)
    # new correction from gas-galaxy correlation callibration by eye using 1>W>0.5 A. (add 250 km/s)
    zv = M.Z_VIMOS[vimos]
    M.Z_VIMOS[vimos] = zv + (250 / Ckms) * (1 + zv)
    # same for GMOS (add 50 km/s)
    # new correction from gas-galaxy correlation callibration by eye using 1>W>0.5 A. (add 100 km/s)
    zg = M.Z_GMOS[gmos]
    M.Z_GMOS[gmos] = zg + (100 / Ckms) * (1 + zg)
    # same for DEIMOS (add 0 km/s)
    # new correction from gas-galaxy correlation callibration by eye using 1>W>0.5 A. (add 50 km/s)
    zg = M.Z_DEIMOS[deimos]
    M.Z_DEIMOS[deimos] = zg + (50 / Ckms) * (1 + zg)

    # Now consolidate z list, choose z such that deimos > gmos > vimos >
    # cfht
    zg = []
    isd = np.zeros(len(M), bool)
    isv = np.zeros(len(M), bool)
    isg = np.zeros(len(M), bool)
    isc = np.zeros(len(M), bool)
    for i in range(len(M)):
        z = -1
        if deimos[i]:
            z = M.Z_DEIMOS[i]
            isd[i] = 1
        elif gmos[i]:
            z = M.Z_GMOS[i]
            isg[i] = 1
        elif vimos[i]:
            z = M.Z_VIMOS[i]
            isv[i] = 1
        elif cfht[i]:
            z = M.Z_CFHT[i]
            isc[i] = 1
        zg.append(z)

    zg = np.array(zg)[isgal]
    isd = isd[isgal]
    isv = isv[isgal]
    isg = isg[isgal]
    isc = isc[isgal]

    ra = M[isgal].ALPHA_J2000
    dec = M[isgal].DELTA_J2000
    # index into the master catalogue
    ind = M[isgal].NUMBER - 1
    mag = M[isgal].MAG_AUTO
    template = M[isgal].VIMOS_TEMPLATE
    rec = np.rec.fromarrays([ra, dec, zg, isd, isv, isg, isc, mag, template],
                            names='ra,dec,z,dei,vim,gmos,cfht,mag,template')
    return rec