Aeromagnetic Compensation

The following are key functions related to aeromagnetic compensation.

Tolles-Lawson

MagNav.create_TL_AFunction
create_TL_A(Bx, By, Bz;
            Bt       = sqrt.(Bx.^2+By.^2+Bz.^2),
            terms    = [:permanent,:induced,:eddy],
            Bt_scale = 50000,
            return_B = false)

Create Tolles-Lawson A matrix using vector magnetometer measurements. Optionally returns the magnitude & derivatives of total field.

Arguments:

  • Bx,By,Bz: vector magnetometer measurements [nT]
  • Bt: (optional) magnitude of vector magnetometer measurements or scalar magnetometer measurements for modified Tolles-Lawson [nT]
  • terms: (optional) Tolles-Lawson terms to use {:permanent,:induced,:eddy,:bias}
  • Bt_scale: (optional) scaling factor for induced & eddy current terms [nT]
  • return_B: (optional) if true, also return Bt & B_dot

Returns:

  • A: Tolles-Lawson A matrix
  • Bt: if return_B = true, magnitude of total field measurements [nT]
  • B_dot: if return_B = true, finite differences of total field vector [nT]
source
create_TL_A(flux::MagV, ind = trues(length(flux.x));
            Bt       = sqrt.(flux.x.^2+flux.y.^2+flux.z.^2)[ind],
            terms    = [:permanent,:induced,:eddy],
            Bt_scale = 50000,
            return_B = false)

Create Tolles-Lawson A matrix using vector magnetometer measurements. Optionally returns the magnitude & derivatives of total field.

Arguments:

  • flux: MagV vector magnetometer measurement struct
  • ind: (optional) selected data indices
  • Bt: (optional) magnitude of vector magnetometer measurements or scalar magnetometer measurements for modified Tolles-Lawson [nT]
  • terms: (optional) Tolles-Lawson terms to use {:permanent,:induced,:eddy,:bias}
  • Bt_scale: (optional) scaling factor for induced & eddy current terms [nT]
  • return_B: (optional) if true, also return Bt & B_dot

Returns:

  • A: Tolles-Lawson A matrix
  • Bt: if return_B = true, magnitude of total field measurements [nT]
  • B_dot: if return_B = true, finite differences of total field vector [nT]
source
MagNav.create_TL_coefFunction
create_TL_coef(Bx, By, Bz, B;
               Bt         = sqrt.(Bx.^2+By.^2+Bz.^2),
               λ          = 0,
               terms      = [:permanent,:induced,:eddy],
               pass1      = 0.1,
               pass2      = 0.9,
               fs         = 10.0,
               pole::Int  = 4,
               trim::Int  = 20,
               Bt_scale   = 50000,
               return_var = false)

Create Tolles-Lawson coefficients using vector & scalar magnetometer measurements with a bandpass, low-pass, or high-pass filter.

Arguments:

  • Bx,By,Bz: vector magnetometer measurements [nT]
  • B: scalar magnetometer measurements [nT]
  • Bt: (optional) magnitude of vector magnetometer measurements or scalar magnetometer measurements for modified Tolles-Lawson [nT]
  • λ: (optional) ridge parameter
  • terms: (optional) Tolles-Lawson terms to use {:permanent,:induced,:eddy,:bias}
  • pass1: (optional) first passband frequency [Hz]
  • pass2: (optional) second passband frequency [Hz]
  • fs: (optional) sampling frequency [Hz]
  • pole: (optional) number of poles for Butterworth filter
  • trim: (optional) number of elements to trim after filtering
  • Bt_scale: (optional) scaling factor for induced & eddy current terms [nT]
  • return_var: (optional) if true, also return B_var

Returns:

  • coef: Tolles-Lawson coefficients
  • B_var: if return_var = true, fit error variance
source
create_TL_coef(flux::MagV, B, ind = trues(length(flux.x));
               Bt         = sqrt.(flux.x.^2+flux.y.^2+flux.z.^2)[ind],
               λ          = 0,
               terms      = [:permanent,:induced,:eddy],
               pass1      = 0.1,
               pass2      = 0.9,
               fs         = 10.0,
               pole::Int  = 4,
               trim::Int  = 20,
               Bt_scale   = 50000,
               return_var = false)

