Пример #1
0
def p11():
    """ Ingest Prochaska et al. 2011 CGM survey
    """
    # Low z OVI summary
    ovi_file = pyigm.__path__[0] + '/data/CGM/P11/lowovidat.fits'
    ovidat = Table.read(ovi_file)
    qso_radec = SkyCoord(ra=ovidat['QSO_RA'],
                         dec=ovidat['QSO_DEC'],
                         unit=(u.hourangle, u.deg))
    qso_nms = np.array([row['QSO'].strip() for row in ovidat])

    # CGM Survey
    p11 = CGMAbsSurvey(survey='P11', ref='Prochaska+11')

    # Dwarfs
    cgm_dwarf_file = pyigm.__path__[0] + '/data/CGM/P11/dwarf_galabs_strct.fits'
    cgm_dwarfs = Table.read(cgm_dwarf_file)
    # sub L*
    cgm_subls_file = pyigm.__path__[0] + '/data/CGM/P11/subls_galabs_strct.fits'
    cgm_subls = Table.read(cgm_subls_file)
    # L*
    cgm_lstar_file = pyigm.__path__[0] + '/data/CGM/P11/lstar_galabs_strct.fits'
    cgm_lstar = Table.read(cgm_lstar_file)

    # Loop on subsets
    for subset in [cgm_dwarfs, cgm_subls, cgm_lstar]:
        for row in subset:
            # RA, DEC
            # Galaxy
            gal = Galaxy((row['RA'], row['DEC']), z=row['Z'])
            gal.Lstar = row['DDEC']
            gal.type = row['GAL_TYPE']
            # IGMSys
            mtqso = np.where(qso_nms == row['FIELD'].strip())[0]
            if len(mtqso) != 1:
                pdb.set_trace()
                raise ValueError("No Field match")
            igmsys = IGMSystem(qso_radec[mtqso[0]], row['Z'],
                               (-400., 400.) * u.km / u.s)
            # HI
            if row['MAG'][2] > 0.:
                # Lya
                lya = AbsLine(1215.67 * u.AA, z=float(row['MAG'][3]))
                lya.attrib['EW'] = row['MAG'][4] / 1e3 * u.AA
                if row['MAG'][5] >= 99.:
                    lya.attrib['flag_EW'] = 3
                else:
                    lya.attrib['flag_EW'] = 1
                lya.attrib['sig_EW'] = row['MAG'][5] / 1e3 * u.AA
                # Ref
                lya.attrib['Ref'] = int(row['MAG'][2])
                # HI component
                if row['MAG'][9] <= 0.:
                    flagN = 3
                elif row['MAG'][9] > 9.:
                    flagN = 2
                else:
                    flagN = 1
                HIcomp = AbsComponent(qso_radec[mtqso[0]], (1, 1),
                                      float(row['MAG'][3]),
                                      (-400, 400) * u.km / u.s,
                                      Ntup=(flagN, row['MAG'][8],
                                            row['MAG'][9]))
                HIcomp._abslines.append(lya)
                igmsys._components.append(HIcomp)
                # NHI
                igmsys.NHI = HIcomp.logN
                igmsys.flag_NHI = HIcomp.flag_N
                igmsys.sig_NHI = HIcomp.sig_N
            # OVI
            if row['MAGERR'][2] > 0.:
                # OVI 1031
                ovi1031 = None
                if row['MAGERR'][4] > 0.:
                    ovi1031 = AbsLine(1031.9261 * u.AA,
                                      z=float(row['MAGERR'][3]))
                    if row['MAGERR'][5] >= 99.:
                        ovi1031.attrib['flag_EW'] = 3
                    else:
                        ovi1031.attrib['flag_EW'] = 1
                    ovi1031.attrib['EW'] = row['MAGERR'][4] / 1e3 * u.AA
                    ovi1031.attrib['sig_EW'] = row['MAGERR'][5] / 1e3 * u.AA
                # OVI component
                if row['MAGERR'][9] <= 0.:
                    flagN = 3
                elif row['MAGERR'][9] > 9.:
                    flagN = 2
                else:
                    flagN = 1
                OVIcomp = AbsComponent(qso_radec[mtqso[0]], (8, 6),
                                       float(row['MAGERR'][3]),
                                       (-400, 400) * u.km / u.s,
                                       Ntup=(flagN, row['MAGERR'][8],
                                             row['MAGERR'][9]))
                if ovi1031 is not None:
                    OVIcomp._abslines.append(ovi1031)
                # Ref
                OVIcomp.Ref = int(row['MAG'][2])
                igmsys._components.append(OVIcomp)
            # CGM
            cgmabs = CGMAbsSys(gal, igmsys, chk_lowz=False)
            p11.cgm_abs.append(cgmabs)
    # Write tarball
    out_file = pyigm.__path__[0] + '/data/CGM/P11/P11_sys.tar'
    p11.to_json_tarball(out_file)
