Magnetic Anomaly Maps

The following are key functions related to magnetic anomaly maps.

Load Map Data

MagNav.get_mapFunction
get_map(map_file::String   = namad,
        map_field::Symbol  = :map_data;
        map_info::String   = splitpath(map_file)[end],
        map_units::Symbol  = :rad,
        file_units::Symbol = :deg,
        flip_map::Bool     = false)

Get map data from saved HDF5 or MAT file or folder containing CSV files. Maps are typically saved in :deg units, while :rad is used internally.

Arguments:

  • map_file: path/name of map data HDF5 or MAT file (.h5 or .mat extension required) or folder containing CSV files
  • map_field: (optional) struct field within MAT file to use, not relevant for CSV or HDF5 file
  • map_info: (optional) map information, only used if not in map_file
  • map_units: (optional) map xx/yy units to use in map_map {:rad,:deg}
  • file_units: (optional) map xx/yy units used in map_file {:rad,:deg}
  • flip_map: (optional) if true, vertically flip data from map file (possibly useful for CSV map)

Returns:

  • map_map: Map magnetic anomaly map struct
source
get_map(map_name::Symbol, df_map::DataFrame,
        map_field::Symbol  = :map_data;
        map_info::String   = "$map_name",
        map_units::Symbol  = :rad,
        file_units::Symbol = :deg,
        flip_map::Bool     = false)

Get map data from saved HDF5 or MAT file or folder containing CSV files via DataFrame lookup. Maps are typically saved in :deg units, while :rad is used internally.

Arguments:

  • map_name: name of magnetic anomaly map
  • df_map: lookup table (DataFrame) of map data HDF5 and/or MAT files and/or folder containing CSV files
FieldTypeDescription
map_nameSymbolname of magnetic anomaly map
map_fileStringpath/name of map data HDF5 or MAT file (.h5 or .mat extension required) or folder containing CSV files
  • map_info: (optional) map information, only used if not in map_file
  • map_field: (optional) struct field within MAT file to use, not relevant for CSV or HDF5 file
  • map_units: (optional) map xx/yy units to use in map_map {:rad,:deg}
  • file_units: (optional) map xx/yy units used in files within df_map {:rad,:deg}
  • flip_map: (optional) if true, vertically flip data from map file (possibly useful for CSV map)

Returns:

  • map_map: Map magnetic anomaly map struct
source

Built-in map data

MagNav.ottawa_area_mapsFunction
ottawa_area_maps(f::Union{String,Symbol} = "")

Magnetic anomaly maps near Ottawa, Ontario, Canada, contains:

  • Eastern_395.h5: Eastern Ontario at 395 m HAE
  • Eastern_drape.h5: Eastern Ontario on drape
  • Renfrew_395.h5: Renfrew at 395 m HAE
  • Renfrew_555.h5: Renfrew at 555 m HAE
  • Renfrew_drape.h5: Renfrew on drape
  • HighAlt_5181.h5: High Altitude mini-survey (within Renfrew) at 5181 m HAE
  • Perth_800.h5: Perth mini-survey (within Eastern Ontario) at 800 m HAE

NOTE: Missing map data within each map has been filled in (using k-nearest neighbors) so that the maps are fully filled. Care must be taken to not navigate in the filled-in areas, as this is not real data and only done for more accurate and consistent upward continuation of the maps. Use the map_check function with the desired map and flight path data to check if the map may be used without navigating into filled-in (artificial) areas.

Arguments:

  • f: (optional) name of data file (.h5 extension optional)

Returns:

  • p: path of folder or f data file
source
MagNav.namadConstant
const namad

North American Magnetic Anomaly Database (NAMAD). Compiled from marine and airborne magnetic measurements by the U.S. Geological Survey (USGS), Geological Survey of Canada (GSC), and Consejo de Recursos Minerales of Mexico (CRM). Reference: https://www.usgs.gov/maps/magnetic-anomaly-map-north-america

source
MagNav.emag2Constant
const emag2