Create Tolles-Lawson coefficients using vector & scalar magnetometer measurements with a bandpass, low-pass, or high-pass filter.

Arguments:

  • flux: MagV vector magnetometer measurement struct
  • B: scalar magnetometer measurements [nT]
  • ind: (optional) selected data indices
  • Bt: (optional) magnitude of vector magnetometer measurements or scalar magnetometer measurements for modified Tolles-Lawson [nT]
  • λ: (optional) ridge parameter
  • terms: (optional) Tolles-Lawson terms to use {:permanent,:induced,:eddy,:bias}
  • pass1: (optional) first passband frequency [Hz]
  • pass2: (optional) second passband frequency [Hz]
  • fs: (optional) sampling frequency [Hz]
  • pole: (optional) number of poles for Butterworth filter
  • trim: (optional) number of elements to trim after filtering
  • Bt_scale: (optional) scaling factor for induced & eddy current terms [nT]
  • return_var: (optional) if true, also return B_var

Returns:

  • coef: Tolles-Lawson coefficients
  • B_var: if return_var = true, fit error variance
source

Model Training/Fitting

MagNav.comp_trainFunction
comp_train(comp_params::CompParams, xyz::XYZ, ind,
           mapS::Union{MapS,MapSd,MapS3D} = mapS_null;
           temp_params::TempParams        = TempParams(),
           xyz_test::XYZ                  = xyz,
           ind_test                       = BitVector(),
           silent::Bool                   = false)

Train an aeromagnetic compensation model.

Arguments:

  • comp_params: CompParams aeromagnetic compensation parameters struct, either:
    • NNCompParams: neural network-based aeromagnetic compensation parameters struct
    • LinCompParams: linear aeromagnetic compensation parameters struct
  • xyz: XYZ flight data struct
  • ind: selected data indices
  • mapS: (optional) MapS, MapSd, or MapS3D scalar magnetic anomaly map struct, only used for y_type = :b, :c
  • temp_params: (optional) TempParams temporary (WIP) parameters struct
  • xyz_test: (optional) XYZ held-out test data struct
  • ind_test: (optional) indices for test data struct
  • silent: (optional) if true, no print outs

Returns:

  • comp_params: CompParams aeromagnetic compensation parameters struct
  • y: length-N target vector
  • y_hat: length-N prediction vector
  • err: length-N compensation error
  • features: length-Nf feature vector (including components of TL A, etc.)
source
comp_train(comp_params::CompParams, xyz_vec::Vector, ind_vec::Vector,
           mapS::Union{MapS,MapSd,MapS3D} = mapS_null;
           temp_params::TempParams        = TempParams(),
           xyz_test::XYZ                  = xyz_vec[1],
           ind_test                       = BitVector(),
           silent::Bool                   = false)

Train an aeromagnetic compensation model.

Arguments:

  • comp_params: CompParams aeromagnetic compensation parameters struct, either:
    • NNCompParams: neural network-based aeromagnetic compensation parameters struct
    • LinCompParams: linear aeromagnetic compensation parameters struct
  • xyz_vec: vector of XYZ flight data structs
  • ind_vec: vector of selected data indices
  • mapS: (optional) MapS, MapSd, or MapS3D scalar magnetic anomaly map struct, only used for y_type = :b, :c
  • temp_params: (optional) TempParams temporary (WIP) parameters struct
  • xyz_test: (optional) XYZ held-out test data struct
  • ind_test: (optional) indices for test data struct
  • silent: (optional) if true, no print outs

Returns:

  • comp_params: CompParams aeromagnetic compensation parameters struct
  • y: length-N target vector
  • y_hat: length-N prediction vector
  • err: length-N compensation error
  • features: length-Nf feature vector (including components of TL A, etc.)
source
comp_train(comp_params::CompParams, lines,
           df_line::DataFrame, df_flight::DataFrame, df_map::DataFrame;
           temp_params::TempParams = TempParams(),
           silent::Bool            = false)

Train an aeromagnetic compensation model.

Arguments:

  • comp_params: CompParams aeromagnetic compensation parameters struct, either:
    • NNCompParams: neural network-based aeromagnetic compensation parameters struct
    • LinCompParams: linear aeromagnetic compensation parameters struct
  • lines: selected line number(s)
  • df_line: lookup table (DataFrame) of lines
