#!/usr/bin/env python # coding: utf-8 # In[5]: get_ipython().run_line_magic('matplotlib', 'inline') from fatiando.gravmag import transform from fatiando import gridder from fatiando.vis import mpl import numpy as np # In[6]: data = np.loadtxt('continued.txt') X = np.loadtxt('X.txt') Y = np.loadtxt('Y.txt') # In[7]: shape = data.shape # In[8]: # convert data, X, and Y arrays to 1D d = data.ravel() # x, y are switched because x in Fatiando is North-South. # So when plotting you pass contourf(y, x, ...) y = X.ravel() x = Y.ravel() # calculate derivatives using Fatiando a Terra and reshape output arrays back # to 2D xderiv = transform.derivx(x, y, d, data.shape) yderiv = transform.derivy(x, y, d, data.shape) zderiv = transform.derivz(x, y, d, data.shape) tga = transform.tga(x, y, data, data.shape) # In[11]: mpl.figure(figsize=(15, 4)) ax = mpl.subplot(141) mpl.axis('scaled') mpl.title('dz') mpl.pcolor(y, x, zderiv, shape, cmap='cubehelix') ax.xaxis.set_ticks([]) ax.yaxis.set_ticks([]) ax = mpl.subplot(142) mpl.axis('scaled') mpl.title('dy') mpl.pcolor(y, x, yderiv, shape, cmap='cubehelix') ax.xaxis.set_ticks([]) ax.yaxis.set_ticks([]) ax = mpl.subplot(143) mpl.axis('scaled') mpl.title('dx') mpl.pcolor(y, x, xderiv, shape, cmap='cubehelix') ax.xaxis.set_ticks([]) ax.yaxis.set_ticks([]) ax = mpl.subplot(144) mpl.axis('scaled') mpl.title('Total gradient amplitude') mpl.pcolor(y, x, tga, shape, cmap='cubehelix') ax.xaxis.set_ticks([]) ax.yaxis.set_ticks([]) mpl.tight_layout()