From 0578e1ff6c1f79cf5b4e6f590e4c92823582bc2c Mon Sep 17 00:00:00 2001 From: D Fournier Date: Sun, 3 Apr 2016 17:23:24 -0700 Subject: [PATCH] Change to source parameters Add color axis handles for data plot --- simpegPF/BaseMag.py | 4 ++-- simpegPF/Magnetics.py | 51 ++++++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/simpegPF/BaseMag.py b/simpegPF/BaseMag.py index c7519038..7c996550 100644 --- a/simpegPF/BaseMag.py +++ b/simpegPF/BaseMag.py @@ -137,8 +137,8 @@ class SrcField(Survey.BaseSrc): param = None #: Inducing field param (Amp, Incl, Decl) - def __init__(self, rxList, A, I, D, **kwargs): - self.param = (A,I,D) + def __init__(self, rxList, param = None, **kwargs): + self.param = param super(SrcField, self).__init__(rxList, **kwargs) class RxObs(Survey.BaseRx): diff --git a/simpegPF/Magnetics.py b/simpegPF/Magnetics.py index 9e7a29dd..b44c7fc9 100644 --- a/simpegPF/Magnetics.py +++ b/simpegPF/Magnetics.py @@ -1193,8 +1193,8 @@ def getActiveTopo(mesh,topo,flag): return inds -def plot_obs_2D(rxLoc,d,wd,varstr): - """ Function plot_obs(rxLoc,d,wd) +def plot_obs_2D(rxLoc,d = None ,varstr = 'Mag Obs', vmin = None, vmax = None): + """ Function plot_obs(rxLoc,d) Generate a 2d interpolated plot from scatter points of data INPUT @@ -1214,22 +1214,32 @@ def plot_obs_2D(rxLoc,d,wd,varstr): from scipy.interpolate import griddata import pylab as plt - # Create grid of points - x = np.linspace(rxLoc[:,0].min(), rxLoc[:,0].max(), 100) - y = np.linspace(rxLoc[:,1].min(), rxLoc[:,1].max(), 100) - - X, Y = np.meshgrid(x,y) - - # Interpolate - d_grid = griddata(rxLoc[:,0:2],d,(X,Y), method ='linear') - + # Plot result plt.figure() plt.subplot() - plt.imshow(d_grid, extent=[x.min(), x.max(), y.min(), y.max()],origin = 'lower') - plt.colorbar(fraction=0.02) - plt.contour(X,Y, d_grid,10) - plt.scatter(rxLoc[:,0],rxLoc[:,1], c=d, s=20) + plt.scatter(rxLoc[:,0],rxLoc[:,1], c='k', s=10) + + if d is not None: + + if (vmin is None): + vmin = d.min() + + if (vmax is None): + vmax = d.max() + + # Create grid of points + x = np.linspace(rxLoc[:,0].min(), rxLoc[:,0].max(), 100) + y = np.linspace(rxLoc[:,1].min(), rxLoc[:,1].max(), 100) + + X, Y = np.meshgrid(x,y) + + # Interpolate + d_grid = griddata(rxLoc[:,0:2],d,(X,Y), method ='linear') + plt.imshow(d_grid, extent=[x.min(), x.max(), y.min(), y.max()],origin = 'lower', vmin = vmin, vmax = vmax) + plt.colorbar(fraction=0.02) + plt.contour(X,Y, d_grid,10,vmin = vmin, vmax = vmax) + plt.title(varstr) plt.gca().set_aspect('equal', adjustable='box') @@ -1273,12 +1283,17 @@ def readUBCmagObs(obs_file): temp = np.array(line.split(),dtype=float) locXYZ[ii,:] = temp[:3] - d[ii] = temp[3] - wd[ii] = temp[4] + + if len(temp) > 3: + d[ii] = temp[3] + + if len(temp)==5: + wd[ii] = temp[4] + line = fid.readline() rxLoc = MAG.RxObs(locXYZ) - srcField = MAG.SrcField([rxLoc],B[2],B[0],B[1]) + srcField = MAG.SrcField([rxLoc],(B[2],B[0],B[1])) survey = MAG.LinearSurvey(srcField) survey.dobs = d survey.std = wd