Skip to content

Commit

Permalink
Update csub autotests to be consistent with redefined observations op…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
jdhughes-usgs committed Dec 20, 2024
1 parent 0f9463b commit 8bd4985
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 56 deletions.
39 changes: 36 additions & 3 deletions autotest/test_gwf_csub_obs.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
import os

import flopy
import numpy as np
import pytest
from framework import TestFramework

obs_names = [
"delay-flowtop", "delay-flowtop",
"delay-flowbot", "delay-flowbot",
"delay-head", "delay-head",
"delay-gstress", "delay-gstress",
"delay-estress", "delay-estress",
"delay-preconstress", "delay-preconstress",
"delay-compaction", "delay-compaction",
"delay-thickness", "delay-thickness",
"delay-theta", "delay-theta",
"csub", "csub",
"inelastic-csub", "inelastic-csub",
"elastic-csub", "elastic-csub",
"interbed-compaction", "interbed-compaction",
"inelastic-compaction", "inelastic-compaction",
"elastic-compaction", "elastic-compaction",
]
boundname = [
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
Expand All @@ -19,6 +40,18 @@
False, False,
False, False,
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
False, True,
False, False,
False, False,
False, False,
False, True,
False, True,
False, True,
]
cases = [f"csub_obs{idx + 1:02d}" for idx, _ in enumerate(obs_names)]

Expand Down
6 changes: 3 additions & 3 deletions autotest/test_gwf_csub_sub03.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ def get_model(idx, ws):
)
orecarray = {}
orecarray["csub_obs.csv"] = [
("tcomp1", "interbed-compaction", "01_05_05"),
("tcomp2", "interbed-compaction", "02_05_05"),
("tcomp3", "interbed-compaction", "03_05_05"),
("tcomp1", "interbed-compaction", (44,)),
("tcomp2", "interbed-compaction", (140,)),
("tcomp3", "interbed-compaction", (240,)),
]
csub_obs_package = csub.obs.initialize(
filename=opth, digits=10, print_input=True, continuous=orecarray
Expand Down
2 changes: 1 addition & 1 deletion autotest/test_gwf_csub_subwt01.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def get_model(idx, ws):
)
orecarray = {}
orecarray["csub_obs.csv"] = [
("w1l1", "interbed-compaction", "01_01_02"),
("w1l1", "compaction-cell", (0, 0, 1)),
("w1l1t", "csub-cell", (0, 0, 1)),
]
csub_obs_package = csub.obs.initialize(
Expand Down
18 changes: 9 additions & 9 deletions autotest/test_gwf_csub_subwt02.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,14 @@ def get_model(idx, ws):
)

cobs = [
("w1l1", "interbed-compaction", "01_09_10"),
("w1l2", "interbed-compaction", "02_09_10"),
("w1l3", "interbed-compaction", "03_09_10"),
("w1l4", "interbed-compaction", "04_09_10"),
("w2l1", "interbed-compaction", "01_12_07"),
("w2l2", "interbed-compaction", "02_12_07"),
("w2l3", "interbed-compaction", "03_12_07"),
("w2l4", "interbed-compaction", "04_12_07"),
("w1l1", "interbed-compaction", (89,)),
("w1l2", "interbed-compaction", (299,)),
("w1l3", "interbed-compaction", (509,)),
("w1l4", "interbed-compaction", (719,)),
("w2l1", "interbed-compaction", (130,)),
("w2l2", "interbed-compaction", (340,)),
("w2l3", "interbed-compaction", (550,)),
("w2l4", "interbed-compaction",(760,)),
("s1l1", "coarse-compaction", (0, 8, 9)),
("s1l2", "coarse-compaction", (1, 8, 9)),
("s1l3", "coarse-compaction", (2, 8, 9)),
Expand Down Expand Up @@ -383,7 +383,7 @@ def get_model(idx, ws):
("pc4", "preconstress-cell", (3, 8, 9)),
("sk1l2", "ske-cell", (1, 8, 9)),
("sk2l4", "ske-cell", (3, 11, 6)),
("t1l2", "theta", "02_09_10"),
("t1l2", "theta", (1, 8, 9)),
]

