From 98385e5f28e1ac89b2f00508a7e956fc1a7f981c Mon Sep 17 00:00:00 2001 From: rowanc1 Date: Fri, 7 Mar 2014 14:14:45 -0800 Subject: [PATCH] Changed Data --> Survey --- docs/conf.py | 1 - .../richards_comparisonToCeiliaEtAl1990.py | 3 +-- simpegFLOW/Richards/RichardsProblem.py | 18 +++++++-------- simpegFLOW/Tests/test_Richards.py | 22 +++++++++---------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 70c40605..86aacce4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -19,7 +19,6 @@ import sys, os #sys.path.insert(0, os.path.abspath('.')) sys.path.append('../') -sys.path.append('../../') # -- General configuration ----------------------------------------------------- diff --git a/docs/examples/richards_comparisonToCeiliaEtAl1990.py b/docs/examples/richards_comparisonToCeiliaEtAl1990.py index c449638a..385263f8 100644 --- a/docs/examples/richards_comparisonToCeiliaEtAl1990.py +++ b/docs/examples/richards_comparisonToCeiliaEtAl1990.py @@ -1,5 +1,4 @@ import sys -sys.path.append('../') sys.path.append('../../') from SimPEG import * @@ -17,7 +16,7 @@ h = np.zeros(M.nC) + bc[0] def getFields(timeStep,method): - prob = Richards.RichardsProblem(M,model, timeStep=timeStep, timeEnd=360, + prob = Richards.RichardsProblem(model, timeStep=timeStep, timeEnd=360, boundaryConditions=bc, initialConditions=h, doNewton=False, method=method) return prob.fields(params['Ks']) diff --git a/simpegFLOW/Richards/RichardsProblem.py b/simpegFLOW/Richards/RichardsProblem.py index 2a37308b..b77b52d5 100644 --- a/simpegFLOW/Richards/RichardsProblem.py +++ b/simpegFLOW/Richards/RichardsProblem.py @@ -1,13 +1,13 @@ from SimPEG import * from Empirical import RichardsModel -class RichardsData(Data.BaseData): - """docstring for RichardsData""" +class RichardsSurvey(Survey.BaseSurvey): + """docstring for RichardsSurvey""" P = None def __init__(self, **kwargs): - Data.BaseData.__init__(self, **kwargs) + Survey.BaseSurvey.__init__(self, **kwargs) @property def dataType(self): @@ -66,11 +66,11 @@ class RichardsProblem(Problem.BaseProblem): boundaryConditions = None initialConditions = None - dataPair = RichardsData + surveyPair = RichardsSurvey modelPair = RichardsModel - def __init__(self, mesh, model, **kwargs): - Problem.BaseProblem.__init__(self, mesh, model, **kwargs) + def __init__(self, model, **kwargs): + Problem.BaseProblem.__init__(self, model, **kwargs) @property def timeStep(self): @@ -221,7 +221,7 @@ class RichardsProblem(Problem.BaseProblem): B = np.array(sp.vstack(Bs).todense()) Ainv = Solver(A) - P = self.data.projectFieldsDeriv(u, m) + P = self.survey.projectFieldsDeriv(u, m) J = P * Ainv.solve(B) return J @@ -244,14 +244,14 @@ class RichardsProblem(Problem.BaseProblem): Adiaginv = Solver(Adiag) JvC[ii] = Adiaginv.solve(B*v - Asub*JvC[ii-1]) - P = self.data.projectFieldsDeriv(u, m) + P = self.survey.projectFieldsDeriv(u, m) return P * np.concatenate(JvC) def Jtvec(self, m, v, u=None): if u is None: u = self.field(m) - P = self.data.projectFieldsDeriv(u, m) + P = self.survey.projectFieldsDeriv(u, m) PTv = P.T*v # This is done via backward substitution. diff --git a/simpegFLOW/Tests/test_Richards.py b/simpegFLOW/Tests/test_Richards.py index 6dcde6c5..84c31c2e 100644 --- a/simpegFLOW/Tests/test_Richards.py +++ b/simpegFLOW/Tests/test_Richards.py @@ -114,21 +114,21 @@ class RichardsTests1D(unittest.TestCase): bc = np.array([-61.5,-20.7]) h = np.zeros(M.nC) + bc[0] - prob = Richards.RichardsProblem(M,model, timeStep=60, timeEnd=180, + prob = Richards.RichardsProblem(model, timeStep=60, timeEnd=180, boundaryConditions=bc, initialConditions=h, doNewton=False, method='mixed') q = sp.csr_matrix((np.ones(3),(np.arange(3),np.array([5,10,15]))),shape=(3,M.nC)) P = sp.kron(sp.identity(prob.numIts),q) - data = Richards.RichardsData(P=P) + survey = Richards.RichardsSurvey(P=P) - prob.pair(data) + prob.pair(survey) self.h0 = h self.M = M self.Ks = params['Ks'] self.prob = prob - self.data = data + self.survey = survey def test_Richards_getResidual_Newton(self): self.prob.doNewton = True @@ -144,7 +144,7 @@ class RichardsTests1D(unittest.TestCase): def test_Adjoint_PressureHead(self): self.prob.dataType = 'pressureHead' - v = np.random.rand(self.data.P.shape[0]) + v = np.random.rand(self.survey.P.shape[0]) z = np.random.rand(self.M.nC) Hs = self.prob.fields(self.Ks) vJz = v.dot(self.prob.Jvec(self.Ks,z,u=Hs)) @@ -157,7 +157,7 @@ class RichardsTests1D(unittest.TestCase): def test_Adjoint_Saturation(self): self.prob.dataType = 'saturation' - v = np.random.rand(self.data.P.shape[0]) + v = np.random.rand(self.survey.P.shape[0]) z = np.random.rand(self.M.nC) Hs = self.prob.fields(self.Ks) vJz = v.dot(self.prob.Jvec(self.Ks,z,u=Hs)) @@ -173,10 +173,10 @@ class RichardsTests1D(unittest.TestCase): self.prob.unpair() mTrue = np.ones(self.M.nC)*self.Ks stdev = 0.01 # The standard deviation for the noise - data = self.prob.createSyntheticData(mTrue, std=stdev, P=self.data.P) + survey = self.prob.createSyntheticSurvey(mTrue, std=stdev, P=self.survey.P) opt = Optimization.InexactGaussNewton(maxIterLS=20, maxIter=10, tolF=1e-6, tolX=1e-6, tolG=1e-6, maxIterCG=6) reg = Regularization.Tikhonov(Model.BaseModel(self.M)) - obj = ObjFunction.BaseObjFunction(data, reg) + obj = ObjFunction.BaseObjFunction(survey, reg) derChk = lambda m: [obj.dataObj(m), obj.dataObjDeriv(m)] print 'Testing Richards Derivative - Pressure Head' passed = checkDerivative(derChk, mTrue, num=5, plotIt=False) @@ -187,10 +187,10 @@ class RichardsTests1D(unittest.TestCase): self.prob.dataType = 'saturation' mTrue = np.ones(self.M.nC)*self.Ks stdev = 0.01 # The standard deviation for the noise - data = self.prob.createSyntheticData(mTrue, std=stdev, P=self.data.P) + survey = self.prob.createSyntheticSurvey(mTrue, std=stdev, P=self.survey.P) opt = Optimization.InexactGaussNewton(maxIterLS=20, maxIter=10, tolF=1e-6, tolX=1e-6, tolG=1e-6, maxIterCG=6) reg = Regularization.Tikhonov(Model.BaseModel(self.M)) - obj = ObjFunction.BaseObjFunction(data, reg) + obj = ObjFunction.BaseObjFunction(survey, reg) derChk = lambda m: [obj.dataObj(m), obj.dataObjDeriv(m)] print 'Testing Richards Derivative - Saturation' passed = checkDerivative(derChk, mTrue, num=5, plotIt=False) @@ -264,7 +264,7 @@ class RichardsTests1D(unittest.TestCase): # self.prob.dataType = 'pressureHead' # mTrue = np.ones(self.M.nC)*self.Ks # stdev = 0.01 # The standard deviation for the noise -# dobs = self.prob.createSyntheticData(mTrue,std=stdev)[0] +# dobs = self.prob.createSyntheticSurvey(mTrue,std=stdev)[0] # self.prob.dobs = dobs # self.prob.std = dobs*0 + stdev # Hs = self.prob.field(mTrue)