Ejemplo n.º 1
0
def continuum_alpha(model1: Spectrum, model2: Spectrum, chip: Optional[int] = None) -> float64:
    """Inherent flux ratio between the continuum of the two models.

    Assumes already scaled by area.
    Takes mean alpha of chip or full
    """
    assert not np.any(np.isnan(model1.xaxis))
    assert not np.any(np.isnan(model1.flux))
    assert not np.any(np.isnan(model2.xaxis))
    assert not np.any(np.isnan(model2.flux))
    # Fit models with continuum
    cont1 = continuum(model1.xaxis, model1.flux, method="exponential")
    cont2 = continuum(model2.xaxis, model2.flux, method="exponential")

    # Masking for individual chips
    if chip is None:
        chip = -1  # Full Crires range

    all_limits = {-1: [2111, 2169], 1: [2111, 2124], 2: [2125, 2139], 3: [2140, 2152], 4: [2153, 2169]}
    chip_limits = all_limits[chip]

    mask1 = (model1.xaxis > chip_limits[0]) * (model1.xaxis < chip_limits[1])
    mask2 = (model2.xaxis > chip_limits[0]) * (model2.xaxis < chip_limits[1])

    continuum_ratio = cont2[mask2] / cont1[mask1]
    alpha_ratio = np.nanmean(continuum_ratio)

    return alpha_ratio
Ejemplo n.º 2
0
def test_continuum_exponential(x1, x0):
    x = np.linspace(2000, 2100, 2000)
    y = np.exp(x1 * x) + x0

    cont = continuum(x, y, method="exponential")
    assert np.allclose(np.mean(y / cont), 1)
    assert np.allclose(cont, y, 2)
Ejemplo n.º 3
0
def test_continuum_linear(x1, x0):
    x = np.linspace(2000, 2100, 2000)
    y = x1 * x + x0

    cont = continuum(x, y, method="linear")
    assert np.allclose(np.mean(y / cont), 1)
    assert np.allclose(cont, y)
Ejemplo n.º 4
0
def test_manual_normalization():
    x = np.arange(1, 100)
    y = np.arange(1, 100)

    local_norm = local_normalization(x,
                                     y,
                                     splits=5,
                                     plot=False,
                                     top=5,
                                     method="linear")
    cont = continuum(x, y, splits=3, plot=False, top=2, method="linear")

    assert np.allclose(cont, y)
    assert np.allclose(local_norm, np.ones_like(y))
Ejemplo n.º 5
0
 def axis_continuum(flux):
     """Continuum to apply along axis with predefined variables parameters."""
     return continuum(obs_spec.xaxis, flux, splits=20, method="exponential", top=20)
Ejemplo n.º 6
0
def test_continuum_scalar(scale):
    x = np.linspace(2000, 2100, 2000)
    y = scale * np.ones(2000)
    cont = continuum(x, y, method="scalar")
    assert np.allclose(np.mean(cont), scale)
    assert np.allclose(np.mean(y / cont), 1)