예제 #1
0
def prism_bz(x, y, z, prism, incf, decf, incs=None, decs=None, azim=0.):
    # Shape condition
    if x.shape != y.shape:
        raise ValueError("All inputs must have same shape!")

    # Stablish some constants
    t2nt = 1.e9  # Testa to nT - conversion
    cm = 1.e-7  # Magnetization constant

    # Condition for directions
    if incs == None:
        incs = incf
    if decs == None:
        decs = decf

    # Calculate the directions for the source magnetization
    mx, my, mz = aux.dircos(incs, decs, azim)

    # Create the zero array
    bz = numpy.zeros_like(x)

    # Calculate the z - component
    bz += (kernelxz(x, y, z, prism) * mx + kernelyz(x, y, z, prism) * my +
           kernelzz(x, y, z, prism) * mz)
    # Conversion
    bz *= cm * t2nt
    # Return the final output
    return bz
예제 #2
0
def sphere_by(x, y, z, sphere, mag, incs, decs):
    '''    
    It is a Python implementation for a Fortran subroutine contained in Blakely (1995). It 
    computes the Y component of the magnetic induction caused by a sphere with uniform  
    distribution of magnetization. The direction X represents the north and Z represents 
    growth downward. This function receives the coordinates of the points of observation 
    (X, Y, Z - arrays), the coordinates of the center  of the sphere (Xe, Ye, Ze), the 
    magnetization intensity M and the values for inclination and declination (in degrees). 
    The observation values are given in meters.
    
    Inputs: 
    x, y, z - numpy arrays - position of the observation points
    sphere[0, 1, 2] - arrays - position of the center of the sphere
    sphere[3] - float - value for the spehre radius  
    sphere[4] - flaot - magnetization intensity value
    direction - numpy array - inclination, declination values
    
    Outputs:
    By - induced field on Y direction
     
    Ps. The value for Z can be a scalar in the case of one depth, otherwise it can be a 
    set of points.    
    '''

    # Stablishing some conditions
    if x.shape != y.shape:
        raise ValueError("All inputs must have same shape!")

    # Calculates some constants
    t2nt = 1.e9  # Testa to nT - conversion
    cm = 1.e-7  # Magnetization constant

    #Setting some constants
    xe, ye, ze = sphere[0], sphere[1], sphere[2]
    radius = sphere[3]

    # Distances in all axis directions - x, y e z
    rx = x - xe
    ry = y - ye
    rz = z - ze

    # Computes the distance (r) as the module of the other three components
    r2 = rx**2 + ry**2 + rz**2

    # Computes the magnetization values for all directions
    mx, my, mz = aux.dircos(incs, decs)

    # Auxiliars calculations
    dot = rx * mx + ry * my + rz * mz  # Scalar product
    m = (4. * np.pi * (radius**3) * mag) / 3.  # Magnetic moment

    # Component calculation - By
    by = m * (3. * dot * ry - (r2 * my)) / (r2**(2.5))

    # Final component calculation
    by *= cm * t2nt

    # Return the final output
    return by
예제 #3
0
def sphere_tfa(x, y, z, sphere, mag, incf, decf, incs=None, decs=None):
    '''    
    This function computes the total field anomaly produced due to a solid sphere, which has 
    its center located in xe, ye and ze, radius equals to r and also the magnetic property 
    (magnetic intensity). This function receives the coordinates of the points of observation 
    (X, Y, Z - arrays), the elements of the sphere, the values for inclination, declination 
    and azimuth (in one array only!) and the elements of the field (intensity, inclination, 
    declination and azimuth - IN THAT ORDER!). The observation values are given in meters.
    
    Inputs: 
    x, y, z - numpy arrays - position of the observation points
    sphere[0, 1, 2] - arrays - position of the center of the sphere
    sphere[3] - float - value for the spehre radius  
    sphere[4] - flaot - magnetization intensity value
    direction - numpy array - inclination and declination values
    field - numpy array - inclination and declination values for the field
    
    Outputs:
    tf_aprox - numpy array - approximated total field anomaly
    
    Ps. The value for Z can be a scalar in the case of one depth, otherwise it can be a 
    set of points.    
    '''

    # Stablishing some conditions
    if x.shape != y.shape:
        raise ValueError("All inputs must have same shape!")

    # Compute de regional field
    fx, fy, fz = aux.dircos(incf, decf)

    if incs == None:
        incs = incf
    if decs == None:
        decs = decf

    # Computing the components and the regional field
    bx = sphere_bx(x, y, z, sphere, mag, incs, decs)
    by = sphere_by(x, y, z, sphere, mag, incs, decs)
    bz = sphere_bz(x, y, z, sphere, mag, incs, decs)

    # Final value for the total field anomaly
    tf_aprox = fx * bx + fy * by + fz * bz

    # Return the final output
    return tf_aprox
