mirror of
https://github.com/wassname/simpeg.git
synced 2026-07-03 14:53:42 +08:00
Futurize 1, futurize 2, pasteurize.
This commit is contained in:
+12
-3
@@ -1,3 +1,12 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from builtins import super
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from SimPEG import *
|
||||
|
||||
class FieldsDC_CC(Problem.Fields):
|
||||
@@ -61,7 +70,7 @@ class SrcDipole(Survey.BaseSrc):
|
||||
pts = [self.loc[0], self.loc[1]]
|
||||
inds = Utils.closestPoints(prob.mesh, pts)
|
||||
q = np.zeros(prob.mesh.nC)
|
||||
q[inds] = - self.current * ( np.r_[1., -1.] / prob.mesh.vol[inds] )
|
||||
q[inds] = - self.current * ( old_div(np.r_[1., -1.], prob.mesh.vol[inds]) )
|
||||
# self._rhsDict[mesh] = q
|
||||
# return self._rhsDict[mesh]
|
||||
return q
|
||||
@@ -145,7 +154,7 @@ class ProblemDC_CC(Problem.BaseProblem):
|
||||
if getattr(self, '_Msig', None) is None:
|
||||
sigma = self.curModel.transform
|
||||
Av = self.mesh.aveF2CC
|
||||
self._Msig = Utils.sdiag(1/(self.mesh.dim * Av.T * (1/sigma)))
|
||||
self._Msig = Utils.sdiag(old_div(1,(self.mesh.dim * Av.T * (old_div(1,sigma)))))
|
||||
return self._Msig
|
||||
|
||||
@property
|
||||
@@ -153,7 +162,7 @@ class ProblemDC_CC(Problem.BaseProblem):
|
||||
if getattr(self, '_dMdsig', None) is None:
|
||||
sigma = self.curModel.transform
|
||||
Av = self.mesh.aveF2CC
|
||||
dMdprop = self.mesh.dim * Utils.sdiag(self.Msig.diagonal()**2) * Av.T * Utils.sdiag(1./sigma**2)
|
||||
dMdprop = self.mesh.dim * Utils.sdiag(self.Msig.diagonal()**2) * Av.T * Utils.sdiag(old_div(1.,sigma**2))
|
||||
self._dMdsig = lambda Gu: Utils.sdiag(Gu) * dMdprop
|
||||
return self._dMdsig
|
||||
|
||||
|
||||
+11
-3
@@ -1,5 +1,13 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from SimPEG import *
|
||||
from BaseDC import SurveyDC, FieldsDC_CC
|
||||
from .BaseDC import SurveyDC, FieldsDC_CC
|
||||
|
||||
class SurveyIP(SurveyDC):
|
||||
"""
|
||||
@@ -52,7 +60,7 @@ class ProblemIP(Problem.BaseProblem):
|
||||
# sigma = self.curModel.transform
|
||||
sigma = self.sigma
|
||||
Av = self.mesh.aveF2CC
|
||||
self._Msig = Utils.sdiag(1/(self.mesh.dim * Av.T * (1/sigma)))
|
||||
self._Msig = Utils.sdiag(old_div(1,(self.mesh.dim * Av.T * (old_div(1,sigma)))))
|
||||
return self._Msig
|
||||
|
||||
@property
|
||||
@@ -61,7 +69,7 @@ class ProblemIP(Problem.BaseProblem):
|
||||
# sigma = self.curModel.transform
|
||||
sigma = self.sigma
|
||||
Av = self.mesh.aveF2CC
|
||||
dMdprop = self.mesh.dim * Utils.sdiag(self.Msig.diagonal()**2) * Av.T * Utils.sdiag(1./sigma**2)
|
||||
dMdprop = self.mesh.dim * Utils.sdiag(self.Msig.diagonal()**2) * Av.T * Utils.sdiag(old_div(1.,sigma**2))
|
||||
self._dMdsig = lambda Gu: Utils.sdiag(Gu) * dMdprop
|
||||
return self._dMdsig
|
||||
|
||||
|
||||
+40
-29
@@ -1,6 +1,17 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from builtins import open
|
||||
from builtins import int
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import map
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from SimPEG import np, Utils
|
||||
import BaseDC as DC
|
||||
import BaseDC as IP
|
||||
from . import BaseDC as DC
|
||||
from . import BaseDC as IP
|
||||
import warnings
|
||||
|
||||
def getActiveindfromTopo(mesh, topo):
|
||||
@@ -67,7 +78,7 @@ def readUBC_DC3Dobstopo(filename,mesh,topo,probType="CC"):
|
||||
if "!" in line.split(): continue
|
||||
elif line == '\n': continue
|
||||
elif line == ' \n': continue
|
||||
temp = map(float, line.split())
|
||||
temp = list(map(float, line.split()))
|
||||
# Read a line for the current electrode
|
||||
if len(temp) == 5: # SRC: Only X and Y are provided (assume no topography)
|
||||
#TODO consider topography and assign the closest cell center in the earth
|
||||
@@ -211,8 +222,8 @@ def plot_pseudoSection(DCsurvey, axs, surveyType='dipole-dipole', unitType='volt
|
||||
MN = np.abs(Rx[1][:,0] - Rx[0][:,0])
|
||||
|
||||
# Create mid-point location
|
||||
Cmid = (Tx[0][0] + Tx[1][0])/2
|
||||
Pmid = (Rx[0][:,0] + Rx[1][:,0])/2
|
||||
Cmid = old_div((Tx[0][0] + Tx[1][0]),2)
|
||||
Pmid = old_div((Rx[0][:,0] + Rx[1][:,0]),2)
|
||||
|
||||
# Change output for unitType
|
||||
if unitType == 'volt':
|
||||
@@ -228,16 +239,16 @@ def plot_pseudoSection(DCsurvey, axs, surveyType='dipole-dipole', unitType='volt
|
||||
|
||||
elif surveyType == 'dipole-dipole':
|
||||
|
||||
leg = data * 2*np.pi / ( 1/MA - 1/MB - 1/NB + 1/NA )
|
||||
leg = data * 2*np.pi / ( old_div(1,MA) - old_div(1,MB) - old_div(1,NB) + old_div(1,NA) )
|
||||
|
||||
else:
|
||||
print """unitType must be 'pole-dipole' | 'dipole-dipole' """
|
||||
print("""unitType must be 'pole-dipole' | 'dipole-dipole' """)
|
||||
break
|
||||
|
||||
|
||||
if unitType == 'appConductivity':
|
||||
|
||||
leg = np.log10(abs(1./leg))
|
||||
leg = np.log10(abs(old_div(1.,leg)))
|
||||
rho = np.hstack([rho,leg])
|
||||
|
||||
elif unitType == 'appResistivity':
|
||||
@@ -246,11 +257,11 @@ def plot_pseudoSection(DCsurvey, axs, surveyType='dipole-dipole', unitType='volt
|
||||
rho = np.hstack([rho,leg])
|
||||
|
||||
else:
|
||||
print """unitType must be 'appResistivity' | 'appConductivity' | 'volt' """
|
||||
print("""unitType must be 'appResistivity' | 'appConductivity' | 'volt' """)
|
||||
break
|
||||
|
||||
midx = np.hstack([midx, ( Cmid + Pmid )/2 ])
|
||||
midz = np.hstack([midz, -np.abs(Cmid-Pmid)/2 + (Tx[0][2] + Tx[1][2])/2 ])
|
||||
midx = np.hstack([midx, old_div(( Cmid + Pmid ),2) ])
|
||||
midz = np.hstack([midz, old_div(-np.abs(Cmid-Pmid),2) + old_div((Tx[0][2] + Tx[1][2]),2) ])
|
||||
|
||||
# Grid points
|
||||
grid_x, grid_z = np.mgrid[np.min(midx):np.max(midx), np.min(midz):np.max(midz)]
|
||||
@@ -337,14 +348,14 @@ def gen_DCIPsurvey(endl, mesh, surveyType, AM_sep, MN_sep, nrx):
|
||||
# Mesure survey length and direction
|
||||
dl_len = xy_2_r(endl[0,0],endl[1,0],endl[0,1],endl[1,1])
|
||||
|
||||
dl_x = ( endl[1,0] - endl[0,0] ) / dl_len
|
||||
dl_y = ( endl[1,1] - endl[0,1] ) / dl_len
|
||||
dl_x = old_div(( endl[1,0] - endl[0,0] ), dl_len)
|
||||
dl_y = old_div(( endl[1,1] - endl[0,1] ), dl_len)
|
||||
|
||||
nstn = np.floor( dl_len / AM_sep )
|
||||
nstn = np.floor( old_div(dl_len, AM_sep) )
|
||||
|
||||
# Compute discrete pole location along line
|
||||
stn_x = endl[0,0] + np.array(range(int(nstn)))*dl_x*AM_sep
|
||||
stn_y = endl[0,1] + np.array(range(int(nstn)))*dl_y*AM_sep
|
||||
stn_x = endl[0,0] + np.array(list(range(int(nstn))))*dl_x*AM_sep
|
||||
stn_y = endl[0,1] + np.array(list(range(int(nstn))))*dl_y*AM_sep
|
||||
|
||||
# Create line of P1 locations
|
||||
M = np.c_[stn_x, stn_y, np.ones(nstn).T*mesh.vectorNz[-1]]
|
||||
@@ -376,15 +387,15 @@ def gen_DCIPsurvey(endl, mesh, surveyType, AM_sep, MN_sep, nrx):
|
||||
AB = xy_2_r(tx[0,1],endl[1,0],tx[1,1],endl[1,1])
|
||||
|
||||
# Number of receivers to fit
|
||||
nstn = np.min([np.floor( (AB - MN_sep) / AM_sep ) , nrx])
|
||||
nstn = np.min([np.floor( old_div((AB - MN_sep), AM_sep) ) , nrx])
|
||||
|
||||
# Check if there is enough space, else break the loop
|
||||
if nstn <= 0:
|
||||
continue
|
||||
|
||||
# Compute discrete pole location along line
|
||||
stn_x = N[ii,0] + dl_x*MN_sep + np.array(range(int(nstn)))*dl_x*AM_sep
|
||||
stn_y = N[ii,1] + dl_y*MN_sep + np.array(range(int(nstn)))*dl_y*AM_sep
|
||||
stn_x = N[ii,0] + dl_x*MN_sep + np.array(list(range(int(nstn))))*dl_x*AM_sep
|
||||
stn_y = N[ii,1] + dl_y*MN_sep + np.array(list(range(int(nstn))))*dl_y*AM_sep
|
||||
|
||||
# Create receiver poles
|
||||
# Create line of P1 locations
|
||||
@@ -417,17 +428,17 @@ def gen_DCIPsurvey(endl, mesh, surveyType, AM_sep, MN_sep, nrx):
|
||||
max_y = endl[1,1] - dl_y * MN_sep
|
||||
|
||||
box_l = np.sqrt( (min_x - max_x)**2 + (min_y - max_y)**2 )
|
||||
box_w = box_l/2.
|
||||
box_w = old_div(box_l,2.)
|
||||
|
||||
nstn = np.floor( box_l / AM_sep )
|
||||
nstn = np.floor( old_div(box_l, AM_sep) )
|
||||
|
||||
# Compute discrete pole location along line
|
||||
stn_x = min_x + np.array(range(int(nstn)))*dl_x*AM_sep
|
||||
stn_y = min_y + np.array(range(int(nstn)))*dl_y*AM_sep
|
||||
stn_x = min_x + np.array(list(range(int(nstn))))*dl_x*AM_sep
|
||||
stn_y = min_y + np.array(list(range(int(nstn))))*dl_y*AM_sep
|
||||
|
||||
# Define number of cross lines
|
||||
nlin = int(np.floor( box_w / AM_sep ))
|
||||
lind = range(-nlin,nlin+1)
|
||||
nlin = int(np.floor( old_div(box_w, AM_sep) ))
|
||||
lind = list(range(-nlin,nlin+1))
|
||||
|
||||
ngrad = nstn * len(lind)
|
||||
|
||||
@@ -449,7 +460,7 @@ def gen_DCIPsurvey(endl, mesh, surveyType, AM_sep, MN_sep, nrx):
|
||||
srcClass = DC.SrcDipole([rxClass], M[0,:], N[-1,:])
|
||||
SrcList.append(srcClass)
|
||||
else:
|
||||
print """surveyType must be either 'pole-dipole', 'dipole-dipole' or 'gradient'. """
|
||||
print("""surveyType must be either 'pole-dipole', 'dipole-dipole' or 'gradient'. """)
|
||||
|
||||
survey = DC.SurveyDC(SrcList)
|
||||
return survey, Tx, Rx
|
||||
@@ -668,7 +679,7 @@ def readUBC_DC3Dobs(fileName, rtype = 'DC'):
|
||||
obsfile = np.genfromtxt(fileName,delimiter=' \n',dtype=np.str,comments='!')
|
||||
|
||||
else:
|
||||
print "rtype must be 'DC'(default) | 'IP'"
|
||||
print("rtype must be 'DC'(default) | 'IP'")
|
||||
|
||||
# Pre-allocate
|
||||
srcLists = []
|
||||
@@ -983,7 +994,7 @@ def xy_2_lineID(DCsurvey):
|
||||
ang2 = np.abs(vec3.dot(vec4))
|
||||
|
||||
# If the angles are smaller then 45d, than next point is on a new line
|
||||
if ((ang1 < np.cos(np.pi/4.)) | (ang2 < np.cos(np.pi/4.))) & (np.all(np.r_[r1,r2,r3,r4] > 0)):
|
||||
if ((ang1 < np.cos(old_div(np.pi,4.))) | (ang2 < np.cos(old_div(np.pi,4.)))) & (np.all(np.r_[r1,r2,r3,r4] > 0)):
|
||||
|
||||
# Re-initiate start and mid-point location
|
||||
xy0 = A[:2]
|
||||
@@ -1023,7 +1034,7 @@ def r_unit(p1,p2):
|
||||
|
||||
|
||||
if r!=0:
|
||||
vec = dx/r
|
||||
vec = old_div(dx,r)
|
||||
|
||||
else:
|
||||
vec = np.zeros(len(p1))
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
import numpy as np
|
||||
|
||||
def WennerSrcList(nElecs, aSpacing, in2D=False, plotIt=False):
|
||||
@@ -5,7 +13,7 @@ def WennerSrcList(nElecs, aSpacing, in2D=False, plotIt=False):
|
||||
import SimPEG.DCIP as DC
|
||||
|
||||
elocs = np.arange(0,aSpacing*nElecs,aSpacing)
|
||||
elocs -= (nElecs*aSpacing - aSpacing)/2
|
||||
elocs -= old_div((nElecs*aSpacing - aSpacing),2)
|
||||
space = 1
|
||||
WENNER = np.zeros((0,),dtype=int)
|
||||
for ii in range(nElecs):
|
||||
|
||||
+10
-4
@@ -1,4 +1,10 @@
|
||||
from BaseDC import *
|
||||
from BaseIP import *
|
||||
from DCIPUtils import *
|
||||
import Utils
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .BaseDC import *
|
||||
from .BaseIP import *
|
||||
from .DCIPUtils import *
|
||||
from . import Utils
|
||||
|
||||
+15
-7
@@ -1,7 +1,17 @@
|
||||
import Utils, Survey, Problem, numpy as np, scipy.sparse as sp, gc
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from builtins import object
|
||||
from . import Utils, Survey, Problem
|
||||
import numpy as np, scipy.sparse as sp, gc
|
||||
from future.utils import with_metaclass
|
||||
|
||||
|
||||
class BaseDataMisfit(object):
|
||||
class BaseDataMisfit(with_metaclass(Utils.SimPEGMetaClass, object)):
|
||||
"""BaseDataMisfit
|
||||
|
||||
.. note::
|
||||
@@ -9,8 +19,6 @@ class BaseDataMisfit(object):
|
||||
You should inherit from this class to create your own data misfit term.
|
||||
"""
|
||||
|
||||
__metaclass__ = Utils.SimPEGMetaClass
|
||||
|
||||
debug = False #: Print debugging information
|
||||
counter = None #: Set this to a SimPEG.Utils.Counter() if you want to count things
|
||||
|
||||
@@ -93,14 +101,14 @@ class l2_DataMisfit(BaseDataMisfit):
|
||||
survey = self.survey
|
||||
|
||||
if getattr(survey,'std', None) is None:
|
||||
print 'SimPEG.DataMisfit.l2_DataMisfit assigning default std of 5%'
|
||||
print('SimPEG.DataMisfit.l2_DataMisfit assigning default std of 5%')
|
||||
survey.std = 0.05
|
||||
|
||||
if getattr(survey, 'eps', None) is None:
|
||||
print 'SimPEG.DataMisfit.l2_DataMisfit assigning default eps of 1e-5 * ||dobs||'
|
||||
print('SimPEG.DataMisfit.l2_DataMisfit assigning default eps of 1e-5 * ||dobs||')
|
||||
survey.eps = np.linalg.norm(Utils.mkvc(survey.dobs),2)*1e-5
|
||||
|
||||
self._Wd = Utils.sdiag(1/(abs(survey.dobs)*survey.std+survey.eps))
|
||||
self._Wd = Utils.sdiag(old_div(1,(abs(survey.dobs)*survey.std+survey.eps)))
|
||||
return self._Wd
|
||||
|
||||
@Wd.setter
|
||||
|
||||
+38
-26
@@ -1,4 +1,16 @@
|
||||
import Utils, numpy as np
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from builtins import open
|
||||
from builtins import int
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from past.utils import old_div
|
||||
from builtins import object
|
||||
from . import Utils
|
||||
import numpy as np
|
||||
|
||||
class InversionDirective(object):
|
||||
"""InversionDirective"""
|
||||
@@ -15,7 +27,7 @@ class InversionDirective(object):
|
||||
@inversion.setter
|
||||
def inversion(self, i):
|
||||
if getattr(self,'_inversion',None) is not None:
|
||||
print 'Warning: InversionDirective %s has switched to a new inversion.' % self.__name__
|
||||
print('Warning: InversionDirective %s has switched to a new inversion.' % self.__name__)
|
||||
self._inversion = i
|
||||
|
||||
@property
|
||||
@@ -68,7 +80,7 @@ class DirectiveList(object):
|
||||
def inversion(self, i):
|
||||
if self.inversion is i: return
|
||||
if getattr(self,'_inversion',None) is not None:
|
||||
print 'Warning: %s has switched to a new inversion.' % self.__name__
|
||||
print('Warning: %s has switched to a new inversion.' % self.__name__)
|
||||
for d in self.dList:
|
||||
d.inversion = i
|
||||
self._inversion = i
|
||||
@@ -120,7 +132,7 @@ class BetaEstimate_ByEig(InversionDirective):
|
||||
:return: beta0
|
||||
"""
|
||||
|
||||
if self.debug: print 'Calculating the beta0 parameter.'
|
||||
if self.debug: print('Calculating the beta0 parameter.')
|
||||
|
||||
m = self.invProb.curModel
|
||||
f = self.invProb.getFields(m, store=True, deleteWarmstart=False)
|
||||
@@ -128,7 +140,7 @@ class BetaEstimate_ByEig(InversionDirective):
|
||||
x0 = np.random.rand(*m.shape)
|
||||
t = x0.dot(self.dmisfit.eval2Deriv(m,x0,f=f))
|
||||
b = x0.dot(self.reg.eval2Deriv(m, v=x0))
|
||||
self.beta0 = self.beta0_ratio*(t/b)
|
||||
self.beta0 = self.beta0_ratio*(old_div(t,b))
|
||||
|
||||
self.invProb.beta = self.beta0
|
||||
|
||||
@@ -141,7 +153,7 @@ class BetaSchedule(InversionDirective):
|
||||
|
||||
def endIter(self):
|
||||
if self.opt.iter > 0 and self.opt.iter % self.coolingRate == 0:
|
||||
if self.debug: print 'BetaSchedule is cooling Beta. Iteration: %d' % self.opt.iter
|
||||
if self.debug: print('BetaSchedule is cooling Beta. Iteration: %d' % self.opt.iter)
|
||||
self.invProb.beta /= self.coolingFactor
|
||||
|
||||
|
||||
@@ -192,7 +204,7 @@ class SaveModelEveryIteration(SaveEveryIteration):
|
||||
"""SaveModelEveryIteration"""
|
||||
|
||||
def initialize(self):
|
||||
print "SimPEG.SaveModelEveryIteration will save your models as: '###-%s.npy'"%self.fileName
|
||||
print("SimPEG.SaveModelEveryIteration will save your models as: '###-%s.npy'"%self.fileName)
|
||||
|
||||
def endIter(self):
|
||||
np.save('%03d-%s' % (self.opt.iter, self.fileName), self.opt.xc)
|
||||
@@ -202,7 +214,7 @@ class SaveOutputEveryIteration(SaveEveryIteration):
|
||||
"""SaveModelEveryIteration"""
|
||||
|
||||
def initialize(self):
|
||||
print "SimPEG.SaveOutputEveryIteration will save your inversion progress as: '###-%s.txt'"%self.fileName
|
||||
print("SimPEG.SaveOutputEveryIteration will save your inversion progress as: '###-%s.txt'"%self.fileName)
|
||||
f = open(self.fileName+'.txt', 'w')
|
||||
f.write(" # beta phi_d phi_m f\n")
|
||||
f.close()
|
||||
@@ -216,7 +228,7 @@ class SaveOutputDictEveryIteration(SaveEveryIteration):
|
||||
"""SaveOutputDictEveryIteration"""
|
||||
|
||||
def initialize(self):
|
||||
print "SimPEG.SaveOutputDictEveryIteration will save your inversion progress as dictionary: '###-%s.npz'"%self.fileName
|
||||
print("SimPEG.SaveOutputDictEveryIteration will save your inversion progress as dictionary: '###-%s.npz'"%self.fileName)
|
||||
|
||||
def endIter(self):
|
||||
# Save the data.
|
||||
@@ -294,7 +306,7 @@ class Update_IRLS(InversionDirective):
|
||||
|
||||
# After reaching target misfit with l2-norm, switch to IRLS (mode:2)
|
||||
if self.invProb.phi_d < self.target and self.mode == 1:
|
||||
print "Convergence with smooth l2-norm regularization: Start IRLS steps..."
|
||||
print("Convergence with smooth l2-norm regularization: Start IRLS steps...")
|
||||
|
||||
self.mode = 2
|
||||
|
||||
@@ -302,17 +314,17 @@ class Update_IRLS(InversionDirective):
|
||||
# model values
|
||||
if getattr(self, 'reg.eps', None) is None:
|
||||
self.reg.eps_p = np.percentile(np.abs(self.invProb.curModel),self.prctile)
|
||||
else:
|
||||
else:
|
||||
self.reg.eps_p = self.eps[0]
|
||||
|
||||
|
||||
if getattr(self, 'reg.eps', None) is None:
|
||||
self.reg.eps_q = np.percentile(np.abs(self.reg.regmesh.cellDiffxStencil*(self.reg.mapping * self.invProb.curModel)),self.prctile)
|
||||
else:
|
||||
else:
|
||||
self.reg.eps_q = self.eps[1]
|
||||
|
||||
print "L[p qx qy qz]-norm : " + str(self.reg.norms)
|
||||
print "eps_p: " + str(self.reg.eps_p) + " eps_q: " + str(self.reg.eps_q)
|
||||
|
||||
|
||||
print("L[p qx qy qz]-norm : " + str(self.reg.norms))
|
||||
print("eps_p: " + str(self.reg.eps_p) + " eps_q: " + str(self.reg.eps_q))
|
||||
|
||||
self.reg.norms = self.norms
|
||||
self.coolingFactor = 1.
|
||||
self.coolingRate = 1
|
||||
@@ -328,7 +340,7 @@ class Update_IRLS(InversionDirective):
|
||||
|
||||
# Beta Schedule
|
||||
if self.opt.iter > 0 and self.opt.iter % self.coolingRate == 0:
|
||||
if self.debug: print 'BetaSchedule is cooling Beta. Iteration: %d' % self.opt.iter
|
||||
if self.debug: print('BetaSchedule is cooling Beta. Iteration: %d' % self.opt.iter)
|
||||
self.invProb.beta /= self.coolingFactor
|
||||
|
||||
|
||||
@@ -338,19 +350,19 @@ class Update_IRLS(InversionDirective):
|
||||
self.IRLSiter += 1
|
||||
|
||||
phim_new = self.reg.eval(self.invProb.curModel)
|
||||
self.f_change = np.abs(self.f_old - phim_new) / self.f_old
|
||||
self.f_change = old_div(np.abs(self.f_old - phim_new), self.f_old)
|
||||
|
||||
print "Regularization decrease: %6.3e" % (self.f_change)
|
||||
print("Regularization decrease: %6.3e" % (self.f_change))
|
||||
|
||||
# Check for maximum number of IRLS cycles
|
||||
if self.IRLSiter == self.maxIRLSiter:
|
||||
print "Reach maximum number of IRLS cycles: %i" % self.maxIRLSiter
|
||||
print("Reach maximum number of IRLS cycles: %i" % self.maxIRLSiter)
|
||||
self.opt.stopNextIteration = True
|
||||
return
|
||||
|
||||
# Check if the function has changed enough
|
||||
if self.f_change < self.f_min_change and self.IRLSiter > 1:
|
||||
print "Minimum decrease in regularization. End of IRLS"
|
||||
print("Minimum decrease in regularization. End of IRLS")
|
||||
self.opt.stopNextIteration = True
|
||||
return
|
||||
else:
|
||||
@@ -385,7 +397,7 @@ class Update_IRLS(InversionDirective):
|
||||
phim_new = self.reg.eval(self.invProb.curModel)
|
||||
|
||||
# Update gamma to scale the regularization between IRLS iterations
|
||||
self.reg.gamma = self.phi_m_last / phim_new
|
||||
self.reg.gamma = old_div(self.phi_m_last, phim_new)
|
||||
|
||||
# Reset the regularization matrices again for new gamma
|
||||
self.reg._Wsmall = None
|
||||
@@ -394,7 +406,7 @@ class Update_IRLS(InversionDirective):
|
||||
self.reg._Wz = None
|
||||
|
||||
# Check if misfit is within the tolerance, otherwise scale beta
|
||||
val = self.invProb.phi_d / (self.survey.nD*0.5)
|
||||
val = old_div(self.invProb.phi_d, (self.survey.nD*0.5))
|
||||
|
||||
if np.abs(1.-val) > self.beta_tol:
|
||||
self.invProb.beta = self.invProb.beta * self.survey.nD*0.5 / self.invProb.phi_d
|
||||
@@ -438,7 +450,7 @@ class Update_Wj(InversionDirective):
|
||||
|
||||
m = self.invProb.curModel
|
||||
if self.k is None:
|
||||
self.k = int(self.survey.nD/10)
|
||||
self.k = int(old_div(self.survey.nD,10))
|
||||
|
||||
def JtJv(v):
|
||||
|
||||
@@ -447,6 +459,6 @@ class Update_Wj(InversionDirective):
|
||||
return self.prob.Jtvec(m,Jv)
|
||||
|
||||
JtJdiag = Utils.diagEst(JtJv,len(m),k=self.k)
|
||||
JtJdiag = JtJdiag / max(JtJdiag)
|
||||
JtJdiag = old_div(JtJdiag, max(JtJdiag))
|
||||
|
||||
self.reg.wght = JtJdiag
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
import numpy as np
|
||||
from scipy.constants import mu_0, pi
|
||||
from scipy import special
|
||||
@@ -24,8 +32,8 @@ def DCAnalyticHalf(txloc, rxlocs, sigma, earth_type="wholespace"):
|
||||
rM = np.sqrt( (M[:,0]-txloc[0])**2 + (M[:,1]-txloc[1])**2 + (M[:,2]-txloc[1])**2 )
|
||||
rN = np.sqrt( (N[:,0]-txloc[0])**2 + (N[:,1]-txloc[1])**2 + (N[:,2]-txloc[1])**2 )
|
||||
|
||||
phiM = 1./(4*np.pi*rM*sigma)
|
||||
phiN = 1./(4*np.pi*rN*sigma)
|
||||
phiM = old_div(1.,(4*np.pi*rM*sigma))
|
||||
phiN = old_div(1.,(4*np.pi*rN*sigma))
|
||||
phi = phiM - phiN
|
||||
|
||||
if earth_type == "halfspace":
|
||||
@@ -69,8 +77,8 @@ def DCAnalyticSphere(txloc, rxloc, xc, radius, sigma, sigma1, \
|
||||
Pleg.append(special.legendre(i, monic=0))
|
||||
|
||||
|
||||
rho = 1./sigma
|
||||
rho1 = 1./sigma1
|
||||
rho = old_div(1.,sigma)
|
||||
rho1 = old_div(1.,sigma1)
|
||||
|
||||
# Center of the sphere should be aligned in txloc in y-direction
|
||||
yc = txloc[1]
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import numpy as np
|
||||
from scipy.constants import mu_0, pi
|
||||
from scipy.special import erf
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import numpy as np
|
||||
from scipy.constants import mu_0, pi, epsilon_0
|
||||
from scipy.special import erf
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from SimPEG import Utils, np
|
||||
from scipy.constants import mu_0, epsilon_0
|
||||
from SimPEG.EM.Utils.EMUtils import k
|
||||
@@ -6,7 +13,7 @@ def getKc(freq,sigma,a,b,mu=mu_0,eps=epsilon_0):
|
||||
a = float(a)
|
||||
b = float(b)
|
||||
# return 1./(2*np.pi) * np.sqrt(b / a) * np.exp(-1j*k(freq,sigma,mu,eps)*(b-a))
|
||||
return np.sqrt(b / a) * np.exp(-1j*k(freq,sigma,mu,eps)*(b-a))
|
||||
return np.sqrt(old_div(b, a)) * np.exp(-1j*k(freq,sigma,mu,eps)*(b-a))
|
||||
|
||||
def _r2(xyz):
|
||||
return np.sum(xyz**2,1)
|
||||
@@ -34,7 +41,7 @@ def _getCasingHertzMagDipoleDeriv_r(srcloc,obsloc,freq,sigma,a,b,mu=mu_0*np.ones
|
||||
sqrtr2z2 = np.sqrt(r2 + dxyz[:,2]**2)
|
||||
k2 = k(freq,sigma[2],mu[2],eps)
|
||||
|
||||
return -HertzZ * np.sqrt(r2) / sqrtr2z2 * (1j*k2 + 1./ sqrtr2z2)
|
||||
return -HertzZ * np.sqrt(r2) / sqrtr2z2 * (1j*k2 + old_div(1., sqrtr2z2))
|
||||
|
||||
|
||||
def _getCasingHertzMagDipoleDeriv_z(srcloc,obsloc,freq,sigma,a,b,mu=mu_0*np.ones(3),eps=epsilon_0,moment=1.):
|
||||
@@ -47,7 +54,7 @@ def _getCasingHertzMagDipoleDeriv_z(srcloc,obsloc,freq,sigma,a,b,mu=mu_0*np.ones
|
||||
sqrtr2z2 = np.sqrt(r2z2)
|
||||
k2 = k(freq,sigma[2],mu[2],eps)
|
||||
|
||||
return -HertzZ*dxyz[:,2] /sqrtr2z2 * (1j*k2 + 1./sqrtr2z2)
|
||||
return -HertzZ*dxyz[:,2] /sqrtr2z2 * (1j*k2 + old_div(1.,sqrtr2z2))
|
||||
|
||||
def _getCasingHertzMagDipole2Deriv_z_r(srcloc,obsloc,freq,sigma,a,b,mu=mu_0*np.ones(3),eps=epsilon_0,moment=1.):
|
||||
HertzZ = _getCasingHertzMagDipole(srcloc,obsloc,freq,sigma,a,b,mu,eps,moment)
|
||||
@@ -62,7 +69,7 @@ def _getCasingHertzMagDipole2Deriv_z_r(srcloc,obsloc,freq,sigma,a,b,mu=mu_0*np.o
|
||||
sqrtr2z2 = np.sqrt(r2 + z**2)
|
||||
k2 = k(freq,sigma[2],mu[2],eps)
|
||||
|
||||
return dHertzZdr*(-z/sqrtr2z2)*(1j*k2+1./sqrtr2z2) + HertzZ*(z*r/sqrtr2z2**3)*(1j*k2 + 2./sqrtr2z2)
|
||||
return dHertzZdr*(old_div(-z,sqrtr2z2))*(1j*k2+old_div(1.,sqrtr2z2)) + HertzZ*(z*r/sqrtr2z2**3)*(1j*k2 + old_div(2.,sqrtr2z2))
|
||||
|
||||
def _getCasingHertzMagDipole2Deriv_z_z(srcloc,obsloc,freq,sigma,a,b,mu=mu_0*np.ones(3),eps=epsilon_0,moment=1.):
|
||||
HertzZ = _getCasingHertzMagDipole(srcloc,obsloc,freq,sigma,a,b,mu,eps,moment)
|
||||
@@ -77,7 +84,7 @@ def _getCasingHertzMagDipole2Deriv_z_z(srcloc,obsloc,freq,sigma,a,b,mu=mu_0*np.o
|
||||
sqrtr2z2 = np.sqrt(r2 + z**2)
|
||||
k2 = k(freq,sigma[2],mu[2],eps)
|
||||
|
||||
return (dHertzZdz*z + HertzZ)/sqrtr2z2*(-1j*k2 - 1./sqrtr2z2) + HertzZ*z/sqrtr2z2**3*(1j*k2*z + 2.*z/sqrtr2z2)
|
||||
return (dHertzZdz*z + HertzZ)/sqrtr2z2*(-1j*k2 - old_div(1.,sqrtr2z2)) + HertzZ*z/sqrtr2z2**3*(1j*k2*z + 2.*z/sqrtr2z2)
|
||||
|
||||
def getCasingEphiMagDipole(srcloc,obsloc,freq,sigma,a,b,mu=mu_0*np.ones(3),eps=epsilon_0,moment=1.):
|
||||
return 1j * omega(freq) * mu * _getCasingHertzMagDipoleDeriv_r(srcloc,obsloc,freq,sigma,a,b,mu,eps,moment)
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
import numpy as np
|
||||
from scipy.constants import mu_0, pi
|
||||
from scipy.special import erf
|
||||
|
||||
def hzAnalyticDipoleT(r, t, sigma):
|
||||
theta = np.sqrt((sigma*mu_0)/(4*t))
|
||||
theta = np.sqrt(old_div((sigma*mu_0),(4*t)))
|
||||
tr = theta*r
|
||||
etr = erf(tr)
|
||||
t1 = (9/(2*tr**2) - 1)*etr
|
||||
t2 = (1/np.sqrt(pi))*(9/tr + 4*tr)*np.exp(-tr**2)
|
||||
hz = (t1 - t2)/(4*pi*r**3)
|
||||
t1 = (old_div(9,(2*tr**2)) - 1)*etr
|
||||
t2 = (old_div(1,np.sqrt(pi)))*(old_div(9,tr) + 4*tr)*np.exp(-tr**2)
|
||||
hz = old_div((t1 - t2),(4*pi*r**3))
|
||||
return hz
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
from TDEM import hzAnalyticDipoleT
|
||||
from FDEM import hzAnalyticDipoleF
|
||||
from FDEMcasing import *
|
||||
from DC import DCAnalyticHalf, DCAnalyticSphere
|
||||
from FDEMDipolarfields import *
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .TDEM import hzAnalyticDipoleT
|
||||
from .FDEM import hzAnalyticDipoleF
|
||||
from .FDEMcasing import *
|
||||
from .DC import DCAnalyticHalf, DCAnalyticSphere
|
||||
from .FDEMDipolarfields import *
|
||||
|
||||
+8
-1
@@ -1,3 +1,10 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from SimPEG import Survey, Problem, Utils, Models, Maps, PropMaps, np, sp, Solver as SimpegSolver
|
||||
from scipy.constants import mu_0
|
||||
|
||||
@@ -11,7 +18,7 @@ class EMPropMap(Maps.PropMap):
|
||||
mu = Maps.Property("Inverse Magnetic Permeability", defaultVal = mu_0, propertyLink=('mui',Maps.ReciprocalMap))
|
||||
|
||||
rho = Maps.Property("Electrical Resistivity", propertyLink=('sigma', Maps.ReciprocalMap))
|
||||
mui = Maps.Property("Inverse Magnetic Permeability", defaultVal = 1./mu_0, propertyLink=('mu', Maps.ReciprocalMap))
|
||||
mui = Maps.Property("Inverse Magnetic Permeability", defaultVal = old_div(1.,mu_0), propertyLink=('mu', Maps.ReciprocalMap))
|
||||
|
||||
|
||||
class BaseEMProblem(Problem.BaseProblem):
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from builtins import int
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
import numpy as np
|
||||
import scipy.sparse as sp
|
||||
import SimPEG
|
||||
@@ -42,7 +50,7 @@ class FieldsFDEM(SimPEG.Problem.Fields):
|
||||
:return: total electric field
|
||||
"""
|
||||
if getattr(self, '_ePrimary', None) is None or getattr(self, '_eSecondary', None) is None:
|
||||
raise NotImplementedError ('Getting e from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting e from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
return self._ePrimary(solution,srcList) + self._eSecondary(solution,srcList)
|
||||
|
||||
@@ -56,7 +64,7 @@ class FieldsFDEM(SimPEG.Problem.Fields):
|
||||
:return: total magnetic flux density
|
||||
"""
|
||||
if getattr(self, '_bPrimary', None) is None or getattr(self, '_bSecondary', None) is None:
|
||||
raise NotImplementedError ('Getting b from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting b from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
return self._bPrimary(solution, srcList) + self._bSecondary(solution, srcList)
|
||||
|
||||
@@ -70,7 +78,7 @@ class FieldsFDEM(SimPEG.Problem.Fields):
|
||||
:return: total magnetic field
|
||||
"""
|
||||
if getattr(self, '_hPrimary', None) is None or getattr(self, '_hSecondary', None) is None:
|
||||
raise NotImplementedError ('Getting h from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting h from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
return self._hPrimary(solution, srcList) + self._hSecondary(solution, srcList)
|
||||
|
||||
@@ -84,7 +92,7 @@ class FieldsFDEM(SimPEG.Problem.Fields):
|
||||
:return: total current density
|
||||
"""
|
||||
if getattr(self, '_jPrimary', None) is None or getattr(self, '_jSecondary', None) is None:
|
||||
raise NotImplementedError ('Getting j from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting j from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
return self._jPrimary(solution, srcList) + self._jSecondary(solution, srcList)
|
||||
|
||||
@@ -100,7 +108,7 @@ class FieldsFDEM(SimPEG.Problem.Fields):
|
||||
:return: derivative times a vector (or tuple for adjoint)
|
||||
"""
|
||||
if getattr(self, '_eDeriv_u', None) is None or getattr(self, '_eDeriv_m', None) is None:
|
||||
raise NotImplementedError ('Getting eDerivs from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting eDerivs from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
if adjoint:
|
||||
return self._eDeriv_u(src, v, adjoint), self._eDeriv_m(src, v, adjoint)
|
||||
@@ -118,7 +126,7 @@ class FieldsFDEM(SimPEG.Problem.Fields):
|
||||
:return: derivative times a vector (or tuple for adjoint)
|
||||
"""
|
||||
if getattr(self, '_bDeriv_u', None) is None or getattr(self, '_bDeriv_m', None) is None:
|
||||
raise NotImplementedError ('Getting bDerivs from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting bDerivs from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
if adjoint:
|
||||
return self._bDeriv_u(src, v, adjoint), self._bDeriv_m(src, v, adjoint)
|
||||
@@ -136,7 +144,7 @@ class FieldsFDEM(SimPEG.Problem.Fields):
|
||||
:return: derivative times a vector (or tuple for adjoint)
|
||||
"""
|
||||
if getattr(self, '_hDeriv_u', None) is None or getattr(self, '_hDeriv_m', None) is None:
|
||||
raise NotImplementedError ('Getting hDerivs from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting hDerivs from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
if adjoint:
|
||||
return self._hDeriv_u(src, v, adjoint), self._hDeriv_m(src, v, adjoint)
|
||||
@@ -154,7 +162,7 @@ class FieldsFDEM(SimPEG.Problem.Fields):
|
||||
:return: derivative times a vector (or tuple for adjoint)
|
||||
"""
|
||||
if getattr(self, '_jDeriv_u', None) is None or getattr(self, '_jDeriv_m', None) is None:
|
||||
raise NotImplementedError ('Getting jDerivs from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting jDerivs from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
if adjoint:
|
||||
return self._jDeriv_u(src, v, adjoint), self._jDeriv_m(src, v, adjoint)
|
||||
@@ -285,7 +293,7 @@ class Fields3D_e(FieldsFDEM):
|
||||
C = self._edgeCurl
|
||||
b = (C * eSolution)
|
||||
for i, src in enumerate(srcList):
|
||||
b[:,i] *= - 1./(1j*omega(src.freq))
|
||||
b[:,i] *= old_div(- 1.,(1j*omega(src.freq)))
|
||||
s_m, _ = src.eval(self.prob)
|
||||
b[:,i] = b[:,i]+ 1./(1j*omega(src.freq)) * s_m
|
||||
return b
|
||||
@@ -331,8 +339,8 @@ class Fields3D_e(FieldsFDEM):
|
||||
:return: current density
|
||||
"""
|
||||
aveE2CCV = self._aveE2CCV
|
||||
n = int(aveE2CCV.shape[0] / self._nC) # number of components (instead of checking if cyl or not)
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(aveE2CCV.shape[0], self._nC)) # number of components (instead of checking if cyl or not)
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
return VI * (aveE2CCV * (self._MeSigma * self._e(eSolution,srcList) ) )
|
||||
|
||||
def _jDeriv_u(self, src, du_dm_v, adjoint = False):
|
||||
@@ -345,8 +353,8 @@ class Fields3D_e(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: product of the derivative of the current density with respect to the field we solved for with a vector
|
||||
"""
|
||||
n = int(self._aveE2CCV.shape[0] / self._nC) # number of components (instead of checking if cyl or not)
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveE2CCV.shape[0], self._nC)) # number of components (instead of checking if cyl or not)
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
|
||||
if adjoint:
|
||||
return self._eDeriv_u(src, self._MeSigma.T * (self._aveE2CCV.T * (VI.T * du_dm_v) ), adjoint = adjoint)
|
||||
@@ -364,8 +372,8 @@ class Fields3D_e(FieldsFDEM):
|
||||
:return: product of the current density derivative with respect to the inversion model with a vector
|
||||
"""
|
||||
e = self[src, 'e']
|
||||
n = int(self._aveE2CCV.shape[0] / self._nC) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveE2CCV.shape[0], self._nC)) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
|
||||
if adjoint:
|
||||
return self._MeSigmaDeriv(e).T * (self._aveE2CCV.T * (VI.T * v)) + self._eDeriv_m(src, self._aveE2CCV.T * (VI.T * v), adjoint=adjoint)
|
||||
@@ -382,8 +390,8 @@ class Fields3D_e(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: magnetic field
|
||||
"""
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) # Number of Components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) # Number of Components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
|
||||
return VI * (self._aveF2CCV * (self._MfMui * self._b(eSolution, srcList)))
|
||||
|
||||
@@ -397,8 +405,8 @@ class Fields3D_e(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: product of the derivative of the magnetic field with respect to the field we solved for with a vector
|
||||
"""
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) # Number of Components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) # Number of Components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
if adjoint:
|
||||
v = self._MfMui.T * (self._aveF2CCV.T * (VI.T * du_dm_v))
|
||||
return self._bDeriv_u(src, v, adjoint=adjoint)
|
||||
@@ -414,8 +422,8 @@ class Fields3D_e(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: product of the magnetic field derivative with respect to the inversion model with a vector
|
||||
"""
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) # Number of Components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) # Number of Components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
if adjoint:
|
||||
v = self._MfMui.T * (self._aveF2CCV.T * (VI.T * v))
|
||||
return self._bDeriv_m(src, v, adjoint=adjoint)
|
||||
@@ -607,8 +615,8 @@ class Fields3D_b(FieldsFDEM):
|
||||
:return: primary current density
|
||||
"""
|
||||
|
||||
n = int(self._aveE2CCV.shape[0] / self._nC) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveE2CCV.shape[0], self._nC)) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
|
||||
return VI * (self._aveE2CCV * ( self._MeSigma * self._e(bSolution,srcList ) ) )
|
||||
|
||||
@@ -624,8 +632,8 @@ class Fields3D_b(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: product of the derivative of the current density with respect to the field we solved for with a vector
|
||||
"""
|
||||
n = int(self._aveE2CCV.shape[0] / self._nC) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveE2CCV.shape[0], self._nC)) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
if adjoint:
|
||||
return self._MfMui.T * ( self._edgeCurl * ( self._aveE2CCV.T * (VI.T * du_dm_v) ) )
|
||||
return VI * (self._aveE2CCV * (self._edgeCurl.T * ( self._MfMui * du_dm_v ) ) )
|
||||
@@ -652,8 +660,8 @@ class Fields3D_b(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: magnetic field
|
||||
"""
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
return VI * (self._aveF2CCV * (self._MfMui * self._b(bSolution, srcList)))
|
||||
|
||||
def _hDeriv_u(self, src, du_dm_v, adjoint=False):
|
||||
@@ -667,8 +675,8 @@ class Fields3D_b(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: product of the derivative of the magnetic field with respect to the field we solved for with a vector
|
||||
"""
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
|
||||
if adjoint:
|
||||
return self._MfMui.T * ( self._aveF2CCV.T * ( VI.T * du_dm_v) )
|
||||
@@ -827,7 +835,7 @@ class Fields3D_j(FieldsFDEM):
|
||||
|
||||
h = (self._edgeCurl.T * (self._MfRho * jSolution) )
|
||||
for i, src in enumerate(srcList):
|
||||
h[:,i] *= -1./(1j*omega(src.freq))
|
||||
h[:,i] *= old_div(-1.,(1j*omega(src.freq)))
|
||||
s_m,_ = src.eval(self.prob)
|
||||
h[:,i] = h[:,i] + 1./(1j*omega(src.freq)) * (s_m)
|
||||
return self._MeMuI * h
|
||||
@@ -890,8 +898,8 @@ class Fields3D_j(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: electric field
|
||||
"""
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
return VI * (self._aveF2CCV * (self._MfRho * self._j(jSolution, srcList)))
|
||||
|
||||
def _eDeriv_u(self, src, du_dm_v, adjoint=False):
|
||||
@@ -904,8 +912,8 @@ class Fields3D_j(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: product of the derivative of the electric field with respect to the field we solved for with a vector
|
||||
"""
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
if adjoint:
|
||||
return self._MfRho.T * ( self._aveF2CCV.T * ( VI.T * du_dm_v ) )
|
||||
return VI * (self._aveF2CCV * (self._MfRho * du_dm_v))
|
||||
@@ -921,8 +929,8 @@ class Fields3D_j(FieldsFDEM):
|
||||
:return: product of the derivative of the electric field with respect to the model with a vector
|
||||
"""
|
||||
jSolution = Utils.mkvc(self[src,'jSolution'])
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
if adjoint:
|
||||
return self._MfRhoDeriv(jSolution).T * ( self._aveF2CCV.T * ( VI.T * v ) )
|
||||
return VI * (self._aveF2CCV * (self._MfRhoDeriv(jSolution) * v))
|
||||
@@ -936,8 +944,8 @@ class Fields3D_j(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: secondary magnetic flux density
|
||||
"""
|
||||
n = int(self._aveE2CCV.shape[0] / self._nC) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveE2CCV.shape[0], self._nC)) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
|
||||
return VI * (self._aveE2CCV * ( self._MeMu * self._h(jSolution,srcList)) )
|
||||
|
||||
@@ -951,8 +959,8 @@ class Fields3D_j(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: product of the derivative of the magnetic flux density with respect to the field we solved for with a vector
|
||||
"""
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
|
||||
if adjoint:
|
||||
return -1./(1j*omega(src.freq)) * self._MfRho.T * ( self._edgeCurl * ( self._aveE2CCV.T * (VI.T * du_dm_v) ) )
|
||||
@@ -969,8 +977,8 @@ class Fields3D_j(FieldsFDEM):
|
||||
:return: product of the derivative of the magnetic flux density with respect to the model with a vector
|
||||
"""
|
||||
jSolution = self[src,'jSolution']
|
||||
n = int(self._aveE2CCV.shape[0] / self._nC) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveE2CCV.shape[0], self._nC)) # number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
s_mDeriv,_ = src.evalDeriv(self.prob, adjoint = adjoint)
|
||||
|
||||
if adjoint:
|
||||
@@ -1151,8 +1159,8 @@ class Fields3D_h(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: electric field
|
||||
"""
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
return VI * (self._aveF2CCV * (self._MfRho * self._j(hSolution, srcList)))
|
||||
|
||||
def _eDeriv_u(self, src, du_dm_v, adjoint=False):
|
||||
@@ -1165,8 +1173,8 @@ class Fields3D_h(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: product of the derivative of the electric field with respect to the field we solved for with a vector
|
||||
"""
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
if adjoint:
|
||||
return self._edgeCurl.T * ( self._MfRho.T * ( self._aveF2CCV.T * ( VI.T * du_dm_v ) ) )
|
||||
return VI * (self._aveF2CCV * (self._MfRho * self._edgeCurl * du_dm_v ))
|
||||
@@ -1182,8 +1190,8 @@ class Fields3D_h(FieldsFDEM):
|
||||
:return: product of the electric field derivative with respect to the inversion model with a vector
|
||||
"""
|
||||
hSolution = Utils.mkvc(self[src,'hSolution'])
|
||||
n = int(self._aveF2CCV.shape[0] / self._nC) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveF2CCV.shape[0], self._nC)) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
if adjoint:
|
||||
return ( self._MfRhoDeriv(self._edgeCurl * hSolution).T * ( self._aveF2CCV.T * (VI.T * v) ) )
|
||||
return VI * (self._aveF2CCV * (self._MfRhoDeriv(self._edgeCurl * hSolution) * v ))
|
||||
@@ -1198,8 +1206,8 @@ class Fields3D_h(FieldsFDEM):
|
||||
:return: magnetic flux density
|
||||
"""
|
||||
h = self._h(hSolution, srcList)
|
||||
n = int(self._aveE2CCV.shape[0] / self._nC) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveE2CCV.shape[0], self._nC)) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
|
||||
return VI * (self._aveE2CCV * (self._MeMu * h))
|
||||
|
||||
@@ -1213,8 +1221,8 @@ class Fields3D_h(FieldsFDEM):
|
||||
:rtype: numpy.ndarray
|
||||
:return: product of the derivative of the magnetic flux density with respect to the field we solved for with a vector
|
||||
"""
|
||||
n = int(self._aveE2CCV.shape[0] / self._nC) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), 1./self.prob.mesh.vol))
|
||||
n = int(old_div(self._aveE2CCV.shape[0], self._nC)) #number of components
|
||||
VI = sdiag(np.kron(np.ones(n), old_div(1.,self.prob.mesh.vol)))
|
||||
if adjoint:
|
||||
return self._MeMu.T * (self._aveE2CCV.T * ( VI.T * du_dm_v ))
|
||||
return VI * (self._aveE2CCV * (self._MeMu * du_dm_v))
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import Problem, Utils, np, sp, Solver as SimpegSolver
|
||||
from scipy.constants import mu_0
|
||||
from SurveyFDEM import Survey as SurveyFDEM
|
||||
from FieldsFDEM import FieldsFDEM, Fields3D_e, Fields3D_b, Fields3D_h, Fields3D_j
|
||||
from .SurveyFDEM import Survey as SurveyFDEM
|
||||
from .FieldsFDEM import FieldsFDEM, Fields3D_e, Fields3D_b, Fields3D_h, Fields3D_j
|
||||
from SimPEG.EM.Base import BaseEMProblem
|
||||
from SimPEG.EM.Utils import omega
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from builtins import super
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import SimPEG
|
||||
from SimPEG import sp
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from SimPEG import Survey, Problem, Utils, np, sp
|
||||
from scipy.constants import mu_0
|
||||
from SimPEG.EM.Utils import *
|
||||
@@ -375,7 +382,7 @@ class MagDipole(BaseSrc):
|
||||
formulation = prob._formulation
|
||||
|
||||
if formulation is 'EB':
|
||||
mui_s = prob.curModel.mui - 1./self.mu
|
||||
mui_s = prob.curModel.mui - old_div(1.,self.mu)
|
||||
MMui_s = prob.mesh.getFaceInnerProduct(mui_s)
|
||||
C = prob.mesh.edgeCurl
|
||||
elif formulation is 'HJ':
|
||||
@@ -489,7 +496,7 @@ class MagDipole_Bfield(BaseSrc):
|
||||
formulation = prob._formulation
|
||||
|
||||
if formulation is 'EB':
|
||||
mui_s = prob.curModel.mui - 1./self.mu
|
||||
mui_s = prob.curModel.mui - old_div(1.,self.mu)
|
||||
MMui_s = prob.mesh.getFaceInnerProduct(mui_s)
|
||||
C = prob.mesh.edgeCurl
|
||||
elif formulation is 'HJ':
|
||||
@@ -601,7 +608,7 @@ class CircularLoop(BaseSrc):
|
||||
formulation = prob._formulation
|
||||
|
||||
if formulation is 'EB':
|
||||
mui_s = prob.curModel.mui - 1./self.mu
|
||||
mui_s = prob.curModel.mui - old_div(1.,self.mu)
|
||||
MMui_s = prob.mesh.getFaceInnerProduct(mui_s)
|
||||
C = prob.mesh.edgeCurl
|
||||
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import SimPEG
|
||||
from SimPEG.EM.Utils import *
|
||||
from SimPEG.EM.Base import BaseEMSurvey
|
||||
from scipy.constants import mu_0
|
||||
from SimPEG.Utils import Zero, Identity
|
||||
import SrcFDEM as Src
|
||||
import RxFDEM as Rx
|
||||
from . import SrcFDEM as Src
|
||||
from . import RxFDEM as Rx
|
||||
from SimPEG import sp
|
||||
|
||||
class Survey(BaseEMSurvey):
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
from SurveyFDEM import Survey
|
||||
import SrcFDEM as Src
|
||||
import RxFDEM as Rx
|
||||
from ProblemFDEM import Problem3D_e, Problem3D_b, Problem3D_j, Problem3D_h
|
||||
from FieldsFDEM import Fields3D_e, Fields3D_b, Fields3D_j, Fields3D_h
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .SurveyFDEM import Survey
|
||||
from . import SrcFDEM as Src
|
||||
from . import RxFDEM as Rx
|
||||
from .ProblemFDEM import Problem3D_e, Problem3D_b, Problem3D_j, Problem3D_h
|
||||
from .FieldsFDEM import Fields3D_e, Fields3D_b, Fields3D_j, Fields3D_h
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
import numpy as np
|
||||
|
||||
def getxBCyBC_CC(mesh, alpha, beta, gamma):
|
||||
@@ -31,15 +38,15 @@ def getxBCyBC_CC(mesh, alpha, beta, gamma):
|
||||
# h_xm, h_xp = mesh.gridCC[fCCxm], mesh.gridCC[fCCxp]
|
||||
h_xm, h_xp = mesh.hx[0], mesh.hx[-1]
|
||||
|
||||
a_xm = gamma_xm/(0.5*alpha_xm-beta_xm/h_xm)
|
||||
b_xm = (0.5*alpha_xm+beta_xm/h_xm)/(0.5*alpha_xm-beta_xm/h_xm)
|
||||
a_xp = gamma_xp/(0.5*alpha_xp-beta_xp/h_xp)
|
||||
b_xp = (0.5*alpha_xp+beta_xp/h_xp)/(0.5*alpha_xp-beta_xp/h_xp)
|
||||
a_xm = old_div(gamma_xm,(0.5*alpha_xm-old_div(beta_xm,h_xm)))
|
||||
b_xm = old_div((0.5*alpha_xm+old_div(beta_xm,h_xm)),(0.5*alpha_xm-old_div(beta_xm,h_xm)))
|
||||
a_xp = old_div(gamma_xp,(0.5*alpha_xp-old_div(beta_xp,h_xp)))
|
||||
b_xp = old_div((0.5*alpha_xp+old_div(beta_xp,h_xp)),(0.5*alpha_xp-old_div(beta_xp,h_xp)))
|
||||
|
||||
xBC_xm = 0.5*a_xm
|
||||
xBC_xp = 0.5*a_xp/b_xp
|
||||
yBC_xm = 0.5*(1.-b_xm)
|
||||
yBC_xp = 0.5*(1.-1./b_xp)
|
||||
yBC_xp = 0.5*(1.-old_div(1.,b_xp))
|
||||
|
||||
xBC = np.r_[xBC_xm, xBC_xp]
|
||||
yBC = np.r_[yBC_xm, yBC_xp]
|
||||
@@ -62,24 +69,24 @@ def getxBCyBC_CC(mesh, alpha, beta, gamma):
|
||||
h_xm, h_xp = mesh.hx[0]*np.ones_like(alpha_xm), mesh.hx[-1]*np.ones_like(alpha_xp)
|
||||
h_ym, h_yp = mesh.hy[0]*np.ones_like(alpha_ym), mesh.hy[-1]*np.ones_like(alpha_yp)
|
||||
|
||||
a_xm = gamma_xm/(0.5*alpha_xm-beta_xm/h_xm)
|
||||
b_xm = (0.5*alpha_xm+beta_xm/h_xm)/(0.5*alpha_xm-beta_xm/h_xm)
|
||||
a_xp = gamma_xp/(0.5*alpha_xp-beta_xp/h_xp)
|
||||
b_xp = (0.5*alpha_xp+beta_xp/h_xp)/(0.5*alpha_xp-beta_xp/h_xp)
|
||||
a_xm = old_div(gamma_xm,(0.5*alpha_xm-old_div(beta_xm,h_xm)))
|
||||
b_xm = old_div((0.5*alpha_xm+old_div(beta_xm,h_xm)),(0.5*alpha_xm-old_div(beta_xm,h_xm)))
|
||||
a_xp = old_div(gamma_xp,(0.5*alpha_xp-old_div(beta_xp,h_xp)))
|
||||
b_xp = old_div((0.5*alpha_xp+old_div(beta_xp,h_xp)),(0.5*alpha_xp-old_div(beta_xp,h_xp)))
|
||||
|
||||
a_ym = gamma_ym/(0.5*alpha_ym-beta_ym/h_ym)
|
||||
b_ym = (0.5*alpha_ym+beta_ym/h_ym)/(0.5*alpha_ym-beta_ym/h_ym)
|
||||
a_yp = gamma_yp/(0.5*alpha_yp-beta_yp/h_yp)
|
||||
b_yp = (0.5*alpha_yp+beta_yp/h_yp)/(0.5*alpha_yp-beta_yp/h_yp)
|
||||
a_ym = old_div(gamma_ym,(0.5*alpha_ym-old_div(beta_ym,h_ym)))
|
||||
b_ym = old_div((0.5*alpha_ym+old_div(beta_ym,h_ym)),(0.5*alpha_ym-old_div(beta_ym,h_ym)))
|
||||
a_yp = old_div(gamma_yp,(0.5*alpha_yp-old_div(beta_yp,h_yp)))
|
||||
b_yp = old_div((0.5*alpha_yp+old_div(beta_yp,h_yp)),(0.5*alpha_yp-old_div(beta_yp,h_yp)))
|
||||
|
||||
xBC_xm = 0.5*a_xm
|
||||
xBC_xp = 0.5*a_xp/b_xp
|
||||
yBC_xm = 0.5*(1.-b_xm)
|
||||
yBC_xp = 0.5*(1.-1./b_xp)
|
||||
yBC_xp = 0.5*(1.-old_div(1.,b_xp))
|
||||
xBC_ym = 0.5*a_ym
|
||||
xBC_yp = 0.5*a_yp/b_yp
|
||||
yBC_ym = 0.5*(1.-b_ym)
|
||||
yBC_yp = 0.5*(1.-1./b_yp)
|
||||
yBC_yp = 0.5*(1.-old_div(1.,b_yp))
|
||||
|
||||
sortindsfx = np.argsort(np.r_[np.arange(mesh.nFx)[fxm], np.arange(mesh.nFx)[fxp]])
|
||||
sortindsfy = np.argsort(np.r_[np.arange(mesh.nFy)[fym], np.arange(mesh.nFy)[fyp]])
|
||||
@@ -114,33 +121,33 @@ def getxBCyBC_CC(mesh, alpha, beta, gamma):
|
||||
h_ym, h_yp = mesh.hy[0]*np.ones_like(alpha_ym), mesh.hy[-1]*np.ones_like(alpha_yp)
|
||||
h_zm, h_zp = mesh.hz[0]*np.ones_like(alpha_zm), mesh.hz[-1]*np.ones_like(alpha_zp)
|
||||
|
||||
a_xm = gamma_xm/(0.5*alpha_xm-beta_xm/h_xm)
|
||||
b_xm = (0.5*alpha_xm+beta_xm/h_xm)/(0.5*alpha_xm-beta_xm/h_xm)
|
||||
a_xp = gamma_xp/(0.5*alpha_xp-beta_xp/h_xp)
|
||||
b_xp = (0.5*alpha_xp+beta_xp/h_xp)/(0.5*alpha_xp-beta_xp/h_xp)
|
||||
a_xm = old_div(gamma_xm,(0.5*alpha_xm-old_div(beta_xm,h_xm)))
|
||||
b_xm = old_div((0.5*alpha_xm+old_div(beta_xm,h_xm)),(0.5*alpha_xm-old_div(beta_xm,h_xm)))
|
||||
a_xp = old_div(gamma_xp,(0.5*alpha_xp-old_div(beta_xp,h_xp)))
|
||||
b_xp = old_div((0.5*alpha_xp+old_div(beta_xp,h_xp)),(0.5*alpha_xp-old_div(beta_xp,h_xp)))
|
||||
|
||||
a_ym = gamma_ym/(0.5*alpha_ym-beta_ym/h_ym)
|
||||
b_ym = (0.5*alpha_ym+beta_ym/h_ym)/(0.5*alpha_ym-beta_ym/h_ym)
|
||||
a_yp = gamma_yp/(0.5*alpha_yp-beta_yp/h_yp)
|
||||
b_yp = (0.5*alpha_yp+beta_yp/h_yp)/(0.5*alpha_yp-beta_yp/h_yp)
|
||||
a_ym = old_div(gamma_ym,(0.5*alpha_ym-old_div(beta_ym,h_ym)))
|
||||
b_ym = old_div((0.5*alpha_ym+old_div(beta_ym,h_ym)),(0.5*alpha_ym-old_div(beta_ym,h_ym)))
|
||||
a_yp = old_div(gamma_yp,(0.5*alpha_yp-old_div(beta_yp,h_yp)))
|
||||
b_yp = old_div((0.5*alpha_yp+old_div(beta_yp,h_yp)),(0.5*alpha_yp-old_div(beta_yp,h_yp)))
|
||||
|
||||
a_zm = gamma_zm/(0.5*alpha_zm-beta_zm/h_zm)
|
||||
b_zm = (0.5*alpha_zm+beta_zm/h_zm)/(0.5*alpha_zm-beta_zm/h_zm)
|
||||
a_zp = gamma_zp/(0.5*alpha_zp-beta_zp/h_zp)
|
||||
b_zp = (0.5*alpha_zp+beta_zp/h_zp)/(0.5*alpha_zp-beta_zp/h_zp)
|
||||
a_zm = old_div(gamma_zm,(0.5*alpha_zm-old_div(beta_zm,h_zm)))
|
||||
b_zm = old_div((0.5*alpha_zm+old_div(beta_zm,h_zm)),(0.5*alpha_zm-old_div(beta_zm,h_zm)))
|
||||
a_zp = old_div(gamma_zp,(0.5*alpha_zp-old_div(beta_zp,h_zp)))
|
||||
b_zp = old_div((0.5*alpha_zp+old_div(beta_zp,h_zp)),(0.5*alpha_zp-old_div(beta_zp,h_zp)))
|
||||
|
||||
xBC_xm = 0.5*a_xm
|
||||
xBC_xp = 0.5*a_xp/b_xp
|
||||
yBC_xm = 0.5*(1.-b_xm)
|
||||
yBC_xp = 0.5*(1.-1./b_xp)
|
||||
yBC_xp = 0.5*(1.-old_div(1.,b_xp))
|
||||
xBC_ym = 0.5*a_ym
|
||||
xBC_yp = 0.5*a_yp/b_yp
|
||||
yBC_ym = 0.5*(1.-b_ym)
|
||||
yBC_yp = 0.5*(1.-1./b_yp)
|
||||
yBC_yp = 0.5*(1.-old_div(1.,b_yp))
|
||||
xBC_zm = 0.5*a_zm
|
||||
xBC_zp = 0.5*a_zp/b_zp
|
||||
yBC_zm = 0.5*(1.-b_zm)
|
||||
yBC_zp = 0.5*(1.-1./b_zp)
|
||||
yBC_zp = 0.5*(1.-old_div(1.,b_zp))
|
||||
|
||||
sortindsfx = np.argsort(np.r_[np.arange(mesh.nFx)[fxm], np.arange(mesh.nFx)[fxp]])
|
||||
sortindsfy = np.argsort(np.r_[np.arange(mesh.nFy)[fym], np.arange(mesh.nFy)[fyp]])
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import SimPEG
|
||||
from SimPEG.Utils import Identity, Zero
|
||||
import numpy as np
|
||||
@@ -9,7 +15,7 @@ class Fields(SimPEG.Problem.Fields):
|
||||
|
||||
def _phiDeriv(self, src, du_dm_v, v, adjoint=False):
|
||||
if getattr(self, '_phiDeriv_u', None) is None or getattr(self, '_phiDeriv_m', None) is None:
|
||||
raise NotImplementedError ('Getting phiDerivs from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting phiDerivs from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
if adjoint:
|
||||
return self._phiDeriv_u(src, v, adjoint=adjoint), self._phiDeriv_m(src, v, adjoint=adjoint)
|
||||
@@ -18,7 +24,7 @@ class Fields(SimPEG.Problem.Fields):
|
||||
|
||||
def _eDeriv(self, src, du_dm_v, v, adjoint=False):
|
||||
if getattr(self, '_eDeriv_u', None) is None or getattr(self, '_eDeriv_m', None) is None:
|
||||
raise NotImplementedError ('Getting eDerivs from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting eDerivs from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
if adjoint:
|
||||
return self._eDeriv_u(src, v, adjoint), self._eDeriv_m(src, v, adjoint)
|
||||
@@ -26,7 +32,7 @@ class Fields(SimPEG.Problem.Fields):
|
||||
|
||||
def _jDeriv(self, src, du_dm_v, v, adjoint=False):
|
||||
if getattr(self, '_jDeriv_u', None) is None or getattr(self, '_jDeriv_m', None) is None:
|
||||
raise NotImplementedError ('Getting jDerivs from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting jDerivs from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
if adjoint:
|
||||
return self._jDeriv_u(src, v, adjoint), self._jDeriv_m(src, v, adjoint)
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import SimPEG
|
||||
from SimPEG.Utils import Identity, Zero
|
||||
import numpy as np
|
||||
@@ -32,7 +38,7 @@ class Fields_ky(SimPEG.Problem.TimeFields):
|
||||
|
||||
def _phiDeriv(self,kyInd, src, du_dm_v, v, adjoint=False):
|
||||
if getattr(self, '_phiDeriv_u', None) is None or getattr(self, '_phiDeriv_m', None) is None:
|
||||
raise NotImplementedError ('Getting phiDerivs from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting phiDerivs from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
if adjoint:
|
||||
return self._phiDeriv_u(kyInd, src, v, adjoint=adjoint), self._phiDeriv_m(kyInd, src, v, adjoint=adjoint)
|
||||
@@ -41,7 +47,7 @@ class Fields_ky(SimPEG.Problem.TimeFields):
|
||||
|
||||
def _eDeriv(self,kyInd, src, du_dm_v, v, adjoint=False):
|
||||
if getattr(self, '_eDeriv_u', None) is None or getattr(self, '_eDeriv_m', None) is None:
|
||||
raise NotImplementedError ('Getting eDerivs from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting eDerivs from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
if adjoint:
|
||||
return self._eDeriv_u(kyInd, src, v, adjoint), self._eDeriv_m(kyInd, src, v, adjoint)
|
||||
@@ -49,7 +55,7 @@ class Fields_ky(SimPEG.Problem.TimeFields):
|
||||
|
||||
def _jDeriv(self,kyInd, src, du_dm_v, v, adjoint=False):
|
||||
if getattr(self, '_jDeriv_u', None) is None or getattr(self, '_jDeriv_m', None) is None:
|
||||
raise NotImplementedError ('Getting jDerivs from %s is not implemented' %self.knownFields.keys()[0])
|
||||
raise NotImplementedError ('Getting jDerivs from %s is not implemented' %list(self.knownFields.keys())[0])
|
||||
|
||||
if adjoint:
|
||||
return self._jDeriv_u(kyInd, src, v, adjoint), self._jDeriv_m(kyInd, src, v, adjoint)
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import Problem, Utils
|
||||
from SimPEG.EM.Base import BaseEMProblem
|
||||
from SurveyDC import Survey
|
||||
from FieldsDC import Fields, Fields_CC, Fields_N
|
||||
from .SurveyDC import Survey
|
||||
from .FieldsDC import Fields, Fields_CC, Fields_N
|
||||
from SimPEG.Utils import sdiag
|
||||
import numpy as np
|
||||
from SimPEG.Utils import Zero
|
||||
from BoundaryUtils import getxBCyBC_CC
|
||||
from .BoundaryUtils import getxBCyBC_CC
|
||||
|
||||
class BaseDCProblem(BaseEMProblem):
|
||||
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from SimPEG import Problem, Utils
|
||||
from SimPEG.EM.Base import BaseEMProblem
|
||||
from SurveyDC import Survey, Survey_ky
|
||||
from FieldsDC_2D import Fields_ky, Fields_ky_CC, Fields_ky_N
|
||||
from .SurveyDC import Survey, Survey_ky
|
||||
from .FieldsDC_2D import Fields_ky, Fields_ky_CC, Fields_ky_N
|
||||
from SimPEG.Utils import sdiag
|
||||
import numpy as np
|
||||
from SimPEG.Utils import Zero
|
||||
from BoundaryUtils import getxBCyBC_CC
|
||||
from .BoundaryUtils import getxBCyBC_CC
|
||||
|
||||
class BaseDCProblem_2D(BaseEMProblem):
|
||||
|
||||
@@ -182,8 +190,8 @@ class Problem2D_CC(BaseDCProblem_2D):
|
||||
MfRhoIDeriv = self.MfRhoIDeriv
|
||||
rho = self.curModel.rho
|
||||
if adjoint:
|
||||
return(MfRhoIDeriv( G * u ).T) * ( D.T * v) + ky**2*Utils.sdiag(u.flatten()*vol*(-1./rho**2))*v
|
||||
return D * ((MfRhoIDeriv( G * u )) * v) + ky**2*Utils.sdiag(u.flatten()*vol*(-1./rho**2))*v
|
||||
return(MfRhoIDeriv( G * u ).T) * ( D.T * v) + ky**2*Utils.sdiag(u.flatten()*vol*(old_div(-1.,rho**2)))*v
|
||||
return D * ((MfRhoIDeriv( G * u )) * v) + ky**2*Utils.sdiag(u.flatten()*vol*(old_div(-1.,rho**2)))*v
|
||||
|
||||
def getRHS(self, ky):
|
||||
"""
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
import SimPEG
|
||||
import numpy as np
|
||||
from SimPEG.Utils import Zero, closestPoints
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import SimPEG
|
||||
# from SimPEG.EM.Base import BaseEMSurvey
|
||||
from SimPEG.Utils import Zero, closestPoints, mkvc
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import SimPEG
|
||||
from SimPEG.EM.Base import BaseEMSurvey
|
||||
from SimPEG import sp, Survey
|
||||
from SimPEG.Utils import Zero, Identity
|
||||
from RxDC import BaseRx
|
||||
from SrcDC import BaseSrc
|
||||
from .RxDC import BaseRx
|
||||
from .SrcDC import BaseSrc
|
||||
|
||||
class Survey(BaseEMSurvey):
|
||||
rxPair = BaseRx
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
import numpy as np
|
||||
|
||||
def WennerSrcList(nElecs, aSpacing, in2D=False, plotIt=False):
|
||||
@@ -5,7 +13,7 @@ def WennerSrcList(nElecs, aSpacing, in2D=False, plotIt=False):
|
||||
import SimPEG.EM.Static.DC as DC
|
||||
|
||||
elocs = np.arange(0,aSpacing*nElecs,aSpacing)
|
||||
elocs -= (nElecs*aSpacing - aSpacing)/2
|
||||
elocs -= old_div((nElecs*aSpacing - aSpacing),2)
|
||||
space = 1
|
||||
WENNER = np.zeros((0,),dtype=int)
|
||||
for ii in range(nElecs):
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
from ProblemDC import Problem3D_CC, Problem3D_N
|
||||
from ProblemDC_2D import Problem2D_CC, Problem2D_N
|
||||
from SurveyDC import Survey, Survey_ky
|
||||
import SrcDC as Src #Pole
|
||||
import RxDC as Rx
|
||||
from FieldsDC import Fields_CC
|
||||
from BoundaryUtils import getxBCyBC_CC
|
||||
import Utils
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .ProblemDC import Problem3D_CC, Problem3D_N
|
||||
from .ProblemDC_2D import Problem2D_CC, Problem2D_N
|
||||
from .SurveyDC import Survey, Survey_ky
|
||||
from . import SrcDC as Src #Pole
|
||||
from . import RxDC as Rx
|
||||
from .FieldsDC import Fields_CC
|
||||
from .BoundaryUtils import getxBCyBC_CC
|
||||
from . import Utils
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import Problem, Utils, Maps, Mesh
|
||||
from SimPEG.EM.Base import BaseEMProblem
|
||||
from SimPEG.EM.Static.DC.FieldsDC import Fields, Fields_CC, Fields_N
|
||||
@@ -5,7 +11,7 @@ from SimPEG.Utils import sdiag
|
||||
import numpy as np
|
||||
from SimPEG.Utils import Zero
|
||||
from SimPEG.EM.Static.DC import getxBCyBC_CC
|
||||
from SurveyIP import Survey
|
||||
from .SurveyIP import Survey
|
||||
|
||||
class IPPropMap(Maps.PropMap):
|
||||
"""
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import SimPEG
|
||||
from SimPEG.EM.Base import BaseEMSurvey
|
||||
from SimPEG import sp, Survey
|
||||
|
||||
@@ -1,2 +1,8 @@
|
||||
from ProblemIP import Problem3D_CC, Problem3D_N
|
||||
from SurveyIP import Survey
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .ProblemIP import Problem3D_CC, Problem3D_N
|
||||
from .SurveyIP import Survey
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from builtins import int
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from SimPEG import Problem, Utils, Maps, Mesh
|
||||
from SimPEG.EM.Base import BaseEMProblem
|
||||
from SimPEG.EM.Static.DC.FieldsDC import Fields, Fields_CC, Fields_N
|
||||
@@ -5,7 +14,7 @@ from SimPEG.Utils import sdiag
|
||||
import numpy as np
|
||||
from SimPEG.Utils import Zero
|
||||
from SimPEG.EM.Static.DC import getxBCyBC_CC
|
||||
from SurveySIP import Survey, Data
|
||||
from .SurveySIP import Survey, Data
|
||||
|
||||
class ColeColePropMap(Maps.PropMap):
|
||||
"""
|
||||
@@ -105,7 +114,7 @@ class BaseSIPProblem(BaseEMProblem):
|
||||
JvAll = []
|
||||
#Assume only eta and tau (eta first then tau)
|
||||
# v = [2*Mx1]
|
||||
v = v.reshape((int(v.size/2), 2), order='F')
|
||||
v = v.reshape((int(old_div(v.size,2)), 2), order='F')
|
||||
|
||||
for tind in range(len(self.survey.times)):
|
||||
t = self.survey.times[tind]
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from SimPEG import Utils, Maps, Mesh, sp, np
|
||||
from SimPEG.Regularization import BaseRegularization, Simple
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import SimPEG
|
||||
import numpy as np
|
||||
from SimPEG.Utils import Zero, closestPoints
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import SimPEG
|
||||
# from SimPEG.EM.Base import BaseEMSurvey
|
||||
from SimPEG.Utils import Zero, closestPoints, mkvc
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
import SimPEG
|
||||
from SimPEG.EM.Base import BaseEMSurvey
|
||||
from SimPEG import np, sp, Survey, Utils
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
from ProblemSIP import Problem3D_CC, Problem3D_N
|
||||
from SurveySIP import Survey, Data
|
||||
import SrcSIP as Src #Pole
|
||||
import RxSIP as Rx
|
||||
from Regularization import MultiRegularization
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .ProblemSIP import Problem3D_CC, Problem3D_N
|
||||
from .SurveySIP import Survey, Data
|
||||
from . import SrcSIP as Src #Pole
|
||||
from . import RxSIP as Rx
|
||||
from .Regularization import MultiRegularization
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from builtins import int
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from SimPEG import np
|
||||
from SimPEG.EM.Static import DC, IP
|
||||
|
||||
@@ -51,7 +60,7 @@ def plot_pseudoSection(DCsurvey, axs, stype='dpdp', dtype="appc", clim=None):
|
||||
|
||||
# Create mid-point location
|
||||
Cmid = Tx[0]
|
||||
Pmid = (Rx[0][:,0] + Rx[1][:,0])/2
|
||||
Pmid = old_div((Rx[0][:,0] + Rx[1][:,0]),2)
|
||||
if DCsurvey.mesh.dim == 2:
|
||||
zsrc = Tx[1]
|
||||
elif DCsurvey.mesh.dim ==3:
|
||||
@@ -64,12 +73,12 @@ def plot_pseudoSection(DCsurvey, axs, stype='dpdp', dtype="appc", clim=None):
|
||||
NB = np.abs(Tx[1][0] - Rx[1][:,0])
|
||||
|
||||
# Create mid-point location
|
||||
Cmid = (Tx[0][0] + Tx[1][0])/2
|
||||
Pmid = (Rx[0][:,0] + Rx[1][:,0])/2
|
||||
Cmid = old_div((Tx[0][0] + Tx[1][0]),2)
|
||||
Pmid = old_div((Rx[0][:,0] + Rx[1][:,0]),2)
|
||||
if DCsurvey.mesh.dim == 2:
|
||||
zsrc = (Tx[0][1] + Tx[1][1])/2
|
||||
zsrc = old_div((Tx[0][1] + Tx[1][1]),2)
|
||||
elif DCsurvey.mesh.dim ==3:
|
||||
zsrc = (Tx[0][2] + Tx[1][2])/2
|
||||
zsrc = old_div((Tx[0][2] + Tx[1][2]),2)
|
||||
|
||||
# Change output for dtype
|
||||
if dtype == 'volt':
|
||||
@@ -85,16 +94,16 @@ def plot_pseudoSection(DCsurvey, axs, stype='dpdp', dtype="appc", clim=None):
|
||||
|
||||
elif stype == 'dpdp':
|
||||
|
||||
leg = data * 2*np.pi / ( 1/MA - 1/MB + 1/NB - 1/NA )
|
||||
LEG.append(1./(2*np.pi) *( 1/MA - 1/MB + 1/NB - 1/NA ))
|
||||
leg = data * 2*np.pi / ( old_div(1,MA) - old_div(1,MB) + old_div(1,NB) - old_div(1,NA) )
|
||||
LEG.append(1./(2*np.pi) *( old_div(1,MA) - old_div(1,MB) + old_div(1,NB) - old_div(1,NA) ))
|
||||
else:
|
||||
print """dtype must be 'pdp'(pole-dipole) | 'dpdp' (dipole-dipole) """
|
||||
print("""dtype must be 'pdp'(pole-dipole) | 'dpdp' (dipole-dipole) """)
|
||||
break
|
||||
|
||||
|
||||
if dtype == 'appc':
|
||||
|
||||
leg = np.log10(abs(1./leg))
|
||||
leg = np.log10(abs(old_div(1.,leg)))
|
||||
rho = np.hstack([rho,leg])
|
||||
|
||||
elif dtype == 'appr':
|
||||
@@ -103,15 +112,15 @@ def plot_pseudoSection(DCsurvey, axs, stype='dpdp', dtype="appc", clim=None):
|
||||
rho = np.hstack([rho,leg])
|
||||
|
||||
else:
|
||||
print """dtype must be 'appr' | 'appc' | 'volt' """
|
||||
print("""dtype must be 'appr' | 'appc' | 'volt' """)
|
||||
break
|
||||
|
||||
|
||||
midx = np.hstack([midx, ( Cmid + Pmid )/2 ])
|
||||
midx = np.hstack([midx, old_div(( Cmid + Pmid ),2) ])
|
||||
if DCsurvey.mesh.dim==3:
|
||||
midz = np.hstack([midz, -np.abs(Cmid-Pmid)/2 + zsrc ])
|
||||
midz = np.hstack([midz, old_div(-np.abs(Cmid-Pmid),2) + zsrc ])
|
||||
elif DCsurvey.mesh.dim==2:
|
||||
midz = np.hstack([midz, -np.abs(Cmid-Pmid)/2 + zsrc ])
|
||||
midz = np.hstack([midz, old_div(-np.abs(Cmid-Pmid),2) + zsrc ])
|
||||
ax = axs
|
||||
|
||||
# Grid points
|
||||
@@ -184,14 +193,14 @@ def gen_DCIPsurvey(endl, mesh, stype, a, b, n):
|
||||
# Mesure survey length and direction
|
||||
dl_len = xy_2_r(endl[0,0],endl[1,0],endl[0,1],endl[1,1])
|
||||
|
||||
dl_x = ( endl[1,0] - endl[0,0] ) / dl_len
|
||||
dl_y = ( endl[1,1] - endl[0,1] ) / dl_len
|
||||
dl_x = old_div(( endl[1,0] - endl[0,0] ), dl_len)
|
||||
dl_y = old_div(( endl[1,1] - endl[0,1] ), dl_len)
|
||||
|
||||
nstn = np.floor( dl_len / a )
|
||||
nstn = np.floor( old_div(dl_len, a) )
|
||||
|
||||
# Compute discrete pole location along line
|
||||
stn_x = endl[0,0] + np.array(range(int(nstn)))*dl_x*a
|
||||
stn_y = endl[0,1] + np.array(range(int(nstn)))*dl_y*a
|
||||
stn_x = endl[0,0] + np.array(list(range(int(nstn))))*dl_x*a
|
||||
stn_y = endl[0,1] + np.array(list(range(int(nstn))))*dl_y*a
|
||||
|
||||
if mesh.dim==2:
|
||||
ztop = mesh.vectorNy[-1]
|
||||
@@ -230,15 +239,15 @@ def gen_DCIPsurvey(endl, mesh, stype, a, b, n):
|
||||
AB = xy_2_r(tx[0,1],endl[1,0],tx[1,1],endl[1,1])
|
||||
|
||||
# Number of receivers to fit
|
||||
nstn = np.min([np.floor( (AB - b) / a ) , n])
|
||||
nstn = np.min([np.floor( old_div((AB - b), a) ) , n])
|
||||
|
||||
# Check if there is enough space, else break the loop
|
||||
if nstn <= 0:
|
||||
continue
|
||||
|
||||
# Compute discrete pole location along line
|
||||
stn_x = N[ii,0] + dl_x*b + np.array(range(int(nstn)))*dl_x*a
|
||||
stn_y = N[ii,1] + dl_y*b + np.array(range(int(nstn)))*dl_y*a
|
||||
stn_x = N[ii,0] + dl_x*b + np.array(list(range(int(nstn))))*dl_x*a
|
||||
stn_y = N[ii,1] + dl_y*b + np.array(list(range(int(nstn))))*dl_y*a
|
||||
|
||||
# Create receiver poles
|
||||
|
||||
@@ -275,17 +284,17 @@ def gen_DCIPsurvey(endl, mesh, stype, a, b, n):
|
||||
max_y = endl[1,1] - dl_y * b
|
||||
|
||||
box_l = np.sqrt( (min_x - max_x)**2 + (min_y - max_y)**2 )
|
||||
box_w = box_l/2.
|
||||
box_w = old_div(box_l,2.)
|
||||
|
||||
nstn = np.floor( box_l / a )
|
||||
nstn = np.floor( old_div(box_l, a) )
|
||||
|
||||
# Compute discrete pole location along line
|
||||
stn_x = min_x + np.array(range(int(nstn)))*dl_x*a
|
||||
stn_y = min_y + np.array(range(int(nstn)))*dl_y*a
|
||||
stn_x = min_x + np.array(list(range(int(nstn))))*dl_x*a
|
||||
stn_y = min_y + np.array(list(range(int(nstn))))*dl_y*a
|
||||
|
||||
# Define number of cross lines
|
||||
nlin = int(np.floor( box_w / a ))
|
||||
lind = range(-nlin,nlin+1)
|
||||
nlin = int(np.floor( old_div(box_w, a) ))
|
||||
lind = list(range(-nlin,nlin+1))
|
||||
|
||||
ngrad = nstn * len(lind)
|
||||
|
||||
@@ -310,7 +319,7 @@ def gen_DCIPsurvey(endl, mesh, stype, a, b, n):
|
||||
srcClass = DC.Src.Dipole([rxClass], M[0,:], N[-1,:])
|
||||
SrcList.append(srcClass)
|
||||
else:
|
||||
print """stype must be either 'pdp', 'dpdp' or 'gradient'. """
|
||||
print("""stype must be either 'pdp', 'dpdp' or 'gradient'. """)
|
||||
|
||||
|
||||
return SrcList
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
from StaticUtils import *
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .StaticUtils import *
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
import DC
|
||||
import IP
|
||||
import SIP
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from . import DC
|
||||
from . import IP
|
||||
from . import SIP
|
||||
|
||||
+21
-14
@@ -1,3 +1,10 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from SimPEG import Solver, Problem
|
||||
from SimPEG.Problem import BaseTimeProblem
|
||||
from SimPEG.EM.Utils import *
|
||||
@@ -47,7 +54,7 @@ class BaseTDEMProblem(BaseTimeProblem, BaseEMProblem):
|
||||
self.waveformType = "GENERAL"
|
||||
|
||||
def fields(self, m):
|
||||
if self.verbose: print '%s\nCalculating fields(m)\n%s'%('*'*50,'*'*50)
|
||||
if self.verbose: print('%s\nCalculating fields(m)\n%s'%('*'*50,'*'*50))
|
||||
self.curModel = m
|
||||
# Create a fields storage object
|
||||
F = self._FieldsForward_pair(self.mesh, self.survey)
|
||||
@@ -55,7 +62,7 @@ class BaseTDEMProblem(BaseTimeProblem, BaseEMProblem):
|
||||
# Set the initial conditions
|
||||
F[src,:,0] = src.getInitialFields(self.mesh)
|
||||
F = self.forward(m, self.getRHS, F=F)
|
||||
if self.verbose: print '%s\nDone calculating fields(m)\n%s'%('*'*50,'*'*50)
|
||||
if self.verbose: print('%s\nDone calculating fields(m)\n%s'%('*'*50,'*'*50))
|
||||
return F
|
||||
|
||||
def forward(self, m, RHS, F=None):
|
||||
@@ -70,13 +77,13 @@ class BaseTDEMProblem(BaseTimeProblem, BaseEMProblem):
|
||||
if Ainv is not None:
|
||||
Ainv.clean()
|
||||
A = self.getA(tInd)
|
||||
if self.verbose: print 'Factoring... (dt = %e)'%dt
|
||||
if self.verbose: print('Factoring... (dt = %e)'%dt)
|
||||
Ainv = self.Solver(A, **self.solverOpts)
|
||||
if self.verbose: print 'Done'
|
||||
if self.verbose: print('Done')
|
||||
rhs = RHS(tInd, F)
|
||||
if self.verbose: print ' Solving... (tInd = %d)'%tInd
|
||||
if self.verbose: print(' Solving... (tInd = %d)'%tInd)
|
||||
sol = Ainv * rhs
|
||||
if self.verbose: print ' Done...'
|
||||
if self.verbose: print(' Done...')
|
||||
if sol.ndim == 1:
|
||||
sol.shape = (sol.size,1)
|
||||
F[:,self.solType,tInd+1] = sol
|
||||
@@ -95,13 +102,13 @@ class BaseTDEMProblem(BaseTimeProblem, BaseEMProblem):
|
||||
if Ainv is not None:
|
||||
Ainv.clean()
|
||||
A = self.getA(tInd)
|
||||
if self.verbose: print 'Factoring (Adjoint)... (dt = %e)'%dt
|
||||
if self.verbose: print('Factoring (Adjoint)... (dt = %e)'%dt)
|
||||
Ainv = self.Solver(A, **self.solverOpts)
|
||||
if self.verbose: print 'Done'
|
||||
if self.verbose: print('Done')
|
||||
rhs = RHS(tInd, F)
|
||||
if self.verbose: print ' Solving (Adjoint)... (tInd = %d)'%tInd
|
||||
if self.verbose: print(' Solving (Adjoint)... (tInd = %d)'%tInd)
|
||||
sol = Ainv * rhs
|
||||
if self.verbose: print ' Done...'
|
||||
if self.verbose: print(' Done...')
|
||||
if sol.ndim == 1:
|
||||
sol.shape = (sol.size,1)
|
||||
F[:,self.solType,tInd+1] = sol
|
||||
@@ -123,14 +130,14 @@ class BaseTDEMProblem(BaseTimeProblem, BaseEMProblem):
|
||||
* Compute \\\(\\\\vec{w} = -\\\mathbf{Q} \\\\vec{y}\\\)
|
||||
|
||||
"""
|
||||
if self.verbose: print '%s\nCalculating J(v)\n%s'%('*'*50,'*'*50)
|
||||
if self.verbose: print('%s\nCalculating J(v)\n%s'%('*'*50,'*'*50))
|
||||
self.curModel = m
|
||||
if f is None:
|
||||
f = self.fields(m)
|
||||
p = self.Gvec(m, v, f)
|
||||
y = self.solveAh(m, p)
|
||||
Jv = self.survey.evalDeriv(f, v=y)
|
||||
if self.verbose: print '%s\nDone calculating J(v)\n%s'%('*'*50,'*'*50)
|
||||
if self.verbose: print('%s\nDone calculating J(v)\n%s'%('*'*50,'*'*50))
|
||||
return - mkvc(Jv)
|
||||
|
||||
def Jtvec(self, m, v, f=None):
|
||||
@@ -148,7 +155,7 @@ class BaseTDEMProblem(BaseTimeProblem, BaseEMProblem):
|
||||
* Compute \\\(\\\\vec{w} = -\\\mathbf{G}^\\\\top y\\\)
|
||||
|
||||
"""
|
||||
if self.verbose: print '%s\nCalculating J^T(v)\n%s'%('*'*50,'*'*50)
|
||||
if self.verbose: print('%s\nCalculating J^T(v)\n%s'%('*'*50,'*'*50))
|
||||
self.curModel = m
|
||||
if f is None:
|
||||
f = self.fields(m)
|
||||
@@ -159,6 +166,6 @@ class BaseTDEMProblem(BaseTimeProblem, BaseEMProblem):
|
||||
p = self.survey.evalDeriv(f, v=v, adjoint=True)
|
||||
y = self.solveAht(m, p)
|
||||
w = self.Gtvec(m, y, f)
|
||||
if self.verbose: print '%s\nDone calculating J^T(v)\n%s'%('*'*50,'*'*50)
|
||||
if self.verbose: print('%s\nDone calculating J^T(v)\n%s'%('*'*50,'*'*50))
|
||||
return - mkvc(w)
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import Utils, Survey, np
|
||||
from SimPEG.Survey import BaseSurvey
|
||||
from SimPEG.EM.Utils import *
|
||||
from BaseTDEM import FieldsTDEM
|
||||
from .BaseTDEM import FieldsTDEM
|
||||
|
||||
|
||||
class RxTDEM(Survey.BaseTimeRx):
|
||||
@@ -87,7 +93,7 @@ class SrcTDEM_VMD_MVP(SrcTDEM):
|
||||
def getInitialFields(self, mesh):
|
||||
"""Vertical magnetic dipole, magnetic vector potential"""
|
||||
if self.waveformType == "STEPOFF":
|
||||
print ">> Step waveform: Non-zero initial condition"
|
||||
print(">> Step waveform: Non-zero initial condition")
|
||||
if mesh._meshType is 'CYL':
|
||||
if mesh.isSymmetric:
|
||||
MVP = MagneticDipoleVectorPotential(self.loc, mesh, 'Ey')
|
||||
@@ -99,7 +105,7 @@ class SrcTDEM_VMD_MVP(SrcTDEM):
|
||||
raise Exception('Unknown mesh for VMD')
|
||||
return {"b": mesh.edgeCurl*MVP}
|
||||
elif self.waveformType == "GENERAL":
|
||||
print ">> General waveform: Zero initial condition"
|
||||
print(">> General waveform: Zero initial condition")
|
||||
return {"b": np.zeros(mesh.nF)}
|
||||
else:
|
||||
raise NotImplementedError("Only use STEPOFF or GENERAL")
|
||||
@@ -127,7 +133,7 @@ class SrcTDEM_CircularLoop_MVP(SrcTDEM):
|
||||
def getInitialFields(self, mesh):
|
||||
"""Circular Loop, magnetic vector potential"""
|
||||
if self.waveformType == "STEPOFF":
|
||||
print ">> Step waveform: Non-zero initial condition"
|
||||
print(">> Step waveform: Non-zero initial condition")
|
||||
if mesh._meshType is 'CYL':
|
||||
if mesh.isSymmetric:
|
||||
MVP = MagneticLoopVectorPotential(self.loc, mesh, 'Ey', self.radius)
|
||||
@@ -139,7 +145,7 @@ class SrcTDEM_CircularLoop_MVP(SrcTDEM):
|
||||
raise Exception('Unknown mesh for CircularLoop')
|
||||
return {"b": mesh.edgeCurl*MVP}
|
||||
elif self.waveformType == "GENERAL":
|
||||
print ">> General waveform: Zero initial condition"
|
||||
print(">> General waveform: Zero initial condition")
|
||||
return {"b": np.zeros(mesh.nF)}
|
||||
else:
|
||||
raise NotImplementedError("Only use STEPOFF or GENERAL")
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
from BaseTDEM import BaseTDEMProblem, FieldsTDEM
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from .BaseTDEM import BaseTDEMProblem, FieldsTDEM
|
||||
from SimPEG.Utils import mkvc, sdiag
|
||||
import numpy as np
|
||||
from SurveyTDEM import SurveyTDEM
|
||||
from .SurveyTDEM import SurveyTDEM
|
||||
|
||||
|
||||
class FieldsTDEM_e_from_b(FieldsTDEM):
|
||||
@@ -69,14 +77,14 @@ class ProblemTDEM_b(BaseTDEMProblem):
|
||||
:return: A
|
||||
"""
|
||||
dt = self.timeSteps[tInd]
|
||||
return self.MfMui*self.mesh.edgeCurl*self.MeSigmaI*self.mesh.edgeCurl.T*self.MfMui + (1.0/dt)*self.MfMui
|
||||
return self.MfMui*self.mesh.edgeCurl*self.MeSigmaI*self.mesh.edgeCurl.T*self.MfMui + (old_div(1.0,dt))*self.MfMui
|
||||
|
||||
def getRHS(self, tInd, F):
|
||||
dt = self.timeSteps[tInd]
|
||||
B_n = np.c_[[F[src,'b',tInd] for src in self.survey.srcList]].T
|
||||
if B_n.shape[0] is not 1:
|
||||
raise NotImplementedError('getRHS not implemented for this shape of B_n')
|
||||
RHS = (1.0/dt)*self.MfMui*B_n[0,:,:] #TODO: This is a hack
|
||||
RHS = (old_div(1.0,dt))*self.MfMui*B_n[0,:,:] #TODO: This is a hack
|
||||
return RHS
|
||||
|
||||
####################################################
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from SurveyTDEM import * #SurveyTDEM, RxTDEM, SrcTDEM
|
||||
from BaseTDEM import BaseTDEMProblem, FieldsTDEM
|
||||
from TDEM_b import ProblemTDEM_b
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .SurveyTDEM import * #SurveyTDEM, RxTDEM, SrcTDEM
|
||||
from .BaseTDEM import BaseTDEMProblem, FieldsTDEM
|
||||
from .TDEM_b import ProblemTDEM_b
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from SimPEG import *
|
||||
from scipy.special import ellipk, ellipe
|
||||
from scipy.constants import mu_0, pi
|
||||
@@ -17,7 +25,7 @@ def MagneticDipoleVectorPotential(srcLoc, obsLoc, component, moment=1., dipoleMo
|
||||
#TODO: break this out!
|
||||
|
||||
if type(component) in [list, tuple]:
|
||||
out = range(len(component))
|
||||
out = list(range(len(component)))
|
||||
for i, comp in enumerate(component):
|
||||
out[i] = MagneticDipoleVectorPotential(srcLoc, obsLoc, comp, dipoleMoment=dipoleMoment)
|
||||
return np.concatenate(out)
|
||||
@@ -49,7 +57,7 @@ def MagneticDipoleVectorPotential(srcLoc, obsLoc, component, moment=1., dipoleMo
|
||||
dR = obsLoc - srcLoc[i, np.newaxis].repeat(nEdges, axis=0)
|
||||
mCr = np.cross(m, dR)
|
||||
r = np.sqrt((dR**2).sum(axis=1))
|
||||
A[:, i] = +(mu/(4*pi)) * mCr[:,dimInd]/(r**3)
|
||||
A[:, i] = +(old_div(mu,(4*pi))) * mCr[:,dimInd]/(r**3)
|
||||
if nSrc == 1:
|
||||
return A.flatten()
|
||||
return A
|
||||
@@ -90,11 +98,11 @@ def MagneticDipoleFields(srcLoc, obsLoc, component, moment=1., mu = mu_0):
|
||||
dR = obsLoc - srcLoc[i, np.newaxis].repeat(nFaces, axis=0)
|
||||
r = np.sqrt((dR**2).sum(axis=1))
|
||||
if dimInd == 0:
|
||||
B[:, i] = +(mu/(4*pi)) /(r**3) * (3*dR[:,2]*dR[:,0]/r**2)
|
||||
B[:, i] = +(old_div(mu,(4*pi))) /(r**3) * (3*dR[:,2]*dR[:,0]/r**2)
|
||||
elif dimInd == 1:
|
||||
B[:, i] = +(mu/(4*pi)) /(r**3) * (3*dR[:,2]*dR[:,1]/r**2)
|
||||
B[:, i] = +(old_div(mu,(4*pi))) /(r**3) * (3*dR[:,2]*dR[:,1]/r**2)
|
||||
elif dimInd == 2:
|
||||
B[:, i] = +(mu/(4*pi)) /(r**3) * (3*dR[:,2]**2/r**2-1)
|
||||
B[:, i] = +(old_div(mu,(4*pi))) /(r**3) * (3*dR[:,2]**2/r**2-1)
|
||||
else:
|
||||
raise Exception("Not Implemented")
|
||||
if nSrc == 1:
|
||||
@@ -118,7 +126,7 @@ def MagneticLoopVectorPotential(srcLoc, obsLoc, component, radius, mu=mu_0):
|
||||
"""
|
||||
|
||||
if type(component) in [list, tuple]:
|
||||
out = range(len(component))
|
||||
out = list(range(len(component)))
|
||||
for i, comp in enumerate(component):
|
||||
out[i] = MagneticLoopVectorPotential(srcLoc, obsLoc, comp, radius, mu)
|
||||
return np.concatenate(out)
|
||||
@@ -148,7 +156,7 @@ def MagneticLoopVectorPotential(srcLoc, obsLoc, component, radius, mu=mu_0):
|
||||
y = obsLoc[:, 1] - srcLoc[i, 1]
|
||||
z = obsLoc[:, 2] - srcLoc[i, 2]
|
||||
r = np.sqrt(x**2 + y**2)
|
||||
m = (4 * radius * r) / ((radius + r)**2 + z**2)
|
||||
m = old_div((4 * radius * r), ((radius + r)**2 + z**2))
|
||||
m[m > 1.] = 1.
|
||||
# m might be slightly larger than 1 due to rounding errors
|
||||
# but ellipke requires 0 <= m <= 1
|
||||
@@ -158,11 +166,11 @@ def MagneticLoopVectorPotential(srcLoc, obsLoc, component, radius, mu=mu_0):
|
||||
# % 1/r singular at r = 0 and K(m) singular at m = 1
|
||||
Aphi = np.zeros(n)
|
||||
# % Common factor is (mu * I) / pi with I = 1 and mu = 4e-7 * pi.
|
||||
Aphi[ind] = 4e-7 / np.sqrt(m[ind]) * np.sqrt(radius / r[ind]) *((1. - m[ind] / 2.) * K[ind] - E[ind])
|
||||
Aphi[ind] = 4e-7 / np.sqrt(m[ind]) * np.sqrt(old_div(radius, r[ind])) *((1. - old_div(m[ind], 2.)) * K[ind] - E[ind])
|
||||
if component == 'x':
|
||||
A[ind, i] = Aphi[ind] * (-y[ind] / r[ind] )
|
||||
A[ind, i] = Aphi[ind] * (old_div(-y[ind], r[ind]) )
|
||||
elif component == 'y':
|
||||
A[ind, i] = Aphi[ind] * ( x[ind] / r[ind] )
|
||||
A[ind, i] = Aphi[ind] * ( old_div(x[ind], r[ind]) )
|
||||
else:
|
||||
raise ValueError('Invalid component')
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
import numpy as np
|
||||
from scipy.constants import mu_0, epsilon_0
|
||||
|
||||
@@ -9,8 +16,8 @@ def omega(freq):
|
||||
def k(freq, sigma, mu=mu_0, eps=epsilon_0):
|
||||
""" Eq 1.47 - 1.49 in Ward and Hohmann """
|
||||
w = omega(freq)
|
||||
alp = w * np.sqrt( mu*eps/2 * ( np.sqrt(1. + (sigma / (eps*w))**2 ) + 1) )
|
||||
beta = w * np.sqrt( mu*eps/2 * ( np.sqrt(1. + (sigma / (eps*w))**2 ) - 1) )
|
||||
alp = w * np.sqrt( mu*eps/2 * ( np.sqrt(1. + (old_div(sigma, (eps*w)))**2 ) + 1) )
|
||||
beta = w * np.sqrt( mu*eps/2 * ( np.sqrt(1. + (old_div(sigma, (eps*w)))**2 ) - 1) )
|
||||
return alp - 1j*beta
|
||||
|
||||
|
||||
|
||||
@@ -1,2 +1,8 @@
|
||||
from EMUtils import omega, k
|
||||
from AnalyticUtils import MagneticDipoleFields, MagneticDipoleVectorPotential, MagneticLoopVectorPotential
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .EMUtils import omega, k
|
||||
from .AnalyticUtils import MagneticDipoleFields, MagneticDipoleVectorPotential, MagneticLoopVectorPotential
|
||||
@@ -1,3 +1,11 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from builtins import int
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
import unittest
|
||||
from SimPEG import *
|
||||
from SimPEG import EM
|
||||
@@ -24,7 +32,7 @@ def getFDEMProblem(fdemType, comp, SrcList, freq, useMu=False, verbose=False):
|
||||
else:
|
||||
mapping = Maps.ExpMap(mesh)
|
||||
|
||||
x = np.array([np.linspace(-5.*cs,-2.*cs,3),np.linspace(5.*cs,2.*cs,3)]) + cs/4. #don't sample right by the source, slightly off alignment from either staggered grid
|
||||
x = np.array([np.linspace(-5.*cs,-2.*cs,3),np.linspace(5.*cs,2.*cs,3)]) + old_div(cs,4.) #don't sample right by the source, slightly off alignment from either staggered grid
|
||||
XYZ = Utils.ndgrid(x,x,np.linspace(-2.*cs,2.*cs,5))
|
||||
Rx0 = getattr(EM.FDEM.Rx, 'Point_' + comp[0])
|
||||
if comp[2] == 'r':
|
||||
@@ -58,7 +66,7 @@ def getFDEMProblem(fdemType, comp, SrcList, freq, useMu=False, verbose=False):
|
||||
Src.append(EM.FDEM.Src.RawVec([rx0], freq, mesh.getEdgeInnerProduct()*S_m, S_e))
|
||||
|
||||
if verbose:
|
||||
print ' Fetching %s problem' % (fdemType)
|
||||
print(' Fetching %s problem' % (fdemType))
|
||||
|
||||
if fdemType == 'e':
|
||||
survey = EM.FDEM.Survey(Src)
|
||||
@@ -83,7 +91,7 @@ def getFDEMProblem(fdemType, comp, SrcList, freq, useMu=False, verbose=False):
|
||||
try:
|
||||
from pymatsolver import MumpsSolver
|
||||
prb.Solver = MumpsSolver
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
prb.Solver = SolverLU
|
||||
|
||||
return prb
|
||||
@@ -94,7 +102,7 @@ def crossCheckTest(SrcList, fdemType1, fdemType2, comp, addrandoms = False, useM
|
||||
|
||||
prb1 = getFDEMProblem(fdemType1, comp, SrcList, freq, useMu, verbose)
|
||||
mesh = prb1.mesh
|
||||
print 'Cross Checking Forward: %s, %s formulations - %s' % (fdemType1, fdemType2, comp)
|
||||
print('Cross Checking Forward: %s, %s formulations - %s' % (fdemType1, fdemType2, comp))
|
||||
|
||||
logsig = np.log(np.ones(mesh.nC)*CONDUCTIVITY)
|
||||
mu = np.ones(mesh.nC)*MU
|
||||
@@ -112,7 +120,7 @@ def crossCheckTest(SrcList, fdemType1, fdemType2, comp, addrandoms = False, useM
|
||||
d1 = survey1.dpred(m)
|
||||
|
||||
if verbose:
|
||||
print ' Problem 1 solved'
|
||||
print(' Problem 1 solved')
|
||||
|
||||
|
||||
prb2 = getFDEMProblem(fdemType2, comp, SrcList, freq, useMu, verbose)
|
||||
@@ -121,11 +129,11 @@ def crossCheckTest(SrcList, fdemType1, fdemType2, comp, addrandoms = False, useM
|
||||
d2 = survey2.dpred(m)
|
||||
|
||||
if verbose:
|
||||
print ' Problem 2 solved'
|
||||
print(' Problem 2 solved')
|
||||
|
||||
r = d2-d1
|
||||
l2r = l2norm(r)
|
||||
|
||||
tol = np.max([TOL*(10**int(np.log10(0.5* (l2norm(d1) + l2norm(d2)) ))),FLR])
|
||||
print l2norm(d1), l2norm(d2), l2r , tol, l2r < tol
|
||||
print(l2norm(d1), l2norm(d2), l2r , tol, l2r < tol)
|
||||
return l2r < tol
|
||||
|
||||
+12
-6
@@ -1,7 +1,13 @@
|
||||
import TDEM
|
||||
import FDEM
|
||||
import Static
|
||||
import Base
|
||||
import Analytics
|
||||
import Utils
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from . import TDEM
|
||||
from . import FDEM
|
||||
from . import Static
|
||||
from . import Base
|
||||
from . import Analytics
|
||||
from . import Utils
|
||||
from scipy.constants import mu_0, epsilon_0
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from SimPEG import *
|
||||
import SimPEG.EM.Static.DC as DC
|
||||
|
||||
@@ -29,7 +36,7 @@ def run(plotIt=True):
|
||||
try:
|
||||
from pymatsolver import MumpsSolver
|
||||
problem.Solver = MumpsSolver
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
pass
|
||||
data = survey.dpred(sigma)
|
||||
|
||||
@@ -38,7 +45,7 @@ def run(plotIt=True):
|
||||
rn = (srclocN.reshape([1,-1])).repeat(rxloc.shape[0], axis = 0)
|
||||
rP = np.sqrt(((rxloc-rp)**2).sum(axis=1))
|
||||
rN = np.sqrt(((rxloc-rn)**2).sum(axis=1))
|
||||
return I/(sigma*2.*np.pi)*(1/rP-1/rN)
|
||||
return I/(sigma*2.*np.pi)*(old_div(1,rP)-old_div(1,rN))
|
||||
|
||||
data_anaP = DChalf(np.r_[-200, 0, 0.],np.r_[+200, 0, 0.], xyz_rxP, sighalf)
|
||||
data_anaN = DChalf(np.r_[-200, 0, 0.],np.r_[+200, 0, 0.], xyz_rxN, sighalf)
|
||||
@@ -61,8 +68,8 @@ def run(plotIt=True):
|
||||
ax[0].set_title('Computed')
|
||||
plt.show()
|
||||
|
||||
return np.linalg.norm(data-data_ana)/np.linalg.norm(data_ana)
|
||||
return old_div(np.linalg.norm(data-data_ana),np.linalg.norm(data_ana))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print run()
|
||||
print(run())
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from builtins import int
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from SimPEG import Mesh, Utils, np, sp
|
||||
import SimPEG.DCIP as DC
|
||||
import time
|
||||
@@ -57,7 +66,7 @@ def run(loc=None, sig=None, radi=None, param=None, surveyType='dipole-dipole', u
|
||||
model[ind] = sig[2]
|
||||
|
||||
# Get index of the center
|
||||
indy = int(mesh.nCy/2)
|
||||
indy = int(old_div(mesh.nCy,2))
|
||||
|
||||
# Plot the model for reference
|
||||
# Define core mesh extent
|
||||
@@ -78,8 +87,8 @@ def run(loc=None, sig=None, radi=None, param=None, surveyType='dipole-dipole', u
|
||||
|
||||
# Define some global geometry
|
||||
dl_len = np.sqrt( np.sum((locs[0,:] - locs[1,:])**2) )
|
||||
dl_x = ( Tx[-1][0,1] - Tx[0][0,0] ) / dl_len
|
||||
dl_y = ( Tx[-1][1,1] - Tx[0][1,0] ) / dl_len
|
||||
dl_x = old_div(( Tx[-1][0,1] - Tx[0][0,0] ), dl_len)
|
||||
dl_y = old_div(( Tx[-1][1,1] - Tx[0][1,0] ), dl_len)
|
||||
#azm = np.arctan(dl_y/dl_x)
|
||||
|
||||
#Set boundary conditions
|
||||
@@ -89,7 +98,7 @@ def run(loc=None, sig=None, radi=None, param=None, surveyType='dipole-dipole', u
|
||||
# line source for simplicity.
|
||||
Div = mesh.faceDiv
|
||||
Grad = mesh.cellGrad
|
||||
Msig = Utils.sdiag(1./(mesh.aveF2CC.T*(1./model)))
|
||||
Msig = Utils.sdiag(old_div(1.,(mesh.aveF2CC.T*(old_div(1.,model)))))
|
||||
|
||||
A = Div*Msig*Grad
|
||||
|
||||
@@ -100,7 +109,7 @@ def run(loc=None, sig=None, radi=None, param=None, surveyType='dipole-dipole', u
|
||||
# We will solve the system iteratively, so a pre-conditioner is helpful
|
||||
# This is simply a Jacobi preconditioner (inverse of the main diagonal)
|
||||
dA = A.diagonal()
|
||||
P = sp.spdiags(1/dA,0,A.shape[0],A.shape[0])
|
||||
P = sp.spdiags(old_div(1,dA),0,A.shape[0],A.shape[0])
|
||||
|
||||
# Now we can solve the system for all the transmitters
|
||||
# We want to store the data
|
||||
@@ -124,10 +133,10 @@ def run(loc=None, sig=None, radi=None, param=None, surveyType='dipole-dipole', u
|
||||
tx = np.squeeze(Tx[ii][:,0:1])
|
||||
tinf = tx + np.array([dl_x,dl_y,0])*dl_len*2
|
||||
inds = Utils.closestPoints(mesh, np.c_[tx,tinf].T)
|
||||
RHS = mesh.getInterpolationMat(np.asarray(Tx[ii]).T, 'CC').T*( [-1] / mesh.vol[inds] )
|
||||
RHS = mesh.getInterpolationMat(np.asarray(Tx[ii]).T, 'CC').T*( old_div([-1], mesh.vol[inds]) )
|
||||
else:
|
||||
inds = Utils.closestPoints(mesh, np.asarray(Tx[ii]).T )
|
||||
RHS = mesh.getInterpolationMat(np.asarray(Tx[ii]).T, 'CC').T*( [-1,1] / mesh.vol[inds] )
|
||||
RHS = mesh.getInterpolationMat(np.asarray(Tx[ii]).T, 'CC').T*( old_div([-1,1], mesh.vol[inds]) )
|
||||
|
||||
# Iterative Solve
|
||||
Ainvb = sp.linalg.bicgstab(P*A,P*RHS, tol=1e-5)
|
||||
@@ -143,10 +152,10 @@ def run(loc=None, sig=None, radi=None, param=None, surveyType='dipole-dipole', u
|
||||
dtemp = (P1*phi - P2*phi)*np.pi
|
||||
|
||||
data.append( dtemp )
|
||||
print '\rTransmitter {0} of {1} -> Time:{2} sec'.format(ii,len(Tx),time.time()- start_time),
|
||||
print('\rTransmitter {0} of {1} -> Time:{2} sec'.format(ii,len(Tx),time.time()- start_time), end=' ')
|
||||
|
||||
print 'Transmitter {0} of {1}'.format(ii,len(Tx))
|
||||
print 'Forward completed'
|
||||
print('Transmitter {0} of {1}'.format(ii,len(Tx)))
|
||||
print('Forward completed')
|
||||
|
||||
# Let's just convert the 3D format into 2D (distance along line) and plot
|
||||
survey2D = DC.convertObs_DC3D_to_2D(survey, np.ones(survey.nSrc) , 'Xloc')
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import *
|
||||
import SimPEG.EM as EM
|
||||
from SimPEG.EM import mu_0
|
||||
@@ -56,7 +62,7 @@ def run(plotIt=True):
|
||||
try:
|
||||
from pymatsolver import MumpsSolver
|
||||
prb.Solver = MumpsSolver
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
prb.Solver = SolverLU
|
||||
|
||||
prb.pair(survey)
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import *
|
||||
import SimPEG.EM as EM
|
||||
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from SimPEG import *
|
||||
from SimPEG.EM import FDEM, Analytics, mu_0
|
||||
import time
|
||||
@@ -67,8 +75,8 @@ def run(plotIt=True):
|
||||
casing_l = 300 # length of the casing
|
||||
|
||||
casing_r = 0.1
|
||||
casing_a = casing_r - casing_t/2. # inner radius
|
||||
casing_b = casing_r + casing_t/2. # outer radius
|
||||
casing_a = casing_r - old_div(casing_t,2.) # inner radius
|
||||
casing_b = casing_r + old_div(casing_t,2.) # outer radius
|
||||
casing_z = np.r_[-casing_l,0.]
|
||||
|
||||
|
||||
@@ -78,25 +86,25 @@ def run(plotIt=True):
|
||||
src_loc = np.r_[0.,0.,dsz]
|
||||
inf_loc = np.r_[0.,0.,1e4]
|
||||
|
||||
print 'Skin Depth: ', [(500./np.sqrt(sigmaback*_)) for _ in freqs]
|
||||
print('Skin Depth: ', [(old_div(500.,np.sqrt(sigmaback*_))) for _ in freqs])
|
||||
|
||||
|
||||
# ------------------ MESH ------------------
|
||||
# fine cells near well bore
|
||||
csx1, csx2 = 2e-3, 60.
|
||||
pfx1, pfx2 = 1.3, 1.3
|
||||
ncx1 = np.ceil(casing_b/csx1+2)
|
||||
ncx1 = np.ceil(old_div(casing_b,csx1)+2)
|
||||
|
||||
# pad nicely to second cell size
|
||||
npadx1 = np.floor(np.log(csx2/csx1) / np.log(pfx1))
|
||||
npadx1 = np.floor(old_div(np.log(old_div(csx2,csx1)), np.log(pfx1)))
|
||||
hx1a,hx1b = Utils.meshTensor([(csx1,ncx1)]),Utils.meshTensor([(csx1,npadx1,pfx1)])
|
||||
dx1 = sum(hx1a)+sum(hx1b)
|
||||
dx1 = np.floor(dx1/csx2)
|
||||
hx1b *= (dx1*csx2 - sum(hx1a))/sum(hx1b)
|
||||
dx1 = np.floor(old_div(dx1,csx2))
|
||||
hx1b *= old_div((dx1*csx2 - sum(hx1a)),sum(hx1b))
|
||||
|
||||
# second chunk of mesh
|
||||
dx2 = 300. # uniform mesh out to here
|
||||
ncx2 = np.ceil((dx2 - dx1)/csx2)
|
||||
ncx2 = np.ceil(old_div((dx2 - dx1),csx2))
|
||||
npadx2 = 45
|
||||
hx2a, hx2b = Utils.meshTensor([(csx2,ncx2)]), Utils.meshTensor([(csx2,npadx2,pfx2)])
|
||||
hx = np.hstack([hx1a,hx1b,hx2a,hx2b])
|
||||
@@ -104,14 +112,14 @@ def run(plotIt=True):
|
||||
# z-direction
|
||||
csz = 0.05
|
||||
nza = 10
|
||||
ncz, npadzu, npadzd = np.int(np.ceil(np.diff(casing_z)[0]/csz))+10, 68, 68 # cell size, number of core cells, number of padding cells in the x- direction
|
||||
ncz, npadzu, npadzd = np.int(np.ceil(old_div(np.diff(casing_z)[0],csz)))+10, 68, 68 # cell size, number of core cells, number of padding cells in the x- direction
|
||||
hz = Utils.meshTensor([(csz,npadzd,-1.3), (csz,ncz), (csz,npadzu,1.3)]) # vector of cell widths in the z-direction
|
||||
|
||||
# Mesh
|
||||
mesh = Mesh.CylMesh([hx,1.,hz], [0.,0.,-np.sum(hz[:npadzu+ncz-nza])])
|
||||
|
||||
print 'Mesh Extent xmax: %f,: zmin: %f, zmax: %f'%(mesh.vectorCCx.max(), mesh.vectorCCz.min(), mesh.vectorCCz.max())
|
||||
print 'Number of cells', mesh.nC
|
||||
print('Mesh Extent xmax: %f,: zmin: %f, zmax: %f'%(mesh.vectorCCx.max(), mesh.vectorCCz.min(), mesh.vectorCCz.max()))
|
||||
print('Number of cells', mesh.nC)
|
||||
|
||||
if plotIt is True:
|
||||
fig, ax = plt.subplots(1, 1, figsize=(6, 4))
|
||||
@@ -182,7 +190,7 @@ def run(plotIt=True):
|
||||
|
||||
# assemble the source
|
||||
sg = np.hstack([sg_x,sg_y,sg_z])
|
||||
sg_p = [FDEM.Src.RawVec_e([],_,sg/mesh.area) for _ in freqs]
|
||||
sg_p = [FDEM.Src.RawVec_e([],_,old_div(sg,mesh.area)) for _ in freqs]
|
||||
|
||||
# downhole source
|
||||
dg_x = np.zeros(mesh.vnF[0],dtype=complex)
|
||||
@@ -191,7 +199,7 @@ def run(plotIt=True):
|
||||
|
||||
# vertically directed wire
|
||||
dgv_indx = (mesh.gridFz[:,0] < csx1) # go through the center of the well
|
||||
dgv_indz = (mesh.gridFz[:,2] <= +csz*nza) & (mesh.gridFz[:,2] > dsz + csz/2.)
|
||||
dgv_indz = (mesh.gridFz[:,2] <= +csz*nza) & (mesh.gridFz[:,2] > dsz + old_div(csz,2.))
|
||||
dgv_ind = dgv_indx & dgv_indz
|
||||
dg_z[dgv_ind] = -1.
|
||||
|
||||
@@ -213,7 +221,7 @@ def run(plotIt=True):
|
||||
|
||||
# assemble the source
|
||||
dg = np.hstack([dg_x,dg_y,dg_z])
|
||||
dg_p = [FDEM.Src.RawVec_e([],_,dg/mesh.area) for _ in freqs]
|
||||
dg_p = [FDEM.Src.RawVec_e([],_,old_div(dg,mesh.area)) for _ in freqs]
|
||||
|
||||
# ------------ Problem and Survey ---------------
|
||||
survey = FDEM.Survey(sg_p + dg_p)
|
||||
@@ -224,7 +232,7 @@ def run(plotIt=True):
|
||||
# ------------- Solve ---------------------------
|
||||
t0 = time.time()
|
||||
fieldsCasing = problem.fields(sigCasing)
|
||||
print 'Time to solve 2 sources', time.time() - t0
|
||||
print('Time to solve 2 sources', time.time() - t0)
|
||||
|
||||
# Plot current
|
||||
|
||||
@@ -251,9 +259,9 @@ def run(plotIt=True):
|
||||
in1_in = in1[np.r_[inds]]
|
||||
z_in = mesh.gridFz[inds_fz,2]
|
||||
|
||||
in0_in = in0_in.reshape([in0_in.shape[0]/3,3])
|
||||
in1_in = in1_in.reshape([in1_in.shape[0]/3,3])
|
||||
z_in = z_in.reshape([z_in.shape[0]/3,3])
|
||||
in0_in = in0_in.reshape([old_div(in0_in.shape[0],3),3])
|
||||
in1_in = in1_in.reshape([old_div(in1_in.shape[0],3),3])
|
||||
z_in = z_in.reshape([old_div(z_in.shape[0],3),3])
|
||||
|
||||
I0 = in0_in.sum(1).real
|
||||
I1 = in1_in.sum(1).real
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import *
|
||||
import SimPEG.EM as EM
|
||||
from SimPEG.EM import mu_0
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from SimPEG import *
|
||||
from SimPEG.FLOW import Richards
|
||||
|
||||
@@ -46,7 +53,7 @@ def run(plotIt=True):
|
||||
|
||||
|
||||
def getFields(timeStep,method):
|
||||
timeSteps = np.ones(360/timeStep)*timeStep
|
||||
timeSteps = np.ones(old_div(360,timeStep))*timeStep
|
||||
prob = Richards.RichardsProblem(M, mapping=E, timeSteps=timeSteps,
|
||||
boundaryConditions=bc, initialConditions=h,
|
||||
doNewton=False, method=method)
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from SimPEG import *
|
||||
|
||||
|
||||
@@ -47,10 +56,10 @@ def run(N=100, plotIt=True):
|
||||
|
||||
# Distance weighting
|
||||
wr = np.sum(prob.G**2.,axis=0)**0.5
|
||||
wr = ( wr/np.max(wr) )
|
||||
wr = ( old_div(wr,np.max(wr)) )
|
||||
|
||||
dmis = DataMisfit.l2_DataMisfit(survey)
|
||||
dmis.Wd = 1./wd
|
||||
dmis.Wd = old_div(1.,wd)
|
||||
|
||||
betaest = Directives.BetaEstimate_ByEig()
|
||||
|
||||
@@ -75,7 +84,7 @@ def run(N=100, plotIt=True):
|
||||
# Run inversion
|
||||
mrec = inv.run(m0)
|
||||
|
||||
print "Final misfit:" + str(invProb.dmisfit.eval(mrec))
|
||||
print("Final misfit:" + str(invProb.dmisfit.eval(mrec)))
|
||||
|
||||
|
||||
if plotIt:
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from SimPEG import *
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
import SimPEG as simpeg
|
||||
import numpy as np
|
||||
import SimPEG.MT as MT
|
||||
@@ -84,7 +91,7 @@ def run(plotIt=True):
|
||||
std = 0.05 # 5% std
|
||||
survey.std = np.abs(survey.dobs*std)
|
||||
# Assign the data weight
|
||||
Wd = 1./survey.std
|
||||
Wd = old_div(1.,survey.std)
|
||||
|
||||
## Setup the inversion proceedure
|
||||
# Define a counter
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
# Test script to use SimPEG.MT platform to forward model synthetic data.
|
||||
|
||||
# Import
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from builtins import dict
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import Mesh, Maps, np
|
||||
|
||||
def run(plotIt=True):
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from SimPEG import Mesh, Maps, Utils
|
||||
|
||||
def run(plotIt=True):
|
||||
@@ -12,7 +19,7 @@ def run(plotIt=True):
|
||||
|
||||
M = Mesh.TensorMesh([100,100])
|
||||
h1 = Utils.meshTensor([(6,7,-1.5),(6,10),(6,7,1.5)])
|
||||
h1 = h1/h1.sum()
|
||||
h1 = old_div(h1,h1.sum())
|
||||
M2 = Mesh.TensorMesh([h1,h1])
|
||||
V = Utils.ModelBuilder.randomModel(M.vnC, seed=79, its=50)
|
||||
v = Utils.mkvc(V)
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import Mesh, Utils, np, SolverLU
|
||||
|
||||
def run(plotIt=True):
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import *
|
||||
|
||||
def run(plotIt=True):
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import *
|
||||
|
||||
def run(plotIt=True):
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from builtins import int
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import zip
|
||||
from SimPEG import *
|
||||
|
||||
def run(plotIt=True, n=60):
|
||||
@@ -87,7 +95,7 @@ def run(plotIt=True, n=60):
|
||||
if elapsed > capture[jj]:
|
||||
PHIS += [(elapsed, phi.copy())]
|
||||
jj += 1
|
||||
if ii % 10 == 0: print ii, elapsed
|
||||
if ii % 10 == 0: print(ii, elapsed)
|
||||
ii += 1
|
||||
|
||||
if plotIt:
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from SimPEG import *
|
||||
|
||||
def run(plotIt=True):
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import zip
|
||||
from builtins import range
|
||||
from SimPEG import *
|
||||
|
||||
def run(plotIt=True, n=60):
|
||||
@@ -28,15 +36,15 @@ def run(plotIt=True, n=60):
|
||||
axes[0].set_xlim([-1,17])
|
||||
axes[0].set_ylim([-1,17])
|
||||
|
||||
for ii, loc in zip(range(M.nC),M.gridCC):
|
||||
for ii, loc in zip(list(range(M.nC)),M.gridCC):
|
||||
axes[0].text(loc[0]+0.2,loc[1],'%d'%ii, color='r')
|
||||
|
||||
axes[0].plot(M.gridFx[:,0],M.gridFx[:,1], 'g>')
|
||||
for ii, loc in zip(range(M.nFx),M.gridFx):
|
||||
for ii, loc in zip(list(range(M.nFx)),M.gridFx):
|
||||
axes[0].text(loc[0]+0.2,loc[1],'%d'%ii, color='g')
|
||||
|
||||
axes[0].plot(M.gridFy[:,0],M.gridFy[:,1], 'm^')
|
||||
for ii, loc in zip(range(M.nFy),M.gridFy):
|
||||
for ii, loc in zip(list(range(M.nFy)),M.gridFy):
|
||||
axes[0].text(loc[0]+0.2,loc[1]+0.2,'%d'%(ii+M.nFx), color='m')
|
||||
|
||||
axes[1].spy(M.faceDiv)
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import *
|
||||
|
||||
def run(plotIt=True):
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import *
|
||||
|
||||
def run(plotIt=True):
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import *
|
||||
from SimPEG.Utils import surface2ind_topo
|
||||
|
||||
|
||||
+30
-23
@@ -1,28 +1,35 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import division
|
||||
from builtins import open
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
# Run this file to add imports.
|
||||
|
||||
##### AUTOIMPORTS #####
|
||||
import DC_Analytic_Dipole
|
||||
import DC_Forward_PseudoSection
|
||||
import EM_FDEM_1D_Inversion
|
||||
import EM_FDEM_Analytic_MagDipoleWholespace
|
||||
import EM_Schenkel_Morrison_Casing
|
||||
import EM_TDEM_1D_Inversion
|
||||
import FLOW_Richards_1D_Celia1990
|
||||
import Inversion_IRLS
|
||||
import Inversion_Linear
|
||||
import Maps_ComboMaps
|
||||
import Maps_Mesh2Mesh
|
||||
import Mesh_Basic_ForwardDC
|
||||
import Mesh_Basic_PlotImage
|
||||
import Mesh_Basic_Types
|
||||
import Mesh_Operators_CahnHilliard
|
||||
import Mesh_QuadTree_Creation
|
||||
import Mesh_QuadTree_FaceDiv
|
||||
import Mesh_QuadTree_HangingNodes
|
||||
import Mesh_Tensor_Creation
|
||||
import MT_1D_ForwardAndInversion
|
||||
import MT_3D_Foward
|
||||
import Utils_surface2ind_topo
|
||||
from . import DC_Analytic_Dipole
|
||||
from . import DC_Forward_PseudoSection
|
||||
from . import EM_FDEM_1D_Inversion
|
||||
from . import EM_FDEM_Analytic_MagDipoleWholespace
|
||||
from . import EM_Schenkel_Morrison_Casing
|
||||
from . import EM_TDEM_1D_Inversion
|
||||
from . import FLOW_Richards_1D_Celia1990
|
||||
from . import Inversion_IRLS
|
||||
from . import Inversion_Linear
|
||||
from . import Maps_ComboMaps
|
||||
from . import Maps_Mesh2Mesh
|
||||
from . import Mesh_Basic_ForwardDC
|
||||
from . import Mesh_Basic_PlotImage
|
||||
from . import Mesh_Basic_Types
|
||||
from . import Mesh_Operators_CahnHilliard
|
||||
from . import Mesh_QuadTree_Creation
|
||||
from . import Mesh_QuadTree_FaceDiv
|
||||
from . import Mesh_QuadTree_HangingNodes
|
||||
from . import Mesh_Tensor_Creation
|
||||
from . import MT_1D_ForwardAndInversion
|
||||
from . import MT_3D_Foward
|
||||
from . import Utils_surface2ind_topo
|
||||
|
||||
__examples__ = ["DC_Analytic_Dipole", "DC_Forward_PseudoSection", "EM_FDEM_1D_Inversion", "EM_FDEM_Analytic_MagDipoleWholespace", "EM_Schenkel_Morrison_Casing", "EM_TDEM_1D_Inversion", "FLOW_Richards_1D_Celia1990", "Inversion_IRLS", "Inversion_Linear", "Maps_ComboMaps", "Maps_Mesh2Mesh", "Mesh_Basic_ForwardDC", "Mesh_Basic_PlotImage", "Mesh_Basic_Types", "Mesh_Operators_CahnHilliard", "Mesh_QuadTree_Creation", "Mesh_QuadTree_FaceDiv", "Mesh_QuadTree_HangingNodes", "Mesh_Tensor_Creation", "MT_1D_ForwardAndInversion", "MT_3D_Foward", "Utils_surface2ind_topo"]
|
||||
|
||||
@@ -104,7 +111,7 @@ if __name__ == '__main__':
|
||||
|
||||
rst = os.path.sep.join((filePath.split(os.path.sep)[:-3] + ['docs', 'content', 'examples', name + '.rst']))
|
||||
|
||||
print 'Creating: %s.rst'%name
|
||||
print('Creating: %s.rst'%name)
|
||||
f = open(rst, 'w')
|
||||
f.write(out)
|
||||
f.close()
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from builtins import object
|
||||
from SimPEG import Mesh, Maps, Utils, np
|
||||
from future.utils import with_metaclass
|
||||
|
||||
|
||||
class NonLinearMap(object):
|
||||
class NonLinearMap(with_metaclass(Utils.SimPEGMetaClass, object)):
|
||||
"""
|
||||
SimPEG NonLinearMap
|
||||
|
||||
"""
|
||||
|
||||
__metaclass__ = Utils.SimPEGMetaClass
|
||||
|
||||
counter = None #: A SimPEG.Utils.Counter object
|
||||
mesh = None #: A SimPEG Mesh
|
||||
|
||||
@@ -186,8 +193,8 @@ class _haverkamp_theta(NonLinearMap):
|
||||
|
||||
def transformDerivU(self, u, m):
|
||||
self.setModel(m)
|
||||
g = (self.alpha*((self.theta_s - self.theta_r)/
|
||||
(self.alpha + abs(u)**self.beta)**2)
|
||||
g = (self.alpha*(old_div((self.theta_s - self.theta_r),
|
||||
(self.alpha + abs(u)**self.beta)**2))
|
||||
*(-self.beta*abs(u)**(self.beta-1)*np.sign(u)))
|
||||
g[u >= 0] = 0
|
||||
g = Utils.sdiag(g)
|
||||
@@ -230,7 +237,7 @@ class _haverkamp_k(NonLinearMap):
|
||||
|
||||
def transformDerivU(self, u, m):
|
||||
self.setModel(m)
|
||||
g = -(np.exp(self.Ks)*self.A*self.gamma*abs(u)**(self.gamma-1)*np.sign(u))/((self.A+abs(u)**self.gamma)**2)
|
||||
g = old_div(-(np.exp(self.Ks)*self.A*self.gamma*abs(u)**(self.gamma-1)*np.sign(u)),((self.A+abs(u)**self.gamma)**2))
|
||||
g[u >= 0] = 0
|
||||
g = Utils.sdiag(g)
|
||||
return g
|
||||
@@ -272,9 +279,9 @@ class _vangenuchten_theta(NonLinearMap):
|
||||
|
||||
def transform(self, u, m):
|
||||
self.setModel(m)
|
||||
m = 1 - 1.0/self.n
|
||||
f = (( self.theta_s - self.theta_r )/
|
||||
((1+abs(self.alpha*u)**self.n)**m) + self.theta_r)
|
||||
m = 1 - old_div(1.0,self.n)
|
||||
f = (old_div(( self.theta_s - self.theta_r ),
|
||||
((1+abs(self.alpha*u)**self.n)**m)) + self.theta_r)
|
||||
if Utils.isScalar(self.theta_s):
|
||||
f[u >= 0] = self.theta_s
|
||||
else:
|
||||
@@ -286,7 +293,7 @@ class _vangenuchten_theta(NonLinearMap):
|
||||
self.setModel(m)
|
||||
|
||||
def transformDerivU(self, u, m):
|
||||
g = -self.alpha*self.n*abs(self.alpha*u)**(self.n - 1)*np.sign(self.alpha*u)*(1./self.n - 1)*(self.theta_r - self.theta_s)*(abs(self.alpha*u)**self.n + 1)**(1./self.n - 2)
|
||||
g = -self.alpha*self.n*abs(self.alpha*u)**(self.n - 1)*np.sign(self.alpha*u)*(old_div(1.,self.n) - 1)*(self.theta_r - self.theta_s)*(abs(self.alpha*u)**self.n + 1)**(old_div(1.,self.n) - 2)
|
||||
g[u >= 0] = 0
|
||||
g = Utils.sdiag(g)
|
||||
return g
|
||||
@@ -315,10 +322,10 @@ class _vangenuchten_k(NonLinearMap):
|
||||
I = self.I
|
||||
n = self.n
|
||||
Ks = self.Ks
|
||||
m = 1.0 - 1.0/n
|
||||
m = 1.0 - old_div(1.0,n)
|
||||
|
||||
theta_e = 1.0/((1.0+abs(alpha*u)**n)**m)
|
||||
f = np.exp(Ks)*theta_e**I* ( ( 1.0 - ( 1.0 - theta_e**(1.0/m) )**m )**2 )
|
||||
theta_e = old_div(1.0,((1.0+abs(alpha*u)**n)**m))
|
||||
f = np.exp(Ks)*theta_e**I* ( ( 1.0 - ( 1.0 - theta_e**(old_div(1.0,m)) )**m )**2 )
|
||||
if Utils.isScalar(self.Ks):
|
||||
f[u >= 0] = np.exp(self.Ks)
|
||||
else:
|
||||
@@ -341,9 +348,9 @@ class _vangenuchten_k(NonLinearMap):
|
||||
I = self.I
|
||||
n = self.n
|
||||
Ks = self.Ks
|
||||
m = 1.0 - 1.0/n
|
||||
m = 1.0 - old_div(1.0,n)
|
||||
|
||||
g = I*alpha*n*np.exp(Ks)*abs(alpha*u)**(n - 1.0)*np.sign(alpha*u)*(1.0/n - 1.0)*((abs(alpha*u)**n + 1)**(1.0/n - 1))**(I - 1)*((1 - 1.0/((abs(alpha*u)**n + 1)**(1.0/n - 1))**(1.0/(1.0/n - 1)))**(1 - 1.0/n) - 1)**2*(abs(alpha*u)**n + 1)**(1.0/n - 2) - (2*alpha*n*np.exp(Ks)*abs(alpha*u)**(n - 1)*np.sign(alpha*u)*(1.0/n - 1)*((abs(alpha*u)**n + 1)**(1.0/n - 1))**I*((1 - 1.0/((abs(alpha*u)**n + 1)**(1.0/n - 1))**(1.0/(1.0/n - 1)))**(1 - 1.0/n) - 1)*(abs(alpha*u)**n + 1)**(1.0/n - 2))/(((abs(alpha*u)**n + 1)**(1.0/n - 1))**(1.0/(1.0/n - 1) + 1)*(1 - 1.0/((abs(alpha*u)**n + 1)**(1.0/n - 1))**(1.0/(1.0/n - 1)))**(1.0/n))
|
||||
g = I*alpha*n*np.exp(Ks)*abs(alpha*u)**(n - 1.0)*np.sign(alpha*u)*(old_div(1.0,n) - 1.0)*((abs(alpha*u)**n + 1)**(old_div(1.0,n) - 1))**(I - 1)*((1 - old_div(1.0,((abs(alpha*u)**n + 1)**(old_div(1.0,n) - 1))**(old_div(1.0,(old_div(1.0,n) - 1)))))**(1 - old_div(1.0,n)) - 1)**2*(abs(alpha*u)**n + 1)**(old_div(1.0,n) - 2) - old_div((2*alpha*n*np.exp(Ks)*abs(alpha*u)**(n - 1)*np.sign(alpha*u)*(old_div(1.0,n) - 1)*((abs(alpha*u)**n + 1)**(old_div(1.0,n) - 1))**I*((1 - old_div(1.0,((abs(alpha*u)**n + 1)**(old_div(1.0,n) - 1))**(old_div(1.0,(old_div(1.0,n) - 1)))))**(1 - old_div(1.0,n)) - 1)*(abs(alpha*u)**n + 1)**(old_div(1.0,n) - 2)),(((abs(alpha*u)**n + 1)**(old_div(1.0,n) - 1))**(old_div(1.0,(old_div(1.0,n) - 1)) + 1)*(1 - old_div(1.0,((abs(alpha*u)**n + 1)**(old_div(1.0,n) - 1))**(old_div(1.0,(old_div(1.0,n) - 1)))))**(old_div(1.0,n))))
|
||||
g[u >= 0] = 0
|
||||
g = Utils.sdiag(g)
|
||||
return g
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from SimPEG import *
|
||||
from Empirical import RichardsMap
|
||||
from .Empirical import RichardsMap
|
||||
import time
|
||||
|
||||
|
||||
@@ -61,7 +69,7 @@ class RichardsSurvey(Survey.BaseSurvey):
|
||||
|
||||
@Utils.requires('prob')
|
||||
def eval(self, U, m):
|
||||
Ds = range(len(self.rxList))
|
||||
Ds = list(range(len(self.rxList)))
|
||||
for ii, rx in enumerate(self.rxList):
|
||||
Ds[ii] = rx.eval(U, m,
|
||||
self.prob.mapping,
|
||||
@@ -73,7 +81,7 @@ class RichardsSurvey(Survey.BaseSurvey):
|
||||
@Utils.requires('prob')
|
||||
def evalDeriv(self, U, m):
|
||||
"""The Derivative with respect to the fields."""
|
||||
Ds = range(len(self.rxList))
|
||||
Ds = list(range(len(self.rxList)))
|
||||
for ii, rx in enumerate(self.rxList):
|
||||
Ds[ii] = rx.evalDeriv(U, m,
|
||||
self.prob.mapping,
|
||||
@@ -135,12 +143,12 @@ class RichardsProblem(Problem.BaseTimeProblem):
|
||||
@Utils.timeIt
|
||||
def fields(self, m):
|
||||
tic = time.time()
|
||||
u = range(self.nT+1)
|
||||
u = list(range(self.nT+1))
|
||||
u[0] = self.initialConditions
|
||||
for ii, dt in enumerate(self.timeSteps):
|
||||
bc = self.getBoundaryConditions(ii, u[ii])
|
||||
u[ii+1] = self.rootFinder.root(lambda hn1m, return_g=True: self.getResidual(m, u[ii], hn1m, dt, bc, return_g=return_g), u[ii])
|
||||
if self.debug: print "Solving Fields (%4d/%d - %3.1f%% Done) %d Iterations, %4.2f seconds"%(ii+1, self.nT, 100.0*(ii+1)/self.nT, self.rootFinder.iter, time.time() - tic)
|
||||
if self.debug: print("Solving Fields (%4d/%d - %3.1f%% Done) %d Iterations, %4.2f seconds"%(ii+1, self.nT, 100.0*(ii+1)/self.nT, self.rootFinder.iter, time.time() - tic))
|
||||
return u
|
||||
|
||||
@Utils.timeIt
|
||||
@@ -168,7 +176,7 @@ class RichardsProblem(Problem.BaseTimeProblem):
|
||||
# DIV*diag(GRAD*hn1+BC*bc)*(AV*(1.0/K))^-1
|
||||
|
||||
DdiagGh1 = DIV*Utils.sdiag(GRAD*hn1+BC*bc)
|
||||
diagAVk2_AVdiagK2 = Utils.sdiag((AV*(1./K1))**(-2)) * AV*Utils.sdiag(K1**(-2))
|
||||
diagAVk2_AVdiagK2 = Utils.sdiag((AV*(old_div(1.,K1)))**(-2)) * AV*Utils.sdiag(K1**(-2))
|
||||
|
||||
# The matrix that we are computing has the form:
|
||||
#
|
||||
@@ -180,12 +188,12 @@ class RichardsProblem(Problem.BaseTimeProblem):
|
||||
# | Asub Adiag | | hn | | bn |
|
||||
# - - - - - -
|
||||
|
||||
Asub = (-1.0/dt)*dT
|
||||
Asub = (old_div(-1.0,dt))*dT
|
||||
|
||||
Adiag = (
|
||||
(1.0/dt)*dT1
|
||||
(old_div(1.0,dt))*dT1
|
||||
-DdiagGh1*diagAVk2_AVdiagK2*dK1
|
||||
-DIV*Utils.sdiag(1./(AV*(1./K1)))*GRAD
|
||||
-DIV*Utils.sdiag(old_div(1.,(AV*(old_div(1.,K1)))))*GRAD
|
||||
-Dz*diagAVk2_AVdiagK2*dK1
|
||||
)
|
||||
|
||||
@@ -215,17 +223,17 @@ class RichardsProblem(Problem.BaseTimeProblem):
|
||||
K = self.mapping.k(h, m)
|
||||
dK = self.mapping.kDerivU(h, m)
|
||||
|
||||
aveK = 1./(AV*(1./K))
|
||||
aveK = old_div(1.,(AV*(old_div(1.,K))))
|
||||
|
||||
RHS = DIV*Utils.sdiag(aveK)*(GRAD*h+BC*bc) + Dz*aveK
|
||||
if self.method == 'mixed':
|
||||
r = (T-Tn)/dt - RHS
|
||||
r = old_div((T-Tn),dt) - RHS
|
||||
elif self.method == 'head':
|
||||
r = dT*(h - hn)/dt - RHS
|
||||
|
||||
if not return_g: return r
|
||||
|
||||
J = dT/dt - DIV*Utils.sdiag(aveK)*GRAD
|
||||
J = old_div(dT,dt) - DIV*Utils.sdiag(aveK)*GRAD
|
||||
if self.doNewton:
|
||||
DDharmAve = Utils.sdiag(aveK**2)*AV*Utils.sdiag(K**(-2)) * dK
|
||||
J = J - DIV*Utils.sdiag(GRAD*h + BC*bc)*DDharmAve - Dz*DDharmAve
|
||||
@@ -238,7 +246,7 @@ class RichardsProblem(Problem.BaseTimeProblem):
|
||||
f = self.fields(m)
|
||||
|
||||
nn = len(f)-1
|
||||
Asubs, Adiags, Bs = range(nn), range(nn), range(nn)
|
||||
Asubs, Adiags, Bs = list(range(nn)), list(range(nn)), list(range(nn))
|
||||
for ii in range(nn):
|
||||
dt = self.timeSteps[ii]
|
||||
bc = self.getBoundaryConditions(ii, f[ii])
|
||||
@@ -263,7 +271,7 @@ class RichardsProblem(Problem.BaseTimeProblem):
|
||||
if f is None:
|
||||
f = self.fields(m)
|
||||
|
||||
JvC = range(len(f)-1) # Cell to hold each row of the long vector.
|
||||
JvC = list(range(len(f)-1)) # Cell to hold each row of the long vector.
|
||||
|
||||
# This is done via forward substitution.
|
||||
bc = self.getBoundaryConditions(0, f[0])
|
||||
@@ -295,7 +303,7 @@ class RichardsProblem(Problem.BaseTimeProblem):
|
||||
bc = self.getBoundaryConditions(ii-1, f[ii-1])
|
||||
Asub, Adiag, B = self.diagsJacobian(m, f[ii-1], f[ii], self.timeSteps[ii-1], bc)
|
||||
#select the correct part of v
|
||||
vpart = range((ii)*Adiag.shape[0], (ii+1)*Adiag.shape[0])
|
||||
vpart = list(range((ii)*Adiag.shape[0], (ii+1)*Adiag.shape[0]))
|
||||
AdiaginvT = self.Solver(Adiag.T, **self.solverOpts)
|
||||
JTvC = AdiaginvT * (PTv[vpart] - minus)
|
||||
minus = Asub.T*JTvC # this is now the super diagonal.
|
||||
|
||||
@@ -1,2 +1,8 @@
|
||||
import Empirical
|
||||
from RichardsProblem import *
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from . import Empirical
|
||||
from .RichardsProblem import *
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
import Richards
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from . import Richards
|
||||
|
||||
+11
-2
@@ -1,4 +1,13 @@
|
||||
import Utils, numpy as np, scipy.sparse as sp
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import range
|
||||
from builtins import object
|
||||
from . import Utils
|
||||
import numpy as np, scipy.sparse as sp
|
||||
|
||||
class Fields(object):
|
||||
"""Fancy Field Storage
|
||||
@@ -244,7 +253,7 @@ class TimeFields(Fields):
|
||||
out = func(pointerFields, srcII, timeII)
|
||||
else: #loop over the time steps
|
||||
nT = pointerShape[2]
|
||||
out = range(nT)
|
||||
out = list(range(nT))
|
||||
for i, TIND_i in enumerate(timeII):
|
||||
fieldI = pointerFields[:,:,i]
|
||||
if fieldI.shape[0] == fieldI.size:
|
||||
|
||||
+19
-12
@@ -1,14 +1,21 @@
|
||||
import Utils, Survey, Problem, numpy as np, scipy.sparse as sp, gc
|
||||
from Utils.SolverUtils import *
|
||||
import DataMisfit
|
||||
import Regularization
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import object
|
||||
from . import Utils, Survey, Problem
|
||||
import numpy as np, scipy.sparse as sp, gc
|
||||
from .Utils.SolverUtils import *
|
||||
from . import DataMisfit
|
||||
from . import Regularization
|
||||
from future.utils import with_metaclass
|
||||
|
||||
|
||||
class BaseInvProblem(object):
|
||||
class BaseInvProblem(with_metaclass(Utils.SimPEGMetaClass, object)):
|
||||
"""BaseInvProblem(dmisfit, reg, opt)"""
|
||||
|
||||
__metaclass__ = Utils.SimPEGMetaClass
|
||||
|
||||
beta = 1.0 #: Trade-off parameter
|
||||
|
||||
debug = False #: Print debugging information
|
||||
@@ -54,10 +61,10 @@ class BaseInvProblem(object):
|
||||
|
||||
Called when inversion is first starting.
|
||||
"""
|
||||
if self.debug: print 'Calling InvProblem.startup'
|
||||
if self.debug: print('Calling InvProblem.startup')
|
||||
|
||||
if self.reg.mref is None:
|
||||
print 'SimPEG.InvProblem will set Regularization.mref to m0.'
|
||||
print('SimPEG.InvProblem will set Regularization.mref to m0.')
|
||||
self.reg.mref = m0
|
||||
|
||||
self.phi_d = np.nan
|
||||
@@ -65,8 +72,8 @@ class BaseInvProblem(object):
|
||||
|
||||
self.curModel = m0
|
||||
|
||||
print """SimPEG.InvProblem is setting bfgsH0 to the inverse of the eval2Deriv.
|
||||
***Done using same Solver and solverOpts as the problem***"""
|
||||
print("""SimPEG.InvProblem is setting bfgsH0 to the inverse of the eval2Deriv.
|
||||
***Done using same Solver and solverOpts as the problem***""")
|
||||
self.opt.bfgsH0 = self.prob.Solver(self.reg.eval2Deriv(self.curModel), **self.prob.solverOpts)
|
||||
|
||||
@property
|
||||
@@ -87,7 +94,7 @@ class BaseInvProblem(object):
|
||||
for mtest, u_ofmtest in self.warmstart:
|
||||
if m is mtest:
|
||||
f = u_ofmtest
|
||||
if self.debug: print 'InvProb is Warm Starting!'
|
||||
if self.debug: print('InvProb is Warm Starting!')
|
||||
break
|
||||
|
||||
if f is None:
|
||||
|
||||
+11
-5
@@ -1,18 +1,24 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import object
|
||||
import SimPEG
|
||||
from SimPEG import Utils, sp, np
|
||||
from Optimization import Remember, IterationPrinters, StoppingCriteria
|
||||
import Directives
|
||||
from .Optimization import Remember, IterationPrinters, StoppingCriteria
|
||||
from . import Directives
|
||||
from future.utils import with_metaclass
|
||||
|
||||
|
||||
class BaseInversion(object):
|
||||
class BaseInversion(with_metaclass(Utils.SimPEGMetaClass, object)):
|
||||
"""
|
||||
|
||||
Inversion Class.
|
||||
|
||||
"""
|
||||
|
||||
__metaclass__ = Utils.SimPEGMetaClass
|
||||
|
||||
name = 'BaseInversion'
|
||||
|
||||
debug = False #: Print debugging information
|
||||
|
||||
+8
-2
@@ -1,7 +1,13 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import SolverLU as SimpegSolver, PropMaps, Utils, mkvc, sp, np
|
||||
from SimPEG.EM.FDEM.ProblemFDEM import BaseFDEMProblem
|
||||
from SurveyMT import Survey, Data
|
||||
from FieldsMT import BaseMTFields
|
||||
from .SurveyMT import Survey, Data
|
||||
from .FieldsMT import BaseMTFields
|
||||
|
||||
|
||||
class BaseMTProblem(BaseFDEMProblem):
|
||||
|
||||
+12
-5
@@ -1,3 +1,10 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from SimPEG import Survey, Utils, Problem, np, sp, mkvc
|
||||
from scipy.constants import mu_0
|
||||
import sys
|
||||
@@ -63,7 +70,7 @@ class Fields1D_e(BaseMTFields):
|
||||
C = self.mesh.nodalGrad
|
||||
b = (C * eSolution)
|
||||
for i, src in enumerate(srcList):
|
||||
b[:,i] *= - 1./(1j*omega(src.freq))
|
||||
b[:,i] *= old_div(- 1.,(1j*omega(src.freq)))
|
||||
# There is no magnetic source in the MT problem
|
||||
# S_m, _ = src.eval(self.survey.prob)
|
||||
# if S_m is not None:
|
||||
@@ -188,7 +195,7 @@ class Fields3D_e(BaseMTFields):
|
||||
# adjoint: returns a 2*nE long vector with zero's for py
|
||||
return np.vstack((v,np.zeros_like(v)))
|
||||
# Not adjoint: return only the px part of the vector
|
||||
return v[:len(v)/2]
|
||||
return v[:old_div(len(v),2)]
|
||||
|
||||
def _e_pyDeriv_u(self, src, v, adjoint = False):
|
||||
'''
|
||||
@@ -198,7 +205,7 @@ class Fields3D_e(BaseMTFields):
|
||||
# adjoint: returns a 2*nE long vector with zero's for px
|
||||
return np.vstack((np.zeros_like(v),v))
|
||||
# Not adjoint: return only the px part of the vector
|
||||
return v[len(v)/2::]
|
||||
return v[old_div(len(v),2)::]
|
||||
|
||||
def _e_pxDeriv_m(self, src, v, adjoint = False):
|
||||
# assuming primary does not depend on the model
|
||||
@@ -227,7 +234,7 @@ class Fields3D_e(BaseMTFields):
|
||||
C = self.mesh.edgeCurl
|
||||
b = (C * e_pxSolution)
|
||||
for i, src in enumerate(srcList):
|
||||
b[:,i] *= - 1./(1j*omega(src.freq))
|
||||
b[:,i] *= old_div(- 1.,(1j*omega(src.freq)))
|
||||
# There is no magnetic source in the MT problem
|
||||
# S_m, _ = src.eval(self.survey.prob)
|
||||
# if S_m is not None:
|
||||
@@ -238,7 +245,7 @@ class Fields3D_e(BaseMTFields):
|
||||
C = self.mesh.edgeCurl
|
||||
b = (C * e_pySolution)
|
||||
for i, src in enumerate(srcList):
|
||||
b[:,i] *= - 1./(1j*omega(src.freq))
|
||||
b[:,i] *= old_div(- 1.,(1j*omega(src.freq)))
|
||||
# There is no magnetic source in the MT problem
|
||||
# S_m, _ = src.eval(self.survey.prob)
|
||||
# if S_m is not None:
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from SimPEG.EM.Utils import omega
|
||||
from SimPEG import mkvc
|
||||
from scipy.constants import mu_0
|
||||
@@ -46,7 +53,7 @@ class eForm_psField(BaseMTProblem):
|
||||
Edge inner product matrix
|
||||
"""
|
||||
if getattr(self, '_MeMui', None) is None:
|
||||
self._MeMui = self.mesh.getEdgeInnerProduct(1.0/mu_0)
|
||||
self._MeMui = self.mesh.getEdgeInnerProduct(old_div(1.0,mu_0))
|
||||
return self._MeMui
|
||||
|
||||
@property
|
||||
@@ -142,7 +149,7 @@ class eForm_psField(BaseMTProblem):
|
||||
for freq in self.survey.freqs:
|
||||
if self.verbose:
|
||||
startTime = time.time()
|
||||
print 'Starting work for {:.3e}'.format(freq)
|
||||
print('Starting work for {:.3e}'.format(freq))
|
||||
sys.stdout.flush()
|
||||
A = self.getA(freq)
|
||||
rhs = self.getRHS(freq)
|
||||
@@ -158,7 +165,7 @@ class eForm_psField(BaseMTProblem):
|
||||
# b = -( self.mesh.nodalGrad * e )/( 1j*omega(freq) )
|
||||
# F[Src, 'b_1d'] = b[:,1]
|
||||
if self.verbose:
|
||||
print 'Ran for {:f} seconds'.format(time.time()-startTime)
|
||||
print('Ran for {:f} seconds'.format(time.time()-startTime))
|
||||
sys.stdout.flush()
|
||||
return F
|
||||
|
||||
@@ -191,7 +198,7 @@ class eForm_TotalField(BaseMTProblem):
|
||||
Edge inner product matrix
|
||||
"""
|
||||
if getattr(self, '_MeMui', None) is None:
|
||||
self._MeMui = self.mesh.getEdgeInnerProduct(1.0/mu_0)
|
||||
self._MeMui = self.mesh.getEdgeInnerProduct(old_div(1.0,mu_0))
|
||||
return self._MeMui
|
||||
|
||||
@property
|
||||
@@ -249,7 +256,7 @@ class eForm_TotalField(BaseMTProblem):
|
||||
Ed, Eu, Hd, Hu = getEHfields(self.mesh,self.curModel.sigma,freq,self.mesh.vectorNx)
|
||||
Etot = (Ed + Eu)
|
||||
sourceAmp = 1.0
|
||||
Etot = ((Etot/Etot[-1])*sourceAmp) # Scale the fields to be equal to sourceAmp at the top
|
||||
Etot = ((old_div(Etot,Etot[-1]))*sourceAmp) # Scale the fields to be equal to sourceAmp at the top
|
||||
## Note: The analytic solution is derived with e^iwt
|
||||
eBC = np.r_[Etot[0],Etot[-1]]
|
||||
# The right hand side
|
||||
@@ -274,7 +281,7 @@ class eForm_TotalField(BaseMTProblem):
|
||||
for freq in self.survey.freqs:
|
||||
if self.verbose:
|
||||
startTime = time.time()
|
||||
print 'Starting work for {:.3e}'.format(freq)
|
||||
print('Starting work for {:.3e}'.format(freq))
|
||||
sys.stdout.flush()
|
||||
A = self.getA(freq)
|
||||
rhs, e_o = self.getRHS(freq)
|
||||
@@ -286,6 +293,6 @@ class eForm_TotalField(BaseMTProblem):
|
||||
# NOTE: only store e fields
|
||||
F[Src, 'e_1dSolution'] = e[:,0]
|
||||
if self.verbose:
|
||||
print 'Ran for {:f} seconds'.format(time.time()-startTime)
|
||||
print('Ran for {:f} seconds'.format(time.time()-startTime))
|
||||
sys.stdout.flush()
|
||||
return F
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
from Probs import eForm_TotalField, eForm_psField
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .Probs import eForm_TotalField, eForm_psField
|
||||
@@ -1 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
pass
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from SimPEG import Survey, Problem, Utils, Models, np, sp, mkvc, SolverLU as SimpegSolver
|
||||
from SimPEG.EM.Utils import omega
|
||||
from scipy.constants import mu_0
|
||||
@@ -115,7 +121,7 @@ class eForm_ps(BaseMTProblem):
|
||||
for freq in self.survey.freqs:
|
||||
if self.verbose:
|
||||
startTime = time.time()
|
||||
print 'Starting work for {:.3e}'.format(freq)
|
||||
print('Starting work for {:.3e}'.format(freq))
|
||||
sys.stdout.flush()
|
||||
A = self.getA(freq)
|
||||
rhs = self.getRHS(freq)
|
||||
@@ -131,7 +137,7 @@ class eForm_ps(BaseMTProblem):
|
||||
# Note curl e = -iwb so b = -curl/iw
|
||||
|
||||
if self.verbose:
|
||||
print 'Ran for {:f} seconds'.format(time.time()-startTime)
|
||||
print('Ran for {:f} seconds'.format(time.time()-startTime))
|
||||
sys.stdout.flush()
|
||||
Ainv.clean()
|
||||
return F
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
from Probs import eForm_ps
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .Probs import eForm_ps
|
||||
+11
-4
@@ -1,10 +1,17 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from SimPEG import Utils, Problem, Maps, np, sp, mkvc
|
||||
from SimPEG.EM.FDEM.SrcFDEM import BaseSrc as FDEMBaseSrc
|
||||
from SimPEG.EM.Utils import omega
|
||||
from scipy.constants import mu_0
|
||||
from numpy.lib import recfunctions as recFunc
|
||||
from Utils.sourceUtils import homo1DModelSource
|
||||
from Utils import rec2ndarr
|
||||
from .Utils.sourceUtils import homo1DModelSource
|
||||
from .Utils import rec2ndarr
|
||||
import sys
|
||||
|
||||
#################
|
||||
@@ -78,7 +85,7 @@ class polxy_1Dprimary(BaseMTSrc):
|
||||
C = problem.mesh.nodalGrad
|
||||
elif problem.mesh.dim == 3:
|
||||
C = problem.mesh.edgeCurl
|
||||
bBG_bp = (- C * self.ePrimary(problem) )*(1/( 1j*omega(self.freq) ))
|
||||
bBG_bp = (- C * self.ePrimary(problem) )*(old_div(1,( 1j*omega(self.freq) )))
|
||||
return bBG_bp
|
||||
|
||||
def S_e(self,problem):
|
||||
@@ -155,7 +162,7 @@ class polxy_3Dprimary(BaseMTSrc):
|
||||
C = problem.mesh.nodalGrad
|
||||
elif problem.mesh.dim == 3:
|
||||
C = problem.mesh.edgeCurl
|
||||
bBG_bp = (- C * self.ePrimary(problem) )*(1/( 1j*omega(self.freq) ))
|
||||
bBG_bp = (- C * self.ePrimary(problem) )*(old_div(1,( 1j*omega(self.freq) )))
|
||||
return bBG_bp
|
||||
|
||||
def S_e(self,problem):
|
||||
|
||||
+28
-21
@@ -1,10 +1,17 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from SimPEG import Survey as SimPEGsurvey, Utils, Problem, Maps, np, sp, mkvc
|
||||
from SimPEG.EM.FDEM.SrcFDEM import BaseSrc as FDEMBaseSrc
|
||||
from SimPEG.EM.Utils import omega
|
||||
from scipy.constants import mu_0
|
||||
from numpy.lib import recfunctions as recFunc
|
||||
from Utils import rec2ndarr
|
||||
import SrcMT
|
||||
from .Utils import rec2ndarr
|
||||
from . import SrcMT
|
||||
import sys
|
||||
|
||||
#################
|
||||
@@ -76,7 +83,7 @@ class Rx(SimPEGsurvey.BaseRx):
|
||||
bx = Pbx*mkvc(f[src,'b_1d'],2)/mu_0
|
||||
# Note: Has a minus sign in front, to comply with quadrant calculations.
|
||||
# Can be derived from zyx case for the 3D case.
|
||||
f_part_complex = -ex/bx
|
||||
f_part_complex = old_div(-ex,bx)
|
||||
# elif self.projType is 'Z2D':
|
||||
elif self.projType is 'Z3D':
|
||||
## NOTE: Assumes that e is on edges and b on the faces. Need to generalize that or use a prop of fields to determine that.
|
||||
@@ -103,13 +110,13 @@ class Rx(SimPEGsurvey.BaseRx):
|
||||
hy_py = Pby*f[src,'b_py']/mu_0
|
||||
# Make the complex data
|
||||
if 'zxx' in self.rxType:
|
||||
f_part_complex = ( ex_px*hy_py - ex_py*hy_px)/(hx_px*hy_py - hx_py*hy_px)
|
||||
f_part_complex = old_div(( ex_px*hy_py - ex_py*hy_px),(hx_px*hy_py - hx_py*hy_px))
|
||||
elif 'zxy' in self.rxType:
|
||||
f_part_complex = (-ex_px*hx_py + ex_py*hx_px)/(hx_px*hy_py - hx_py*hy_px)
|
||||
f_part_complex = old_div((-ex_px*hx_py + ex_py*hx_px),(hx_px*hy_py - hx_py*hy_px))
|
||||
elif 'zyx' in self.rxType:
|
||||
f_part_complex = ( ey_px*hy_py - ey_py*hy_px)/(hx_px*hy_py - hx_py*hy_px)
|
||||
f_part_complex = old_div(( ey_px*hy_py - ey_py*hy_px),(hx_px*hy_py - hx_py*hy_px))
|
||||
elif 'zyy' in self.rxType:
|
||||
f_part_complex = (-ey_px*hx_py + ey_py*hx_px)/(hx_px*hy_py - hx_py*hy_px)
|
||||
f_part_complex = old_div((-ey_px*hx_py + ey_py*hx_px),(hx_px*hy_py - hx_py*hy_px))
|
||||
elif self.projType is 'T3D':
|
||||
if self.locs.ndim == 3:
|
||||
horLoc = self.locs[:,:,0]
|
||||
@@ -127,9 +134,9 @@ class Rx(SimPEGsurvey.BaseRx):
|
||||
by_py = Pby*f[src,'b_py']
|
||||
bz_py = Pbz*f[src,'b_py']
|
||||
if 'tzx' in self.rxType:
|
||||
f_part_complex = (- by_px*bz_py + by_py*bz_px)/(bx_px*by_py - bx_py*by_px)
|
||||
f_part_complex = old_div((- by_px*bz_py + by_py*bz_px),(bx_px*by_py - bx_py*by_px))
|
||||
if 'tzy' in self.rxType:
|
||||
f_part_complex = ( bx_px*bz_py - bx_py*bz_px)/(bx_px*by_py - bx_py*by_px)
|
||||
f_part_complex = old_div(( bx_px*bz_py - bx_py*bz_px),(bx_px*by_py - bx_py*by_px))
|
||||
|
||||
else:
|
||||
NotImplementedError('Projection of {:s} receiver type is not implemented.'.format(self.rxType))
|
||||
@@ -157,8 +164,8 @@ class Rx(SimPEGsurvey.BaseRx):
|
||||
Pbx = mesh.getInterpolationMat(self.locs[:,-1],'Ex')
|
||||
# ex = Pex*mkvc(f[src,'e_1d'],2)
|
||||
# bx = Pbx*mkvc(f[src,'b_1d'],2)/mu_0
|
||||
dP_de = -mkvc(Utils.sdiag(1./(Pbx*mkvc(f[src,'b_1d'],2)/mu_0))*(Pex*v),2)
|
||||
dP_db = mkvc( Utils.sdiag(Pex*mkvc(f[src,'e_1d'],2))*(Utils.sdiag(1./(Pbx*mkvc(f[src,'b_1d'],2)/mu_0)).T*Utils.sdiag(1./(Pbx*mkvc(f[src,'b_1d'],2)/mu_0)))*(Pbx*f._bDeriv_u(src,v)/mu_0),2)
|
||||
dP_de = -mkvc(Utils.sdiag(old_div(1.,(Pbx*mkvc(f[src,'b_1d'],2)/mu_0)))*(Pex*v),2)
|
||||
dP_db = mkvc( Utils.sdiag(Pex*mkvc(f[src,'e_1d'],2))*(Utils.sdiag(old_div(1.,(Pbx*mkvc(f[src,'b_1d'],2)/mu_0))).T*Utils.sdiag(old_div(1.,(Pbx*mkvc(f[src,'b_1d'],2)/mu_0))))*(Pbx*f._bDeriv_u(src,v)/mu_0),2)
|
||||
PDeriv_complex = np.sum(np.hstack((dP_de,dP_db)),1)
|
||||
elif self.projType is 'Z2D':
|
||||
raise NotImplementedError('Has not been implement for 2D impedance tensor')
|
||||
@@ -198,7 +205,7 @@ class Rx(SimPEGsurvey.BaseRx):
|
||||
# Update the input vector
|
||||
sDiag = lambda t: Utils.sdiag(mkvc(t,2))
|
||||
# Define the components of the derivative
|
||||
Hd = sDiag(1./(sDiag(hx_px)*hy_py - sDiag(hx_py)*hy_px))
|
||||
Hd = sDiag(old_div(1.,(sDiag(hx_px)*hy_py - sDiag(hx_py)*hy_px)))
|
||||
Hd_uV = sDiag(hy_py)*hx_px_u(v) + sDiag(hx_px)*hy_py_u(v) - sDiag(hx_py)*hy_px_u(v) - sDiag(hy_px)*hx_py_u(v)
|
||||
# Calculate components
|
||||
if 'zxx' in self.rxType:
|
||||
@@ -247,7 +254,7 @@ class Rx(SimPEGsurvey.BaseRx):
|
||||
# Update the input vector
|
||||
sDiag = lambda t: Utils.sdiag(mkvc(t,2))
|
||||
# Define the components of the derivative
|
||||
Hd = sDiag(1./(sDiag(bx_px)*by_py - sDiag(bx_py)*by_px))
|
||||
Hd = sDiag(old_div(1.,(sDiag(bx_px)*by_py - sDiag(bx_py)*by_px)))
|
||||
Hd_uV = sDiag(by_py)*bx_px_u(v) + sDiag(bx_px)*by_py_u(v) - sDiag(bx_py)*by_px_u(v) - sDiag(by_px)*bx_py_u(v)
|
||||
if 'tzx' in self.rxType:
|
||||
Tij = sDiag(Hd*( - sDiag(by_px)*bz_py + sDiag(by_py)*bz_px ))
|
||||
@@ -267,8 +274,8 @@ class Rx(SimPEGsurvey.BaseRx):
|
||||
Pbx = mesh.getInterpolationMat(self.locs[:,-1],'Ex')
|
||||
# ex = Pex*mkvc(f[src,'e_1d'],2)
|
||||
# bx = Pbx*mkvc(f[src,'b_1d'],2)/mu_0
|
||||
dP_deTv = -mkvc(Pex.T*Utils.sdiag(1./(Pbx*mkvc(f[src,'b_1d'],2)/mu_0)).T*v,2)
|
||||
db_duv = Pbx.T/mu_0*Utils.sdiag(1./(Pbx*mkvc(f[src,'b_1d'],2)/mu_0))*(Utils.sdiag(1./(Pbx*mkvc(f[src,'b_1d'],2)/mu_0))).T*Utils.sdiag(Pex*mkvc(f[src,'e_1d'],2)).T*v
|
||||
dP_deTv = -mkvc(Pex.T*Utils.sdiag(old_div(1.,(Pbx*mkvc(f[src,'b_1d'],2)/mu_0))).T*v,2)
|
||||
db_duv = Pbx.T/mu_0*Utils.sdiag(old_div(1.,(Pbx*mkvc(f[src,'b_1d'],2)/mu_0)))*(Utils.sdiag(old_div(1.,(Pbx*mkvc(f[src,'b_1d'],2)/mu_0)))).T*Utils.sdiag(Pex*mkvc(f[src,'e_1d'],2)).T*v
|
||||
dP_dbTv = mkvc(f._bDeriv_u(src,db_duv,adjoint=True),2)
|
||||
PDeriv_real = np.sum(np.hstack((dP_deTv,dP_dbTv)),1)
|
||||
elif self.projType is 'Z2D':
|
||||
@@ -300,17 +307,17 @@ class Rx(SimPEGsurvey.BaseRx):
|
||||
aey_px_u = lambda vec: f._e_pxDeriv_u(src,Pey.T*vec,adjoint=True)
|
||||
aex_py_u = lambda vec: f._e_pyDeriv_u(src,Pex.T*vec,adjoint=True)
|
||||
aey_py_u = lambda vec: f._e_pyDeriv_u(src,Pey.T*vec,adjoint=True)
|
||||
ahx_px_u = lambda vec: f._b_pxDeriv_u(src,Pbx.T*vec,adjoint=True)/mu_0
|
||||
ahy_px_u = lambda vec: f._b_pxDeriv_u(src,Pby.T*vec,adjoint=True)/mu_0
|
||||
ahx_py_u = lambda vec: f._b_pyDeriv_u(src,Pbx.T*vec,adjoint=True)/mu_0
|
||||
ahy_py_u = lambda vec: f._b_pyDeriv_u(src,Pby.T*vec,adjoint=True)/mu_0
|
||||
ahx_px_u = lambda vec: old_div(f._b_pxDeriv_u(src,Pbx.T*vec,adjoint=True),mu_0)
|
||||
ahy_px_u = lambda vec: old_div(f._b_pxDeriv_u(src,Pby.T*vec,adjoint=True),mu_0)
|
||||
ahx_py_u = lambda vec: old_div(f._b_pyDeriv_u(src,Pbx.T*vec,adjoint=True),mu_0)
|
||||
ahy_py_u = lambda vec: old_div(f._b_pyDeriv_u(src,Pby.T*vec,adjoint=True),mu_0)
|
||||
|
||||
# Update the input vector
|
||||
# Define shortcuts
|
||||
sDiag = lambda t: Utils.sdiag(mkvc(t,2))
|
||||
sVec = lambda t: Utils.sp.csr_matrix(mkvc(t,2))
|
||||
# Define the components of the derivative
|
||||
aHd = sDiag(1./(sDiag(ahx_px)*ahy_py - sDiag(ahx_py)*ahy_px))
|
||||
aHd = sDiag(old_div(1.,(sDiag(ahx_px)*ahy_py - sDiag(ahx_py)*ahy_px)))
|
||||
aHd_uV = lambda x: ahx_px_u(sDiag(ahy_py)*x) + ahx_px_u(sDiag(ahy_py)*x) - ahy_px_u(sDiag(ahx_py)*x) - ahx_py_u(sDiag(ahy_px)*x)
|
||||
# Need to fix this to reflect the adjoint
|
||||
if 'zxx' in self.rxType:
|
||||
@@ -362,7 +369,7 @@ class Rx(SimPEGsurvey.BaseRx):
|
||||
sDiag = lambda t: Utils.sdiag(mkvc(t,2))
|
||||
sVec = lambda t: Utils.sp.csr_matrix(mkvc(t,2))
|
||||
# Define the components of the derivative
|
||||
aHd = sDiag(1./(sDiag(abx_px)*aby_py - sDiag(abx_py)*aby_px))
|
||||
aHd = sDiag(old_div(1.,(sDiag(abx_px)*aby_py - sDiag(abx_py)*aby_px)))
|
||||
aHd_uV = lambda x: abx_px_u(sDiag(aby_py)*x) + abx_px_u(sDiag(aby_py)*x) - aby_px_u(sDiag(abx_py)*x) - abx_py_u(sDiag(aby_px)*x)
|
||||
# Need to fix this to reflect the adjoint
|
||||
if 'tzx' in self.rxType:
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import zip
|
||||
from past.utils import old_div
|
||||
# Analytic solution of EM fields due to a plane wave
|
||||
|
||||
import numpy as np, SimPEG as simpeg
|
||||
@@ -33,8 +41,8 @@ def getEHfields(m1d,sigma,freq,zd,scaleUD=True):
|
||||
# Loop over all the layers, starting at the bottom layer
|
||||
for lnr, h in enumerate(m1d.hx): # lnr-number of layer, h-thickness of the layer
|
||||
# Calculate
|
||||
yp1 = k[lnr]/(w*mu[lnr]) # Admittance of the layer below the current layer
|
||||
zp = (w*mu[lnr+1])/k[lnr+1] # Impedance in the current layer
|
||||
yp1 = old_div(k[lnr],(w*mu[lnr])) # Admittance of the layer below the current layer
|
||||
zp = old_div((w*mu[lnr+1]),k[lnr+1]) # Impedance in the current layer
|
||||
# Build the propagation matrix
|
||||
|
||||
# Convert fields to down/up going components in layer below current layer
|
||||
@@ -48,7 +56,7 @@ def getEHfields(m1d,sigma,freq,zd,scaleUD=True):
|
||||
UDp[:,lnr+1] = elamh.dot(Pjinv.dot(Pj1)).dot(UDp[:,lnr])
|
||||
|
||||
if scaleUD:
|
||||
UDp[:,lnr+1::-1] = UDp[:,lnr+1::-1]/UDp[1,lnr+1]
|
||||
UDp[:,lnr+1::-1] = old_div(UDp[:,lnr+1::-1],UDp[1,lnr+1])
|
||||
|
||||
# Calculate the fields
|
||||
Ed = np.empty((zd.size,),dtype=complex)
|
||||
@@ -62,14 +70,14 @@ def getEHfields(m1d,sigma,freq,zd,scaleUD=True):
|
||||
dind = dup >= zd
|
||||
Ed[dind] = UDp[1,0]*np.exp(-1j*k[0]*(dup-zd[dind]))
|
||||
Eu[dind] = UDp[0,0]*np.exp(1j*k[0]*(dup-zd[dind]))
|
||||
Hd[dind] = (k[0]/(w*mu[0]))*UDp[1,0]*np.exp(-1j*k[0]*(dup-zd[dind]))
|
||||
Hu[dind] = -(k[0]/(w*mu[0]))*UDp[0,0]*np.exp(1j*k[0]*(dup-zd[dind]))
|
||||
Hd[dind] = (old_div(k[0],(w*mu[0])))*UDp[1,0]*np.exp(-1j*k[0]*(dup-zd[dind]))
|
||||
Hu[dind] = -(old_div(k[0],(w*mu[0])))*UDp[0,0]*np.exp(1j*k[0]*(dup-zd[dind]))
|
||||
for ki,mui,epsi,dlow,dup,Up,Dp in zip(k[1::],mu[1::],eps[1::],m1d.vectorNx[:-1],m1d.vectorNx[1::],UDp[0,1::],UDp[1,1::]):
|
||||
dind = np.logical_and(dup >= zd, zd > dlow)
|
||||
Ed[dind] = Dp*np.exp(-1j*ki*(dup-zd[dind]))
|
||||
Eu[dind] = Up*np.exp(1j*ki*(dup-zd[dind]))
|
||||
Hd[dind] = (ki/(w*mui))*Dp*np.exp(-1j*ki*(dup-zd[dind]))
|
||||
Hu[dind] = -(ki/(w*mui))*Up*np.exp(1j*ki*(dup-zd[dind]))
|
||||
Hd[dind] = (old_div(ki,(w*mui)))*Dp*np.exp(-1j*ki*(dup-zd[dind]))
|
||||
Hu[dind] = -(old_div(ki,(w*mui)))*Up*np.exp(1j*ki*(dup-zd[dind]))
|
||||
|
||||
# Return return the fields
|
||||
return Ed, Eu, Hd, Hu
|
||||
@@ -92,15 +100,15 @@ def getImpedance(m1d,sigma,freq):
|
||||
om = 2*np.pi*fr
|
||||
Zall = np.empty(len(h)+1,dtype='complex')
|
||||
# Calculate the impedance for the bottom layer
|
||||
Zall[0] = (mu_0*om)/np.sqrt(mu_0*eps_0*(om)**2 - 1j*mu_0*sigma[0]*om)
|
||||
Zall[0] = old_div((mu_0*om),np.sqrt(mu_0*eps_0*(om)**2 - 1j*mu_0*sigma[0]*om))
|
||||
|
||||
for nr,hi in enumerate(h):
|
||||
# Calculate the wave number
|
||||
# print nr,sigma[nr]
|
||||
k = np.sqrt(mu_0*eps_0*om**2 - 1j*mu_0*sigma[nr]*om)
|
||||
Z = (mu_0*om)/k
|
||||
Z = old_div((mu_0*om),k)
|
||||
|
||||
Zall[nr+1] = Z *((Zall[nr] + Z*np.tanh(1j*k*hi))/(Z + Zall[nr]*np.tanh(1j*k*hi)))
|
||||
Zall[nr+1] = Z *(old_div((Zall[nr] + Z*np.tanh(1j*k*hi)),(Z + Zall[nr]*np.tanh(1j*k*hi))))
|
||||
|
||||
#pdb.set_trace()
|
||||
Z1d[nrFr] = Zall[-1]
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
import numpy as np, SimPEG as simpeg
|
||||
from MT1Danalytic import getEHfields
|
||||
from .MT1Danalytic import getEHfields
|
||||
from scipy.constants import mu_0
|
||||
|
||||
def get1DEfields(m1d,sigma,freq,sourceAmp=1.0):
|
||||
@@ -9,7 +16,7 @@ def get1DEfields(m1d,sigma,freq,sourceAmp=1.0):
|
||||
G = m1d.nodalGrad
|
||||
# Mass matrices
|
||||
# Magnetic permeability
|
||||
Mmu = simpeg.Utils.sdiag(m1d.vol*(1.0/mu_0))
|
||||
Mmu = simpeg.Utils.sdiag(m1d.vol*(old_div(1.0,mu_0)))
|
||||
# Conductivity
|
||||
Msig = m1d.getFaceInnerProduct(sigma)
|
||||
# Set up the solution matrix
|
||||
@@ -23,7 +30,7 @@ def get1DEfields(m1d,sigma,freq,sourceAmp=1.0):
|
||||
Ed, Eu, Hd, Hu = getEHfields(m1d,sigma,freq,m1d.vectorNx)
|
||||
Etot = (Ed + Eu)
|
||||
if sourceAmp is not None:
|
||||
Etot = ((Etot/Etot[-1])*sourceAmp) # Scale the fields to be equal to sourceAmp at the top
|
||||
Etot = ((old_div(Etot,Etot[-1]))*sourceAmp) # Scale the fields to be equal to sourceAmp at the top
|
||||
## Note: The analytic solution is derived with e^iwt
|
||||
bc = np.r_[Etot[0],Etot[-1]]
|
||||
# The right hand side
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
from MT1Dsolutions import * # Add the names of the functions
|
||||
from MT1Danalytic import *
|
||||
from dataUtils import *
|
||||
from ediFilesUtils import *
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from .MT1Dsolutions import * # Add the names of the functions
|
||||
from .MT1Danalytic import *
|
||||
from .dataUtils import *
|
||||
from .ediFilesUtils import *
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
# Utils used for the data,
|
||||
import numpy as np, matplotlib.pyplot as plt, sys
|
||||
import SimPEG as simpeg
|
||||
@@ -45,13 +52,13 @@ def rotateData(MTdata, rotAngle):
|
||||
|
||||
|
||||
def appResPhs(freq, z):
|
||||
app_res = ((1./(8e-7*np.pi**2))/freq)*np.abs(z)**2
|
||||
app_phs = np.arctan2(z.imag,z.real)*(180/np.pi)
|
||||
app_res = (old_div((old_div(1.,(8e-7*np.pi**2))),freq))*np.abs(z)**2
|
||||
app_phs = np.arctan2(z.imag,z.real)*(old_div(180,np.pi))
|
||||
return app_res, app_phs
|
||||
|
||||
def skindepth(rho, freq):
|
||||
''' Function to calculate the skindepth of EM waves'''
|
||||
return np.sqrt( (rho*((1/(freq * mu_0 * np.pi )))))
|
||||
return np.sqrt( (rho*((old_div(1,(freq * mu_0 * np.pi ))))))
|
||||
|
||||
def rec2ndarr(x, dt=float):
|
||||
return x.view((dt, len(x.dtype.names)))
|
||||
@@ -64,7 +71,7 @@ def makeAnalyticSolution(mesh, model, elev, freqs):
|
||||
anaE = anaEd+anaEu
|
||||
anaH = anaHd+anaHu
|
||||
|
||||
anaZ = anaE/anaH
|
||||
anaZ = old_div(anaE,anaH)
|
||||
# Add to the list
|
||||
data1D.append((freq,0,0,elev,anaZ[0]))
|
||||
dataRec = np.array(data1D,dtype=[('freq',float),('x',float),('y',float),('z',float),('zyx',complex)])
|
||||
@@ -97,7 +104,7 @@ def plotMT1DModelData(problem, models, symList=None):
|
||||
|
||||
# if not symList:
|
||||
# symList = ['x']*len(models)
|
||||
import plotDataTypes as pDt
|
||||
from . import plotDataTypes as pDt
|
||||
# Loop through the models.
|
||||
modelList = [problem.survey.mtrue]
|
||||
modelList.extend(models)
|
||||
@@ -110,14 +117,14 @@ def plotMT1DModelData(problem, models, symList=None):
|
||||
else:
|
||||
data1D = problem.dataPair(problem.survey,problem.survey.dpred(model)).toRecArray('Complex')
|
||||
# Plot the data and the model
|
||||
colRat = nr/((len(modelList)-1.999)*1.)
|
||||
colRat = old_div(nr,((len(modelList)-1.999)*1.))
|
||||
if colRat > 1.:
|
||||
col = 'k'
|
||||
else:
|
||||
col = plt.cm.seismic(1-colRat)
|
||||
# The model - make the pts to plot
|
||||
meshPts = np.concatenate((problem.mesh.gridN[0:1],np.kron(problem.mesh.gridN[1::],np.ones(2))[:-1]))
|
||||
modelPts = np.kron(1./(problem.mapping.sigmaMap*model),np.ones(2,))
|
||||
modelPts = np.kron(old_div(1.,(problem.mapping.sigmaMap*model)),np.ones(2,))
|
||||
axM.semilogx(modelPts,meshPts,color=col)
|
||||
|
||||
## Data
|
||||
@@ -144,7 +151,7 @@ def plotMT1DModelData(problem, models, symList=None):
|
||||
|
||||
# Fix labels and ticks
|
||||
|
||||
yMtick = [l/1000 for l in axM.get_yticks().tolist()]
|
||||
yMtick = [old_div(l,1000) for l in axM.get_yticks().tolist()]
|
||||
axM.set_yticklabels(yMtick)
|
||||
[ l.set_rotation(90) for l in axM.get_yticklabels()]
|
||||
[ l.set_rotation(90) for l in axR.get_yticklabels()]
|
||||
@@ -157,7 +164,7 @@ def plotMT1DModelData(problem, models, symList=None):
|
||||
|
||||
def printTime():
|
||||
import time
|
||||
print time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime())
|
||||
print(time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime()))
|
||||
|
||||
def convert3Dto1Dobject(MTdata,rxType3D='zyx'):
|
||||
from SimPEG import MT
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from builtins import open
|
||||
from builtins import int
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import object
|
||||
from past.utils import old_div
|
||||
# Functions to import and export MT EDI files.
|
||||
from SimPEG import mkvc
|
||||
from scipy.constants import mu_0
|
||||
@@ -9,7 +19,7 @@ import numpy as np
|
||||
import os, sys, re
|
||||
|
||||
|
||||
class EDIimporter:
|
||||
class EDIimporter(object):
|
||||
"""
|
||||
A class to import EDIfiles.
|
||||
|
||||
@@ -18,7 +28,7 @@ class EDIimporter:
|
||||
|
||||
# Define data converters
|
||||
_impUnitEDI2SI = 4*np.pi*1e-4 # Convert Z[mV/km/nT] (as in EDI)to Z[V/A] SI unit
|
||||
_impUnitSI2EDI = 1./_impUnitEDI2SI # ConvertZ[V/A] SI unit to Z[mV/km/nT] (as in EDI)
|
||||
_impUnitSI2EDI = old_div(1.,_impUnitEDI2SI) # ConvertZ[V/A] SI unit to Z[mV/km/nT] (as in EDI)
|
||||
|
||||
# Properties
|
||||
filesList = None
|
||||
@@ -116,7 +126,7 @@ class EDIimporter:
|
||||
try:
|
||||
import osr
|
||||
except ImportError as e:
|
||||
print 'Could not import osr, missing the gdal package\nCan not project coordinates'
|
||||
print('Could not import osr, missing the gdal package\nCan not project coordinates')
|
||||
raise e
|
||||
# Coordinates convertor
|
||||
if self._2out is None:
|
||||
@@ -126,7 +136,7 @@ class EDIimporter:
|
||||
if self._outEPSG is None:
|
||||
# Find the UTM EPSG number
|
||||
Nnr = 700 if latD < 0.0 else 600
|
||||
utmZ = int(1+(longD+180.0)/6.0)
|
||||
utmZ = int(1+old_div((longD+180.0),6.0))
|
||||
self._outEPSG = 32000 + Nnr + utmZ
|
||||
out.ImportFromEPSG(self._outEPSG)
|
||||
self._2out = osr.CoordinateTransformation(src,out)
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from past.utils import old_div
|
||||
from matplotlib import pyplot as plt, colors, numpy as np
|
||||
|
||||
|
||||
@@ -65,9 +72,9 @@ def plotIsoFreqNSDiff(ax,freq,arrayList,flag,par='abs',colorbar=True,cLevel=True
|
||||
x, y = arrayList[0]['x'][indUniFreq0],arrayList[0]['y'][indUniFreq0]
|
||||
if par == 'abs':
|
||||
if useLog:
|
||||
zPlot = (np.log10(np.abs(arrayList[0][flag][indUniFreq0])) - np.log10(np.abs(arrayList[1][flag][indUniFreq1])))/np.log10(np.abs(arrayList[1][flag][indUniFreq1]))
|
||||
zPlot = old_div((np.log10(np.abs(arrayList[0][flag][indUniFreq0])) - np.log10(np.abs(arrayList[1][flag][indUniFreq1]))),np.log10(np.abs(arrayList[1][flag][indUniFreq1])))
|
||||
else:
|
||||
zPlot = (np.abs(arrayList[0][flag][indUniFreq0]) - np.abs(arrayList[1][flag][indUniFreq1]))/np.abs(arrayList[1][flag][indUniFreq1])
|
||||
zPlot = old_div((np.abs(arrayList[0][flag][indUniFreq0]) - np.abs(arrayList[1][flag][indUniFreq1])),np.abs(arrayList[1][flag][indUniFreq1]))
|
||||
if mask:
|
||||
maskInd = np.logical_or(np.abs(arrayList[0][flag][indUniFreq0])< 1e-3,np.abs(arrayList[1][flag][indUniFreq1]) < 1e-3)
|
||||
zPlot = np.ma.array(zPlot)
|
||||
@@ -80,9 +87,9 @@ def plotIsoFreqNSDiff(ax,freq,arrayList,flag,par='abs',colorbar=True,cLevel=True
|
||||
clevel = np.linspace(zPlot.min(),zPlot.max(),10)
|
||||
elif par == 'real':
|
||||
if useLog:
|
||||
zPlot = (np.log10(np.real(arrayList[0][flag][indUniFreq0])) -np.log10(np.real(arrayList[1][flag][indUniFreq1])))/np.log10(np.abs((np.real(arrayList[1][flag][indUniFreq1]))))
|
||||
zPlot = old_div((np.log10(np.real(arrayList[0][flag][indUniFreq0])) -np.log10(np.real(arrayList[1][flag][indUniFreq1]))),np.log10(np.abs((np.real(arrayList[1][flag][indUniFreq1])))))
|
||||
else:
|
||||
zPlot = (np.real(arrayList[0][flag][indUniFreq0]) -np.real(arrayList[1][flag][indUniFreq1]))/np.abs((np.real(arrayList[1][flag][indUniFreq1])))
|
||||
zPlot = old_div((np.real(arrayList[0][flag][indUniFreq0]) -np.real(arrayList[1][flag][indUniFreq1])),np.abs((np.real(arrayList[1][flag][indUniFreq1]))))
|
||||
if mask:
|
||||
maskInd = np.logical_or(np.abs(np.real(arrayList[0][flag][indUniFreq0])) < 1e-3,np.abs(np.real(arrayList[1][flag][indUniFreq1])) < 1e-3)
|
||||
zPlot = np.ma.array(zPlot)
|
||||
@@ -95,9 +102,9 @@ def plotIsoFreqNSDiff(ax,freq,arrayList,flag,par='abs',colorbar=True,cLevel=True
|
||||
clevel = np.linspace(zPlot.min(),zPlot.max(),10)
|
||||
elif par == 'imag':
|
||||
if useLog:
|
||||
zPlot = (np.log10(np.imag(arrayList[0][flag][indUniFreq0])) -np.log10(np.imag(arrayList[1][flag][indUniFreq1])))/np.log10(np.abs((np.imag(arrayList[1][flag][indUniFreq1]))))
|
||||
zPlot = old_div((np.log10(np.imag(arrayList[0][flag][indUniFreq0])) -np.log10(np.imag(arrayList[1][flag][indUniFreq1]))),np.log10(np.abs((np.imag(arrayList[1][flag][indUniFreq1])))))
|
||||
else:
|
||||
zPlot = (np.imag(arrayList[0][flag][indUniFreq0]) -np.imag(arrayList[1][flag][indUniFreq1]))/np.abs((np.imag(arrayList[1][flag][indUniFreq1])))
|
||||
zPlot = old_div((np.imag(arrayList[0][flag][indUniFreq0]) -np.imag(arrayList[1][flag][indUniFreq1])),np.abs((np.imag(arrayList[1][flag][indUniFreq1]))))
|
||||
if mask:
|
||||
maskInd = np.logical_or(np.abs(np.imag(arrayList[0][flag][indUniFreq0])) < 1e-3,np.abs(np.imag(arrayList[1][flag][indUniFreq1])) < 1e-3)
|
||||
zPlot = np.ma.array(zPlot)
|
||||
@@ -176,7 +183,7 @@ def plotIsoFreqNStipper(ax,freq,array,flag,par='abs',colorbar=True,colorNorm='Sy
|
||||
|
||||
def plotIsoStaImpedance(ax,loc,array,flag,par='abs',pSym='s',pColor=None):
|
||||
|
||||
appResFact = 1/(8*np.pi**2*10**(-7))
|
||||
appResFact = old_div(1,(8*np.pi**2*10**(-7)))
|
||||
treshold = 1.0 # 1 meter
|
||||
indUniSta = np.sqrt(np.sum((rec2nd(array[['x','y']])-loc)**2,axis=1)) < treshold
|
||||
freq = array['freq'][indUniSta]
|
||||
@@ -188,9 +195,9 @@ def plotIsoStaImpedance(ax,loc,array,flag,par='abs',pSym='s',pColor=None):
|
||||
elif par == 'imag':
|
||||
zPlot = np.imag(array[flag][indUniSta])
|
||||
elif par == 'res':
|
||||
zPlot = (appResFact/freq)*np.abs(array[flag][indUniSta])**2
|
||||
zPlot = (old_div(appResFact,freq))*np.abs(array[flag][indUniSta])**2
|
||||
elif par == 'phs':
|
||||
zPlot = np.arctan2(array[flag][indUniSta].imag,array[flag][indUniSta].real)*(180/np.pi)
|
||||
zPlot = np.arctan2(array[flag][indUniSta].imag,array[flag][indUniSta].real)*(old_div(180,np.pi))
|
||||
|
||||
if not pColor:
|
||||
if 'xx' in flag:
|
||||
@@ -211,10 +218,10 @@ def plotIsoStaImpedance(ax,loc,array,flag,par='abs',pSym='s',pColor=None):
|
||||
|
||||
def plotPsudoSectNSimpedance(ax,sectDict,array,flag,par='abs',colorbar=True,colorNorm='None',cLevel=None,contour=True):
|
||||
|
||||
indSect = np.where(sectDict.values()[0]==array[sectDict.keys()[0]])
|
||||
indSect = np.where(list(sectDict.values())[0]==array[list(sectDict.keys())[0]])
|
||||
|
||||
# Define the plot axes
|
||||
if 'x' in sectDict.keys()[0]:
|
||||
if 'x' in list(sectDict.keys())[0]:
|
||||
x = array['y'][indSect]
|
||||
else:
|
||||
x = array['x'][indSect]
|
||||
@@ -231,7 +238,7 @@ def plotPsudoSectNSimpedance(ax,sectDict,array,flag,par='abs',colorbar=True,colo
|
||||
clevel = np.linspace(zPlot.min(),zPlot.max(),10,endpoint=True)
|
||||
|
||||
elif par == 'ares':
|
||||
zPlot = np.abs(array[flag][indSect])**2/(8*np.pi**2*10**(-7)*array['freq'][indSect])
|
||||
zPlot = old_div(np.abs(array[flag][indSect])**2,(8*np.pi**2*10**(-7)*array['freq'][indSect]))
|
||||
cmap = plt.get_cmap('RdYlBu')#seismic)
|
||||
if cLevel:
|
||||
zMax = np.log10(cLevel[1])
|
||||
@@ -244,7 +251,7 @@ def plotPsudoSectNSimpedance(ax,sectDict,array,flag,par='abs',colorbar=True,colo
|
||||
plotNorm = colors.LogNorm()
|
||||
|
||||
elif par == 'aphs':
|
||||
zPlot = np.arctan2(array[flag][indSect].imag,array[flag][indSect].real)*(180/np.pi)
|
||||
zPlot = np.arctan2(array[flag][indSect].imag,array[flag][indSect].real)*(old_div(180,np.pi))
|
||||
cmap = plt.get_cmap('RdYlBu')#seismic)
|
||||
if cLevel:
|
||||
zMax = cLevel[1]
|
||||
@@ -307,14 +314,14 @@ def plotPsudoSectNSDiff(ax,sectDict,arrayList,flag,par='abs',colorbar=True,color
|
||||
def sortInArr(arr):
|
||||
return np.sort(arr,order=['freq','x','y','z'])
|
||||
# Find the index for the slice
|
||||
indSect0 = np.where(sectDict.values()[0]==arrayList[0][sectDict.keys()[0]])
|
||||
indSect1 = np.where(sectDict.values()[0]==arrayList[1][sectDict.keys()[0]])
|
||||
indSect0 = np.where(list(sectDict.values())[0]==arrayList[0][list(sectDict.keys())[0]])
|
||||
indSect1 = np.where(list(sectDict.values())[0]==arrayList[1][list(sectDict.keys())[0]])
|
||||
# Extract and sort the mats
|
||||
arr0 = sortInArr(arrayList[0][indSect0])
|
||||
arr1 = sortInArr(arrayList[1][indSect1])
|
||||
|
||||
# Define the plot axes
|
||||
if 'x' in sectDict.keys()[0]:
|
||||
if 'x' in list(sectDict.keys())[0]:
|
||||
x0 = arr0['y']
|
||||
x1 = arr1['y']
|
||||
else:
|
||||
@@ -326,20 +333,20 @@ def plotPsudoSectNSDiff(ax,sectDict,arrayList,flag,par='abs',colorbar=True,color
|
||||
|
||||
if par == 'abs':
|
||||
if useLog:
|
||||
zPlot = (np.log10(np.abs(arr0[flag])) - np.log10(np.abs(arr1[flag])))/np.log10(np.abs(arr1[flag]))
|
||||
zPlot = old_div((np.log10(np.abs(arr0[flag])) - np.log10(np.abs(arr1[flag]))),np.log10(np.abs(arr1[flag])))
|
||||
else:
|
||||
zPlot = (np.abs(arr0[flag]) - np.abs(arr1[flag]))/np.abs(arr1[flag])
|
||||
zPlot = old_div((np.abs(arr0[flag]) - np.abs(arr1[flag])),np.abs(arr1[flag]))
|
||||
if mask:
|
||||
maskInd = np.logical_or(np.abs(arr0[flag])< 1e-3,np.abs(arr1[flag]) < 1e-3)
|
||||
zPlot = np.ma.array(zPlot)
|
||||
zPlot[maskInd] = mask
|
||||
cmap = plt.get_cmap('RdYlBu')#seismic)
|
||||
elif par == 'ares':
|
||||
arF = 1/(8*np.pi**2*10**(-7))
|
||||
arF = old_div(1,(8*np.pi**2*10**(-7)))
|
||||
if useLog:
|
||||
zPlot = (np.log10((arF/arr0['freq'])*np.abs(arr0[flag])**2) - np.log10((arF/arr1['freq'])*np.abs(arr1[flag])**2))/np.log10((arF/arr1['freq'])*np.abs(arr1[flag])**2)
|
||||
zPlot = old_div((np.log10((old_div(arF,arr0['freq']))*np.abs(arr0[flag])**2) - np.log10((old_div(arF,arr1['freq']))*np.abs(arr1[flag])**2)),np.log10((old_div(arF,arr1['freq']))*np.abs(arr1[flag])**2))
|
||||
else:
|
||||
zPlot = ((arF/arr0['freq'])*np.abs(arr0[flag])**2 - (arF/arr1['freq'])*np.abs(arr1[flag])**2)/((arF/arr1['freq'])*np.abs(arr1[flag])**2)
|
||||
zPlot = old_div(((old_div(arF,arr0['freq']))*np.abs(arr0[flag])**2 - (old_div(arF,arr1['freq']))*np.abs(arr1[flag])**2),((old_div(arF,arr1['freq']))*np.abs(arr1[flag])**2))
|
||||
if mask:
|
||||
maskInd = np.logical_or(np.abs(arr0[flag])< 1e-3,np.abs(arr1[flag]) < 1e-3)
|
||||
zPlot = np.ma.array(zPlot)
|
||||
@@ -348,9 +355,9 @@ def plotPsudoSectNSDiff(ax,sectDict,arrayList,flag,par='abs',colorbar=True,color
|
||||
|
||||
elif par == 'aphs':
|
||||
if useLog:
|
||||
zPlot = (np.log10(np.arctan2(arr0[flag].imag,arr0[flag].real)*(180/np.pi)) - np.log10(np.arctan2(arr1[flag].imag,arr1[flag].real)*(180/np.pi)) )/np.log10(np.arctan2(arr1[flag].imag,arr1[flag].real)*(180/np.pi))
|
||||
zPlot = old_div((np.log10(np.arctan2(arr0[flag].imag,arr0[flag].real)*(old_div(180,np.pi))) - np.log10(np.arctan2(arr1[flag].imag,arr1[flag].real)*(old_div(180,np.pi))) ),np.log10(np.arctan2(arr1[flag].imag,arr1[flag].real)*(old_div(180,np.pi))))
|
||||
else:
|
||||
zPlot = ( np.arctan2(arr0[flag].imag,arr0[flag].real)*(180/np.pi) - np.arctan2(arr1[flag].imag,arr1[flag].real)*(180/np.pi) )/(np.arctan2(arr1[flag].imag,arr1[flag].real)*(180/np.pi))
|
||||
zPlot = old_div(( np.arctan2(arr0[flag].imag,arr0[flag].real)*(old_div(180,np.pi)) - np.arctan2(arr1[flag].imag,arr1[flag].real)*(old_div(180,np.pi)) ),(np.arctan2(arr1[flag].imag,arr1[flag].real)*(old_div(180,np.pi))))
|
||||
if mask:
|
||||
maskInd = np.logical_or(np.abs(arr0[flag])< 1e-3,np.abs(arr1[flag]) < 1e-3)
|
||||
zPlot = np.ma.array(zPlot)
|
||||
@@ -358,9 +365,9 @@ def plotPsudoSectNSDiff(ax,sectDict,arrayList,flag,par='abs',colorbar=True,color
|
||||
cmap = plt.get_cmap('Spectral')#seismic)
|
||||
elif par == 'real':
|
||||
if useLog:
|
||||
zPlot = (np.log10(arr0[flag].real) - np.log10(arr1[flag].real))/np.log10(arr1[flag].real)
|
||||
zPlot = old_div((np.log10(arr0[flag].real) - np.log10(arr1[flag].real)),np.log10(arr1[flag].real))
|
||||
else:
|
||||
zPlot = (arr0[flag].real - arr1[flag].real)/arr1[flag].real
|
||||
zPlot = old_div((arr0[flag].real - arr1[flag].real),arr1[flag].real)
|
||||
if mask:
|
||||
maskInd = np.logical_or(arr0[flag].real< 1e-3,arr1[flag].real < 1e-3)
|
||||
zPlot = np.ma.array(zPlot)
|
||||
@@ -369,9 +376,9 @@ def plotPsudoSectNSDiff(ax,sectDict,arrayList,flag,par='abs',colorbar=True,color
|
||||
|
||||
elif par == 'imag':
|
||||
if useLog:
|
||||
zPlot = (np.log10(arr0[flag].imag) - np.log10(arr1[flag].imag))/np.log10(arr1[flag].imag)
|
||||
zPlot = old_div((np.log10(arr0[flag].imag) - np.log10(arr1[flag].imag)),np.log10(arr1[flag].imag))
|
||||
else:
|
||||
zPlot = (arr0[flag].imag - arr1[flag].imag)/arr1[flag].imag
|
||||
zPlot = old_div((arr0[flag].imag - arr1[flag].imag),arr1[flag].imag)
|
||||
if mask:
|
||||
maskInd = np.logical_or(arr0[flag].imag< 1e-3,arr1[flag].imag < 1e-3)
|
||||
zPlot = np.ma.array(zPlot)
|
||||
@@ -392,11 +399,11 @@ def plotPsudoSectNSDiff(ax,sectDict,arrayList,flag,par='abs',colorbar=True,color
|
||||
plotNorm = colors.SymLogNorm(np.abs(level).min(),linscale=0.1)
|
||||
elif colorNorm=='Lin':
|
||||
if cLevel:
|
||||
level = np.arange(cLevel[0],cLevel[1]+.1,(cLevel[1] - cLevel[0])/50.)
|
||||
clevel = np.arange(cLevel[0],cLevel[1]+.1,(cLevel[1] - cLevel[0])/10.)
|
||||
level = np.arange(cLevel[0],cLevel[1]+.1,old_div((cLevel[1] - cLevel[0]),50.))
|
||||
clevel = np.arange(cLevel[0],cLevel[1]+.1,old_div((cLevel[1] - cLevel[0]),10.))
|
||||
else:
|
||||
level = np.arange(zPlot.min(),zPlot.max(),(zPlot.max() - zPlot.min())/50.)
|
||||
clevel = np.arange(zPlot.min(),zPlot.max(),(zPlot.max() - zPlot.min())/10.)
|
||||
level = np.arange(zPlot.min(),zPlot.max(),old_div((zPlot.max() - zPlot.min()),50.))
|
||||
clevel = np.arange(zPlot.min(),zPlot.max(),old_div((zPlot.max() - zPlot.min()),10.))
|
||||
plotNorm = colors.Normalize()
|
||||
elif colorNorm=='Log':
|
||||
level = np.logspace(zMin-.125,zMax,(zMax-zMin)*8+1,endpoint=True)
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from builtins import dict
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import zip
|
||||
import SimPEG as simpeg, numpy as np
|
||||
|
||||
def homo1DModelSource(mesh,freq,sigma_1d):
|
||||
@@ -90,7 +98,7 @@ def analytic1DModelSource(mesh,freq,sigma_1d):
|
||||
Eu, Ed, _, _ = getEHfields(mesh1d,sigma_1d,freq,mesh.vectorNz)
|
||||
# Make the fields into a dictionary of location and the fields
|
||||
e0_1d = Eu+Ed
|
||||
E1dFieldDict = dict(zip(mesh.vectorNz,e0_1d))
|
||||
E1dFieldDict = dict(list(zip(mesh.vectorNz,e0_1d)))
|
||||
if mesh.dim == 1:
|
||||
eBG_px = simpeg.mkvc(e0_1d,2)
|
||||
eBG_py = -simpeg.mkvc(e0_1d,2) # added a minus to make the results in the correct quadrents.
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import SimPEG as simpeg, numpy as np
|
||||
|
||||
def homo1DModelSource(mesh,freq,m_back):
|
||||
|
||||
+11
-5
@@ -1,5 +1,11 @@
|
||||
import Utils
|
||||
from SurveyMT import Rx, Survey, Data
|
||||
from FieldsMT import Fields1D_e, Fields3D_e
|
||||
import Problem1D, Problem2D, Problem3D
|
||||
import SrcMT
|
||||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
from __future__ import division
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from . import Utils
|
||||
from .SurveyMT import Rx, Survey, Data
|
||||
from .FieldsMT import Fields1D_e, Fields3D_e
|
||||
from . import Problem1D, Problem2D, Problem3D
|
||||
from . import SrcMT
|
||||
+58
-47
@@ -1,23 +1,34 @@
|
||||
import Utils, numpy as np, scipy.sparse as sp
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import str
|
||||
from builtins import range
|
||||
from past.utils import old_div
|
||||
from builtins import object
|
||||
from . import Utils
|
||||
import numpy as np, scipy.sparse as sp
|
||||
from scipy.sparse.linalg import LinearOperator
|
||||
from Tests import checkDerivative
|
||||
from PropMaps import PropMap, Property
|
||||
from .Tests import checkDerivative
|
||||
from .PropMaps import PropMap, Property
|
||||
from numpy.polynomial import polynomial
|
||||
from scipy.interpolate import UnivariateSpline
|
||||
import warnings
|
||||
from future.utils import with_metaclass
|
||||
|
||||
class IdentityMap(object):
|
||||
class IdentityMap(with_metaclass(Utils.SimPEGMetaClass, object)):
|
||||
"""
|
||||
SimPEG Map
|
||||
|
||||
"""
|
||||
__metaclass__ = Utils.SimPEGMetaClass
|
||||
|
||||
def __init__(self, mesh=None, nP=None, **kwargs):
|
||||
Utils.setKwargs(self, **kwargs)
|
||||
|
||||
if nP is not None:
|
||||
assert type(nP) in [int, long], ' Number of parameters must be an integer.'
|
||||
assert type(nP) in [int, int], ' Number of parameters must be an integer.'
|
||||
|
||||
self.mesh = mesh
|
||||
self._nP = nP
|
||||
@@ -101,7 +112,7 @@ class IdentityMap(object):
|
||||
:return: passed the test?
|
||||
|
||||
"""
|
||||
print 'Testing %s' % str(self)
|
||||
print('Testing %s' % str(self))
|
||||
if m is None:
|
||||
m = abs(np.random.rand(self.nP))
|
||||
if 'plotIt' not in kwargs:
|
||||
@@ -248,10 +259,10 @@ class ReciprocalMap(IdentityMap):
|
||||
|
||||
"""
|
||||
def _transform(self, m):
|
||||
return 1.0 / Utils.mkvc(m)
|
||||
return old_div(1.0, Utils.mkvc(m))
|
||||
|
||||
def inverse(self, D):
|
||||
return 1.0 / Utils.mkvc(m)
|
||||
return old_div(1.0, Utils.mkvc(m))
|
||||
|
||||
def deriv(self, m):
|
||||
# TODO: if this is a tensor, you might have a problem.
|
||||
@@ -291,7 +302,7 @@ class LogMap(IdentityMap):
|
||||
deriv = np.zeros(mod.shape)
|
||||
tol = 1e-16 # zero
|
||||
ind = np.greater_equal(np.abs(mod),tol)
|
||||
deriv[ind] = 1.0/mod[ind]
|
||||
deriv[ind] = old_div(1.0,mod[ind])
|
||||
return Utils.sdiag(deriv)
|
||||
|
||||
def inverse(self, m):
|
||||
@@ -372,7 +383,7 @@ class SurjectVertical1D(IdentityMap):
|
||||
repNum = self.mesh.vnC[:self.mesh.dim-1].prod()
|
||||
repVec = sp.csr_matrix(
|
||||
(np.ones(repNum),
|
||||
(range(repNum), np.zeros(repNum))
|
||||
(list(range(repNum)), np.zeros(repNum))
|
||||
), shape=(repNum, 1))
|
||||
return sp.kron(sp.identity(self.nP), repVec)
|
||||
|
||||
@@ -434,7 +445,7 @@ class Surject2Dto3D(IdentityMap):
|
||||
nC, nP = self.mesh.nC, self.nP
|
||||
P = sp.csr_matrix(
|
||||
(np.ones(nC),
|
||||
(range(nC), inds)
|
||||
(list(range(nC)), inds)
|
||||
), shape=(nC, nP))
|
||||
return P
|
||||
|
||||
@@ -504,11 +515,11 @@ class InjectActiveCells(IdentityMap):
|
||||
else:
|
||||
self.valInactive = np.ones(self.nC)
|
||||
self.valInactive[self.indInactive] = valInactive.copy()
|
||||
|
||||
|
||||
self.valInactive[self.indActive] = 0
|
||||
|
||||
inds = np.nonzero(self.indActive)[0]
|
||||
self.P = sp.csr_matrix((np.ones(inds.size),(inds, range(inds.size))), shape=(self.nC, self.nP))
|
||||
self.P = sp.csr_matrix((np.ones(inds.size),(inds, list(range(inds.size)))), shape=(self.nC, self.nP))
|
||||
|
||||
@property
|
||||
def shape(self):
|
||||
@@ -595,14 +606,14 @@ class ComplexMap(IdentityMap):
|
||||
|
||||
@property
|
||||
def shape(self):
|
||||
return (self.nP/2,self.nP)
|
||||
return (old_div(self.nP,2),self.nP)
|
||||
|
||||
def _transform(self, m):
|
||||
nC = self.mesh.nC
|
||||
return m[:nC] + m[nC:]*1j
|
||||
|
||||
def deriv(self, m):
|
||||
nC = self.nP/2
|
||||
nC = old_div(self.nP,2)
|
||||
shp = (nC, nC*2)
|
||||
def fwd(v):
|
||||
return v[:nC] + v[nC:]*1j
|
||||
@@ -647,7 +658,7 @@ class CircleMap(IdentityMap):
|
||||
sig1, sig2 = np.exp(sig1), np.exp(sig2)
|
||||
X = self.mesh.gridCC[:,0]
|
||||
Y = self.mesh.gridCC[:,1]
|
||||
return sig1 + (sig2 - sig1)*(np.arctan(a*(np.sqrt((X-x)**2 + (Y-y)**2) - r))/np.pi + 0.5)
|
||||
return sig1 + (sig2 - sig1)*(old_div(np.arctan(a*(np.sqrt((X-x)**2 + (Y-y)**2) - r)),np.pi) + 0.5)
|
||||
|
||||
def deriv(self, m):
|
||||
a = self.slope
|
||||
@@ -657,11 +668,11 @@ class CircleMap(IdentityMap):
|
||||
X = self.mesh.gridCC[:,0]
|
||||
Y = self.mesh.gridCC[:,1]
|
||||
if self.logSigma:
|
||||
g1 = -(np.arctan(a*(-r + np.sqrt((X - x)**2 + (Y - y)**2)))/np.pi + 0.5)*sig1 + sig1
|
||||
g2 = (np.arctan(a*(-r + np.sqrt((X - x)**2 + (Y - y)**2)))/np.pi + 0.5)*sig2
|
||||
g1 = -(old_div(np.arctan(a*(-r + np.sqrt((X - x)**2 + (Y - y)**2))),np.pi) + 0.5)*sig1 + sig1
|
||||
g2 = (old_div(np.arctan(a*(-r + np.sqrt((X - x)**2 + (Y - y)**2))),np.pi) + 0.5)*sig2
|
||||
else:
|
||||
g1 = -(np.arctan(a*(-r + np.sqrt((X - x)**2 + (Y - y)**2)))/np.pi + 0.5) + 1.0
|
||||
g2 = (np.arctan(a*(-r + np.sqrt((X - x)**2 + (Y - y)**2)))/np.pi + 0.5)
|
||||
g1 = -(old_div(np.arctan(a*(-r + np.sqrt((X - x)**2 + (Y - y)**2))),np.pi) + 0.5) + 1.0
|
||||
g2 = (old_div(np.arctan(a*(-r + np.sqrt((X - x)**2 + (Y - y)**2))),np.pi) + 0.5)
|
||||
g3 = a*(-X + x)*(-sig1 + sig2)/(np.pi*(a**2*(-r + np.sqrt((X - x)**2 + (Y - y)**2))**2 + 1)*np.sqrt((X - x)**2 + (Y - y)**2))
|
||||
g4 = a*(-Y + y)*(-sig1 + sig2)/(np.pi*(a**2*(-r + np.sqrt((X - x)**2 + (Y - y)**2))**2 + 1)*np.sqrt((X - x)**2 + (Y - y)**2))
|
||||
g5 = -a*(-sig1 + sig2)/(np.pi*(a**2*(-r + np.sqrt((X - x)**2 + (Y - y)**2))**2 + 1))
|
||||
@@ -695,7 +706,7 @@ class PolyMap(IdentityMap):
|
||||
self.actInd = actInd
|
||||
|
||||
if getattr(self, 'actInd', None) is None:
|
||||
self.actInd = range(self.mesh.nC)
|
||||
self.actInd = list(range(self.mesh.nC))
|
||||
self.nC = self.mesh.nC
|
||||
|
||||
else:
|
||||
@@ -731,7 +742,7 @@ class PolyMap(IdentityMap):
|
||||
elif self.normal =='Y':
|
||||
f = polynomial.polyval(X, c) - Y
|
||||
else:
|
||||
raise(Exception("Input for normal = X or Y or Z"))
|
||||
raise Exception
|
||||
#3D
|
||||
elif self.mesh.dim == 3:
|
||||
X = self.mesh.gridCC[self.actInd,0]
|
||||
@@ -744,13 +755,13 @@ class PolyMap(IdentityMap):
|
||||
elif self.normal =='Z':
|
||||
f = polynomial.polyval2d(X, Y, c.reshape((self.order[0]+1,self.order[1]+1))) - Z
|
||||
else:
|
||||
raise(Exception("Input for normal = X or Y or Z"))
|
||||
raise Exception
|
||||
|
||||
else:
|
||||
raise(Exception("Only supports 2D"))
|
||||
raise Exception
|
||||
|
||||
|
||||
return sig1+(sig2-sig1)*(np.arctan(alpha*f)/np.pi+0.5)
|
||||
return sig1+(sig2-sig1)*(old_div(np.arctan(alpha*f),np.pi)+0.5)
|
||||
|
||||
def deriv(self, m):
|
||||
alpha = self.slope
|
||||
@@ -769,7 +780,7 @@ class PolyMap(IdentityMap):
|
||||
f = polynomial.polyval(X, c) - Y
|
||||
V = polynomial.polyvander(X, len(c)-1)
|
||||
else:
|
||||
raise(Exception("Input for normal = X or Y or Z"))
|
||||
raise Exception
|
||||
#3D
|
||||
elif self.mesh.dim == 3:
|
||||
X = self.mesh.gridCC[self.actInd,0]
|
||||
@@ -786,14 +797,14 @@ class PolyMap(IdentityMap):
|
||||
f = polynomial.polyval2d(X, Y, c.reshape((self.order[0]+1,self.order[1]+1))) - Z
|
||||
V = polynomial.polyvander2d(X, Y, self.order)
|
||||
else:
|
||||
raise(Exception("Input for normal = X or Y or Z"))
|
||||
raise Exception
|
||||
|
||||
if self.logSigma:
|
||||
g1 = -(np.arctan(alpha*f)/np.pi + 0.5)*sig1 + sig1
|
||||
g2 = (np.arctan(alpha*f)/np.pi + 0.5)*sig2
|
||||
g1 = -(old_div(np.arctan(alpha*f),np.pi) + 0.5)*sig1 + sig1
|
||||
g2 = (old_div(np.arctan(alpha*f),np.pi) + 0.5)*sig2
|
||||
else:
|
||||
g1 = -(np.arctan(alpha*f)/np.pi + 0.5) + 1.0
|
||||
g2 = (np.arctan(alpha*f)/np.pi + 0.5)
|
||||
g1 = -(old_div(np.arctan(alpha*f),np.pi) + 0.5) + 1.0
|
||||
g2 = (old_div(np.arctan(alpha*f),np.pi) + 0.5)
|
||||
|
||||
g3 = Utils.sdiag(alpha*(sig2-sig1)/(1.+(alpha*f)**2)/np.pi)*V
|
||||
|
||||
@@ -834,7 +845,7 @@ class SplineMap(IdentityMap):
|
||||
elif self.mesh.dim == 3:
|
||||
return np.size(self.pts)*2+2
|
||||
else:
|
||||
raise(Exception("Only supports 2D and 3D"))
|
||||
raise Exception
|
||||
|
||||
def _transform(self, m):
|
||||
# Set model parameters
|
||||
@@ -853,7 +864,7 @@ class SplineMap(IdentityMap):
|
||||
elif self.normal =='Y':
|
||||
f = self.spl(X) - Y
|
||||
else:
|
||||
raise(Exception("Input for normal = X or Y or Z"))
|
||||
raise Exception
|
||||
|
||||
# 3D:
|
||||
# Comments:
|
||||
@@ -868,7 +879,7 @@ class SplineMap(IdentityMap):
|
||||
|
||||
npts = np.size(self.pts)
|
||||
if np.mod(c.size, 2):
|
||||
raise(Exception("Put even points!"))
|
||||
raise Exception
|
||||
|
||||
self.spl = {"splb":UnivariateSpline(self.pts, c[:npts], k=self.order, s=0),
|
||||
"splt":UnivariateSpline(self.pts, c[npts:], k=self.order, s=0)}
|
||||
@@ -881,12 +892,12 @@ class SplineMap(IdentityMap):
|
||||
# elif self.normal =='Y':
|
||||
# elif self.normal =='Z':
|
||||
else:
|
||||
raise(Exception("Input for normal = X or Y or Z"))
|
||||
raise Exception
|
||||
else:
|
||||
raise(Exception("Only supports 2D and 3D"))
|
||||
raise Exception
|
||||
|
||||
|
||||
return sig1+(sig2-sig1)*(np.arctan(alpha*f)/np.pi+0.5)
|
||||
return sig1+(sig2-sig1)*(old_div(np.arctan(alpha*f),np.pi)+0.5)
|
||||
|
||||
def deriv(self, m):
|
||||
alpha = self.slope
|
||||
@@ -903,7 +914,7 @@ class SplineMap(IdentityMap):
|
||||
elif self.normal =='Y':
|
||||
f = self.spl(X) - Y
|
||||
else:
|
||||
raise(Exception("Input for normal = X or Y or Z"))
|
||||
raise Exception
|
||||
#3D
|
||||
elif self.mesh.dim == 3:
|
||||
X = self.mesh.gridCC[:,0]
|
||||
@@ -917,14 +928,14 @@ class SplineMap(IdentityMap):
|
||||
# elif self.normal =='Y':
|
||||
# elif self.normal =='Z':
|
||||
else:
|
||||
raise(Exception("Not Implemented for Y and Z, your turn :)"))
|
||||
raise Exception
|
||||
|
||||
if self.logSigma:
|
||||
g1 = -(np.arctan(alpha*f)/np.pi + 0.5)*sig1 + sig1
|
||||
g2 = (np.arctan(alpha*f)/np.pi + 0.5)*sig2
|
||||
g1 = -(old_div(np.arctan(alpha*f),np.pi) + 0.5)*sig1 + sig1
|
||||
g2 = (old_div(np.arctan(alpha*f),np.pi) + 0.5)*sig2
|
||||
else:
|
||||
g1 = -(np.arctan(alpha*f)/np.pi + 0.5) + 1.0
|
||||
g2 = (np.arctan(alpha*f)/np.pi + 0.5)
|
||||
g1 = -(old_div(np.arctan(alpha*f),np.pi) + 0.5) + 1.0
|
||||
g2 = (old_div(np.arctan(alpha*f),np.pi) + 0.5)
|
||||
|
||||
|
||||
if self.mesh.dim ==2:
|
||||
@@ -943,7 +954,7 @@ class SplineMap(IdentityMap):
|
||||
cb[i] = ctemp-dy
|
||||
spla = UnivariateSpline(self.pts, ca, k=self.order, s=0)
|
||||
splb = UnivariateSpline(self.pts, cb, k=self.order, s=0)
|
||||
fderiv = (spla(X)-splb(X))/(2*dy)
|
||||
fderiv = old_div((spla(X)-splb(X)),(2*dy))
|
||||
g3[:,i] = Utils.sdiag(alpha*(sig2-sig1)/(1.+(alpha*f)**2)/np.pi)*fderiv
|
||||
|
||||
elif self.mesh.dim==3:
|
||||
@@ -970,10 +981,10 @@ class SplineMap(IdentityMap):
|
||||
spltb = UnivariateSpline(self.pts, ca[self.npts:], k=self.order, s=0)
|
||||
flinesa = (self.spl["splt"](Y)-splta(Y))*(Z-zb)/(zt-zb) + splta(Y) - X
|
||||
flinesb = (self.spl["splt"](Y)-spltb(Y))*(Z-zb)/(zt-zb) + spltb(Y) - X
|
||||
fderiv = (flinesa-flinesb)/(2*dy)
|
||||
fderiv = old_div((flinesa-flinesb),(2*dy))
|
||||
g3[:,i] = Utils.sdiag(alpha*(sig2-sig1)/(1.+(alpha*f)**2)/np.pi)*fderiv
|
||||
else :
|
||||
raise(Exception("Not Implemented for Y and Z, your turn :)"))
|
||||
raise Exception
|
||||
return sp.csr_matrix(np.c_[g1,g2,g3])
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user