Beispiel #1
0
def test_sfrcheck():

    m = flopy.modflow.Modflow.load('test1tr.nam', model_ws=path, verbose=False)

    # run level=0 check
    m.model_ws= cpth
    fpth = 'SFRchecker_results.txt'
    m.sfr.check(fpth, level=0)
    
    # test checks without modifications
    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.passed
    chk.routing()
    assert 'circular routing' in chk.passed
    chk.overlapping_conductance()
    assert 'overlapping conductance' in chk.warnings # this example model has overlapping conductance
    chk.elevations()
    for test in ['segment elevations', 'reach elevations', 'reach elevations vs. grid elevations']:
        assert test in chk.passed
    chk.slope()
    assert 'minimum slope' in chk.passed
    
    # create gaps in segment numbering
    m.sfr.segment_data[0]['nseg'][-1] += 1
    m.sfr.reach_data['ireach'][3] += 1
    
    # create circular routing instance
    m.sfr.segment_data[0]['outseg'][1] = 1
    m.sfr.segment_data[0]['outseg']
    
    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.errors
    chk.routing()
    assert 'circular routing' in chk.errors
    m.sfr.segment_data[0]['nseg'][-1] -= 1
    m.sfr.isfropt = 1.
    chk = check(m.sfr)
    chk.elevations()
    # throw warning if isfropt=1 and strtop at default
    assert 'maximum streambed top' in chk.warnings
    assert 'minimum streambed top' in chk.warnings
    m.sfr.reach_data['strtop'] = m.sfr._interpolate_to_reaches('elevup', 'elevdn')
    m.sfr.get_slopes()
    m.sfr.reach_data['strhc1'] = 1.
    m.sfr.reach_data['strthick'] = 1.
    chk = check(m.sfr)
    chk.elevations()
    assert 'maximum streambed top' in chk.passed
    assert 'minimum streambed top' in chk.passed
    m.sfr.reach_data['strtop'][2] = -99.
    chk = check(m.sfr)
    chk.elevations()
    assert 'minimum streambed top' in chk.warnings
    m.sfr.reach_data['strtop'][2] = 99999.
    chk = check(m.sfr)
    chk.elevations()
    assert 'maximum streambed top' in chk.warnings
    assert True
Beispiel #2
0
def test_sfrcheck():

    m = flopy.modflow.Modflow.load('test1tr.nam', model_ws=path, verbose=False)

    # run level=0 check
    m.model_ws= cpth
    fpth = 'SFRchecker_results.txt'
    m.sfr.check(fpth, level=0)
    
    # test checks without modifications
    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.passed
    chk.routing()
    assert 'circular routing' in chk.passed
    chk.overlapping_conductance()
    assert 'overlapping conductance' in chk.warnings # this example model has overlapping conductance
    chk.elevations()
    for test in ['segment elevations', 'reach elevations', 'reach elevations vs. grid elevations']:
        assert test in chk.passed
    chk.slope()
    assert 'minimum slope' in chk.passed
    
    # create gaps in segment numbering
    m.sfr.segment_data[0]['nseg'][-1] += 1
    m.sfr.reach_data['ireach'][3] += 1
    
    # create circular routing instance
    m.sfr.segment_data[0]['outseg'][1] = 1
    m.sfr.segment_data[0]['outseg']
    
    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.errors
    chk.routing()
    assert 'circular routing' in chk.errors
    m.sfr.segment_data[0]['nseg'][-1] -= 1
    m.sfr.isfropt = 1.
    chk = check(m.sfr)
    chk.elevations()
    # throw warning if isfropt=1 and strtop at default
    assert 'maximum streambed top' in chk.warnings
    assert 'minimum streambed top' in chk.warnings
    m.sfr.reach_data['strtop'] = m.sfr._interpolate_to_reaches('elevup', 'elevdn')
    m.sfr.get_slopes()
    m.sfr.reach_data['strhc1'] = 1.
    m.sfr.reach_data['strthick'] = 1.
    chk = check(m.sfr)
    chk.elevations()
    assert 'maximum streambed top' in chk.passed
    assert 'minimum streambed top' in chk.passed
    m.sfr.reach_data['strtop'][2] = -99.
    chk = check(m.sfr)
    chk.elevations()
    assert 'minimum streambed top' in chk.warnings
    m.sfr.reach_data['strtop'][2] = 99999.
    chk = check(m.sfr)
    chk.elevations()
    assert 'maximum streambed top' in chk.warnings
    assert True
