Skip to contents

Provides interactive 3D and 2D plots for exploring GeoPressureR tag object sensor data, including raw and calibrated magnetic data, fitted calibration ellipsoids, and (projected) acceleration data. Color-coding by stationary period or movement state is supported. Time series plots can optionally overlay a reference path, and histogram plots compare errors against a reference path.

Plot types:

  • "magnetic": Raw magnetic data in sensor frame, colored by stationary period.

  • "magnetic_c": Calibrated magnetic data in sensor frame, colored by stationary period.

  • "magnetic_cp": Calibrated magnetic data projected in the Earth frame, colored by stationary period.

  • "magnetic_calib": Calibration points and fitted ellipsoids for selected periods.

  • "calib": Alias of "magnetic_calib" (kept for backward compatibility).

  • "acceleration": Raw acceleration, colored by static/moving classification.

  • "acceleration_p": Projected acceleration (NED frame), with reference gravity.

  • "timeseries": Time series of inclination and intensity, with optional reference path overlay.

  • "histogram": Histogram of errors (sample and mean per stationary period) against reference path.

Usage

plot_mag(
  tag,
  type = "magnetic",
  stap_id = NULL,
  path = NULL,
  static_thr_hard = NULL,
  static_thr_outlier = NULL
)

Arguments

tag

A GeoPressureR tag object containing magnetic (and optionally calibration) data.

type

Character, plot type. One of "magnetic", "magnetic_c", "magnetic_cp", "magnetic_calib" (or alias "calib"), "acceleration", "acceleration_p", "timeseries", or "histogram".

stap_id

Integer or vector, stationary period(s) to plot calibration fit for (type="magnetic_calib" or "calib").

path

Optional for "timeseries" and required for "histogram". A data frame with columns start, end, stap_id, lon, lat for plotting reference paths.

static_thr_hard

Numeric. Hard threshold around 1 g used when classifying static samples in "acceleration" plots. Passed to tag_static().

static_thr_outlier

Numeric. MAD threshold used to remove outliers among candidate static samples. Passed to tag_static().

Value

A plotly::plot_ly() object for magnetic, calibration, and acceleration plots; a plotly::ggplotly() object for timeseries plots; or a ggplot2 object for histogram plots.

Details

  • Uses the scico or viridisLite palettes for clear color separation.

  • For magnetic plots, "magnetic_c" and "magnetic_cp" require calibrated data from geomag_calib().

  • For type "magnetic_calib" (or alias "calib"), if stap_id is missing, periods with min/max radii are shown.

  • If stap_id is missing in tag$magnetic and/or tag$mag_calib, a fallback grouping is created automatically so plots still render.

  • For acceleration plots, static/moving state is estimated if not present.

  • For histogram plots, a reference path is required for error analysis.

  • For timeseries plots, a reference path is optional and only used for overlaying reference segments.

Examples

library(GeoPressureR)
withr::with_dir(system.file("extdata", package = "GeoMagR"), {
  tag <- tag_create("14DM", quiet = TRUE)
  tag <- tag_label(tag, quiet = TRUE)
  tag <- geomag_calib(tag, quiet = TRUE)
})
#>  Using raw magnetic data for calibration data
plot_mag(tag, type = "acceleration")
plot_mag(tag, type = "magnetic")
plot_mag(tag, type = "calib")