From 0e6e09d9588e22f24432295af529c668a8e4b7c8 Mon Sep 17 00:00:00 2001 From: White Date: Thu, 23 Jul 2020 12:48:09 -0600 Subject: [PATCH] added PstFrom.add_py_function() to help get python functions needed for pre and post processing into the forward run script --- autotest/pst_from_tests.py | 18 ++++++++ bin/.DS_Store | Bin 12292 -> 12292 bytes pyemu/utils/pst_from.py | 83 +++++++++++++++++++++++++++++++++++-- 3 files changed, 98 insertions(+), 3 deletions(-) diff --git a/autotest/pst_from_tests.py b/autotest/pst_from_tests.py index cb45699cb..873bd80fc 100644 --- a/autotest/pst_from_tests.py +++ b/autotest/pst_from_tests.py @@ -471,6 +471,14 @@ def freyberg_prior_build_test(): # cleanup=False, port=4005) +def generic_function(): + import pandas as pd + onames = ["generic_obs_{0}".format(i) for i in range(100)] + df = pd.DataFrame({"obsval":1,"simval":2,"obsnme":onames},index=onames) + df.to_csv("generic.csv",index=False) + return df + + def mf6_freyberg_test(): import numpy as np import pandas as pd @@ -576,6 +584,16 @@ def mf6_freyberg_test(): # pf.add_observations('freyberg.hds.dat', insfile='freyberg.hds.dat.ins2', # index_cols='obsnme', use_cols='obsval', prefix='hds') + # call generic once so that the output file exists + os.chdir(template_ws) + df = generic_function() + os.chdir("..") + # add the values in generic to the ctl file + pf.add_observations("generic.csv",insfile="generic.csv.ins",index_cols="obsnme",use_cols="simval") + # add the function call to make generic to the forward run script + pf.add_py_function("pst_from_tests.py","generic_function()",is_pre_cmd=False) + + #pf.post_py_cmds.append("generic_function()") df = pd.read_csv(os.path.join(tmp_model_ws, "sfr.csv"), index_col=0) pf.add_observations("sfr.csv", insfile="sfr.csv.ins", index_cols="time", use_cols=list(df.columns.values)) v = pyemu.geostats.ExpVario(contribution=1.0,a=1000) diff --git a/bin/.DS_Store b/bin/.DS_Store index 95825ac5273c76f01dee3ea3524a0bccd5a8d017..346c402a3ec5ae87b3c35849c1432b04bfe24720 100644 GIT binary patch delta 70 zcmZokXi3;mCd^@KY@nlHWNbcJUfp@~LE#rX$RduLKPjlP!9_O9tN&n!^ME>@0szak B6L|mt delta 98 zcmZokXi3;mCM;rMYO14PXlPKYqfl*bZlI%JW^6uruY&33{lc$!u*z=Us}RM;VP