Пример #2
0
def ingest_johnson15():
    """ Ingest Johnson+15
    """
    # Dict for QSO coords
    qsos = {}
    qsos['1ES1028+511'] = ltu.radec_to_coord('J103118.52517+505335.8193')
    qsos['FBQS1010+3003'] = ltu.radec_to_coord((152.5029167, 30.056111))
    qsos['HE0226-4110'] = ltu.radec_to_coord('J022815.252-405714.62')
    qsos['HS1102+3441'] = ltu.radec_to_coord('J110539.8189+342534.672')
    qsos['LBQS1435-0134'] = ltu.radec_to_coord((219.451183, -1.786328))
    qsos['PG0832+251'] = ltu.radec_to_coord('J083535.8048+245940.146')
    qsos['PG1522+101'] = ltu.radec_to_coord((231.1023075, 9.9749372))
    qsos['PKS0405-123'] = ltu.radec_to_coord('J040748.4376-121136.662')
    qsos['SBS1108+560'] = ltu.radec_to_coord((167.8841667, 55.790556))
    qsos['SBS1122+594'] = ltu.radec_to_coord((171.4741250, 59.172667))
    qsos['Ton236'] = ltu.radec_to_coord((232.1691746, 28.424928))

    # Virial matching
    j15_file = resource_filename('pyigm',
                                 'data/CGM/z0/johnson2015_table1.fits')
    j15_tbl = Table.read(j15_file)

    # Clip COS-Halos
    keep = j15_tbl['Survey'] != 'COS-Halos'
    j15_tbl = j15_tbl[keep]

    # CGM Survey
    j15 = CGMAbsSurvey(survey='J15', ref='Johnson+15')

    # Linelist
    llist = LineList('ISM')

    for row in j15_tbl:
        # RA, DEC
        # Galaxy
        gal = Galaxy((row['RAJ2000'], row['DEJ2000']), z=float(row['zgal']))
        gal.Class = row['Class']
        gal.Mstar = row['logM_']
        gal.field = row['Name']
        gal.Env = row['Env']
        gal.d_Rh = row['d_Rh']
        #
        igmsys = IGMSystem(qsos[row['Name']], float(row['zgal']),
                           (-400., 400.) * u.km / u.s)
        # HI
        if np.isnan(row['logNHI']):
            pass
        else:
            # HI component
            if row['l_logNHI'] == '<':
                flagN = 3
                sigNHI = 99.
            elif np.isnan(row['e_logNHI']):
                flagN = 2
                sigNHI = 99.
            else:
                flagN = 1
                sigNHI = row['e_logNHI']
            HIcomp = AbsComponent(qsos[row['Name']], (1, 1),
                                  float(row['zgal']), (-400, 400) * u.km / u.s,
                                  Ntup=(flagN, row['logNHI'], sigNHI))
            igmsys._components.append(HIcomp)
            # NHI
            igmsys.NHI = HIcomp.logN
            igmsys.flag_NHI = HIcomp.flag_N
            igmsys.sig_NHI = HIcomp.sig_N
        # OVI
        if np.isnan(row['logNHOVI']):
            pass
        else:
            # OVI component
            if row['l_logNHOVI'] == '<':
                flagN = 3
                sigNHOVI = 99.
            elif np.isnan(row['e_logNHOVI']):
                flagN = 2
                sigNHOVI = 99.
            else:
                flagN = 1
                sigNHOVI = row['e_logNHOVI']
            OVIcomp = AbsComponent(qsos[row['Name']], (8, 6),
                                   float(row['zgal']),
                                   (-400, 400) * u.km / u.s,
                                   Ntup=(flagN, row['logNHOVI'], sigNHOVI))
            igmsys._components.append(OVIcomp)
        # CGM
        cgmabs = CGMAbsSys(gal, igmsys, chk_lowz=False)
        j15.cgm_abs.append(cgmabs)
    # Write tarball
    out_file = resource_filename('pyigm', '/data/CGM/z0/J15_sys.tar')
    j15.to_json_tarball(out_file)
