Ejemplo n.º 1
0
def test_finalize_opt_duration_stochastic_false(clock_07, grid_1):
    params = {
        "grid": grid_1,
        "opt_stochastic_duration": False,
        "clock": clock_07,
        "record_rain": True,
        "m_sp": 0.5,
        "n_sp": 1.0,
        "water_erodibility": 0.01,
        "regolith_transport_parameter": 0.1,
        "infiltration_capacity": 0.0,
        "rainfall__mean_rate": 1.0,
        "rainfall_intermittency_factor": 0.1,
        "rainfall__shape_factor": 0.6,
        "number_of_sub_time_steps": 1,
        "random_seed": 1234,
    }
    model = BasicSt(**params)
    model.reset_random_seed()
    model.run_for(model.clock.step, model.clock.stop)
    model.finalize()

    # assert that these are correct
    truth_file = os.path.join(_TEST_DATA_DIR,
                              "opt_dur_false_storm_sequence.txt")
    assert filecmp("storm_sequence.txt", truth_file) is True

    truth_file = os.path.join(_TEST_DATA_DIR,
                              "opt_dur_false_exceedance_summary.txt")
    assert filecmp("exceedance_summary.txt", truth_file) is True

    os.remove("storm_sequence.txt")
    os.remove("exceedance_summary.txt")
Ejemplo n.º 2
0
def test_finalize_opt_duration_stochastic_true(clock_07, grid_1):
    params = {
        "grid": grid_1,
        "opt_stochastic_duration": True,
        "clock": clock_07,
        "record_rain": True,
        "m_sp": 0.5,
        "n_sp": 1.0,
        "water_erodibility": 0.01,
        "regolith_transport_parameter": 0.1,
        "infiltration_capacity": 0.0,
        "mean_storm_duration": 2.0,
        "mean_interstorm_duration": 3.0,
        "mean_storm_depth": 1.0,
        "random_seed": 1234,
    }

    model = BasicSt(**params)
    model.reset_random_seed()
    model.run_for(model.clock.step, model.clock.stop)
    model.finalize()

    # assert that these are correct
    truth_file = os.path.join(_TEST_DATA_DIR,
                              "opt_dur_true_storm_sequence.txt")
    assert filecmp("storm_sequence.txt", truth_file) is True

    os.remove("storm_sequence.txt")
Ejemplo n.º 3
0
def test_finalize_opt_duration_stochastic_false_too_short(clock_05, grid_1):
    params = {
        "grid": grid_1,
        "opt_stochastic_duration": False,
        "clock": clock_05,
        "record_rain": True,
        "m_sp": 0.5,
        "n_sp": 1.0,
        "water_erodibility": 0.01,
        "regolith_transport_parameter": 0.1,
        "infiltration_capacity": 0.0,
        "rainfall__mean_rate": 1.0,
        "rainfall_intermittency_factor": 0.1,
        "rainfall__shape_factor": 0.6,
        "number_of_sub_time_steps": 1,
        "random_seed": 1234,
    }

    model = BasicSt(**params)
    model.reset_random_seed()
    model.run_for(model.clock.step, model.clock.stop)
    with pytest.raises(RuntimeError):
        model.finalize()

    os.remove("storm_sequence.txt")