Exemplo n.º 1
0
    def test_ana_forward(self):

        survey = PF.BaseMag.BaseMagSurvey()

        Inc = 45.
        Dec = 45.
        Btot = 51000

        b0 = PF.MagAnalytics.IDTtoxyz(Inc, Dec, Btot)
        survey.setBackgroundField(Inc, Dec, Btot)
        xr = np.linspace(-300, 300, 41)
        yr = np.linspace(-300, 300, 41)
        X, Y = np.meshgrid(xr, yr)
        Z = np.ones((xr.size, yr.size))*150
        rxLoc = np.c_[Utils.mkvc(X), Utils.mkvc(Y), Utils.mkvc(Z)]
        survey.rxLoc = rxLoc

        self.prob.pair(survey)
        u = self.prob.fields(self.chi)
        B = u['B']

        bxa, bya, bza = PF.MagAnalytics.MagSphereAnaFunA(rxLoc[:, 0], rxLoc[:, 1], rxLoc[:, 2], 100., 0., 0., 0., 0.01, b0, 'secondary')

        dpred = survey.projectFieldsAsVector(B)
        err = np.linalg.norm(dpred-np.r_[bxa, bya, bza])/np.linalg.norm(np.r_[bxa, bya, bza])
        self.assertTrue(err < 0.08)
Exemplo n.º 2
0
    def test_ana_forward(self):

        survey = PF.BaseMag.BaseMagSurvey()

        Inc = 45.0
        Dec = 45.0
        Btot = 51000

        b0 = PF.MagAnalytics.IDTtoxyz(Inc, Dec, Btot)
        survey.setBackgroundField(Inc, Dec, Btot)
        xr = np.linspace(-300, 300, 41)
        yr = np.linspace(-300, 300, 41)
        X, Y = np.meshgrid(xr, yr)
        Z = np.ones((xr.size, yr.size)) * 150
        rxLoc = np.c_[Utils.mkvc(X), Utils.mkvc(Y), Utils.mkvc(Z)]
        survey.rxLoc = rxLoc

        self.prob.pair(survey)
        u = self.prob.fields(self.chi)
        B = u["B"]

        bxa, bya, bza = PF.MagAnalytics.MagSphereAnaFunA(
            rxLoc[:, 0], rxLoc[:, 1], rxLoc[:, 2], 100.0, 0.0, 0.0, 0.0, 0.01, b0, "secondary"
        )

        dpred = survey.projectFieldsAsVector(B)
        err = np.linalg.norm(dpred - np.r_[bxa, bya, bza]) / np.linalg.norm(np.r_[bxa, bya, bza])
        self.assertTrue(err < 0.08)
