Skip to content

Commit

Permalink
Create copy of models
Browse files Browse the repository at this point in the history
  • Loading branch information
domfournier committed Dec 19, 2023
1 parent 5fa5e19 commit d58c460
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions geoapps/inversion/components/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,31 @@ def active_cells(self, active_cells):

@property
def starting(self):
mstart = self._starting.model
mstart = self._starting.model.copy()

if mstart is not None and self.is_sigma:
mstart = mstart.copy()
mstart = np.log(mstart)

return mstart

@property
def reference(self):
mref = self._reference.model
mref = self._reference.model.copy()

if self.driver.params.forward_only:
return mref

if mref is None:
mref = self.starting
self.driver.params.alpha_s = 0.0
elif self.is_sigma & (all(mref == 0)):
mref = self.starting
self.driver.params.alpha_s = 0.0
else:
mref = np.log(mref) if self.is_sigma else mref
mref = mref.copy()
if self.is_sigma & (all(mref == 0)):
mref = self.starting
self.driver.params.alpha_s = 0.0
else:
mref = np.log(mref) if self.is_sigma else mref
return mref

@property
Expand All @@ -146,6 +149,8 @@ def lower_bound(self):
if lbound is None:
return -np.inf

lbound = lbound.copy()

if self.is_sigma:
is_finite = np.isfinite(lbound)
lbound[is_finite] = np.log(lbound[is_finite])
Expand All @@ -158,6 +163,7 @@ def upper_bound(self):
if ubound is None:
return np.inf

ubound = ubound.copy()
if self.is_sigma:
is_finite = np.isfinite(ubound)
ubound[is_finite] = np.log(ubound[is_finite])
Expand All @@ -169,6 +175,7 @@ def conductivity(self):
mstart = self._conductivity.model

if mstart is not None and self.is_sigma:
mstart = mstart.copy()
mstart = np.log(mstart)

return mstart
Expand Down

0 comments on commit d58c460

Please sign in to comment.