Example #1
0
def test_heterogeneous_multi(modes_all_single, bin_set,
                             path_to_ussa76_approx_data):
    """
    Unit tests for a HeterogeneousAtmosphere with multiple (2+) components.
    """
    # Construct succeeds
    if eradiate.mode().has_flags(ModeFlags.ANY_MONO):
        molecular_atmosphere = MolecularAtmosphere.ussa1976(
            absorption_data_sets={"us76_u86_4": path_to_ussa76_approx_data}, )
    elif eradiate.mode().has_flags(ModeFlags.ANY_CKD):
        molecular_atmosphere = MolecularAtmosphere.afgl_1986()
    else:
        pytest.skip(f"unsupported mode '{eradiate.mode().id}'")

    atmosphere = HeterogeneousAtmosphere(
        molecular_atmosphere=molecular_atmosphere,
        particle_layers=[ParticleLayer() for _ in range(2)],
    )

    # Radiative property metadata are correct
    ctx = KernelDictContext(spectral_ctx=CKDSpectralContext(bin_set=bin_set))

    # Kernel dict production succeeds
    assert atmosphere.kernel_phase(ctx)
    assert atmosphere.kernel_media(ctx)
    assert atmosphere.kernel_shapes(ctx)

    # Produced kernel dict can be loaded
    kernel_dict = atmosphere.kernel_dict(ctx)
    assert kernel_dict.load()
Example #2
0
def test_heterogeneous_single(modes_all_single, components, bin_set,
                              path_to_ussa76_approx_data):
    """
    Unit tests for a HeterogeneousAtmosphere with a single component.
    """
    # Construct succeeds
    if components == "molecular":
        if eradiate.mode().has_flags(ModeFlags.ANY_MONO):
            component = MolecularAtmosphere.ussa1976(absorption_data_sets={
                "us76_u86_4":
                path_to_ussa76_approx_data
            }, )
        elif eradiate.mode().has_flags(ModeFlags.ANY_CKD):
            component = MolecularAtmosphere.afgl_1986()
        else:
            pytest.skip(f"unsupported mode '{eradiate.mode().id}'")

        atmosphere = HeterogeneousAtmosphere(molecular_atmosphere=component)
    else:
        component = ParticleLayer()
        atmosphere = HeterogeneousAtmosphere(particle_layers=[component])

    # Produced kernel dict can be loaded
    ctx = KernelDictContext(spectral_ctx=CKDSpectralContext(bin_set=bin_set))
    assert atmosphere.kernel_dict(ctx).load()
Example #3
0
def test_molecular_atmosphere_afgl_1986(
    mode_mono,
    tmpdir,
    afgl_1986_test_absorption_data_sets,
):
    """MolecularAtmosphere 'afgl_1986' constructor produces a valid kernel
    dictionary."""
    spectral_ctx = SpectralContext.new(wavelength=550.0)
    ctx = KernelDictContext(spectral_ctx=spectral_ctx)
    atmosphere = MolecularAtmosphere.afgl_1986(
        absorption_data_sets=afgl_1986_test_absorption_data_sets)
    assert KernelDict.from_elements(atmosphere, ctx=ctx).load() is not None
Example #4
0
def test_onedim_experiment_ckd(mode_ckd, bin_set):
    """
    OneDimExperiment with heterogeneous atmosphere in CKD mode can be created.
    """
    ctx = KernelDictContext(spectral_ctx=CKDSpectralContext(bin_set=bin_set))
    exp = OneDimExperiment(
        atmosphere=HeterogeneousAtmosphere(
            molecular_atmosphere=MolecularAtmosphere.afgl_1986()),
        surface={"type": "lambertian"},
        measures={
            "type": "distant",
            "id": "distant_measure"
        },
    )
    assert exp.kernel_dict(ctx=ctx).load()
Example #5
0
def test_onedim_measure_inside_atmosphere(mode_mono):
    ctx = KernelDictContext()
    atm = HeterogeneousAtmosphere(
        molecular_atmosphere=MolecularAtmosphere.afgl_1986())

    s1 = eradiate.scenes.measure.MultiDistantMeasure()
    s2 = eradiate.scenes.measure.PerspectiveCameraMeasure(origin=[1, 1, 1],
                                                          target=[0, 0, 0])
    s3 = eradiate.scenes.measure.MultiRadiancemeterMeasure(
        origins=[[1, 1, 1], [0, 0, 1000000]],
        directions=[[0, 0, -1], [0, 0, -1]])

    assert not measure_inside_atmosphere(atm, s1, ctx)
    assert measure_inside_atmosphere(atm, s2, ctx)

    with pytest.raises(ValueError):
        measure_inside_atmosphere(atm, s3, ctx)