Exemplo n.º 3
0
def run(plotIt=True):
    """
        PF: Magnetics: Analytics
        ========================

        Comparing the magnetics field in Vancouver to Seoul

    """

    xr = np.linspace(-300, 300, 41)
    yr = np.linspace(-300, 300, 41)
    X, Y = np.meshgrid(xr, yr)
    Z = np.ones((np.size(xr), np.size(yr)))*150

    # Bz component in Korea
    inckr = -8. + 3./60
    deckr = 54. + 9./60
    btotkr = 50898.6
    Bokr = PF.MagAnalytics.IDTtoxyz(inckr, deckr, btotkr)

    bx, by, bz = PF.MagAnalytics.MagSphereAnaFunA(
        X, Y, Z, 100., 0., 0., 0., 0.01, Bokr, 'secondary'
    )
    Bzkr = np.reshape(bz, (np.size(xr), np.size(yr)), order='F')

    # Bz component in Canada
    incca = 16. + 49./60
    decca = 70. + 19./60
    btotca = 54692.1
    Boca = PF.MagAnalytics.IDTtoxyz(incca, decca, btotca)

    bx, by, bz = PF.MagAnalytics.MagSphereAnaFunA(
        X, Y, Z, 100., 0., 0., 0., 0.01, Boca, 'secondary'
    )
    Bzca = np.reshape(bz, (np.size(xr), np.size(yr)), order='F')

    if plotIt:
        import matplotlib.pyplot as plt
        from mpl_toolkits.axes_grid1 import make_axes_locatable
        fig = plt.figure(figsize=(14, 5))

        ax1 = plt.subplot(121)
        dat1 = plt.imshow(Bzkr, extent=[min(xr), max(xr), min(yr), max(yr)])
        divider = make_axes_locatable(ax1)
        cax1 = divider.append_axes("right", size="5%", pad=0.05)
        ax1.set_xlabel('East-West (m)')
        ax1.set_ylabel('South-North (m)')
        plt.colorbar(dat1, cax=cax1)
        ax1.set_title('$B_z$ field at Seoul, South Korea')

        ax2 = plt.subplot(122)
        dat2 = plt.imshow(Bzca, extent=[min(xr), max(xr), min(yr), max(yr)])
        divider = make_axes_locatable(ax2)
        cax2 = divider.append_axes("right", size="5%", pad=0.05)
        ax2.set_xlabel('East-West (m)')
        ax2.set_ylabel('South-North (m)')
        plt.colorbar(dat2, cax=cax2)
        ax2.set_title('$B_z$ field at Vancouver, Canada')
        plt.show()
Exemplo n.º 4
0
def run(plotIt=True, nFreq=1):
    """
        MT: 3D: Forward
        ===============

        Forward model 3D MT data.

    """

    # Make a mesh
    M = simpeg.Mesh.TensorMesh([[(100,5,-1.5),(100.,10),(100,5,1.5)],[(100,5,-1.5),(100.,10),(100,5,1.5)],[(100,5,1.6),(100.,10),(100,3,2)]], x0=['C','C',-3529.5360])
    # Setup the model
    conds = [1e-2,1]
    sig = simpeg.Utils.ModelBuilder.defineBlock(M.gridCC,[-1000,-1000,-400],[1000,1000,-200],conds)
    sig[M.gridCC[:,2]>0] = 1e-8
    sig[M.gridCC[:,2]<-600] = 1e-1
    sigBG = np.zeros(M.nC) + conds[0]
    sigBG[M.gridCC[:,2]>0] = 1e-8

    ## Setup the the survey object
    # Receiver locations
    rx_x, rx_y = np.meshgrid(np.arange(-500,501,50),np.arange(-500,501,50))
    rx_loc = np.hstack((simpeg.Utils.mkvc(rx_x,2),simpeg.Utils.mkvc(rx_y,2),np.zeros((np.prod(rx_x.shape),1))))
    # Make a receiver list
    rxList = []
    for loc in rx_loc:
        # NOTE: loc has to be a (1,3) np.ndarray otherwise errors accure
        for rx_orientation in ['xx','xy','yx','yy']:
            rxList.append(NSEM.Rx.Point_impedance3D(simpeg.mkvc(loc,2).T,rx_orientation, 'real'))
            rxList.append(NSEM.Rx.Point_impedance3D(simpeg.mkvc(loc,2).T,rx_orientation, 'imag'))
        for rx_orientation in ['zx','zy']:
            rxList.append(NSEM.Rx.Point_tipper3D(simpeg.mkvc(loc,2).T,rx_orientation, 'real'))
            rxList.append(NSEM.Rx.Point_tipper3D(simpeg.mkvc(loc,2).T,rx_orientation, 'imag'))
    # Source list
    srcList =[]
    for freq in np.logspace(3,-3,nFreq):
        srcList.append(NSEM.Src.Planewave_xy_1Dprimary(rxList,freq))
    # Survey MT
    survey = NSEM.Survey(srcList)

    ## Setup the problem object
    problem = NSEM.Problem3D_ePrimSec(M, sigmaPrimary=sigBG)

    problem.pair(survey)
    problem.Solver = Solver

    # Calculate the data
    fields = problem.fields(sig)
    dataVec = survey.eval(fields)

    # Make the data
    mtData = NSEM.Data(survey,dataVec)

    # Add plots
    if plotIt:
        pass
