Skip to content

Commit

Permalink
Merge pull request #33 from jtwhite79/hotfix_m2o
Browse files Browse the repository at this point in the history
mod2obs with different depvar names
  • Loading branch information
jtwhite79 authored Oct 10, 2024
2 parents 357d5ce + 490e60c commit e2e60d6
Show file tree
Hide file tree
Showing 36 changed files with 573 additions and 14 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# General
.DS_Store
*.swp
*.*~

# Modflow outputs
*.lst
*.list
*.grb
*.cbc
*.cbb
*.bud
*.hds
*.hed
*.ucn
*.out
*.out.csv

# Byte-compiled / optimized
__pycache__/
*.py[cod]
Expand All @@ -9,6 +27,7 @@ __pycache__/
*.o
*.obj
*.so
*.lib

# Local installation and misc. dirs
inst/
Expand Down
1 change: 0 additions & 1 deletion etc/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ dependencies:
- git+https://github.com/modflowpy/flopy.git
- pdoc3


# Win64 may also want
# - m2w64-gcc-fortran
8 changes: 4 additions & 4 deletions examples/exploring_lowlevel_pypestutils_functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,9 @@
" ppeasting.append(Easting[i,j])\n",
" ppnorthing.append(Northing[i,j])\n",
" ppval.append(r[i,j])\n",
"ppeasting = np.array(ppeasting)\n",
"ppnorthing = np.array(ppnorthing)\n",
"ppval = np.array(ppval)\n",
"ppeasting = np.asarray(ppeasting)\n",
"ppnorthing = np.asarray(ppnorthing)\n",
"ppval = np.asarray(ppval)\n",
"ppeasting.shape,ppnorthing.shape,ppval.shape"
]
},
Expand Down Expand Up @@ -793,7 +793,7 @@
"metadata": {},
"outputs": [],
"source": [
"result = lib.krige_using_file(fac_file,\"binary\",len(easting),\"ordinary\",\"none\",np.array(ppval),np.zeros_like(easting),0)"
"result = lib.krige_using_file(fac_file,\"binary\",len(easting),\"ordinary\",\"none\",ppval,np.zeros_like(easting),0)"
]
},
{
Expand Down
7 changes: 4 additions & 3 deletions pypestutils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __init__(
raise KeyError(f"'{name}' defined more than once")
self._names.append(name)
# Each must be 1D and the same shape
ar = np.array(float_arrays[name], np.float64, order="F")
ar = np.asarray(float_arrays[name], np.float64, order="F")
if ar.ndim != 1:
raise ValueError(f"expected '{name}' ndim to be 1; found {ar.ndim}")
if not self.shape:
Expand All @@ -157,14 +157,15 @@ def __init__(
if name in self._names:
raise KeyError(f"'{name}' defined more than once")
self._names.append(name)
float_any[name] = ar = np.array(float_any[name], np.float64, order="F")
float_any[name] = ar = np.asarray(
float_any[name], np.float64, order="F")
if not self.shape and ar.ndim == 1:
self.shape = ar.shape
for name in int_any.keys():
if name in self._names:
raise KeyError(f"'{name}' defined more than once")
self._names.append(name)
int_any[name] = ar = np.array(int_any[name], order="F")
int_any[name] = ar = np.asarray(int_any[name], order="F")
if not self.shape and ar.ndim == 1:
self.shape = ar.shape
if not self.shape:
Expand Down
2 changes: 1 addition & 1 deletion pypestutils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def mod2obs_mf6(gridinfo_fname: str,depvar_fname: str,obscsv_fname: str ,model_t
print("warning: the following site(s) failed to have interpolation factors calculated:")
fsites = usitedf.reset_index().site.iloc[interp_fac_results==0].to_list()
print(fsites)
all_results = lib.interp_from_mf6_depvar_file(depvar_fname,fac_file,"binary",depvar_info["ntime"],"head",interp_thresh,True,
all_results = lib.interp_from_mf6_depvar_file(depvar_fname,fac_file,"binary",depvar_info["ntime"],depvar_name,interp_thresh,True,
no_interp_val,usitedf.shape[0])
datetimes = start_datetime+pd.to_timedelta(all_results["simtime"],unit=model_timeunit)
allresults_df = pd.DataFrame(all_results["simstate"],index=datetimes,columns=usitedf.index)
Expand Down
9 changes: 4 additions & 5 deletions pypestutils/pestutilslib.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Mid-level pestutilslib module to implement ctypes functions."""

from __future__ import annotations

import logging
Expand Down Expand Up @@ -387,10 +386,10 @@ def interp_to_obstime(
np.ndarray
Time-interpolated simulation values with shape (nobs,).
"""
simtime = np.array(simtime, dtype=np.float64, order="F")
simval = np.array(simval, dtype=np.float64, order="F")
obspoint = np.array(obspoint, order="F")
obstime = np.array(obstime, dtype=np.float64, order="F")
simtime = np.asarray(simtime, dtype=np.float64, order="F")
simval = np.asarray(simval, dtype=np.float64, order="F")
obspoint = np.asarray(obspoint, order="F")
obstime = np.asarray(obstime, dtype=np.float64, order="F")
if simtime.ndim != 1:
raise ValueError("expected 'simtime' to have ndim=1")
elif simval.ndim != 2:
Expand Down
40 changes: 40 additions & 0 deletions tests/data/p09/gwf-p09-mf6.chd
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# File generated by Flopy version 3.7.0.dev0 on 05/14/2024 at 15:14:54.
BEGIN options
auxiliary CONCENTRATION
END options

BEGIN dimensions
MAXBOUND 28
END dimensions

BEGIN period 1
1 1 1 2.50000000E+02 0.00000000E+00
1 18 1 2.00000000E+01 0.00000000E+00
1 1 2 2.50000000E+02 0.00000000E+00
1 18 2 2.25000000E+01 0.00000000E+00
1 1 3 2.50000000E+02 0.00000000E+00
1 18 3 2.50000000E+01 0.00000000E+00
1 1 4 2.50000000E+02 0.00000000E+00
1 18 4 2.75000000E+01 0.00000000E+00
1 1 5 2.50000000E+02 0.00000000E+00
1 18 5 3.00000000E+01 0.00000000E+00
1 1 6 2.50000000E+02 0.00000000E+00
1 18 6 3.25000000E+01 0.00000000E+00
1 1 7 2.50000000E+02 0.00000000E+00
1 18 7 3.50000000E+01 0.00000000E+00
1 1 8 2.50000000E+02 0.00000000E+00
1 18 8 3.75000000E+01 0.00000000E+00
1 1 9 2.50000000E+02 0.00000000E+00
1 18 9 4.00000000E+01 0.00000000E+00
1 1 10 2.50000000E+02 0.00000000E+00
1 18 10 4.25000000E+01 0.00000000E+00
1 1 11 2.50000000E+02 0.00000000E+00
1 18 11 4.50000000E+01 0.00000000E+00
1 1 12 2.50000000E+02 0.00000000E+00
1 18 12 4.75000000E+01 0.00000000E+00
1 1 13 2.50000000E+02 0.00000000E+00
1 18 13 5.00000000E+01 0.00000000E+00
1 1 14 2.50000000E+02 0.00000000E+00
1 18 14 5.25000000E+01 0.00000000E+00
END period 1

42 changes: 42 additions & 0 deletions tests/data/p09/gwf-p09-mf6.dis
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# File generated by Flopy version 3.7.0.dev0 on 05/14/2024 at 15:14:54.
BEGIN options
LENGTH_UNITS meters
END options

BEGIN dimensions
NLAY 1
NROW 18
NCOL 14
END dimensions

BEGIN griddata
delr
CONSTANT 100.00000000
delc
CONSTANT 100.00000000
top
CONSTANT 0.00000000
botm
CONSTANT -10.00000000
idomain
INTERNAL FACTOR 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1
END griddata

Binary file added tests/data/p09/gwf-p09-mf6.dis.grb
Binary file not shown.
Binary file added tests/data/p09/gwf-p09-mf6.hds
Binary file not shown.
25 changes: 25 additions & 0 deletions tests/data/p09/gwf-p09-mf6.hds.all.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
,site1
2000-04-10,0.9201481898615829
2000-07-19,1.8174624075062107
2000-10-27,2.673376944047418
2001-02-04,3.478759967373495
2001-05-15,4.230300686465257
2001-08-23,4.928176343388853
2001-12-01,5.574558339297976
2002-03-11,6.172667022899383
2002-06-19,6.726183761086104
2002-09-27,7.238894344063356
2003-01-05,7.714480997061258
2003-04-15,8.156408812297478
2003-07-24,8.567871250830635
2003-11-01,8.951771778224016
2004-02-09,9.310726863434926
2004-05-19,9.647080926047904
2004-08-27,9.962927316107594
2004-12-05,10.26013168493022
2005-03-15,10.540355572727687
2005-06-23,10.805078976632442
2005-10-01,11.055621253955753
2006-01-09,11.293160081237884
2006-04-19,11.518748409603724
2006-07-28,11.7333294835427
24 changes: 24 additions & 0 deletions tests/data/p09/gwf-p09-mf6.ic
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# File generated by Flopy version 3.7.0.dev0 on 05/14/2024 at 15:14:54.
BEGIN griddata
strt
INTERNAL FACTOR 1.0
250.00000000 250.00000000 250.00000000 250.00000000 250.00000000 250.00000000 250.00000000 250.00000000 250.00000000 250.00000000 250.00000000 250.00000000 250.00000000 250.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
20.00000000 22.50000000 25.00000000 27.50000000 30.00000000 32.50000000 35.00000000 37.50000000 40.00000000 42.50000000 45.00000000 47.50000000 50.00000000 52.50000000
END griddata

21 changes: 21 additions & 0 deletions tests/data/p09/gwf-p09-mf6.ims
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# File generated by Flopy version 3.7.0.dev0 on 05/14/2024 at 15:14:54.
BEGIN options
PRINT_OPTION summary
END options

BEGIN nonlinear
OUTER_DVCLOSE 1.00000000E-06
OUTER_MAXIMUM 100
UNDER_RELAXATION none
END nonlinear

BEGIN linear
INNER_MAXIMUM 300
INNER_DVCLOSE 1.00000000E-06
inner_rclose 1.00000000E-06
LINEAR_ACCELERATION cg
RELAXATION_FACTOR 1.00000000
SCALING_METHOD none
REORDERING_METHOD none
END linear

15 changes: 15 additions & 0 deletions tests/data/p09/gwf-p09-mf6.nam
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# File generated by Flopy version 3.7.0.dev0 on 05/14/2024 at 15:14:54.
BEGIN options
SAVE_FLOWS
END options

BEGIN packages
DIS6 gwf-p09-mf6.dis dis
IC6 gwf-p09-mf6.ic ic
NPF6 gwf-p09-mf6.npf npf
STO6 gwf-p09-mf6.sto sto
CHD6 gwf-p09-mf6.chd chd-1
WEL6 gwf-p09-mf6.wel wel-1
OC6 gwf-p09-mf6.oc oc
END packages

Loading

0 comments on commit e2e60d6

Please sign in to comment.