Пример #3
0
def ingest_burchett16(smthd='vir'):
    """ Ingest Burchett+16
    """
    # Virial matching
    if smthd == 'vir':
        b16_file = resource_filename(
            'pyigm', 'data/CGM/z0/Burchett2016_CIV_HI_virselect.fits')
    else:
        b16_file = resource_filename(
            'pyigm', 'data/CGM/z0/Burchett2016_CIV_HI_kpcselect.fits')
    b16_tbl = Table.read(b16_file)

    # CGM Survey
    b16 = CGMAbsSurvey(survey='B16', ref='Burchett+16')

    # Linelist
    llist = LineList('ISM')

    for row in b16_tbl:
        # RA, DEC
        # Galaxy
        gal = Galaxy((row['ra_gal'], row['dec_gal']), z=row['zgal'])
        gal.SFR = row['SFR']
        gal.sig_SFR = row['SFR_err']
        gal.Mstar = row['mstars']
        gal.field = row['field']
        gal.RRvir = row['rrvir']
        gal.NSAidx = row['NSAidx']
        #
        igmsys = IGMSystem((row['ra_qso'], row['dec_qso']), row['zgal'],
                           (-400., 400.) * u.km / u.s)
        # HI
        if row['flag_h1'] > 0:
            # Lya
            lya = AbsLine(1215.67 * u.AA, z=row['zgal'], linelist=llist)
            lya.attrib['EW'] = row['EW_h1'] * u.AA
            lya.attrib['logN'] = row['col_h1']
            lya.attrib['N'] = 10**row['col_h1'] * u.cm**-2
            if row['flag_h1'] == 3:
                lya.attrib['flag_EW'] = 3
                lya.attrib['flag_N'] = 3
                lya.attrib['sig_N'] = (10**(row['col_h1'])) / 3. * u.cm**-2
            elif row['flag_h1'] == 2:
                lya.attrib['flag_EW'] = 1
                lya.attrib['flag_N'] = 2
            else:
                lya.attrib['flag_EW'] = 1
                lya.attrib['flag_N'] = 1
                lya.attrib['sig_N'] = (10**(row['col_h1'] + row['colsig_h1']) -
                                       10**row['col_h1']) * u.cm**-2
            lya.attrib['sig_EW'] = row['EWsig_h1'] * u.AA
            # Ref
            lya.attrib['Ref'] = 'Burchett+16'
            # HI component
            if row['colsig_h1'] >= 99.:
                flagN = 2
            elif row['colsig_h1'] <= 0.:
                flagN = 3
            else:
                flagN = 1
            HIcomp = AbsComponent(
                (row['ra_qso'], row['dec_qso']), (1, 1),
                row['zgal'], (-400, 400) * u.km / u.s,
                Ntup=(flagN, row['col_h1'], row['colsig_h1']))
            HIcomp._abslines.append(lya)
            igmsys._components.append(HIcomp)
            # NHI
            igmsys.NHI = HIcomp.logN
            igmsys.flag_NHI = HIcomp.flag_N
            igmsys.sig_NHI = HIcomp.sig_N
        # CIV
        if row['flag_c4'] > 0:
            # CIV 1548
            civ1548 = AbsLine(1548.195 * u.AA, z=row['zgal'], linelist=llist)
            civ1548.attrib['EW'] = row['EW_c4'] * u.AA
            civ1548.attrib['logN'] = row['col_c4']
            civ1548.attrib['N'] = 10**row['col_c4'] * u.cm**-2
            if row['flag_c4'] == 3:
                civ1548.attrib['flag_EW'] = 3
                civ1548.attrib['flag_N'] = 3
                civ1548.attrib['sig_N'] = (10**(row['col_c4'])) / 3. * u.cm**-2
            elif row['flag_c4'] == 2:
                civ1548.attrib['flag_EW'] = 1
                civ1548.attrib['flag_N'] = 2
            else:
                civ1548.attrib['flag_EW'] = 1
                civ1548.attrib['flag_N'] = 1
                civ1548.attrib['sig_N'] = (10**
                                           (row['col_c4'] + row['colsig_c4']) -
                                           10**row['col_c4']) * u.cm**-2
            civ1548.attrib['sig_EW'] = row['EWsig_c4'] * u.AA
            # Ref
            civ1548.attrib['Ref'] = 'Burchett+16'
            # CIV component
            if row['colsig_c4'] >= 99.:
                flagN = 2
            elif row['colsig_c4'] <= 0.:
                flagN = 3
            else:
                flagN = 1
            CIVcomp = AbsComponent(
                (row['ra_qso'], row['dec_qso']), (6, 4),
                row['zgal'], (-400, 400) * u.km / u.s,
                Ntup=(flagN, row['col_c4'], row['colsig_c4']))
            CIVcomp._abslines.append(civ1548)
            igmsys._components.append(CIVcomp)
        # CGM
        cgmabs = CGMAbsSys(gal, igmsys, correct_lowz=False)
        b16.cgm_abs.append(cgmabs)
    # Write tarball
    if smthd == 'vir':
        out_file = resource_filename('pyigm', '/data/CGM/z0/B16_vir_sys.tar')
    else:
        out_file = resource_filename('pyigm', '/data/CGM/z0/B16_kpc_sys.tar')
    b16.to_json_tarball(out_file)