Beispiel #3
0
def test_sfrcheck():

    m = flopy.modflow.Modflow.load('test1tr.nam', model_ws=path, verbose=False)

    # run level=0 check
    m.model_ws = cpth
    fpth = 'SFRchecker_results.txt'
    m.sfr.check(fpth, level=0)

    # test checks without modifications
    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.passed
    chk.routing()
    assert 'circular routing' in chk.passed
    chk.overlapping_conductance()
    assert 'overlapping conductance' in chk.warnings  # this example model has overlapping conductance
    chk.elevations()
    for test in [
            'segment elevations', 'reach elevations',
            'reach elevations vs. grid elevations'
    ]:
        assert test in chk.passed
    chk.slope()
    assert 'minimum slope' in chk.passed

    # create gaps in segment numbering
    m.sfr.segment_data[0]['nseg'][-1] += 1
    m.sfr.reach_data['ireach'][3] += 1

    # create circular routing instance
    m.sfr.segment_data[0]['outseg'][1] = 1
    m.sfr.segment_data[0]['outseg']

    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.errors
    chk.routing()
    assert 'circular routing' in chk.errors
Beispiel #4
0
def test_sfrcheck():

    m = flopy.modflow.Modflow.load('test1tr.nam', model_ws=path, verbose=False)

    # run level=0 check
    m.model_ws= cpth
    fpth = 'SFRchecker_results.txt'
    m.sfr.check(fpth, level=0)
    
    # test checks without modifications
    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.passed
    chk.routing()
    assert 'circular routing' in chk.passed
    chk.overlapping_conductance()
    assert 'overlapping conductance' in chk.warnings # this example model has overlapping conductance
    chk.elevations()
    for test in ['segment elevations', 'reach elevations', 'reach elevations vs. grid elevations']:
        assert test in chk.passed
    chk.slope()
    assert 'minimum slope' in chk.passed
    
    # create gaps in segment numbering
    m.sfr.segment_data[0]['nseg'][-1] += 1
    m.sfr.reach_data['ireach'][3] += 1
    
    # create circular routing instance
    m.sfr.segment_data[0]['outseg'][1] = 1
    m.sfr.segment_data[0]['outseg']
    
    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.errors
    chk.routing()
    assert 'circular routing' in chk.errors
Beispiel #5
0
def test_sfrcheck():

    if os.path.split(os.getcwd())[-1] == 'flopy3':
        path = os.path.join('examples', 'data', 'mf2005_test')
        cpth = os.path.join('py.test/temp')
    else:
        path = os.path.join('..', 'examples', 'data', 'mf2005_test')
        cpth = os.path.join('temp')

    m = flopy.modflow.Modflow.load('test1tr.nam', model_ws=path, verbose=False)

    # run level=0 check
    m.model_ws= cpth
    fpth = 'SFRchecker_results.txt'
    m.sfr.check(fpth, level=0)
    
    # test checks without modifications
    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.passed
    chk.routing()
    assert 'circular routing' in chk.passed
    chk.overlapping_conductance()
    assert 'overlapping conductance' in chk.warnings # this example model has overlapping conductance
    chk.elevations()
    for test in ['segment elevations', 'reach elevations', 'reach elevations vs. grid elevations']:
        assert test in chk.passed
    chk.slope()
    assert 'minimum slope' in chk.passed
    
    # create gaps in segment numbering
    m.sfr.segment_data[0]['nseg'][-1] += 1
    m.sfr.reach_data['ireach'][3] += 1
    
    # create circular routing instance
    m.sfr.segment_data[0]['outseg'][1] = 1
    m.sfr.segment_data[0]['outseg']
    
    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.errors
    chk.routing()
    assert 'circular routing' in chk.errors
    
    sfr_items = {0: {'mfnam': 'test1ss.nam',
                     'sfrfile': 'test1ss.sfr'},
                 1: {'mfnam': 'test1tr.nam',
                     'sfrfile': 'test1tr.sfr'},
                 2: {'mfnam': 'testsfr2_tab.nam',
                     'sfrfile': 'testsfr2_tab_ICALC1.sfr'},
                 3: {'mfnam': 'testsfr2_tab.nam',
                     'sfrfile': 'testsfr2_tab_ICALC2.sfr'},
                 4: {'mfnam': 'testsfr2.nam',
                     'sfrfile': 'testsfr2.sfr'},
                 5: {'mfnam': 'UZFtest2.nam',
                     'sfrfile': 'UZFtest2.sfr'},
                 }
    

    passed = {}
    warnings = {}
    
    for i, case in sfr_items.items():
        chk = load_check_sfr(case['mfnam'], model_ws=path, checker_output_path=cpth)
        passed[i] = chk.passed
        warnings[i] = chk.warnings
    assert 'overlapping conductance' in warnings[1]
    assert 'segment elevations vs. model grid' in warnings[2]
