Пример #1
0
    def setBackgroundField(self, Inc, Dec, Btot):

        Bx = Btot * np.cos(Inc / 180. * np.pi) * np.sin(Dec / 180. * np.pi)
        By = Btot * np.cos(Inc / 180. * np.pi) * np.cos(Dec / 180. * np.pi)
        Bz = -Btot * np.sin(Inc / 180. * np.pi)

        self.B0 = np.r_[Bx, By, Bz]
Пример #2
0
    def setBackgroundField(self, Inc, Dec, Btot):

        Bx = Btot*np.cos(Inc/180.*np.pi)*np.sin(Dec/180.*np.pi)
        By = Btot*np.cos(Inc/180.*np.pi)*np.cos(Dec/180.*np.pi)
        Bz = -Btot*np.sin(Inc/180.*np.pi)

        self.B0 = np.r_[Bx, By, Bz]
Пример #3
0
 def simpleFail(x):
     return np.sin(x), -sdiag(np.cos(x))
Пример #4
0
 def simpleFunction(x):
     return np.sin(x), lambda xi: sdiag(np.cos(x)) * xi
Пример #5
0
 def simplePass(x):
     return np.sin(x), sdiag(np.cos(x))
Пример #6
0
def xy_2_lineID(DCsurvey):
    """
        Read DC survey class and append line ID.
        Assumes that the locations are listed in the order
        they were collected. May need to generalize for random
        point locations, but will be more expensive

        Input:
        :param DCdict Vectors of station location

        Output:
        :param LineID Vector of integers
        :return

        Created on Thu Feb 11, 2015

        @author: dominiquef

    """

    # Compute unit vector between two points
    nstn = DCsurvey.nSrc

    # Pre-allocate space
    lineID = np.zeros(nstn)

    linenum = 0
    indx    = 0

    for ii in range(nstn):

        if ii == 0:

            A = DCsurvey.srcList[ii].loc[0]
            B = DCsurvey.srcList[ii].loc[1]

            xout = np.mean([A[0:2],B[0:2]], axis = 0)

            xy0 = A[:2]
            xym = xout

            # Deal with replicate pole location
            if np.all(xy0==xym):

                xym[0] = xym[0] + 1e-3

            continue

        A = DCsurvey.srcList[ii].loc[0]
        B = DCsurvey.srcList[ii].loc[1]

        xin = np.mean([A[0:2],B[0:2]], axis = 0)

        # Compute vector between neighbours
        vec1, r1 = r_unit(xout,xin)

        # Compute vector between current stn and mid-point
        vec2, r2 = r_unit(xym,xin)

        # Compute vector between current stn and start line
        vec3, r3 = r_unit(xy0,xin)

        # Compute vector between mid-point and start line
        vec4, r4 = r_unit(xym,xy0)

        # Compute dot product
        ang1 = np.abs(vec1.dot(vec2))
        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)):

            # Re-initiate start and mid-point location
            xy0 = A[:2]
            xym = xin

            # Deal with replicate pole location
            if np.all(xy0==xym):

                xym[0] = xym[0] + 1e-3

            linenum += 1
            indx = ii

        else:
            xym = np.mean([xy0,xin], axis = 0)

        lineID[ii] = linenum
        xout = xin

    return lineID
Пример #7
0
 DC.writeUBC_DCobs(home_dir+'\FWR_3D_2_2D.dat',Tx2d,Rx2d,data,unct,'2D')        
 
 #%% Create a 2D mesh along axis of Tx end points and keep z-discretization    
 dx = np.min( [ np.min(mesh.hx), np.min(mesh.hy) ])
 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
 
  
Пример #8
0
 def simpleFail(x):
     return np.sin(x), -sdiag(np.cos(x))
Пример #9
0
 def simpleFunction(x):
     return np.sin(x), lambda xi: sdiag(np.cos(x))*xi
Пример #10
0
 def simplePass(x):
     return np.sin(x), sdiag(np.cos(x))