Exemplo n.º 1
0
def test_sw_set_end_time(tmpdir):

    pfs = PfsCore("tests/testdata/lake.sw", "FemEngineSW")

    assert pfs.start_time.year == 2002
    assert pfs.section("TIME")["number_of_time_steps"].value == 450
    new_end_time = datetime(2002, 1, 2, 0)
    pfs.end_time = new_end_time

    assert pfs.end_time == new_end_time
    assert pfs.section("TIME")["number_of_time_steps"].value == 720
Exemplo n.º 2
0
def test_sw_new_start_time_write(tmpdir):

    pfs = PfsCore("tests/testdata/lake.sw", "FemEngineSW")

    new_start = datetime(2020, 6, 10, 12)

    assert pfs.start_time.year == 2002
    pfs.start_time = new_start

    assert pfs.start_time.year == 2020

    outfilename = os.path.join(tmpdir.dirname, "lake_mod.sw")

    pfs.write(outfilename)
Exemplo n.º 3
0
def test_sw_modify_and_write(tmpdir):

    # [SPECTRAL_WAVE_MODULE][WIND]Charnock_parameter
    pfs = PfsCore("tests/testdata/lake.sw")

    wind_section = pfs.section("SPECTRAL_WAVE_MODULE").section("WIND")

    assert type(wind_section["Charnock_parameter"].value) == float

    # modify parameter without needing to specify that the float is a float...
    wind_section["Charnock_parameter"] = 0.02

    wind_section["Charnock_parameter"] = 1.0

    # Force parameter to be interpreted as float to avoid interpreting 1.0 as integer
    wind_section["Charnock_parameter"].modify(0.1, float)

    # modify a filename
    pfs.section("DOMAIN")["file_name"] = "tests\\testdata\\odense_rough.mesh"

    # attribute access
    out_file_1 = (pfs.section("SPECTRAL_WAVE_MODULE").section(
        "OUTPUTS").section("OUTPUT_1").file_name)

    assert out_file_1.value == "Wave_parameters.dfsu"

    outfilename = os.path.join(tmpdir.dirname, "lake_mod.sw")

    pfs.write(outfilename)
Exemplo n.º 4
0
def test_sw_get_end_time(tmpdir):

    pfs = PfsCore("tests/testdata/lake.sw", "FemEngineSW")

    assert pfs.start_time.year == 2002
    assert pfs.end_time.year == 2002
    assert pfs.end_time.month == 1
    assert pfs.end_time.day == 1
    assert pfs.end_time.hour == 15
Exemplo n.º 5
0
def test_sw_modify_and_write(tmpdir):

    # [SPECTRAL_WAVE_MODULE][WIND]Charnock_parameter
    pfs = PfsCore("tests/testdata/lake.sw")

    wind_section = pfs.section("SPECTRAL_WAVE_MODULE").section("WIND")

    assert isinstance(wind_section["Charnock_parameter"].value, float)

    # modify parameter without needing to specify that the float is a float...
    wind_section["Charnock_parameter"] = 0.02

    wind_section["Charnock_parameter"] = 1.0

    # Force parameter to be interpreted as float to avoid interpreting 1.0 as integer
    wind_section["Charnock_parameter"] = 0.1

    assert wind_section["Charnock_parameter"].value == 0.1

    spectral_section = pfs.section("SPECTRAL_WAVE_MODULE").section("SPECTRAL")

    assert spectral_section["separation_of_wind_sea_and_swell"].value == 0
    spectral_section["separation_of_wind_sea_and_swell"] = 1

    assert spectral_section["separation_of_wind_sea_and_swell"].value == 1

    # Check that numpy types works as well
    for i in np.arange(2, 25):
        spectral_section["number_of_frequencies"] = i

    # modify a filename
    pfs.section("DOMAIN")["file_name"] = "tests\\testdata\\odense_rough.mesh"

    # attribute access
    out_file_1 = (pfs.section("SPECTRAL_WAVE_MODULE").section(
        "OUTPUTS").section("OUTPUT_1").file_name)

    assert out_file_1.value == "Wave_parameters.dfsu"

    outfilename = os.path.join(tmpdir.dirname, "lake_mod.sw")

    pfs.write(outfilename)