Пример #4
0
    def load_data(self, **kwargs):
        #
        #q8file = resource_filename('pyigm', 'data/CGM/QPQ/qpq8_all_measured.dat')
        q8file = self.data_file

        if self.from_dict:
            q8file = self.data_file
            qpq8dict = CGMAbsSurvey.from_json(q8file)
            ism = LineList('ISM')
            qpq8dict.build_systems_from_dict(llist=ism)
            self.survey_data = qpq8dict
            #self.cgm_abs = qpq8dict.cgm_abs

        else:

            qpqdata = Table.read(q8file, format='ascii')
            #nmax = len(qpqdata)   # max number of QSOs
            q8filecoord = resource_filename('pyigm',
                                            'data/CGM/QPQ/qpq8_pairs.fits')
            qpqdatacoord = Table.read(q8filecoord)
            if self.nmax is not None:
                nmax = self.nmax
            else:
                nmax = len(qpqdatacoord)  #(qpqdata)

            # match names with qpqdatacoord
            qnames = []
            for i in range(len(qpqdatacoord)):
                qname = qpqdatacoord['QSO'][i].strip()
                qnames.append(qname[-10:])
            qnames2 = []
            for i in range(len(qpqdata)):
                qname = qpqdata['Pair'][i]
                qnames2.append(qname)

            for j in range(nmax):  # i,j
                # match names with qpqdatacoord
                i = np.where(np.asarray(qnames2) == qnames[j])[0]
                # Instantiate the galaxy
                gal = Galaxy((qpqdatacoord['RAD'][j], qpqdatacoord['DECD'][j]),
                             z=qpqdatacoord['Z_FG'][j])
                gal.L_BOL = qpqdatacoord['L_BOL'][j]
                gal.L_912 = qpqdatacoord['L_912'][j]
                gal.G_UV = qpqdatacoord['G_UV'][j]
                gal.zsig = qpqdatacoord['Z_FSIG'][j] * u.km / u.s

                # Instantiate the IGM System
                igm_sys = IGMSystem(
                    (qpqdatacoord['RAD_BG'][j], qpqdatacoord['DECD_BG'][j]),
                    qpqdatacoord['Z_FG'][j], [-5500, 5500.] * u.km / u.s,
                    abs_type='CGM')
                # Redshifts: QSO emission redshifts
                igm_sys.zem = qpqdatacoord['Z_BG'][j]
                igm_sys.NHI = qpqdata['HIcol'][i]
                igm_sys.sig_NHI = [
                    qpqdata['HIcolhierr'][i], qpqdata['HIcolloerr'][i]
                ]
                igm_sys.s2n_lya = qpqdatacoord['S2N_LYA'][j]

                iname = qpqdata['Pair'][i][0]  #+'_'+qpqdata['subsys'][i]
                # Instantiate
                rho = qpqdatacoord['R_PHYS'][j] * u.kpc
                cgabs = CGMAbsSys(gal, igm_sys, name=iname, rho=rho, **kwargs)

                ### add metal lines
                ### not included CII*, SiII*
                lines = [
                    ['CII 1334'],  ## ['CII* 1335'],
                    ['CIV 1548', 'CIV 1550'],
                    ['NI 1134', 'NI 1199'],
                    ['NII 1083'],
                    ['NV 1238', 'NV 1242'],
                    ['OI 1302'],
                    ['OVI 1037'],
                    ['MgI 2852'],
                    ['MgII 2796', 'MgII 2803'],
                    ['AlII 1670'],
                    ['AlIII 1854', 'AlIII 1862'],
                    [
                        'SiII 1190', 'SiII 1193', 'SiII 1304', 'SiII 1260',
                        'SiII 1526', 'SiII 1808'
                    ],  ## ['SiII* 1264'],
                    ['SiIII 1206'],
                    ['SiIV 1393', 'SiIV 1402'],
                    [
                        'FeII 1608', 'FeII 2344', 'FeII 2374', 'FeII 2382',
                        'FeII 2586', 'FeII 2600'
                    ],
                    ['FeIII 1122']
                ]

                for kk in i:

                    for icmp in range(len(lines)):
                        abslines = []
                        for ii in range(len(lines[icmp])):
                            wave0 = float(lines[icmp][ii].split(' ')[1])
                            ewstr = str(lines[icmp][ii].split(' ')[1]) + 'EW'
                            ewerrstr = str(
                                lines[icmp][ii].split(' ')[1]) + 'EWerr'
                            if ewstr == '1808EW':
                                ewstr = '1808E'
                            if ewerrstr == '1122EWerr':
                                ewerrstr = '122EWerr'
                            if qpqdata[ewstr][kk] != '/':
                                # find z
                                v0 = 0.5 * (
                                    qpqdata['v_lobound'][kk] +
                                    qpqdata['v_upbound'][kk]) * u.km / u.s
                                dv = v0
                                zref = igm_sys.zabs
                                z_cmp = ltu.z_from_dv(dv, zref)

                                ## vlim
                                v1 = qpqdata['v_lobound'][kk] * u.km / u.s
                                z1 = ltu.z_from_dv(v1, zref)
                                v1_cmp = ltu.dv_from_z(z1, z_cmp)

                                v2 = qpqdata['v_upbound'][kk] * u.km / u.s
                                z2 = ltu.z_from_dv(v2, zref)
                                v2_cmp = ltu.dv_from_z(z2, z_cmp)

                                # iline
                                iline = AbsLine(wave0 * u.AA,
                                                closest=True,
                                                z=z_cmp)
                                iline.attrib['coord'] = igm_sys.coord

                                ## EW
                                iline.attrib['EW'] = float(
                                    qpqdata[ewstr][kk]) * u.AA  # Rest EW
                                iline.attrib['sig_EW'] = float(
                                    qpqdata[ewerrstr][kk]) * u.AA
                                flgew = 1
                                if iline.attrib[
                                        'EW'] < 3. * iline.attrib['sig_EW']:
                                    flgew = 3
                                iline.attrib['flag_EW'] = flgew

                                ## column densities
                                colstr = str(
                                    lines[icmp][ii].split(' ')[0]) + 'col'
                                colerrstr = str(
                                    lines[icmp][ii].split(' ')[0]) + 'colerr'
                                iline.attrib['logN'] = qpqdata[colstr][kk]
                                iline.attrib['sig_logN'] = qpqdata[colerrstr][
                                    kk]

                                abslines.append(iline)

                        if len(abslines) > 0:
                            comp = AbsComponent.from_abslines(abslines,
                                                              chk_vel=False)
                            comp.limits._vlim = [v1_cmp.value, v2_cmp.value
                                                 ] * u.km / u.s
                            cgabs.igm_sys.add_component(comp)

                # add ang_sep
                qsocoord = SkyCoord(ra=qpqdatacoord['RAD'][j],
                                    dec=qpqdatacoord['DECD'][j],
                                    unit='deg')
                bgcoord = SkyCoord(ra=qpqdatacoord['RAD_BG'][j],
                                   dec=qpqdatacoord['DECD_BG'][j],
                                   unit='deg')
                cgabs.ang_sep = qsocoord.separation(bgcoord).to('arcsec')

                self.cgm_abs.append(cgabs)
