Bug fixes in Save, incorporation of data into the inversion object, taken out of problem.

This commit is contained in:
rowanc1
2013-12-06 16:54:38 -08:00
parent 09938ed7df
commit 783cd40538
4 changed files with 53 additions and 74 deletions
+12 -31
View File
@@ -1,4 +1,4 @@
from SimPEG import utils, np, sp
from SimPEG import utils, data, np, sp
norm = np.linalg.norm
@@ -37,9 +37,11 @@ class Problem(object):
__metaclass__ = utils.Save.Savable
counter = None
counter = None #: A SimPEG.utils.Counter object
def __init__(self, mesh):
def __init__(self, mesh, *args, **kwargs):
utils.setKwargs(self, **kwargs)
self.mesh = mesh
@property
@@ -65,26 +67,6 @@ class Problem(object):
def P(self, value):
self._P = value
@property
def std(self):
"""
Estimated Standard Deviations.
"""
return self._std
@std.setter
def std(self, value):
self._std = value
@property
def dobs(self):
"""
Observed data.
"""
return self._dobs
@dobs.setter
def dobs(self, value):
self._dobs = value
@utils.count
def dpred(self, m, u=None):
"""
@@ -98,7 +80,7 @@ class Problem(object):
return self.P*u
@utils.count
def dataResidual(self, m, u=None):
def dataResidual(self, m, data, u=None):
"""
:param numpy.array m: geophysical model
:param numpy.array u: fields
@@ -115,7 +97,7 @@ class Problem(object):
u is the field of interest; d_obs is the observed data.
"""
return self.dpred(m, u=u) - self.dobs
return self.dpred(m, u=u) - data.dobs
@utils.timeIt
def J(self, m, v, u=None):
@@ -238,12 +220,11 @@ class Problem(object):
Returns the observed data with random Gaussian noise
and Wd which is the same size as data, and can be used to weight the inversion.
"""
dobs = self.dpred(m,u=u)
noise = std*abs(dobs)*np.random.randn(*dobs.shape)
dobs = dobs+noise
eps = np.linalg.norm(utils.mkvc(dobs),2)*1e-5
Wd = 1/(abs(dobs)*std+eps)
return dobs, Wd
dtrue = self.dpred(m,u=u)
noise = std*abs(dtrue)*np.random.randn(*dtrue.shape)
dobs = dtrue+noise
stdev = dobs*0 + std
return data.SimPEGData(self, dobs=dobs, std=stdev, dtrue=dtrue, mtrue=m)