Exemple #1
0
def test_clean_duplicates():
    field = ('PG1407+265', 212.349634 * u.deg, 26.3058650 * u.deg)
    lfield = IgmGalaxyField((field[1], field[2]), name=field[0], verbose=False)

    targets = create_fake_target_table()
    new_target = lfield.clean_duplicates(targets)
    np.testing.assert_allclose(new_target['TARG_RA'], np.arange(0, 10, 1))
Exemple #2
0
def test_clean_duplicates():
    field = ('PG1407+265', 212.349634*u.deg, 26.3058650*u.deg)
    lfield = IgmGalaxyField((field[1],field[2]), name=field[0], verbose=False)

    targets = create_fake_target_table()
    new_target = lfield.clean_duplicates(targets)
    np.testing.assert_allclose(new_target['TARG_RA'], np.arange(0,10,1))
Exemple #3
0
    def __init__(self, radec, igal_rand=10, iabs_rand=100, proper=False, field_name='',
                 wrapped=True, cosmo=None, **kwargs):

        IgmGalaxyField.__init__(self, radec, **kwargs)

        self.igal_rand = igal_rand
        self.iabs_rand = iabs_rand

        self.absreal = None # absreal  # np rec array with absorber properties (single ion)
        self.absrand = None

        # Cosmology
        if cosmo is None:
            cosmo = Planck15
        self.cosmo = cosmo

        # Central coordiantes
        self.CRA = self.coord.ra.value #np.mean(self.absreal.RA)
        self.CDEC = self.coord.dec.value # np.mean(self.absreal.DEC)

        if len(field_name) == 0:
            self.name = ltu.name_from_coord(self.coord)
        else:
            self.name = field_name
        self.proper = proper
        self.wrapped = wrapped

        self.galreal = None # Filled with addGal
        self.absreal = None # Filled with addAbs
        self.ion = None
Exemple #4
0
def test_calc_rho():
    field = ('PG1407+265', 212.349634 * u.deg, 26.3058650 * u.deg)
    lfield = IgmGalaxyField((field[1], field[2]), name=field[0], verbose=False)
    # Objects
    obj = dict(RA=np.array([212.349634] * 3),
               DEC=np.array([26.3057] * 3),
               Z=np.array([0.1, 0.2, 0.3]))
    rho = lfield.calc_rhoimpact(obj)
    np.isclose(rho[0].value, 1.244429196296971)
Exemple #5
0
def load_field(field):
    ''' Load up CASBAH data for a given field

    Parameters:
    -----------
    field: tuple
      (Name, ra, dec)

    Returns:
    --------
    lfield:     
      Loaded IgmGalaxyField class
    '''
    reload(xcasbahu)
    lfield = IgmGalaxyField((field[1],field[2]), name=field[0])

    # Load targets
    targ_file = xcasbahu.get_filename(field,'TARGETS')
    lfield.targets = Table.read(targ_file,delimiter='|',
        format='ascii.fixed_width', 
        fill_values=[('--','0','MASK_NAME')])

    # Load observing details for multi-object follow-up
    obs_file = xcasbahu.get_filename(field,'MULTI_OBJ')
    lfield.observing = Table.read(obs_file,delimiter='|',
        format='ascii.fixed_width', 
        fill_values=[('--','0','DATE_OBS','TEXP')])
    lfield.observing = Table(lfield.observing,masked=True) # Insist on Masked

    # Load galaxies
    sdss_file = xcasbahu.get_filename(field,'SDSS')
    sdss_tab = Table.read(sdss_file)
    # VSTACK
    hectospec_file = xcasbahu.get_filename(field,'HECTOSPEC')

    lfield.galaxies = sdss_tab

    # Return
    return lfield
