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 (level frame, z up), with reference gravity.

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

  • "histogram": Histograms of the observation error (sample minus its stationary-period mean, whose SD estimates sd_e_* of geomag_map()) and of the stationary-period error (period mean minus WMM at the reference path, whose SD estimates sd_m_*, slightly inflated by sd_e_*).

Usage

plot_mag(
  tag,
  type = "magnetic",
  stap_id = NULL,
  path = NULL,
  static_thr_hard = NULL,
  static_thr_outlier = NULL,
  color_by = c("auto", "stap_id", "date"),
  point_opacity = 1
)

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) whose fitted calibration ellipsoid is overlaid on the 3D magnetic plots ("magnetic", "magnetic_c", "magnetic_cp", "magnetic_calib"). Negative values count from the last period. Ignored by other types.

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 in acceleration plots. Passed to tag_static(). When both thresholds are NULL and tag$magnetic$is_static exists (e.g. after geomag_calib()), that classification is used.

color_by

Character, color mapping for 3D magnetic plots. One of "auto" (stap_id when available, otherwise date), "stap_id", or "date".

point_opacity

Numeric, opacity of plotted points.

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. Inclination is shown in degrees and intensity in Gauss.

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)
})
plot_mag(tag, type = "acceleration")
plot_mag(tag, type = "magnetic")
plot_mag(tag, type = "calib")