@@ -720,13 +720,21 @@ def test_cellbudgetfile_get_ts_aux_vars_mf6_readme_example(function_tmpdir):
720720 sim .write_simulation (silent = True )
721721 sim .run_simulation (silent = True )
722722
723- hds = gwf .output .head (). get_data ()
723+ hds = gwf .output .head ()
724724 cbc = gwf .output .budget ()
725725
726726 cellid = (0 , 5 , 5 )
727-
728- head = hds .get_ts (idx = cellid )
729- spdis = cbc .get_ts (idx = cellid , text = "DATA-SPDIS" )
727+ assert (
728+ hds .get_ts (idx = cellid )[0 ][1 ] == hds .get_data ()[cellid [0 ], cellid [1 ], cellid [2 ]]
729+ )
730+ assert (
731+ cbc .get_ts (idx = cellid , text = "DATA-SPDIS" , variable = "qx" )[0 ][1 ]
732+ == cbc .get_data (text = "DATA-SPDIS" )[0 ][gwf .modelgrid .get_node ([cellid ])[0 ]]["qx" ]
733+ )
734+ cellid = (0 , 0 , 0 )
735+ assert (
736+ cbc .get_ts (idx = cellid , text = "CHD" )[0 ][1 ] == cbc .get_data (text = "CHD" )[0 ][0 ]["q" ]
737+ )
730738
731739
732740@pytest .fixture
@@ -785,28 +793,19 @@ def test_cellbudgetfile_get_ts_aux_vars_mf6_dis(dis_sim):
785793 gwf = sim .get_model ()
786794 cbc = gwf .output .budget ()
787795
788- cellid = (0 , 2 , 2 )
789- nn = gwf .modelgrid .get_node (cellid )[0 ]
790-
791796 text = "DATA-SPDIS"
792797 spdis = cbc .get_data (text = text )
793798 for field in ["node" , "q" , "qx" , "qy" , "qz" ]:
794799 assert field in spdis [0 ].dtype .names
795800
796- text = "CHD"
797- chd = cbc .get_data (text = text )
798- for field in ["node" , "node2" , "q" ]:
799- assert field in chd [0 ].dtype .names
801+ cellid = (0 , 2 , 2 )
802+ nn = gwf .modelgrid .get_node (cellid )[0 ]
800803
801804 spdis_q = cbc .get_ts (idx = cellid , text = text , variable = "q" )
802805 spdis_qx = cbc .get_ts (idx = cellid , text = text , variable = "qx" )
803806 spdis_qy = cbc .get_ts (idx = cellid , text = text , variable = "qy" )
804807 spdis_qz = cbc .get_ts (idx = cellid , text = text , variable = "qz" )
805808
806- chd_q = cbc .get_ts (
807- idx = cellid ,
808- )
809-
810809 assert spdis_q .shape == spdis_qx .shape == spdis_qy .shape == spdis_qz .shape
811810 assert spdis_q .shape [1 ] == 2 # time + 1 data column
812811 assert spdis_qx .shape [1 ] == 2
@@ -823,25 +822,43 @@ def test_cellbudgetfile_get_ts_aux_vars_mf6_dis(dis_sim):
823822 assert np .allclose (
824823 spdis_q [i , 1 ],
825824 rec ["q" ][mask ][0 ],
826- ), f"get_ts() q value doesn't match get_data() at time { i } "
825+ ), f"get_ts() SPDIS q value doesn't match get_data() at time { i } "
827826 assert np .allclose (
828827 spdis_qx [i , 1 ],
829828 rec ["qx" ][mask ][0 ],
830- ), f"get_ts() qx value doesn't match get_data() at time { i } "
829+ ), f"get_ts() SPDIS qx value doesn't match get_data() at time { i } "
831830 assert np .allclose (
832831 spdis_qy [i , 1 ],
833832 rec ["qy" ][mask ][0 ],
834- ), f"get_ts() qy value doesn't match get_data() at time { i } "
833+ ), f"get_ts() SPDIS qy value doesn't match get_data() at time { i } "
835834 assert np .allclose (
836835 spdis_qz [i , 1 ],
837836 rec ["qz" ][mask ][0 ],
838- ), f"get_ts() qz value doesn't match get_data() at time { i } "
837+ ), f"get_ts() SPDIS qz value doesn't match get_data() at time { i } "
839838
840839 assert not np .allclose (spdis_qx [:, 1 ], 0.0 ), "qx should have non-zero flow"
841840 assert not np .allclose (spdis_qy [:, 1 ], 0.0 ), "qy should have non-zero flow"
842841 assert np .allclose (spdis_q [:, 1 ], 0.0 ), "q should be zero for internal cells"
843842 assert np .allclose (spdis_qz [:, 1 ], 0.0 ), "qz should be zero for single layer"
844843
844+ text = "CHD"
845+ chd = cbc .get_data (text = text )
846+ for field in ["node" , "node2" , "q" ]:
847+ assert field in chd [0 ].dtype .names
848+
849+ cellid = (0 , 0 , 0 )
850+ nn = gwf .modelgrid .get_node (cellid )[0 ]
851+
852+ chd_q = cbc .get_ts (idx = cellid , text = text )
853+
854+ # check get_ts() values match get_data() for each time step
855+ for i , rec in enumerate (chd ):
856+ mask = rec ["node" ] == nn + 1 # 1-based
857+ assert np .allclose (
858+ chd_q [i , 1 ],
859+ rec ["q" ][mask ][0 ],
860+ ), f"get_ts() CHD q value doesn't match get_data() at time { i } "
861+
845862
846863@pytest .mark .requires_exe ("mf6" )
847864def test_cellbudgetfile_get_ts_aux_vars_mf6_disv (dis_sim ):
0 commit comments