Exemplo n.º 5
0
    def setUp(self):

        # Define inducing field and sphere parameters
        H0 = (50000., 60., 270.)
        self.b0 = PF.MagAnalytics.IDTtoxyz(-H0[1], H0[2], H0[0])
        self.rad = 2.
        self.chi = 0.01

        # Define a mesh
        cs = 0.2
        hxind = [(cs, 21)]
        hyind = [(cs, 21)]
        hzind = [(cs, 21)]
        mesh = Mesh.TensorMesh([hxind, hyind, hzind], 'CCC')

        # Get cells inside the sphere
        sph_ind = PF.MagAnalytics.spheremodel(mesh, 0., 0., 0., self.rad)

        # Adjust susceptibility for volume difference
        Vratio = (4. / 3. * np.pi * self.rad**3.) / (np.sum(sph_ind) * cs**3.)
        model = np.ones(mesh.nC) * self.chi * Vratio
        self.model = model[sph_ind]

        # Creat reduced identity map for Linear Pproblem
        idenMap = Maps.IdentityMap(nP=int(sum(sph_ind)))

        # Create plane of observations
        xr = np.linspace(-20, 20, 21)
        yr = np.linspace(-20, 20, 21)
        X, Y = np.meshgrid(xr, yr)

        # Move obs plane 2 radius away from sphere
        Z = np.ones((xr.size, yr.size)) * 2. * self.rad
        self.locXyz = np.c_[Utils.mkvc(X), Utils.mkvc(Y), Utils.mkvc(Z)]
        rxLoc = PF.BaseMag.RxObs(self.locXyz)
        srcField = PF.BaseMag.SrcField([rxLoc], param=H0)
        self.survey = PF.BaseMag.LinearSurvey(srcField)

        self.prob_xyz = PF.Magnetics.MagneticIntegral(mesh,
                                                      mapping=idenMap,
                                                      actInd=sph_ind,
                                                      forwardOnly=True,
                                                      rtype='xyz')

        self.prob_tmi = PF.Magnetics.MagneticIntegral(mesh,
                                                      mapping=idenMap,
                                                      actInd=sph_ind,
                                                      forwardOnly=True,
                                                      rtype='tmi')
Exemplo n.º 6
0
    def setUp(self):

        # Define sphere parameters
        self.rad = 2.
        self.rho = 0.1

        # Define a mesh
        cs = 0.2
        hxind = [(cs, 21)]
        hyind = [(cs, 21)]
        hzind = [(cs, 21)]
        mesh = Mesh.TensorMesh([hxind, hyind, hzind], 'CCC')

        # Get cells inside the sphere
        sph_ind = PF.MagAnalytics.spheremodel(mesh, 0., 0., 0., self.rad)

        # Adjust density for volume difference
        Vratio = (4. / 3. * np.pi * self.rad**3.) / (np.sum(sph_ind) * cs**3.)
        model = np.ones(mesh.nC) * self.rho * Vratio
        self.model = model[sph_ind]

        # Create reduced identity map for Linear Pproblem
        idenMap = Maps.IdentityMap(nP=int(sum(sph_ind)))

        # Create plane of observations
        xr = np.linspace(-20, 20, 21)
        yr = np.linspace(-20, 20, 21)
        X, Y = np.meshgrid(xr, yr)

        # Move obs plane 2 radius away from sphere
        Z = np.ones((xr.size, yr.size)) * 2. * self.rad
        self.locXyz = np.c_[Utils.mkvc(X), Utils.mkvc(Y), Utils.mkvc(Z)]
        rxLoc = PF.BaseGrav.RxObs(self.locXyz)
        srcField = PF.BaseGrav.SrcField([rxLoc])
        self.survey = PF.BaseGrav.LinearSurvey(srcField)

        self.prob_xyz = PF.Gravity.GravityIntegral(mesh,
                                                   mapping=idenMap,
                                                   actInd=sph_ind,
                                                   forwardOnly=True,
                                                   rtype='xyz')

        self.prob_z = PF.Gravity.GravityIntegral(mesh,
                                                 mapping=idenMap,
                                                 actInd=sph_ind,
                                                 forwardOnly=True,
                                                 rtype='z')
