Esempio n. 1
0
def test_init_failures():
    with pytest.raises(IOError):
        AbsComponent.from_abslines('blah')
    with pytest.raises(IOError):
        AbsComponent.from_abslines(['blah'])
    with pytest.raises(IOError):
        AbsComponent.from_component('blah')
Esempio n. 2
0
def test_init_failures():
    with pytest.raises(IOError):
        AbsComponent.from_abslines('blah')
    with pytest.raises(IOError):
        AbsComponent.from_abslines(['blah'])
    with pytest.raises(IOError):
        AbsComponent.from_component('blah')
Esempio n. 3
0
def test_init_failures():
    with pytest.raises(IOError):
        AbsComponent.from_abslines('blah')
    with pytest.raises(IOError):
        AbsComponent.from_abslines(['blah'])
    with pytest.raises(IOError):
        AbsComponent.from_component('blah')
    with pytest.raises(IOError):
        AbsComponent((10.0*u.deg, 45*u.deg), (14,2), 1.0, [-300,300]*u.km/u.s, Ej=0.1/u.cm) # need stars!
Esempio n. 4
0
def test_init_failures():
    with pytest.raises(IOError):
        AbsComponent.from_abslines('blah')
    with pytest.raises(IOError):
        AbsComponent.from_abslines(['blah'])
    with pytest.raises(IOError):
        AbsComponent.from_component('blah')
    with pytest.raises(IOError):
        AbsComponent((10.0 * u.deg, 45 * u.deg), (14, 2),
                     1.0, [-300, 300] * u.km / u.s,
                     Ej=0.1 / u.cm)  # need stars!
Esempio n. 5
0
def test_init_failures():
    with pytest.raises(IOError):
        AbsComponent.from_abslines('blah')
    with pytest.raises(IOError):
        AbsComponent.from_abslines(['blah'])
    with pytest.raises(IOError):
        AbsComponent.from_component('blah')

    # Inconsistent abslines with median
    lya = AbsLine(1215.670 * u.AA, z=2.92939)
    lya.attrib['N'] = 1e12 / u.cm**2
    lya.attrib['sig_N'] = [1e11] * 2 / u.cm**2
    lya.attrib['b'] = 30 * u.km / u.s
    lyb = AbsLine('HI 1025', z=2.92939)
    lyb.attrib['N'] = 3e12 / u.cm**2
    lyb.attrib['sig_N'] = [3e11] * 2 / u.cm**2
    lyb.attrib['b'] = 30 * u.km / u.s
    with pytest.raises(ValueError):
        AbsComponent.from_abslines([lya, lyb],
                                   adopt_median=True,
                                   chk_meas=True)
Esempio n. 6
0
def synthesize_components(components, zcomp=None, vbuff=0 * u.km / u.s):
    """Synthesize a list of components into one

    Requires consistent RA/DEC, Zion, Ej, (A; future)
    Is agnostic about z+vlim
    Melds column densities
    Melds velocities with a small buffer (10 km/s)

    Note: Could make this a way to instantiate AbsComponent

    Parameters
    ----------
    components : list
      list of AbsComponent objects
    zcomp : float, optional
      Input z to reference the synthesized component
      If not input, the mean of the input components is used
    vbuff : Quantity, optional
      Buffer for synthesizing velocities.  Deals with round off, c, etc.
    """
    # Checks
    assert chk_components(components, chk_A_none=True, chk_match=True)

    # Init final component
    synth_comp = AbsComponent.from_component(components[0],
                                             Ntup=(components[0].flag_N,
                                                   components[0].logN,
                                                   components[0].sig_logN))

    # Meld column densities
    for comp in components[1:]:
        if comp.flag_N != 0:
            synth_comp.flag_N, synth_comp.logN, synth_comp.sig_logN = ltaa.sum_logN(
                synth_comp, comp)

    # Meld z, vlim
    # zcomp
    if zcomp is None:
        zcomp = np.mean([comp.zcomp for comp in components])
    synth_comp.zcomp = zcomp
    # Set vlim by min/max  [Using non-relativistic + buffer]
    vmin = u.Quantity([
        (comp.zcomp - zcomp) / (1 + zcomp) * const.c.to('km/s') + comp.vlim[0]
        for comp in components
    ])
    vmax = u.Quantity([
        (comp.zcomp - zcomp) / (1 + zcomp) * const.c.to('km/s') + comp.vlim[1]
        for comp in components
    ])
    synth_comp.vlim = u.Quantity([np.min(vmin) - vbuff, np.max(vmax) + vbuff])

    # Return
    return synth_comp
Esempio n. 7
0
File: utils.py Progetto: nhmc/pyigm
def synthesize_components(components, zcomp=None, vbuff=0 * u.km / u.s):
    """Synthesize a list of components into one

    Requires consistent RA/DEC, Zion, Ej, (A; future)
    Is agnostic about z+vlim
    Melds column densities
    Melds velocities with a small buffer (10 km/s)

    Note: Could make this a way to instantiate AbsComponent

    Parameters
    ----------
    components : list
      list of AbsComponent objects
    zcomp : float, optional
      Input z to reference the synthesized component
      If not input, the mean of the input components is used
    vbuff : Quantity, optional
      Buffer for synthesizing velocities.  Deals with round off, c, etc.
    """
    # Checks
    assert chk_components(components, chk_A_none=True, chk_match=True)

    # Init final component
    synth_comp = AbsComponent.from_component(
        components[0], Ntup=(components[0].flag_N, components[0].logN, components[0].sig_logN)
    )

    # Meld column densities
    for comp in components[1:]:
        synth_comp.flag_N, synth_comp.logN, synth_comp.sig_logN = ltaa.sum_logN(synth_comp, comp)

    # Meld z, vlim
    # zcomp
    if zcomp is None:
        zcomp = np.mean([comp.zcomp for comp in components])
    synth_comp.zcomp = zcomp
    # Set vlim by min/max  [Using non-relativistic + buffer]
    vmin = u.Quantity([(comp.zcomp - zcomp) / (1 + zcomp) * const.c.to("km/s") + comp.vlim[0] for comp in components])
    vmax = u.Quantity([(comp.zcomp - zcomp) / (1 + zcomp) * const.c.to("km/s") + comp.vlim[1] for comp in components])
    synth_comp.vlim = u.Quantity([np.min(vmin) - vbuff, np.max(vmax) + vbuff])

    # Return
    return synth_comp