FieldTypeDescription
flightSymbolflight name (e.g., :Flt1001)
lineRealline number, i.e., segments within flight
t_startRealstart time of line to use [s]
t_endRealend time of line to use [s]
map_nameSymbol(optional) name of magnetic anomaly map relevant to line
  • df_flight: lookup table (DataFrame) of flight data files
FieldTypeDescription
flightSymbolflight name (e.g., :Flt1001)
xyz_typeSymbolsubtype of XYZ to use for flight data {:XYZ0,:XYZ1,:XYZ20,:XYZ21}
xyz_setRealflight dataset number (used to prevent improper mixing of datasets, such as different magnetometer locations)
xyz_fileStringpath/name of flight data CSV, HDF5, or MAT file (.csv, .h5, or .mat extension required)
  • df_map: lookup table (DataFrame) of map data files
FieldTypeDescription
map_nameSymbolname of magnetic anomaly map
map_fileStringpath/name of map data HDF5 or MAT file (.h5 or .mat extension required)
  • temp_params: (optional) TempParams temporary (WIP) parameters struct
  • silent: (optional) if true, no print outs

Returns:

  • comp_params: CompParams aeromagnetic compensation parameters struct
  • y: length-N target vector
  • y_hat: length-N prediction vector
  • err: length-N mean-corrected (per line) compensation error
  • features: length-Nf feature vector (including components of TL A, etc.)
source

Model Testing

MagNav.comp_testFunction
comp_test(comp_params::CompParams, xyz::XYZ, ind,
          mapS::Union{MapS,MapSd,MapS3D} = mapS_null;
          temp_params::TempParams        = TempParams(),
          silent::Bool                   = false)

Evaluate performance of an aeromagnetic compensation model.

Arguments:

  • comp_params: CompParams aeromagnetic compensation parameters struct, either:
    • NNCompParams: neural network-based aeromagnetic compensation parameters struct
    • LinCompParams: linear aeromagnetic compensation parameters struct
  • xyz: XYZ flight data struct
  • ind: selected data indices
  • mapS: (optional) MapS, MapSd, or MapS3D scalar magnetic anomaly map struct, only used for y_type = :b, :c
  • temp_params: (optional) TempParams temporary (WIP) parameters struct
  • silent: (optional) if true, no print outs

Returns:

  • y: length-N target vector
  • y_hat: length-N prediction vector
  • err: length-N compensation error
  • features: length-Nf feature vector (including components of TL A, etc.)
source
comp_test(comp_params::CompParams, lines,
          df_line::DataFrame, df_flight::DataFrame, df_map::DataFrame;
          temp_params::TempParams = TempParams(),
          silent::Bool            = false)

Evaluate performance of an aeromagnetic compensation model.

Arguments:

  • comp_params: CompParams aeromagnetic compensation parameters struct, either:
    • NNCompParams: neural network-based aeromagnetic compensation parameters struct
    • LinCompParams: linear aeromagnetic compensation parameters struct
  • lines: selected line number(s)
  • df_line: lookup table (DataFrame) of lines
FieldTypeDescription
flightSymbolflight name (e.g., :Flt1001)
lineRealline number, i.e., segments within flight
t_startRealstart time of line to use [s]
t_endRealend time of line to use [s]
map_nameSymbol(optional) name of magnetic anomaly map relevant to line
  • df_flight: lookup table (DataFrame) of flight data files
FieldTypeDescription
flightSymbolflight name (e.g., :Flt1001)
xyz_typeSymbolsubtype of XYZ to use for flight data {:XYZ0,:XYZ1,:XYZ20,:XYZ21}
xyz_setRealflight dataset number (used to prevent improper mixing of datasets, such as different magnetometer locations)
xyz_fileStringpath/name of flight data CSV, HDF5, or MAT file (.csv, .h5, or .mat extension required)
  • df_map: lookup table (DataFrame) of map data files
FieldTypeDescription
map_nameSymbolname of magnetic anomaly map
map_fileStringpath/name of map data HDF5 or MAT file (.h5 or .mat extension required)
  • temp_params: (optional) TempParams temporary (WIP) parameters struct
  • silent: (optional) if true, no print outs

Returns:

  • y: length-N target vector
  • y_hat: length-N prediction vector
  • err: length-N mean-corrected (per line) compensation error
  • features: length-Nf feature vector (including components of TL A, etc.)
source