Exemplo n.º 7
0
    def setUp(self):

        # Define inducing field and sphere parameters
        H0 = (50000., 60., 270.)
        self.b0 = PF.MagAnalytics.IDTtoxyz(-H0[1], H0[2], H0[0])
        self.rad = 2.
        self.chi = 0.01

        # Define a mesh
        cs = 0.2
        hxind = [(cs, 21)]
        hyind = [(cs, 21)]
        hzind = [(cs, 21)]
        mesh = Mesh.TensorMesh([hxind, hyind, hzind], 'CCC')

        # Get cells inside the sphere
        sph_ind = PF.MagAnalytics.spheremodel(mesh, 0., 0., 0., self.rad)

        # Adjust susceptibility for volume difference
        Vratio = (4./3.*np.pi*self.rad**3.) / (np.sum(sph_ind)*cs**3.)
        model = np.ones(mesh.nC)*self.chi*Vratio
        self.model = model[sph_ind]

        # Creat reduced identity map for Linear Pproblem
        idenMap = Maps.IdentityMap(nP=int(sum(sph_ind)))

        # Create plane of observations
        xr = np.linspace(-20, 20, 21)
        yr = np.linspace(-20, 20, 21)
        X, Y = np.meshgrid(xr, yr)

        # Move obs plane 2 radius away from sphere
        Z = np.ones((xr.size, yr.size))*2.*self.rad
        self.locXyz = np.c_[Utils.mkvc(X), Utils.mkvc(Y), Utils.mkvc(Z)]
        rxLoc = PF.BaseMag.RxObs(self.locXyz)
        srcField = PF.BaseMag.SrcField([rxLoc], param=H0)
        self.survey = PF.BaseMag.LinearSurvey(srcField)

        self.prob_xyz = PF.Magnetics.MagneticIntegral(mesh, mapping=idenMap,
                                                      actInd=sph_ind,
                                                      forwardOnly=True,
                                                      rtype='xyz')

        self.prob_tmi = PF.Magnetics.MagneticIntegral(mesh, mapping=idenMap,
                                                      actInd=sph_ind,
                                                      forwardOnly=True,
                                                      rtype='tmi')
Exemplo n.º 8
0
    def setUp(self):

        # Define sphere parameters
        self.rad = 2.
        self.rho = 0.1

        # Define a mesh
        cs = 0.2
        hxind = [(cs, 21)]
        hyind = [(cs, 21)]
        hzind = [(cs, 21)]
        mesh = Mesh.TensorMesh([hxind, hyind, hzind], 'CCC')

        # Get cells inside the sphere
        sph_ind = PF.MagAnalytics.spheremodel(mesh, 0., 0., 0., self.rad)

        # Adjust density for volume difference
        Vratio = (4./3.*np.pi*self.rad**3.) / (np.sum(sph_ind)*cs**3.)
        model = np.ones(mesh.nC)*self.rho*Vratio
        self.model = model[sph_ind]

        # Create reduced identity map for Linear Pproblem
        idenMap = Maps.IdentityMap(nP=int(sum(sph_ind)))

        # Create plane of observations
        xr = np.linspace(-20, 20, 21)
        yr = np.linspace(-20, 20, 21)
        X, Y = np.meshgrid(xr, yr)

        # Move obs plane 2 radius away from sphere
        Z = np.ones((xr.size, yr.size))*2.*self.rad
        self.locXyz = np.c_[Utils.mkvc(X), Utils.mkvc(Y), Utils.mkvc(Z)]
        rxLoc = PF.BaseGrav.RxObs(self.locXyz)
        srcField = PF.BaseGrav.SrcField([rxLoc])
        self.survey = PF.BaseGrav.LinearSurvey(srcField)

        self.prob_xyz = PF.Gravity.GravityIntegral(mesh, mapping=idenMap,
                                                   actInd=sph_ind,
                                                   forwardOnly=True,
                                                   rtype='xyz')

        self.prob_z = PF.Gravity.GravityIntegral(mesh, mapping=idenMap,
                                                 actInd=sph_ind,
                                                 forwardOnly=True,
                                                 rtype='z')