Exemple #6
0
def test_cgmsurvey_from_fields_sightlines():
    # Instantiate fields and add galaxies
    field1 = ('PG1407+265', 212.349634 * u.deg, 26.3058650 * u.deg)
    fieldobj1 = IgmGalaxyField((field1[1], field1[2]),
                               name=field1[0],
                               verbose=False)
    field2 = ('PG1148+549', 177.83526042 * u.deg, 54.625855 * u.deg)
    fieldobj2 = IgmGalaxyField((field2[1], field2[2]),
                               name=field2[0],
                               verbose=False)
    f1ras = [212.33310891, 212.329875] * u.deg
    f1decs = [26.3722716934, 26.3084391667] * u.deg
    f1zs = [0.974413514137, 0.22016787529]
    f1gals = Table([f1ras, f1decs, f1zs], names=['RA', 'DEC', 'Z'])
    f2ras = [177.835229336, 178.536958333] * u.deg
    f2decs = [54.625851084, 54.6176108333] * u.deg
    f2zs = [0.0595485754311, 0.00385531364009]
    f2gals = Table([f2ras, f2decs, f2zs], names=['RA', 'DEC', 'Z'])
    fieldobj1.galaxies = f1gals
    fieldobj2.galaxies = f2gals
    fields = [fieldobj1, fieldobj2]

    # Instantiate sightlines
    sl1coord = SkyCoord(field1[1], field1[2], unit='deg')
    sl2coord = SkyCoord(field2[1], field2[2], unit='deg')
    comp11 = AbsComponent(sl1coord, (8, 6), 0.9743, [-200, 200] * u.km / u.s)
    comp12 = AbsComponent(sl1coord, (1, 1), 0.9743, [-200, 200] * u.km / u.s)
    al11 = AbsLine('OVI 1031')
    al11.attrib['coord'] = sl1coord
    al11.analy['spec'] = 'files/J0042-1037.358_9.fits.gz'
    al12 = AbsLine('HI 1215')
    al12.attrib['coord'] = sl1coord
    al12.analy['spec'] = 'files/J0042-1037.358_9.fits.gz'
    comp11.add_absline(al11, chk_sep=False, chk_vel=False)
    comp12.add_absline(al12, chk_sep=False, chk_vel=False)
    sys1 = IGMSystem.from_components([comp11, comp12])
    sl1 = IGMSightline.from_systems([sys1])
    comp21 = AbsComponent(sl2coord, (6, 4), 0.0037, [-200, 200] * u.km / u.s)
    comp22 = AbsComponent(sl2coord, (1, 1), 0.0037, [-200, 200] * u.km / u.s)
    al21 = AbsLine('CIV 1548')
    al21.attrib['coord'] = sl1coord
    al21.analy['spec'] = 'files/J0042-1037.358_9.fits.gz'
    al22 = AbsLine('HI 1215')
    al22.attrib['coord'] = sl1coord
    al22.analy['spec'] = 'files/J0042-1037.358_9.fits.gz'
    comp21.add_absline(al21, chk_sep=False, chk_vel=False)
    comp22.add_absline(al22, chk_sep=False, chk_vel=False)
    sys2 = IGMSystem.from_components([comp21, comp22])
    sl2 = IGMSightline.from_systems([sys2])
    sightlines = [sl1, sl2]

    # Run function
    csurvey = cgmsurvey_from_sightlines_fields(fields, sightlines)
    assert isinstance(csurvey, CGMAbsSurvey)
Exemple #7
0
def load_field(field):
    ''' Load up CASBAH data for a given field

    Parameters:
    -----------
    field: tuple
      (Name, ra, dec)

    Returns:
    --------
    lfield:     
      Loaded IgmGalaxyField class
    '''
    reload(xcasbahu)
    lfield = IgmGalaxyField((field[1], field[2]), name=field[0])

    # Load targets
    targ_file = xcasbahu.get_filename(field, 'TARGETS')
    lfield.targets = Table.read(targ_file,
                                delimiter='|',
                                format='ascii.fixed_width',
                                fill_values=[('--', '0', 'MASK_NAME')])

    # Load observing details for multi-object follow-up
    obs_file = xcasbahu.get_filename(field, 'MULTI_OBJ')
    lfield.observing = Table.read(obs_file,
                                  delimiter='|',
                                  format='ascii.fixed_width',
                                  fill_values=[('--', '0', 'DATE_OBS', 'TEXP')
                                               ])
    lfield.observing = Table(lfield.observing, masked=True)  # Insist on Masked

    # Load galaxies
    sdss_file = xcasbahu.get_filename(field, 'SDSS')
    sdss_tab = Table.read(sdss_file)
    # VSTACK
    hectospec_file = xcasbahu.get_filename(field, 'HECTOSPEC')

    lfield.galaxies = sdss_tab

    # Return
    return lfield
Exemple #8
0
def test_init():
    field = ('PG1407+265', 212.349634 * u.deg, 26.3058650 * u.deg)
    lfield = IgmGalaxyField((field[1], field[2]), name=field[0], verbose=True)
    print(lfield)