Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions doc/gallery_src/transformations/reduction_to_pole.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import pygmt
import verde as vd
import xarray as xr
import xrft

import harmonica as hm

Expand All @@ -22,15 +21,6 @@
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
Expand All @@ -39,16 +29,11 @@
# 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
magnetic_grid, 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"):
Expand Down
16 changes: 1 addition & 15 deletions doc/gallery_src/transformations/tga.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import pygmt
import verde as vd
import xarray as xr
import xrft

import harmonica as hm

Expand All @@ -22,21 +21,8 @@
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)

# Compute the total gradient amplitude of the grid
tga = hm.total_gradient_amplitude(magnetic_grid_padded)

# Unpad the total gradient amplitude grid
tga = xrft.unpad(tga, pad_width)

tga = hm.total_gradient_amplitude(magnetic_grid)
# Show the total gradient amplitude
print("\nTotal Gradient Amplitude:\n", tga)

Expand Down
29 changes: 4 additions & 25 deletions doc/gallery_src/transformations/tilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import pygmt
import verde as vd
import xarray as xr
import xrft

import harmonica as hm

Expand All @@ -22,21 +21,8 @@
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)

# Compute the tilt of the grid
tilt_grid = hm.tilt_angle(magnetic_grid_padded)

# Unpad the tilt grid
tilt_grid = xrft.unpad(tilt_grid, pad_width)

tilt_grid = hm.tilt_angle(magnetic_grid)
# Show the tilt
print("\nTilt:\n", tilt_grid)

Expand All @@ -47,19 +33,12 @@
# 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_padded = hm.reduction_to_pole(
magnetic_grid_padded, inclination=inclination, declination=declination
rtp_grid = hm.reduction_to_pole(
magnetic_grid, inclination=inclination, declination=declination
)

# Unpad the reduced to the pole grid
rtp_grid = xrft.unpad(rtp_grid_padded, pad_width)

# Compute the tilt of the padded rtp grid
tilt_rtp_grid = hm.tilt_angle(rtp_grid_padded)

# Unpad the tilt grid
tilt_rtp_grid = xrft.unpad(tilt_rtp_grid, pad_width)

tilt_rtp_grid = hm.tilt_angle(rtp_grid)
# Show the tilt from RTP
print("\nTilt from RTP:\n", tilt_rtp_grid)

Expand Down
16 changes: 1 addition & 15 deletions doc/gallery_src/transformations/upward_continuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import ensaio
import pygmt
import xarray as xr
import xrft

import harmonica as hm

Expand All @@ -21,22 +20,9 @@
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)

# Upward continue the magnetic grid, from 500 m to 1000 m
# (a height displacement of 500m)
upward_continued = hm.upward_continuation(magnetic_grid_padded, height_displacement=500)

# Unpad the upward continued grid
upward_continued = xrft.unpad(upward_continued, pad_width)

upward_continued = hm.upward_continuation(magnetic_grid, height_displacement=500)
# Show the upward continued grid
print("\nUpward continued magnetic grid:\n", upward_continued)

Expand Down
16 changes: 1 addition & 15 deletions doc/gallery_src/transformations/upward_derivative.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import pygmt
import verde as vd
import xarray as xr
import xrft

import harmonica as hm

Expand All @@ -22,21 +21,8 @@
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)

# Compute the upward derivative of the grid
deriv_upward = hm.derivative_upward(magnetic_grid_padded)

# Unpad the derivative grid
deriv_upward = xrft.unpad(deriv_upward, pad_width)

deriv_upward = hm.derivative_upward(magnetic_grid)
# Show the upward derivative
print("\nUpward derivative:\n", deriv_upward)

Expand Down
Loading
Loading