Exemplo n.º 9
0
# Get cells inside the sphere
sph_ind = PF.MagAnalytics.spheremodel(mesh, 0., 0., 0., rad)

# Adjust susceptibility for volume difference
Vratio = (4./3.*np.pi*rad**3.) / (np.sum(sph_ind)*cs**3.)
model = np.zeros(mesh.nC)
model[sph_ind] = chi*Vratio
m = model[sph_ind]

# Creat reduced identity map for Linear Pproblem
idenMap = Maps.IdentityMap(nP=int(sum(sph_ind)))

# Create plane of observations
xr = np.linspace(-10, 10, 21)
yr = np.linspace(-10, 10, 21)
X, Y = np.meshgrid(xr, yr)

# Move obs plane 2 radius away from sphere
Z = np.ones((xr.size, yr.size))*2.*rad
locXyz = np.c_[Utils.mkvc(X), Utils.mkvc(Y), Utils.mkvc(Z)]
rxLoc = PF.BaseMag.RxObs(locXyz)
srcField = PF.BaseMag.SrcField([rxLoc], param=H0)
survey = PF.BaseMag.LinearSurvey(srcField)

prob_xyz = PF.Magnetics.MagneticIntegral(mesh, chiMap=idenMap,
                                              actInd=sph_ind,
                                              forwardOnly=True,
                                              rtype='xyz')

prob_tmi = PF.Magnetics.MagneticIntegral(mesh, chiMap=idenMap,
                                              actInd=sph_ind,
Exemplo n.º 10
0
 nc = np.ceil(dl_len/dx)+3
 
 padx = dx*np.power(1.4,range(1,15))
 
 # Creating padding cells
 h1 = np.r_[padx[::-1], np.ones(nc)*dx , padx]
 
 # Create mesh with 0 coordinate centerer on the ginput points in cell center
 mesh2d = Mesh.TensorMesh([h1, mesh.hz], x0=(-np.sum(padx)-dx/2,mesh.x0[2]))
 
 # Create array of points for interpolating from 3D to 2D mesh
 xx = Tx[0][0,0] + mesh2d.vectorCCx * np.cos(azm)
 yy = Tx[0][1,0] + mesh2d.vectorCCx * np.sin(azm)
 zz = mesh2d.vectorCCy
 
 [XX,ZZ] = np.meshgrid(xx,zz)
 [YY,ZZ] = np.meshgrid(yy,zz)
 
 xyz2d = np.c_[mkvc(XX),mkvc(YY),mkvc(ZZ)]
 
 #plt.scatter(xx,yy,s=20,c='y')
 
 
 F = interpolation.NearestNDInterpolator(mesh.gridCC,model)
 m2D = np.reshape(F(xyz2d),[mesh2d.nCx,mesh2d.nCy]).T
 
  
 #==============================================================================
 # mesh2d = Mesh.TensorMesh([mesh.hx, mesh.hz], x0=(mesh.x0[0]-endl[0,0],mesh.x0[2]))
 # m3D = np.reshape(model, (mesh.nCz, mesh.nCy, mesh.nCx))
 # m2D = m3D[:,1,:]