예제 #4
0
def prism_tf(x, y, z, prism, incf, decf, incs=None, decs=None, azim=0.):
    '''
    This function calculates the total field anomaly produced by a rectangular prism located under 
    surface; it is a Python implementation for the Subroutin MBox which is contained on Blakely (1995). 
    It recieves: the coordinates of the positions in all directions, the elements of the prims, the 
    angle directions and the elements of the field. That function also uses the auxilary function 
    DIR_COSSINE to calculate the projections due to the field F and the source S.
    
    Inputs:
    x, y - numpy arrays - observation points in x and y directions
    z - numpy array/float - height for the observation
    prism - numpy array - all elements for the prims
        prism[0, 1] - initial and final coordinates at X (dimension at X axis!)
        prism[2, 3] - initial and final coordinates at Y (dimension at Y axis!)
        prism[4, 5] - initial and final coordinates at Z (dimension at Z axis!)
        prism[6] - magnetic intensity
    directions - numpy array - elements for source directions
        directions[0] - float - source inclination
        directions[1] - float - source declination
    field - numpy array - elementes for regional field
        field[0] - float - magnetic field inclination
        field[1] - float - magnetic field declination
        
    Output:
    tfa - numpy array - calculated total field anomaly
    
    X and Y represents North and East; Z is positive downward.
    Ps. Z can be a array with all elements for toppography or a float point as a flight height.
    '''

    # Stablishing some conditions
    if x.shape != y.shape:
        raise ValueError("All inputs must have same shape!")

    # Stablish some constants
    t2nt = 1.e9  # Testa to nT - conversion
    cm = 1.e-7  # Magnetization constant

    if incs == None:
        incs = incf
    if decs == None:
        decs = decf

    # Calculate the directions for the source magnetization and for the field
    Ma, Mb, Mc = aux.dircos(incs, decs, azim)  # s -> source
    Fa, Fb, Fc = aux.dircos(incf, decf, azim)  # f -> field

    # Aranges all values as a vector
    MF = [
        Ma * Fb + Mb * Fa, Ma * Fc + Mc * Fa, Mb * Fc + Mc * Fb, Ma * Fa,
        Mb * Fb, Mc * Fc
    ]

    # Limits for initial and final position along the directions
    A = [prism[1] - x, prism[0] - x]
    B = [prism[3] - y, prism[2] - y]
    H = [prism[5] - z, prism[4] - z]

    # Create the zero array to allocate the total field result
    tfa = numpy.zeros_like(x)

    # Magnetization
    mag = prism[6]

    # Loop for controling the signal of the function
    for k in range(2):
        mag *= -1
        H2 = H[k]**2
        for j in range(2):
            Y2 = B[j]**2
            for i in range(2):
                X2 = A[i]**2
                AxB = A[i] * B[j]
                R2 = X2 + Y2 + H2
                R = numpy.sqrt(R2)
                HxR = H[k] * R
                tfa += ((-1.)**(i + j)) * mag * (
                    0.5 * (MF[2]) * aux.my_log(
                        (R - A[i]) / (R + A[i])) + 0.5 * (MF[1]) * aux.my_log(
                            (R - B[j]) /
                            (R + B[j])) - (MF[0]) * aux.my_log(R + H[k]) -
                    (MF[3]) * aux.my_atan(AxB, X2 + HxR + H2) -
                    (MF[4]) * aux.my_atan(AxB, R2 + HxR - X2) +
                    (MF[5]) * aux.my_atan(AxB, HxR))
    # Multiplying for constants conversion
    tfa *= t2nt * cm

    # Return the final output
    return tfa