Пример #5
0
    def load_data(self, **kwargs):
        #

        if self.from_dict:
            q5file = self.data_file
            qpq5dict = CGMAbsSurvey.from_json(q5file)
            ism = LineList('ISM')
            qpq5dict.build_systems_from_dict(llist=ism)
            self.survey_data = qpq5dict
            #self.cgm_abs = qpq5dict.cgm_abs

        else:
            qpqdata = load_qpq(5)
            nmax = len(qpqdata)  # max number of QSOs
            for i in range(nmax):
                # Instantiate the galaxy
                gal = Galaxy((qpqdata['RAD'][i], qpqdata['DECD'][i]),
                             z=qpqdata['Z_FG'][i])
                gal.L_BOL = qpqdata['L_BOL'][i]
                gal.L_912 = qpqdata['L_912'][i]
                gal.G_UV = qpqdata['G_UV'][i]
                gal.flg_BOSS = qpqdata['FLG_BOSS'][i]
                gal.zsig = qpqdata['Z_FSIG'][i] * u.km / u.s

                # Instantiate the IGM System
                igm_sys = IGMSystem(
                    (qpqdata['RAD_BG'][i], qpqdata['DECD_BG'][i]),
                    qpqdata['Z_FG'][i], [-5500, 5500.] * u.km / u.s,
                    abs_type='CGM')
                igm_sys.zem = qpqdata['Z_BG'][i]
                igm_sys.NHI = qpqdata['NHI'][i]
                igm_sys.sig_NHI = qpqdata['SIG_NHI'][i]
                igm_sys.flag_NHI = qpqdata['FLG_NHI'][i]
                igm_sys.s2n_lya = qpqdata['S2N_LYA'][i]
                igm_sys.flg_othick = qpqdata['FLG_OTHICK'][i]
                igm_sys.z_lya = qpqdata['Z_LYA'][i]

                iname = qpqdata['QSO'][i]
                # Instantiate
                rho = qpqdata['R_PHYS'][i] * u.kpc
                cgabs = CGMAbsSys(gal, igm_sys, name=iname, rho=rho, **kwargs)
                aline = AbsLine(1215.67 * u.AA,
                                closest=True,
                                z=igm_sys.zabs,
                                linelist=ism)
                aline.attrib['EW'] = qpqdata['EWLYA'][i] * u.AA  # Rest EW
                aline.attrib['sig_EW'] = qpqdata['SIG_EWLYA'][i] * u.AA
                if aline.attrib['EW'] > 3. * aline.attrib['sig_EW']:
                    aline.attrib['flag_EW'] = 1
                else:
                    aline.attrib['flag_EW'] = 3

                aline.attrib['coord'] = igm_sys.coord
                #aline.limits._wvlim = qpqdata['WVMNX'][i]*u.AA   ##   (no data in QPQ7 file)
                #dv = ltu.rel_vel(aline.limits._wvlim, aline.wrest * (1 + qpqdata['Z_FG'][i]))
                #aline.limits._vlim = dv

                abslines = []
                abslines.append(aline)
                comp = AbsComponent.from_abslines(abslines, chk_vel=False)
                cgabs.igm_sys.add_component(comp)

                # add metal lines
                for j in range(100):
                    if qpqdata[i]['FLG_METAL_EW'][j] > 0:
                        wave0 = qpqdata[i]['METAL_WREST'][j]
                        iline = AbsLine(wave0 * u.AA,
                                        closest=True,
                                        z=igm_sys.zabs,
                                        linelist=ism)
                        iline.attrib[
                            'EW'] = qpqdata['METAL_EW'][i][j] * u.AA  # Rest EW
                        iline.attrib[
                            'sig_EW'] = qpqdata['METAL_SIGEW'][i][j] * u.AA
                        iline.attrib['flag_EW'] = qpqdata['FLG_METAL_EW'][i][j]
                        iline.analy['flg_eye'] = qpqdata['FLG_METAL_EYE'][i][j]
                        iline.attrib['coord'] = igm_sys.coord
                        abslines = []
                        abslines.append(iline)
                        comp = AbsComponent.from_abslines(abslines,
                                                          chk_vel=False)
                        cgabs.igm_sys.add_component(comp)

                # add ang_sep
                qsocoord = SkyCoord(ra=qpqdata['RAD'][i],
                                    dec=qpqdata['DECD'][i],
                                    unit='deg')
                bgcoord = SkyCoord(ra=qpqdata['RAD_BG'][i],
                                   dec=qpqdata['DECD_BG'][i],
                                   unit='deg')
                cgabs.ang_sep = qsocoord.separation(bgcoord).to('arcsec')

                self.cgm_abs.append(cgabs)
