UFO
ufo::TrackCheckShip Class Reference

Checks tracks of ships and buoys, rejecting observations whose locations and timestamps make them inconsistent with the rest of the track. The full track is rejected if there are too many inconsistent observations. More...

#include <TrackCheckShip.h>

Inheritance diagram for ufo::TrackCheckShip:
Collaboration diagram for ufo::TrackCheckShip:

Classes

struct  ObservationStatistics
 Relevant calculated values that are specific to each pair or triplet of adjacent/alternating observations. More...
 
class  TrackObservation
 
struct  TrackStatistics
 A container for all track-wise counters and calculations that indicate the overall quality of the tracks' data. More...
 

Public Types

typedef TrackCheckShipParameters Parameters_
 

Public Member Functions

 TrackCheckShip (ioda::ObsSpace &obsdb, const Parameters_ &parameters, std::shared_ptr< ioda::ObsDataVector< int > > flags, std::shared_ptr< ioda::ObsDataVector< float > > obserr)
 
 ~TrackCheckShip () override
 
const TrackCheckShipDiagnosticsdiagnostics () const
 
- Public Member Functions inherited from ufo::FilterBase
 FilterBase (ioda::ObsSpace &, const FilterParametersBaseWithAbstractAction &parameters, std::shared_ptr< ioda::ObsDataVector< int > >, std::shared_ptr< ioda::ObsDataVector< float > >)
 
 FilterBase (ioda::ObsSpace &, const eckit::Configuration &, std::shared_ptr< ioda::ObsDataVector< int > >, std::shared_ptr< ioda::ObsDataVector< float > >)
 
 ~FilterBase ()
 
- Public Member Functions inherited from ufo::ObsProcessorBase
 ObsProcessorBase (ioda::ObsSpace &, bool deferToPost, std::shared_ptr< ioda::ObsDataVector< int > >, std::shared_ptr< ioda::ObsDataVector< float > >)
 
 ~ObsProcessorBase ()
 
void preProcess () override
 
void priorFilter (const GeoVaLs &) override
 
void postFilter (const ioda::ObsVector &, const ioda::ObsVector &, const ObsDiagnostics &) override
 
oops::Variables requiredVars () const override
 
oops::Variables requiredHdiagnostics () const override
 

Static Public Member Functions

static const std::string classname ()
 
static double distance (const TrackObservation &a, const TrackObservation &b)
 Extends distance for TrackObservation inputs a and b. More...
 
static double speedEstimate (const TrackCheckShip::TrackObservation &obs1, const TrackCheckShip::TrackObservation &obs2, const TrackCheckShipParameters &options)
 Estimate of speed as calculated in Ops_CheckShipTrack. More...
 
static float angle (const TrackCheckShip::TrackObservation &a, const TrackCheckShip::TrackObservation &b, const TrackCheckShip::TrackObservation &c)
 Returns the angle in degrees (rounded to the nearest .1 degree) between displacement vectors going from observations a to b and b to c. More...
 

Private Types

enum  CalculationMethod { FIRSTITERATION , MAINLOOP }
 

Private Member Functions

void flagRejectedTrackObservations (std::vector< size_t >::const_iterator trackObsIndicesBegin, std::vector< size_t >::const_iterator trackObsIndicesEnd, const std::vector< size_t > &validObsIds, const std::vector< TrackObservation > &trackObservations, std::vector< bool > &isRejected) const
 
void print (std::ostream &) const override
 
void applyFilter (const std::vector< bool > &, const Variables &, std::vector< std::vector< bool >> &) const override
 
int qcFlag () const override
 
void calculateTrackSegmentProperties (const std::vector< std::reference_wrapper< TrackObservation >> &trackObservations, CalculationMethod calculationMethod=MAINLOOP) const
 
std::vector< TrackObservationcollectTrackObservations (std::vector< size_t >::const_iterator trackObsIndicesBegin, std::vector< size_t >::const_iterator trackObsIndicesEnd, const std::vector< size_t > &validObsIds, const TrackCheckUtils::ObsGroupLocationTimes &obsLoc) const
 
bool earlyBreak (const std::vector< std::reference_wrapper< TrackObservation >> &trackObs, const std::string trackId) const
 
void removeFaultyObservation (std::vector< std::reference_wrapper< TrackObservation > > &track, const std::vector< std::reference_wrapper< TrackObservation > >::iterator &it, bool firstIterativeRemoval, const std::string trackId) const
 Chooses which of the observations surrounding the speediest segment to remove, flagging it accordingly. More...
 

