# Maps: ComboMaps¶

We will use an example where we want a 1D layered earth as our model, but we want to map this to a 2D discretization to do our forward modeling. We will also assume that we are working in log conductivity still, so after the transformation we map to conductivity space. To do this we will introduce the vertical 1D map (SimPEG.Maps.SurjectVertical1D), which does the first part of what we just described. The second part will be done by the SimPEG.Maps.ExpMap described above.

 1 2 3 4 5 6 M = Mesh.TensorMesh([7,5]) v1dMap = Maps.SurjectVertical1D(M) expMap = Maps.ExpMap(M) myMap = expMap * v1dMap m = np.r_[0.2,1,0.1,2,2.9] # only 5 model parameters! sig = myMap * m 

If you noticed, it was pretty easy to combine maps. What is even cooler is that the derivatives also are made for you (if everything goes right). Just to be sure that the derivative is correct, you should always run the test on the mapping that you create.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 from SimPEG import Mesh, Maps import numpy as np import matplotlib.pyplot as plt def run(plotIt=True): """ Maps: ComboMaps =============== We will use an example where we want a 1D layered earth as our model, but we want to map this to a 2D discretization to do our forward modeling. We will also assume that we are working in log conductivity still, so after the transformation we map to conductivity space. To do this we will introduce the vertical 1D map (:class:SimPEG.Maps.SurjectVertical1D), which does the first part of what we just described. The second part will be done by the :class:SimPEG.Maps.ExpMap described above. .. code-block:: python :linenos: M = Mesh.TensorMesh([7,5]) v1dMap = Maps.SurjectVertical1D(M) expMap = Maps.ExpMap(M) myMap = expMap * v1dMap m = np.r_[0.2,1,0.1,2,2.9] # only 5 model parameters! sig = myMap * m If you noticed, it was pretty easy to combine maps. What is even cooler is that the derivatives also are made for you (if everything goes right). Just to be sure that the derivative is correct, you should always run the test on the mapping that you create. """ M = Mesh.TensorMesh([7, 5]) v1dMap = Maps.SurjectVertical1D(M) expMap = Maps.ExpMap(M) myMap = expMap * v1dMap m = np.r_[0.2, 1, 0.1, 2, 2.9] # only 5 model parameters! sig = myMap * m if not plotIt: return figs, axs = plt.subplots(1, 2) axs[0].plot(m, M.vectorCCy, 'b-o') axs[0].set_title('Model') axs[0].set_ylabel('Depth, y') axs[0].set_xlabel('Value, $m_i$') axs[0].set_xlim(0, 3) axs[0].set_ylim(0, 1) clbar = plt.colorbar(M.plotImage( sig, ax=axs[1], grid=True, gridOpts=dict(color='grey') )[0]) axs[1].set_title('Physical Property') axs[1].set_ylabel('Depth, y') clbar.set_label('$\sigma = \exp(\mathbf{P}m)$') plt.tight_layout() if __name__ == '__main__': run() plt.show()