Earth Magnetic Anomaly Grid with 2 arcminute resolution (EMAG2). Compiled from satellite, marine, and airborne magnetic measurements. Reference: https://www.ncei.noaa.gov/products/earth-magnetic-model-anomaly-grid-2

source
MagNav.emm720Constant
const emm720

Enhanced Magnetic Model (EMM). Compiled from satellite, marine, airborne, and ground magnetic measurements. Expands the scalar crustal field up to spherical harmonic degree and order 720, providing a vector of the magnetic field with approximately 15 arcminute resolution. Underlying crustal field model derived from Earth Magnetic Anomaly Grid with 2-arc-minute resolution (EMAG2). Reference: https://www.ncei.noaa.gov/products/enhanced-magnetic-model

source

Upward Continue Map

MagNav.upward_fftFunction
upward_fft(map_map::Matrix, dx, dy, dz; expand::Bool = true, α = 0)

Upward continuation of a potential field (i.e., magnetic anomaly field) map. Uses the Fast Fourier Transform (FFT) to convert the map to the frequency domain, applies an upward continuation filter, and uses the inverse FFT to convert the map back to the spatial domain. Optionally expands the map temporarily with periodic padding. Downward continuation may be performed to a limited degree as well, but be careful, as this is generally unstable and amplifies high frequencies (i.e., noise).

Reference: Blakely, Potential Theory in Gravity and Magnetic Applications, 2009, Chapter 12 & Appendix B (pg. 315-317 & 402).

Arguments:

  • map_map: ny x nx 2D gridded map data
  • dx: x-direction map step size [m]
  • dy: y-direction map step size [m]
  • dz: nz z-direction upward/downward continuation distance(s) [m]
  • expand: (optional) if true, expand map temporarily to reduce edge effects
  • α: (optional) regularization parameter for downward continuation

Returns:

  • map_map: ny x nx (x nz) 2D or 3D gridded map data, upward/downward continued
source
upward_fft(map_map::Map, alt; expand::Bool = true, α = 0)

Upward continuation of a potential field (i.e., magnetic anomaly field) map. Uses the Fast Fourier Transform (FFT) to convert the map to the frequency domain, applies an upward continuation filter, and uses the inverse FFT to convert the map back to the spatial domain. Optionally expands the map temporarily with periodic padding. Downward continuation may be performed to a limited degree as well, but be careful, as this is generally unstable and amplifies high frequencies (i.e., noise).

Reference: Blakely, Potential Theory in Gravity and Magnetic Applications, 2009, Chapter 12 & Appendix B (pg. 315-317 & 402).

Arguments:

  • map_map: Map magnetic anomaly map struct
  • alt: target upward continuation altitude(s) [m]
  • expand: (optional) if true, expand map temporarily to reduce edge effects
  • α: (optional) regularization parameter for downward continuation

Returns:

  • map_map: Map magnetic anomaly map struct, upward/downward continued (MapS with alt vector => MapS3D)
source

Interpolate Map

MagNav.map_interpolateFunction
map_interpolate(map_map::AbstractArray{T},
                map_xx::AbstractVector{T},
                map_yy::AbstractVector{T},
                type::Symbol = :cubic,
                map_alt::AbstractVector{T} = T[0]) where T

Create map interpolation function, equivalent of griddedInterpolant in MATLAB.

Arguments:

  • map_map: ny x nx (x nz) 2D or 3D gridded map data
  • map_xx: nx map x-direction (longitude) coordinates
  • map_yy: ny map y-direction (latitude) coordinates
  • type: (optional) type of interpolation {:linear,:quad,:cubic}
  • map_alt: (optional) map altitude levels