Private Attributes

Parameters_ options_
 
std::unique_ptr< TrackCheckShipDiagnosticsdiagnostics_
 

Additional Inherited Members

- Protected Attributes inherited from ufo::FilterBase
const eckit::LocalConfiguration config_
 
ufo::Variables filtervars_
 
- Protected Attributes inherited from ufo::ObsProcessorBase
ioda::ObsSpace & obsdb_
 
std::shared_ptr< ioda::ObsDataVector< int > > flags_
 
std::shared_ptr< ioda::ObsDataVector< float > > obserr_
 
ufo::Variables allvars_
 
ObsFilterData data_
 

Detailed Description

Checks tracks of ships and buoys, rejecting observations whose locations and timestamps make them inconsistent with the rest of the track. The full track is rejected if there are too many inconsistent observations.

Each track is checked separately. The algorithm will first calculate speeds and distances between every two adjacent and alternating observations, and angles between any three adjacent observations. Based on these values, it will increment a set of "error counters" that reflect how many errors exist within the track. If the "early break check" parameter is set to true and the "error counters" sum up to a value greater than or equal to half of the segments, the filter will ignore the current track and move on to the next one. Otherwise, observations will be iteratively removed based on the location of the fastest segment until all segments between observations are slower than the speed set by the "max speed" parameter (or 80% of it if angles between segments are large).

See TrackCheckShipsParameters for the documentation of this filter's parameters.

Definition at line 62 of file src/ufo/filters/TrackCheckShip.h.

Member Typedef Documentation

◆ Parameters_

Member Enumeration Documentation

◆ CalculationMethod

Enumerator
FIRSTITERATION 
MAINLOOP 

Definition at line 208 of file src/ufo/filters/TrackCheckShip.h.

Constructor & Destructor Documentation

◆ TrackCheckShip()

ufo::TrackCheckShip::TrackCheckShip ( ioda::ObsSpace &  obsdb,
const Parameters_ parameters,
std::shared_ptr< ioda::ObsDataVector< int > >  flags,
std::shared_ptr< ioda::ObsDataVector< float > >  obserr 
)

Definition at line 37 of file TrackCheckShip.cc.

◆ ~TrackCheckShip()

ufo::TrackCheckShip::~TrackCheckShip ( )
override

Definition at line 107 of file TrackCheckShip.cc.

Member Function Documentation

◆ angle()

float ufo::TrackCheckShip::angle ( const TrackCheckShip::TrackObservation a,
const TrackCheckShip::TrackObservation b,
const TrackCheckShip::TrackObservation c 
)
static

Returns the angle in degrees (rounded to the nearest .1 degree) between displacement vectors going from observations a to b and b to c.

Definition at line 74 of file TrackCheckShip.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyFilter()

void ufo::TrackCheckShip::applyFilter ( const std::vector< bool > &  apply,
const Variables filtervars,
std::vector< std::vector< bool >> &  flagged 
) const
overrideprivatevirtual

The filter begins with separating observations into tracks based on Station_Id. Various calculations are then performed between consecutive observations: distances/speeds between observation pairs, and angles between the displacement vectors formed by triplets of consecutive observations. Track-specific counters are incremented for various metrics that indicate an unexpected track path.

Based on these counter values, the filter may ignore the current track and move on to the next one. Using the described calculations and additional ones if necessary, the observation directly before and/or after the fastest segment is chosen for rejection. This will continue until all remaining segments that link accepted observations are either:

  1. slower than a user-defined "max speed (m/s)" where the angles between the fastest accepted segment's displacement vector and its two neighbouring segments' displacement vectors are both less than 90 degrees.
  2. slower than 80 percent of this user-defined speed.

The full track will be rejected if the number of observations removed is more than the user-defined "rejection threshold".

Implements ufo::FilterBase.

Definition at line 155 of file TrackCheckShip.cc.

Here is the call graph for this function:

◆ calculateTrackSegmentProperties()

void ufo::TrackCheckShip::calculateTrackSegmentProperties ( const std::vector< std::reference_wrapper< TrackObservation >> &  trackObservations,
CalculationMethod  calculationMethod = MAINLOOP 
) const
private

This performs all of the necessary calculations based on the observations' locations and timestamps by calling calculateTwoObservationValues and calculateThreeObservationValues for the non-edge-case observations.

Definition at line 586 of file TrackCheckShip.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ classname()

static const std::string ufo::TrackCheckShip::classname ( )
inlinestatic

Definition at line 67 of file src/ufo/filters/TrackCheckShip.h.

