.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/transformations/reduction_to_pole.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_transformations_reduction_to_pole.py: Reduction to the pole of a magnetic anomaly grid ================================================ .. GENERATED FROM PYTHON SOURCE LINES 11-78 .. image-sg:: /gallery/transformations/images/sphx_glr_reduction_to_pole_001.png :alt: reduction to pole :srcset: /gallery/transformations/images/sphx_glr_reduction_to_pole_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Reduced to the pole magnetic grid: array([[ 14.15556282, 10.38429905, 10.02003492, ..., -219.81018247, -210.93025635, -179.38408421], [ -3.21243279, -9.37121782, -10.96584477, ..., -165.15303656, -158.0958179 , -133.29352054], [ -2.3217145 , -9.44938578, -11.35228505, ..., -170.79735965, -165.25667548, -141.046265 ], ..., [ 45.45699147, -24.80993602, -51.27393817, ..., -40.42604764, -64.12375288, -75.97556361], [ 36.91047424, -37.13717168, -58.40649469, ..., -34.55576242, -55.65612416, -71.01718934], [-102.42457874, -155.67864799, -165.96649111, ..., -36.95819436, -35.04014832, -40.15060688]]) Coordinates: * northing (northing) float64 7.576e+06 7.576e+06 ... 7.595e+06 7.595e+06 * easting (easting) float64 4.655e+05 4.656e+05 ... 4.827e+05 4.828e+05 | .. code-block:: default import ensaio import pygmt import verde as vd import xarray as xr import xrft import harmonica as hm # Fetch magnetic grid over the Lightning Creek Sill Complex, Australia using # Ensaio and load it with Xarray fname = ensaio.fetch_lightning_creek_magnetic(version=1) magnetic_grid = xr.load_dataarray(fname) # Pad the grid to increase accuracy of the FFT filter pad_width = { "easting": magnetic_grid.easting.size // 3, "northing": magnetic_grid.northing.size // 3, } # drop the extra height coordinate magnetic_grid_no_height = magnetic_grid.drop_vars("height") magnetic_grid_padded = xrft.pad(magnetic_grid_no_height, pad_width) # Define the inclination and declination of the region by the time of the data # acquisition (1990). inclination, declination = -52.98, 6.51 # Apply a reduction to the pole over the magnetic anomaly grid. We will assume # that the sources share the same inclination and declination as the # geomagnetic field. rtp_grid = hm.reduction_to_pole( magnetic_grid_padded, inclination=inclination, declination=declination ) # Unpad the reduced to the pole grid rtp_grid = xrft.unpad(rtp_grid, pad_width) # Show the reduced to the pole grid print("\nReduced to the pole magnetic grid:\n", rtp_grid) # Plot original magnetic anomaly and the reduced to the pole fig = pygmt.Figure() with fig.subplot(nrows=1, ncols=2, figsize=("28c", "15c"), sharey="l"): # Make colormap for both plots (saturate it a little bit) scale = 0.5 * vd.maxabs(magnetic_grid, rtp_grid) pygmt.makecpt(cmap="polar+h", series=[-scale, scale], background=True) with fig.set_panel(panel=0): # Plot magnetic anomaly grid fig.grdimage( grid=magnetic_grid, projection="X?", cmap=True, ) # Add colorbar fig.colorbar( frame='af+l"Magnetic anomaly [nT]"', position="JBC+h+o0/1c+e", ) with fig.set_panel(panel=1): # Plot upward reduced to the pole grid fig.grdimage(grid=rtp_grid, projection="X?", cmap=True) # Add colorbar fig.colorbar( frame='af+l"Reduced to the pole [nT]"', position="JBC+h+o0/1c+e", ) fig.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 6.581 seconds) .. _sphx_glr_download_gallery_transformations_reduction_to_pole.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: reduction_to_pole.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: reduction_to_pole.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_