Пример #6
0
    def load_data(self, **kwargs):
        #
        q6file = self.data_file
        if self.from_dict:
            qpq6dict = CGMAbsSurvey.from_json(q6file)
            ism = LineList('ISM')
            qpq6dict.build_systems_from_dict(llist=ism)
            self.survey_data = qpq6dict
            #self.cgm_abs = qpq6dict.cgm_abs

        else:

            qpqdata = Table.read(q6file)
            if self.nmax is not None:
                nmax = self.nmax
            else:
                nmax = len(qpqdata)
            for i in range(nmax):
                # Instantiate the galaxy
                gal = Galaxy((qpqdata['RAD'][i], qpqdata['DECD'][i]),
                             z=qpqdata['Z_FG'][i])
                gal.L_BOL = qpqdata['L_BOL'][i]
                gal.L_912 = qpqdata['L_912'][i]
                gal.G_UV = qpqdata['G_UV'][i]
                gal.flg_BOSS = qpqdata['FLG_BOSS'][i]
                gal.zsig = qpqdata['Z_FSIG'][i] * u.km / u.s

                # Instantiate the IGM System
                igm_sys = IGMSystem(
                    (qpqdata['RAD_BG'][i], qpqdata['DECD_BG'][i]),
                    qpqdata['Z_FG'][i], [-5500, 5500.] * u.km / u.s,
                    abs_type='CGM'
                )  ## if velocity range lower - does not load all abslines
                igm_sys.zem = qpqdata['Z_BG'][i]
                igm_sys.NHI = qpqdata['NHI'][i]
                igm_sys.sig_NHI = qpqdata['SIG_NHI'][i]
                igm_sys.flag_NHI = qpqdata['FLG_NHI'][i]
                igm_sys.s2n_lya = qpqdata['S2N_LYA'][i]
                igm_sys.flg_othick = qpqdata['FLG_OTHICK'][i]
                igm_sys.z_lya = qpqdata['Z_LYA'][i]

                iname = qpqdata['QSO'][i]
                # Instantiate
                rho = qpqdata['R_PHYS'][i] * u.kpc
                cgabs = CGMAbsSys(gal, igm_sys, name=iname, rho=rho, **kwargs)
                aline = AbsLine(1215.67 * u.AA, closest=True, z=igm_sys.zabs)
                aline.attrib['EW'] = qpqdata['EWLYA'][i] * u.AA  # Rest EW
                aline.attrib['sig_EW'] = qpqdata['SIG_EWLYA'][i] * u.AA
                if aline.attrib['EW'] > 3. * aline.attrib['sig_EW']:
                    aline.attrib['flag_EW'] = 1
                else:
                    aline.attrib['flag_EW'] = 3

                aline.attrib['coord'] = igm_sys.coord
                aline.limits._wvlim = qpqdata['WVMNX'][i] * u.AA
                dv = ltu.rel_vel(aline.limits._wvlim,
                                 aline.wrest * (1 + qpqdata['Z_FG'][i]))
                aline.limits._vlim = dv

                abslines = []
                abslines.append(aline)
                ###
                comp = AbsComponent.from_abslines(abslines, chk_vel=False)

                # add ang_sep
                qsocoord = SkyCoord(ra=qpqdata['RAD'][i],
                                    dec=qpqdata['DECD'][i],
                                    unit='deg')
                bgcoord = SkyCoord(ra=qpqdata['RAD_BG'][i],
                                   dec=qpqdata['DECD_BG'][i],
                                   unit='deg')
                cgabs.ang_sep = qsocoord.separation(bgcoord).to('arcsec')

                cgabs.igm_sys.add_component(comp)
                self.cgm_abs.append(cgabs)