Exemplo n.º 1
0
def test_zonbud_aliases():
    """
    t039 Test zonbud aliases
    """
    zon = read_zbarray(zon_f)
    aliases = {1: 'Trey', 2: 'Mike', 4: 'Wilson', 0: 'Carini'}
    zb = ZoneBudget(cbc_f, zon, kstpkper=(0, 1096), aliases=aliases, verbose=True)
    bud = zb.get_budget()
    assert bud[bud['name'] == 'FROM_Mike'].shape[0] > 0, 'No records returned.'
    return
Exemplo n.º 2
0
def test_zonbud_aliases():
    """
    t039 Test zonbud aliases
    """
    zon = read_zbarray(zon_f)
    aliases = {1: 'Trey', 2: 'Mike', 4: 'Wilson', 0: 'Carini'}
    zb = ZoneBudget(cbc_f, zon, kstpkper=(0, 1096), aliases=aliases, verbose=True)
    bud = zb.get_budget()
    assert bud[bud['name'] == 'FROM_Mike'].shape[0] > 0, 'No records returned.'
    return
Exemplo n.º 3
0
def test_zonbud_aliases():
    """
    t039 Test zonbud aliases
    """
    cbc_f = os.path.join(loadpth, 'freyberg_mlt', 'freyberg.gitcbc')
    zon = read_zbarray(os.path.join(loadpth, 'zonef_mlt'))
    aliases = {1: 'Trey', 2: 'Mike', 4: 'Wilson', 0: 'Carini'}
    zb = ZoneBudget(cbc_f, zon, kstpkper=(0, 1096), aliases=aliases)
    bud = zb.get_budget()
    m = bud['name'] == 'Mike_IN'
    assert bud[m].shape[0] > 0, 'No records returned.'
    return
Exemplo n.º 4
0
def test_get_budget():
    zon = read_zbarray(zon_f)
    aliases = {1: 'Trey', 2: 'Mike', 4: 'Wilson', 0: 'Carini'}
    zb = ZoneBudget(cbc_f, zon, kstpkper=(0, 0), aliases=aliases)
    zb.get_budget(names='FROM_CONSTANT_HEAD', zones=1)
    zb.get_budget(names=['FROM_CONSTANT_HEAD'], zones=[1, 2])
    zb.get_budget(net=True)
    return
Exemplo n.º 5
0
def test_get_budget():
    zon = read_zbarray(zon_f)
    aliases = {1: 'Trey', 2: 'Mike', 4: 'Wilson', 0: 'Carini'}
    zb = ZoneBudget(cbc_f, zon, kstpkper=(0, 0), aliases=aliases)
    zb.get_budget(names='FROM_CONSTANT_HEAD', zones=1)
    zb.get_budget(names=['FROM_CONSTANT_HEAD'], zones=[1, 2])
    zb.get_budget(net=True)
    return
Exemplo n.º 6
0
def test_get_budget():
    zon = ZoneBudget.read_zone_file(zon_f)
    aliases = {1: "Trey", 2: "Mike", 4: "Wilson", 0: "Carini"}
    zb = ZoneBudget(cbc_f, zon, kstpkper=(0, 0), aliases=aliases)
    zb.get_budget(names="FROM_CONSTANT_HEAD", zones=1)
    zb.get_budget(names=["FROM_CONSTANT_HEAD"], zones=[1, 2])
    zb.get_budget(net=True)
    return
Exemplo n.º 7
0
def test_zonbud_aliases():
    """
    t039 Test zonbud aliases
    """
    zon = ZoneBudget.read_zone_file(zon_f)
    aliases = {1: "Trey", 2: "Mike", 4: "Wilson", 0: "Carini"}
    zb = ZoneBudget(cbc_f,
                    zon,
                    kstpkper=(0, 1096),
                    aliases=aliases,
                    verbose=True)
    bud = zb.get_budget()
    assert bud[bud["name"] == "FROM_Mike"].shape[0] > 0, "No records returned."
    return
