コード例 #1
0
ファイル: test_glacier.py プロジェクト: OGGM/oggm-edu
def test_progress_to_year():
    """Test the method progress_to_year."""
    glacier = Glacier(bed=real_bed, mass_balance=real_mb)

    # Progress the glacier.
    year = 50
    glacier.progress_to_year(year)

    # This will progress the glacier normally and relies on
    # oggm.FluxBasedModel for run and store.
    assert glacier.age == year
    # Length of history will be 1 longer since we include the 0 year.
    assert len(glacier.history.time) == year + 1
    assert glacier.history.time.isel(time=-1) == year
    # State history appending should work as well.
    assert len(glacier.state_history.time) == year + 1

    # Progress a bit further, checks that appending to history works as intended.
    year = 60
    glacier.progress_to_year(year)
    assert glacier.age == year
    # Length of history will be 1 longer since we include the 0 year.
    assert len(glacier.history.time) == year + 1
    assert glacier.history.time.isel(time=-1) == year
    assert len(glacier.state_history.time) == year + 1
コード例 #2
0
ファイル: test_glacier.py プロジェクト: OGGM/oggm-edu
def test_progress_to_equilibrium():
    """Should be possible to combine progress_to_year and progress_to_equilibrium"""
    glacier = Glacier(bed=real_bed, mass_balance=real_mb)
    glacier.progress_to_year(100)
    glacier.progress_to_equilibrium()

    # We don't really now what the eq state is. But at least some checks on the data.
    assert len(glacier.history.time) == len(glacier.state_history.time)
コード例 #3
0
ファイル: test_glacier.py プロジェクト: OGGM/oggm-edu
def test_add_random_climate():
    """Test parts of the random climate."""
    glacier = Glacier(bed=real_bed, mass_balance=real_mb)

    glacier.progress_to_year(100)
    assert len(glacier.mass_balance.temp_bias_series.bias) == 101

    # Add a random climate.
    glacier.add_random_climate(duration=200, temperature_range=(-2.0, 2.0))
    # Should now be of the length 301
    assert len(glacier.mass_balance.temp_bias_series.bias) == 301
    glacier.progress_to_year(300)
    # Should still be of the length 301
    assert len(glacier.mass_balance.temp_bias_series.bias) == 301
コード例 #4
0
ファイル: test_glacier.py プロジェクト: OGGM/oggm-edu
def test_add_temperature_bias():
    """Test to make sure that the entire temperature bias mechanism works as intended."""
    glacier = Glacier(bed=real_bed, mass_balance=real_mb)
    # Add a temperature bias
    duration = 10
    bias = 2.0
    glacier.add_temperature_bias(bias=2.0, duration=duration)
    # Progress the glacier a few years.
    year = 2
    glacier.progress_to_year(year)
    # Check the current temperature bias.
    assert glacier.mass_balance.temp_bias == bias / duration * year

    # Progress a bit further
    year = 10
    glacier.progress_to_year(year)
    # We should have reached the final temp bias now.
    assert glacier.mass_balance.temp_bias == bias
    # This should've also have update the ELA, check against the original ELA.
    assert glacier.ela == real_mb.ela + 150 * 2
    assert glacier.age == 10
    # Progress even further, bias should not continue to evolve
    glacier.progress_to_year(20)
    assert glacier.mass_balance.temp_bias == bias
    assert glacier.ela == real_mb.ela + 150 * 2
    # If we then set a new bias this should start to evolve again.
    new_bias = -1.0
    new_duration = 10
    glacier.add_temperature_bias(bias=new_bias, duration=new_duration)
    # Progress
    year = 25
    glacier.progress_to_year(year)
    # What should the bias be now?
    # We should be going from the previous bias towards the new bias.
    assert glacier.mass_balance.temp_bias == bias + (
        (new_bias - bias) / new_duration * 5)

    # Progress further
    year = 35
    glacier.progress_to_year(year)
    assert glacier.mass_balance.temp_bias == new_bias
    assert glacier.ela == real_mb.ela + 150 * new_bias