Beispiel #6
0
def test_sfrcheck():

    if os.path.split(os.getcwd())[-1] == 'flopy3':
        path = os.path.join('examples', 'data', 'mf2005_test')
        cpth = os.path.join('py.test/temp')
    else:
        path = os.path.join('..', 'examples', 'data', 'mf2005_test')
        cpth = os.path.join('temp')

    m = flopy.modflow.Modflow.load('test1tr.nam', model_ws=path, verbose=False)

    # run level=0 check
    m.model_ws = cpth
    fpth = 'SFRchecker_results.txt'
    m.sfr.check(fpth, level=0)

    # test checks without modifications
    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.passed
    chk.routing()
    assert 'circular routing' in chk.passed
    chk.overlapping_conductance()
    assert 'overlapping conductance' in chk.warnings  # this example model has overlapping conductance
    chk.elevations()
    for test in [
            'segment elevations', 'reach elevations',
            'reach elevations vs. grid elevations'
    ]:
        assert test in chk.passed
    chk.slope()
    assert 'minimum slope' in chk.passed

    # create gaps in segment numbering
    m.sfr.segment_data[0]['nseg'][-1] += 1
    m.sfr.reach_data['ireach'][3] += 1

    # create circular routing instance
    m.sfr.segment_data[0]['outseg'][1] = 1
    m.sfr.segment_data[0]['outseg']

    chk = check(m.sfr)
    chk.numbering()
    assert 'continuity in segment and reach numbering' in chk.errors
    chk.routing()
    assert 'circular routing' in chk.errors

    sfr_items = {
        0: {
            'mfnam': 'test1ss.nam',
            'sfrfile': 'test1ss.sfr'
        },
        1: {
            'mfnam': 'test1tr.nam',
            'sfrfile': 'test1tr.sfr'
        },
        2: {
            'mfnam': 'testsfr2_tab.nam',
            'sfrfile': 'testsfr2_tab_ICALC1.sfr'
        },
        3: {
            'mfnam': 'testsfr2_tab.nam',
            'sfrfile': 'testsfr2_tab_ICALC2.sfr'
        },
        4: {
            'mfnam': 'testsfr2.nam',
            'sfrfile': 'testsfr2.sfr'
        },
        5: {
            'mfnam': 'UZFtest2.nam',
            'sfrfile': 'UZFtest2.sfr'
        },
    }

    passed = {}
    warnings = {}

    for i, case in sfr_items.items():
        chk = load_check_sfr(case['mfnam'],
                             model_ws=path,
                             checker_output_path=cpth)
        passed[i] = chk.passed
        warnings[i] = chk.warnings
    assert 'overlapping conductance' in warnings[1]
    assert 'segment elevations vs. model grid' in warnings[2]