コード例 #1
0
def test_afgl_1986_rad_profile_concentrations(
        mode_mono, afgl_1986_test_absorption_data_sets):
    """
    Absorption coefficient is twice larger when H2O concentration is doubled.
    """

    thermoprops = make_profile_afgl_1986()
    column_amount_H2O = compute_column_number_density(ds=thermoprops,
                                                      species="H2O")
    p1 = AFGL1986RadProfile(
        thermoprops=thermoprops,
        absorption_data_sets=afgl_1986_test_absorption_data_sets,
    )

    p2 = AFGL1986RadProfile(
        thermoprops=dict(concentrations={
            "H2O": 2 * column_amount_H2O,
        }),
        absorption_data_sets=afgl_1986_test_absorption_data_sets,
    )
    spectral_ctx = SpectralContext.new(wavelength=1500.0 * ureg.nm)

    sigma_a_initial = p1.eval_sigma_a(spectral_ctx)
    sigma_a_doubled = p2.eval_sigma_a(spectral_ctx)

    assert np.allclose(sigma_a_doubled, 2 * sigma_a_initial, rtol=1e-2)
コード例 #2
0
def test_afgl_1986_rad_profile_model_id_ckd_not_implemented(
        mode_ckd, model_id):
    """
    Models other than 'us_standard' are not implemented in CKD mode.
    """
    with pytest.raises(NotImplementedError):
        AFGL1986RadProfile(thermoprops=dict(model_id=model_id))
コード例 #3
0
def test_afgl_1986_rad_profile_concentrations_ckd_not_implemented(
        mode_ckd, molecule):
    """
    Concentrations rescaling is not implemented for molecules other than
    H2O and O3 in CKD mode.
    """
    with pytest.raises(NotImplementedError):
        AFGL1986RadProfile(thermoprops=dict(
            concentrations={molecule: 1.0 * ureg.kg / ureg.m**2}))
コード例 #4
0
def test_afgl_1986_rad_profile_ckd_10nm(mode_ckd, bin):
    """
    Can evaluate absorption coefficient.
    """
    p = AFGL1986RadProfile()
    bin = eradiate.scenes.measure._core.CKDMeasureSpectralConfig(
        bins=bin).bins[0]
    bindex = eradiate.ckd.Bindex(bin=bin, index=3)
    spectral_ctx = eradiate.contexts.CKDSpectralContext(bindex=bindex,
                                                        bin_set="10nm")
    assert isinstance(p.eval_sigma_a(spectral_ctx), pint.Quantity)
コード例 #5
0
def test_afgl_1986_rad_profile_has_scattering_default(
        mode_mono, afgl_1986_test_absorption_data_sets):
    """
    Default value for 'has_scattering' is True, hence the absorption
    coefficient is computed and is not zero everywhere at 550 nm.
    """
    p = AFGL1986RadProfile(
        absorption_data_sets=afgl_1986_test_absorption_data_sets)
    assert p.has_scattering
    spectral_ctx = SpectralContext.new(wavelength=550.0)
    ds = p.eval_dataset(spectral_ctx)
    assert (ds.sigma_s.values != 0.0).any()
コード例 #6
0
def test_afgl_1986_rad_profile_default(mode_mono,
                                       afgl_1986_test_absorption_data_sets):
    """
    Collision coefficient evaluation methods return pint.Quantity objects.
    """
    p = AFGL1986RadProfile(
        absorption_data_sets=afgl_1986_test_absorption_data_sets)

    spectral_ctx = SpectralContext.new(wavelength=1500.0)
    for field in ["sigma_a", "sigma_s", "sigma_t", "albedo"]:
        x = getattr(p, f"eval_{field}")(spectral_ctx)
        assert isinstance(x, ureg.Quantity)
コード例 #7
0
def test_afgl_1986_rad_profile_has_scattering_false(
        mode_mono, afgl_1986_test_absorption_data_sets):
    """
    When 'has_scattering' is False, the scattering coefficient is not
    computed and is zero everywhere.
    """
    p = AFGL1986RadProfile(
        has_scattering=False,
        absorption_data_sets=afgl_1986_test_absorption_data_sets)
    assert not p.has_scattering
    spectral_ctx = SpectralContext.new(wavelength=550.0)
    ds = p.eval_dataset(spectral_ctx)
    assert (ds.sigma_s.values == 0.0).all()
コード例 #8
0
def test_afgl_1986_rad_profile_has_absorption_true(
        mode_mono, afgl_1986_test_absorption_data_sets):
    """
    When 'has_absorption' is True, the absorption coefficient is computed
    and is not zero everywhere at 1650 nm.
    """
    p = AFGL1986RadProfile(
        has_absorption=True,
        absorption_data_sets=afgl_1986_test_absorption_data_sets)
    assert p.has_absorption
    spectral_ctx = SpectralContext.new(wavelength=1650.0)
    ds = p.eval_dataset(spectral_ctx)
    assert (ds.sigma_a.values != 0.0).any()
コード例 #9
0
def test_afgl_1986_rad_profile_default_ckd(mode_ckd):
    """
    Collision coefficient evaluation methods return pint.Quantity objects.
    """
    p = AFGL1986RadProfile()

    spectral_ctx = SpectralContext.new(bin_set="10nm")
    for field in ["albedo", "sigma_a", "sigma_t"]:
        x = getattr(p, f"eval_{field}_ckd")(spectral_ctx.bindex,
                                            bin_set_id=spectral_ctx.bin_set.id)
        assert isinstance(x, ureg.Quantity)

    sigma_s = p.eval_sigma_s_ckd(spectral_ctx.bindex)
    assert isinstance(sigma_s, ureg.Quantity)
コード例 #10
0
def test_afgl_1986_rad_profile_levels(mode_mono,
                                      afgl_1986_test_absorption_data_sets):
    """
    Collision coefficients' shape match altitude levels shape.
    """
    n_layers = 101
    p = AFGL1986RadProfile(
        thermoprops=dict(
            levels=ureg.Quantity(np.linspace(0.0, 100.0, n_layers + 1), "km")),
        absorption_data_sets=afgl_1986_test_absorption_data_sets,
    )

    spectral_ctx = SpectralContext.new(wavelength=550.0)
    for field in ["sigma_a", "sigma_s", "sigma_t", "albedo"]:
        x = getattr(p, f"eval_{field}")(spectral_ctx)
        assert x.shape == (n_layers, )