◆ collectTrackObservations()

std::vector< TrackCheckShip::TrackObservation > ufo::TrackCheckShip::collectTrackObservations ( std::vector< size_t >::const_iterator  trackObsIndicesBegin,
std::vector< size_t >::const_iterator  trackObsIndicesEnd,
const std::vector< size_t > &  validObsIds,
const TrackCheckUtils::ObsGroupLocationTimes obsLocTime 
) const
private
Returns
a vector of TrackObservations that all hold a shared_ptr to an instance of TrackStatistics, which holds all of the track-specific counters.

Definition at line 232 of file TrackCheckShip.cc.

Here is the caller graph for this function:

◆ diagnostics()

const TrackCheckShipDiagnostics * ufo::TrackCheckShip::diagnostics ( ) const

Definition at line 87 of file TrackCheckShip.cc.

Here is the caller graph for this function:

◆ distance()

static double ufo::TrackCheckShip::distance ( const TrackObservation a,
const TrackObservation b 
)
inlinestatic

Extends distance for TrackObservation inputs a and b.

Definition at line 178 of file src/ufo/filters/TrackCheckShip.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ earlyBreak()

bool ufo::TrackCheckShip::earlyBreak ( const std::vector< std::reference_wrapper< TrackObservation >> &  trackObs,
const std::string  trackId 
) const
private
Returns
true if at least half of the track segments have incremented the relevant rejection counters

This filter is best for mostly-accurate observation tracks. If the track has many "errors" (as indicated by the counters that are incremented before any observations are removed), it will stop early by default.

Sometimes caused by two ships with same callsign or various reports with wrong time, the check gives up. This is particularly a problem with WOD01 data - case studies suggest that most suspect data is reasonable.

Definition at line 265 of file TrackCheckShip.cc.

Here is the caller graph for this function:

◆ flagRejectedTrackObservations()

void ufo::TrackCheckShip::flagRejectedTrackObservations ( std::vector< size_t >::const_iterator  trackObsIndicesBegin,
std::vector< size_t >::const_iterator  trackObsIndicesEnd,
const std::vector< size_t > &  validObsIds,
const std::vector< TrackObservation > &  trackObservations,
std::vector< bool > &  isRejected 
) const
private

Detects whether each observation in a track has been rejected, and marks the corresponding space in isRejected as true if so.

Parameters
trackObsIndicesBeginthe begin iterator of the track
trackObsIndicesEndthe end iterator
validObsIdsthe vector marking all of the observations' global positions
trackObservationsthe full vector of observations within the single track
isRejectedthe boolean vector whose indices correspond to all of the rejected observations in the full input dataset

Definition at line 120 of file TrackCheckShip.cc.

Here is the caller graph for this function:

◆ print()

void ufo::TrackCheckShip::print ( std::ostream &  os) const
overrideprivatevirtual

Implements ufo::FilterBase.

Definition at line 132 of file TrackCheckShip.cc.

◆ qcFlag()

int ufo::TrackCheckShip::qcFlag ( ) const
inlineoverrideprivatevirtual

Implements ufo::FilterBase.

Definition at line 206 of file src/ufo/filters/TrackCheckShip.h.

◆ removeFaultyObservation()

void ufo::TrackCheckShip::removeFaultyObservation ( std::vector< std::reference_wrapper< TrackObservation > > &  track,
const std::vector< std::reference_wrapper< TrackObservation > >::iterator &  it,
bool  firstIterativeRemoval,
const std::string  trackId 
) const
private

Chooses which of the observations surrounding the speediest segment to remove, flagging it accordingly.

Definition at line 292 of file TrackCheckShip.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ speedEstimate()

double ufo::TrackCheckShip::speedEstimate ( const TrackCheckShip::TrackObservation obs1,
const TrackCheckShip::TrackObservation obs2,
const TrackCheckShipParameters options 
)
static

Estimate of speed as calculated in Ops_CheckShipTrack.

Speed is calculated between obs1 and obs2, accounting for spatial/temporal uncertainty using the resolution values stored in options.

Definition at line 52 of file TrackCheckShip.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ diagnostics_

std::unique_ptr<TrackCheckShipDiagnostics> ufo::TrackCheckShip::diagnostics_
private

Definition at line 194 of file src/ufo/filters/TrackCheckShip.h.

◆ options_

Parameters_ ufo::TrackCheckShip::options_
private

Definition at line 193 of file src/ufo/filters/TrackCheckShip.h.


The documentation for this class was generated from the following files: