flightpathr

Tools to analyze aircraft and flight path data.
git clone https://git.eamoncaddigan.net/flightpathr.git
Log | Files | Refs | README | LICENSE

commit 3d7980afa36fde1ab212ad80d52c4942e002cc2d
parent b7a63f14777d2dfc32bf786b14f1544106dd49a8
Author: eamoncaddigan <eamon.caddigan@gmail.com>
Date:   Wed,  2 Nov 2016 12:35:01 -0400

Changed thresholding algorithm.

Diffstat:
MR/identifyManeuvers.R | 69++++++++++++++++++++++++++++++---------------------------------------
Dman/hysteresisThresh.Rd | 16----------------
Mman/identifyAltitudeChanges.Rd | 8++++----
Mman/identifyBearingChanges.Rd | 13++++++++-----
Aman/identifyChanges.Rd | 14++++++++++++++
Mman/identifySpeedChanges.Rd | 14+++++++-------
6 files changed, 63 insertions(+), 71 deletions(-)

diff --git a/R/identifyManeuvers.R b/R/identifyManeuvers.R @@ -3,28 +3,27 @@ #' #' @param trajectory A \code{flighttrajectory} object (or input coercable to #' one) indicating the trajectory of an aircraft. -#' @param loThresh A bearing change (in degrees per second) -#' @param hiThresh A bearing change (in degrees per second); any time point -#' associated with a change in bearing greater than this value will definitely -#' be labeled a turn. +#' @param bearingThresh A bearing change threshold (in degrees). +#' @param turnThresh A turn rate threshold (in degrees per second). #' #' @return A logical vector indicating whether each timepoint can be considered #' a turn. #' +#' @details A period is marked as a turn if the turn rate is greater than +#' \code{turnThresh} and the total bearing change is greater than +#' \code{bearingThresh}. +#' #' @export -identifyBearingChanges <- function(trajectory, loThresh, hiThresh = NA) { - t <- as.flighttrajectory(trajectory) +identifyBearingChanges <- function(trajectory, bearingThresh, turnThresh) { + traj <- as.flighttrajectory(trajectory) bearingChanges <- c(NA, - angleDiff(t$bearing[1:(length(t$bearing)-1)], - t$bearing[2:length(t$bearing)])) / - c(NA, diff(t$time)) + angleDiff(traj$bearing[1:(length(traj$bearing)-1)], + traj$bearing[2:length(traj$bearing)])) / + c(NA, diff(traj$time)) - isBearingChange <- hysteresisThresh(bearingChanges, loThresh, hiThresh) - # if (length(loThresh) > 1) { - # isBearingChange <- isBearingChange | - # hysteresisThresh(-bearingChanges, -min(loThresh), -min(hiThresh)) - # } + isBearingChange <- identifyChanges(traj$bearing, bearingChanges, + bearingThresh, turnThresh) return(isBearingChange) } @@ -34,49 +33,41 @@ identifyBearingChanges <- function(trajectory, loThresh, hiThresh = NA) { #' #' @param trajectory A \code{flighttrajectory} object (or input coercable to #' one) indicating the trajectory of an aircraft. -#' @param hiThresh An altitude change (in feet per second); any time point -#' associated with a change in altitude greater than this value will -#' definitely be labeled a climb or descent. +#' @param altitudeThresh An altitude threshold (in feet). +#' @param verticalSpeedThresh A vertical speed threshold (in feet per second). #' #' @return A logical vector indicating whether each timepoint can be considered #' a climb or descent. #' #' @export -identifyAltitudeChanges <- function(trajectory, loThresh, hiThresh = NA) { - t <- as.flighttrajectory(trajectory) - altitudeChanges <- c(NA, diff(t$altitude)) / c(NA, diff(t$time)) +identifyAltitudeChanges <- function(trajectory, altitudeThresh, verticalSpeedThresh) { + traj <- as.flighttrajectory(trajectory) + altitudeChanges <- c(NA, diff(traj$altitude)) / c(NA, diff(traj$time)) - isAltitudeChange <- hysteresisThresh(altitudeChanges, loThresh, hiThresh) - # if (length(loThresh) > 1) { - # isAltitudeChange <- isAltitudeChange | - # hysteresisThresh(-altitudeChanges, -min(loThresh), -min(hiThresh)) - # } + isAltitudeChange <- identifyChanges(traj$altitude, altitudeChanges, + altitudeThresh, verticalSpeedThresh) return(isAltitudeChange) } #' Identify the timepoints in a trajectory that correspond to a change in -#' altitude. +#' speed. #' #' @param trajectory A \code{flighttrajectory} object (or input coercable to #' one) indicating the trajectory of an aircraft. -#' @param hiThresh An altitude change (in feet per second); any time point -#' associated with a change in altitude greater than this value will -#' definitely be labeled a climb or descent. +#' @param speedThresh A speed threshold (in knots). +#' @param accelerationThresh An accelaration threshold (in knots per second). #' #' @return A logical vector indicating whether each timepoint can be considered -#' a climb or descent. +#' a change in speed #' #' @export -identifySpeedChanges <- function(trajectory, loThresh, hiThresh = NA) { - t <- as.flighttrajectory(trajectory) - speedChanges <- c(NA, diff(t$groundspeed)) / c(NA, diff(t$time)) - - isSpeedChange <- hysteresisThresh(speedChanges, loThresh, hiThresh) - # if (length(loThresh) > 1) { - # isSpeedChange <- isSpeedChange | - # hysteresisThresh(-speedChanges, -min(loThresh), -min(hiThresh)) - # } +identifySpeedChanges <- function(trajectory, speedThresh, accelerationThresh) { + traj <- as.flighttrajectory(trajectory) + speedChanges <- c(NA, diff(traj$groundspeed)) / c(NA, diff(traj$time)) + + isSpeedChange <- identifyChanges(traj$groundspeed, speedChanges, + speedThresh, accelerationThresh) return(isSpeedChange) } diff --git a/man/hysteresisThresh.Rd b/man/hysteresisThresh.Rd @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/identifyManeuvers.R -\name{hysteresisThresh} -\alias{hysteresisThresh} -\title{Helper function for hysteresis thresholding: if a group of neighboring -segments are all above the low threshold and neighbor a segment above the -high threshold, they're "above threshold".} -\usage{ -hysteresisThresh(x, lo, hi = NA) -} -\description{ -Helper function for hysteresis thresholding: if a group of neighboring -segments are all above the low threshold and neighbor a segment above the -high threshold, they're "above threshold". -} - diff --git a/man/identifyAltitudeChanges.Rd b/man/identifyAltitudeChanges.Rd @@ -5,15 +5,15 @@ \title{Identify the timepoints in a trajectory that correspond to a change in altitude.} \usage{ -identifyAltitudeChanges(trajectory, loThresh, hiThresh = NA) +identifyAltitudeChanges(trajectory, altitudeThresh, verticalSpeedThresh) } \arguments{ \item{trajectory}{A \code{flighttrajectory} object (or input coercable to one) indicating the trajectory of an aircraft.} -\item{hiThresh}{An altitude change (in feet per second); any time point -associated with a change in altitude greater than this value will -definitely be labeled a climb or descent.} +\item{altitudeThresh}{An altitude threshold (in feet).} + +\item{verticalSpeedThresh}{A vertical speed threshold (in feet per second).} } \value{ A logical vector indicating whether each timepoint can be considered diff --git a/man/identifyBearingChanges.Rd b/man/identifyBearingChanges.Rd @@ -5,17 +5,15 @@ \title{Identify the timepoints in a trajectory that correspond to a change in commanded heading.} \usage{ -identifyBearingChanges(trajectory, loThresh, hiThresh = NA) +identifyBearingChanges(trajectory, bearingThresh, turnThresh) } \arguments{ \item{trajectory}{A \code{flighttrajectory} object (or input coercable to one) indicating the trajectory of an aircraft.} -\item{loThresh}{A bearing change (in degrees per second)} +\item{bearingThresh}{A bearing change threshold (in degrees).} -\item{hiThresh}{A bearing change (in degrees per second); any time point -associated with a change in bearing greater than this value will definitely -be labeled a turn.} +\item{turnThresh}{A turn rate threshold (in degrees per second).} } \value{ A logical vector indicating whether each timepoint can be considered @@ -25,4 +23,9 @@ A logical vector indicating whether each timepoint can be considered Identify the timepoints in a trajectory that correspond to a change in commanded heading. } +\details{ +A period is marked as a turn if the turn rate is greater than + \code{turnThresh} and the total bearing change is greater than + \code{bearingThresh}. +} diff --git a/man/identifyChanges.Rd b/man/identifyChanges.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/identifyManeuvers.R +\name{identifyChanges} +\alias{identifyChanges} +\title{Helper function for identifying changes based on change magnitude and change +slope.} +\usage{ +identifyChanges(x, dx, xThresh, dxThresh) +} +\description{ +Helper function for identifying changes based on change magnitude and change +slope. +} + diff --git a/man/identifySpeedChanges.Rd b/man/identifySpeedChanges.Rd @@ -3,24 +3,24 @@ \name{identifySpeedChanges} \alias{identifySpeedChanges} \title{Identify the timepoints in a trajectory that correspond to a change in -altitude.} +speed.} \usage{ -identifySpeedChanges(trajectory, loThresh, hiThresh = NA) +identifySpeedChanges(trajectory, speedThresh, accelerationThresh) } \arguments{ \item{trajectory}{A \code{flighttrajectory} object (or input coercable to one) indicating the trajectory of an aircraft.} -\item{hiThresh}{An altitude change (in feet per second); any time point -associated with a change in altitude greater than this value will -definitely be labeled a climb or descent.} +\item{speedThresh}{A speed threshold (in knots).} + +\item{accelerationThresh}{An accelaration threshold (in knots per second).} } \value{ A logical vector indicating whether each timepoint can be considered - a climb or descent. + a change in speed } \description{ Identify the timepoints in a trajectory that correspond to a change in -altitude. +speed. }