orecarray = {"csub_obs.csv": cobs}
Expand Down
8 changes: 4 additions & 4 deletions autotest/test_gwf_csub_zdisp01.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ def build_models(idx, test):
packagedata=sub6,
)
orecarray = {}
tag = f"{3:02d}_{wrp[0] + 1:02d}_{wcp[0] + 1:02d}"
oloc = (2, wrp[0], wcp[0])
ibloc = (449,)
orecarray["csub_obs.csv"] = [
("tcomp3", "interbed-compaction", tag),
("tcomp3", "interbed-compaction", ibloc),
("sk-tcomp3", "coarse-compaction", oloc),
("ibi-tcomp3", "inelastic-compaction", tag),
("ibe-tcomp3", "elastic-compaction", tag),
("ibi-tcomp3", "inelastic-compaction", ibloc),
("ibe-tcomp3", "elastic-compaction", ibloc),
]
csub_obs_package = csub.obs.initialize(
filename=opth, digits=10, print_input=True, continuous=orecarray
Expand Down
2 changes: 1 addition & 1 deletion doc/Common/gwf-csubobs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
CSUB & coarse-thickness & cellid & -- & thickness of coarse-grained materials in a GWF cell. \\
CSUB & thickness-cell & cellid & -- & total thickness of coarse-grained materials and all interbeds in a GWF cell. \\

CSUB & theta & icsubno or boundname & -- & porosity of a interbed or group of interbeds. \\
CSUB & theta & icsubno & -- & porosity of a interbed. \\
CSUB & coarse-theta & cellid & -- & porosity of coarse-grained materials in a GWF cell. \\
CSUB & theta-cell & cellid & -- & thickness-weighted porosity of coarse-grained materials and all interbeds in a GWF cell. \\

Expand Down
73 changes: 38 additions & 35 deletions src/Model/GroundWaterFlow/gwf-csub.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7341,10 +7341,18 @@ subroutine csub_process_obsID(obsrv, dis, inunitobs, iout)
character(len=LINELENGTH) :: string
character(len=LENBOUNDNAME) :: bndname
logical(LGP) :: flag_string
logical(LGP) :: flag_idcellno
logical(LGP) :: flag_error
!
! -- initialize variables
string = obsrv%IDstring
flag_string = .TRUE.
flag_idcellno = .FALSE.
flag_error = .FALSE.
if (obsrv%ObsTypeId(1:5) == "DELAY" .AND. &
obsrv%ObsTypeId(1:10) /= "DELAY-FLOW") then
flag_idcellno = .TRUE.
end if
!
! -- Extract reach number from string and store it.
! If 1st item is not an integer(I4B), it should be a
Expand Down Expand Up @@ -7372,7 +7380,7 @@ subroutine csub_process_obsID(obsrv, dis, inunitobs, iout)
obsrv%ObsTypeId == 'DELAY-FLOWTOP' .or. &
obsrv%ObsTypeId == 'DELAY-FLOWBOT') then
call extract_idnum_or_bndname(string, icol, istart, istop, nn1, bndname)
! read cellid
! read cellid
else
nn1 = dis%noder_from_string(icol, istart, istop, inunitobs, &
iout, string, flag_string)
Expand All @@ -7382,57 +7390,52 @@ subroutine csub_process_obsID(obsrv, dis, inunitobs, iout)
obsrv%ObsTypeId == 'SKE' .or. &
obsrv%ObsTypeId == 'THETA' .or. &
obsrv%ObsTypeId == 'THICKNESS' .or. &
obsrv%ObsTypeId == 'INTERBED-COMPACTION' .or. &
obsrv%ObsTypeId == 'INELASTIC-COMPACTION' .or. &
obsrv%ObsTypeId == 'ELASTIC-COMPACTION' .or. &
obsrv%ObsTypeId == 'DELAY-HEAD' .or. &
obsrv%ObsTypeId == 'DELAY-GSTRESS' .or. &
obsrv%ObsTypeId == 'DELAY-ESTRESS' .or. &
obsrv%ObsTypeId == 'DELAY-PRECONSTRESS' .or. &
obsrv%ObsTypeId == 'DELAY-COMPACTION' .or. &
obsrv%ObsTypeId == 'DELAY-THICKNESS' .or. &
obsrv%ObsTypeId == 'DELAY-THETA') then
if (nn1 == NAMEDBOUNDFLAG) then
write (errmsg, '(5a)') &
"BOUNDNAME ('", trim(adjustl(bndname)), &
"') not allowed for CSUB observation type '", &
trim(adjustl(obsrv%ObsTypeId)), "'."
call store_error(errmsg)
end if
! boundnames are allowed for these observation types
if (nn1 == NAMEDBOUNDFLAG) then
write (errmsg, '(5a)') &
"BOUNDNAME ('", trim(adjustl(bndname)), &
"') not allowed for CSUB observation type '", &
trim(adjustl(obsrv%ObsTypeId)), "'."
call store_error(errmsg)
flag_error = .TRUE.
end if
! boundnames are allowed for these observation types
else if (obsrv%ObsTypeId == 'CSUB' .or. &
obsrv%ObsTypeId == 'INELASTIC-CSUB' .or. &
obsrv%ObsTypeId == 'ELASTIC-CSUB' .or. &
! obsrv%ObsTypeId == 'THICKNESS' .or. &
obsrv%ObsTypeId == 'INTERBED-COMPACTION' .or. &
obsrv%ObsTypeId == 'INELASTIC-COMPACTION' .or. &
obsrv%ObsTypeId == 'ELASTIC-COMPACTION' .or. &
! obsrv%ObsTypeId == 'INTERBED-COMPACTION' .or. &
! obsrv%ObsTypeId == 'INELASTIC-COMPACTION' .or. &
! obsrv%ObsTypeId == 'ELASTIC-COMPACTION' .or. &
obsrv%ObsTypeId == 'DELAY-FLOWTOP' .or. &
obsrv%ObsTypeId == 'DELAY-FLOWBOT') then
if (nn1 == NAMEDBOUNDFLAG) then
obsrv%FeatureName = bndname
else
if (obsrv%ObsTypeId == 'DELAY-HEAD' .or. &
obsrv%ObsTypeId == 'DELAY-GSTRESS' .or. &
obsrv%ObsTypeId == 'DELAY-ESTRESS' .or. &
obsrv%ObsTypeId == 'DELAY-PRECONSTRESS' .or. &
obsrv%ObsTypeId == 'DELAY-COMPACTION' .or. &
obsrv%ObsTypeId == 'DELAY-THICKNESS' .or. &
obsrv%ObsTypeId == 'DELAY-THETA') then
call extract_idnum_or_bndname(string, icol, istart, istop, nn2, bndname)
if (nn2 == NAMEDBOUNDFLAG) then
write (errmsg, '(5a)') &
"BOUNDNAME ('", trim(adjustl(bndname)), &
"') not allowed for CSUB observation type '", &
trim(adjustl(obsrv%ObsTypeId)), "' idcellno."
call store_error(errmsg)
! obsrv%FeatureName = bndname
! ! -- reset nn1
! nn1 = nn2
else
obsrv%NodeNumber2 = nn2
end if
end if
end if
! read idcellno for delay observations
if (flag_idcellno .EQV. .TRUE. .AND. flag_error .EQV. .FALSE.) then
if (nn1 /= NAMEDBOUNDFLAG) then
call extract_idnum_or_bndname(string, icol, istart, istop, nn2, bndname)
if (nn2 == NAMEDBOUNDFLAG) then
write (errmsg, '(5a)') &
"BOUNDNAME ('", trim(adjustl(bndname)), &
"') not allowed for CSUB observation type '", &
trim(adjustl(obsrv%ObsTypeId)), "' idcellno."
call store_error(errmsg)
else
obsrv%NodeNumber2 = nn2
end if
end if
end if

!
! -- store reach number (NodeNumber)
obsrv%NodeNumber = nn1
Expand Down

0 comments on commit 8bd4985

Please sign in to comment.