Exemplo n.º 8
0
def test_compare2zonebudget(rtol=1e-2):
    """
    t039 Compare output from zonbud.exe to the budget calculated by zonbud
    utility using the multilayer transient freyberg model.
    """
    zonebudget_recarray = read_zonebudget_file(os.path.join(loadpth,
                                                            'zonebudget_mlt.csv'))

    zon = read_zbarray(os.path.join(loadpth, 'zonef_mlt'))
    cbc_fname = os.path.join(loadpth, 'freyberg_mlt', 'freyberg.gitcbc')
    zb = ZoneBudget(cbc_fname, zon, verbose=False)
    zbutil_recarray = zb.get_budget()

    times = np.unique(zonebudget_recarray['totim'])
    print(times)

    zonenames = [n for n in zonebudget_recarray.dtype.names if 'ZONE' in n]

    for time in times:
        print('Time:', time)
        zb_arr = zonebudget_recarray[zonebudget_recarray['totim'] == time]
        zbu_arr = zbutil_recarray[zbutil_recarray['totim'] == time]
        for name in zbu_arr['name']:
            r1 = np.where((zb_arr['name'] == name))
            r2 = np.where((zbu_arr['name'] == name))
            if r1[0].shape[0] < 1 or r2[0].shape[0] < 1:
                continue
            if r1[0].shape[0] != r2[0].shape[0]:
                continue
            a1 = np.array([v for v in zb_arr[zonenames][r1[0]][0]])
            a2 = np.array([v for v in zbu_arr[zonenames][r2[0]][0]])
            allclose = np.allclose(a1, a2, rtol)

            mxdiff = np.abs(a1 - a2).max()
            idxloc = np.argmax(np.abs(a1 - a2))
            txt = '{} - Max: {}  a1: {}  a2: {}'.format(name, mxdiff,
                                                        a1[idxloc],
                                                        a2[idxloc])
            print(txt)
            s = 'Zonebudget arrays do not match at time {0} ({1}): {2}.' \
                .format(time, name, mxdiff)
            assert allclose, s
    return
Exemplo n.º 9
0
def test_compare2zonebudget(rtol=1e-2):
    """
    t039 Compare output from zonbud.exe to the budget calculated by zonbud
    utility using the multilayer transient freyberg model.
    """
    zba = read_zonebudget_file(zbud_f)
    zonenames = [n for n in zba.dtype.names if 'ZONE' in n]
    times = np.unique(zba['totim'])

    zon = read_zbarray(zon_f)
    zb = ZoneBudget(cbc_f, zon, totim=times, verbose=False)
    fpa = zb.get_budget()

    for time in times:
        zb_arr = zba[zba['totim'] == time]
        fp_arr = fpa[fpa['totim'] == time]
        for name in fp_arr['name']:
            r1 = np.where((zb_arr['name'] == name))
            r2 = np.where((fp_arr['name'] == name))
            if r1[0].shape[0] < 1 or r2[0].shape[0] < 1:
                continue
            if r1[0].shape[0] != r2[0].shape[0]:
                continue
            a1 = np.array([v for v in zb_arr[zonenames][r1[0]][0]])
            a2 = np.array([v for v in fp_arr[zonenames][r2[0]][0]])
            allclose = np.allclose(a1, a2, rtol)

            mxdiff = np.abs(a1 - a2).max()
            idxloc = np.argmax(np.abs(a1 - a2))
            # txt = '{}: {} - Max: {}  a1: {}  a2: {}'.format(time,
            #                                                 name,
            #                                                 mxdiff,
            #                                                 a1[idxloc],
            #                                                 a2[idxloc])
            # print(txt)
            s = 'Zonebudget arrays do not match at time {0} ({1}): {2}.' \
                .format(time, name, mxdiff)
            assert allclose, s
    return
Exemplo n.º 10
0
def test_compare2zonebudget(rtol=1e-2):
    """
    t039 Compare output from zonbud.exe to the budget calculated by zonbud
    utility using the multilayer transient freyberg model.
    """
    zba = read_zonebudget_file(zbud_f)
    zonenames = [n for n in zba.dtype.names if 'ZONE' in n]
    times = np.unique(zba['totim'])

    zon = read_zbarray(zon_f)
    zb = ZoneBudget(cbc_f, zon, totim=times, verbose=False)
    fpa = zb.get_budget()

    for time in times:
        zb_arr = zba[zba['totim'] == time]
        fp_arr = fpa[fpa['totim'] == time]
        for name in fp_arr['name']:
            r1 = np.where((zb_arr['name'] == name))
            r2 = np.where((fp_arr['name'] == name))
            if r1[0].shape[0] < 1 or r2[0].shape[0] < 1:
                continue
            if r1[0].shape[0] != r2[0].shape[0]:
                continue
            a1 = np.array([v for v in zb_arr[zonenames][r1[0]][0]])
            a2 = np.array([v for v in fp_arr[zonenames][r2[0]][0]])
            allclose = np.allclose(a1, a2, rtol)

            mxdiff = np.abs(a1 - a2).max()
            idxloc = np.argmax(np.abs(a1 - a2))
            # txt = '{}: {} - Max: {}  a1: {}  a2: {}'.format(time,
            #                                                 name,
            #                                                 mxdiff,
            #                                                 a1[idxloc],
            #                                                 a2[idxloc])
            # print(txt)
            s = 'Zonebudget arrays do not match at time {0} ({1}): {2}.' \
                .format(time, name, mxdiff)
            assert allclose, s
    return