Returns:

  • itp_map: map interpolation function (f(yy,xx) or (f(yy,xx,alt))
source
map_interpolate(mapS::Union{MapS,MapSd,MapS3D}, type::Symbol = :cubic;
                return_vert_deriv::Bool = false)

Create map interpolation function, equivalent of griddedInterpolant in MATLAB. Optionally return vertical derivative map interpolation function, which is calculated using finite differences between map and 1 m upward continued map.

Arguments:

  • mapS: MapS, MapSd, or MapS3D scalar magnetic anomaly map struct
  • type: (optional) type of interpolation {:linear,:quad,:cubic}
  • return_vert_deriv: (optional) if true, also return der_map

Returns:

  • itp_map: map interpolation function (f(yy,xx) or (f(yy,xx,alt))
  • der_map: if return_vert_deriv = true, vertical derivative map interpolation function (f(yy,xx) or (f(yy,xx,alt))
source
map_interpolate(mapV::MapV, dim::Symbol = :X, type::Symbol = :cubic)

Create map interpolation function, equivalent of griddedInterpolant in MATLAB.

Arguments:

  • mapV: MapV vector magnetic anomaly map struct
  • dim: map dimension to interpolate {:X,:Y,:Z}
  • type: (optional) type of interpolation {:linear,:quad,:cubic}

Returns:

  • itp_map: map interpolation function (f(yy,xx))
source

Plot Map

MagNav.plot_mapFunction
plot_map(map_map::Matrix,
         map_xx::Vector       = [],
         map_yy::Vector       = [];
         clims::Tuple         = (),
         dpi::Int             = 200,
         margin::Int          = 2,
         Nmax::Int            = 6*dpi,
         legend::Bool         = true,
         axis::Bool           = true,
         map_color::Symbol    = :usgs,
         bg_color::Symbol     = :white,
         map_units::Symbol    = :rad,
         plot_units::Symbol   = :deg,
         b_e::AbstractBackend = gr())

Plot map.

Arguments:

  • map_map: ny x nx 2D gridded map data
  • map_xx: nx map x-direction (longitude) coordinates [rad] or [deg]
  • map_yy: ny map y-direction (latitude) coordinates [rad] or [deg]
  • clims: (optional) length-2 colorbar limits (cmin,cmax)
  • dpi: (optional) dots per inch (image resolution)
  • margin: (optional) margin around plot [mm]
  • Nmax: (optional) maximum number of data points plotted (per axis)
  • legend: (optional) if true, show legend
  • axis: (optional) if true, show axes
  • map_color: (optional) filled contour color scheme {:usgs,:gray,:gray1,:gray2,:plasma,:magma}
  • bg_color: (optional) background color
  • map_units: (optional) map xx/yy units {:rad,:deg}
  • plot_units: (optional) plot xx/yy units {:rad,:deg,:m}
  • b_e: (optional) plotting backend

Returns:

  • p1: plot of map
source
plot_map(map_map::Map;
         use_mask::Bool       = true,
         clims::Tuple         = (),
         dpi::Int             = 200,
         margin::Int          = 2,
         Nmax::Int            = 6*dpi,
         legend::Bool         = true,
         axis::Bool           = true,
         map_color::Symbol    = :usgs,
         bg_color::Symbol     = :white,
         map_units::Symbol    = :rad,
         plot_units::Symbol   = :deg,
         b_e::AbstractBackend = gr())

Plot map.

Arguments:

  • map_map: Map magnetic anomaly map struct
  • use_mask: (optional) if true, apply map_map mask to map
  • clims: (optional) length-2 colorbar limits (cmin,cmax)
  • dpi: (optional) dots per inch (image resolution)
  • margin: (optional) margin around plot [mm]
  • Nmax: (optional) maximum number of data points plotted (per axis)
  • legend: (optional) if true, show legend
  • axis: (optional) if true, show axes
  • map_color: (optional) filled contour color scheme {:usgs,:gray,:gray1,:gray2,:plasma,:magma}
  • bg_color: (optional) background color
  • map_units: (optional) map xx/yy units {:rad,:deg}
  • plot_units: (optional) plot xx/yy units {:rad,:deg,:m}
  • b_e: (optional) plotting backend

Returns:

  • p1: plot of map (if map_map isa MapV, mapX)
  • p2: if map_map isa MapV, mapY
  • p3: if map_map isa MapV, mapZ
source