contents

mark_duplicates

Called by:   main each iteration.

Includes:   iscloc.h

Input arguments:
Pointer to solution structure.
Array of phase structures.

Calls:
same_sta from this file.
same_pha and same_time from this file called by same_sta.
read_ttime called by same_time.
print_pha from utils if diagnostic is on.

Structure members updated ( in same_pha ) :
weight_factor, pref_rd, duplicate in phase structure.

Return:   0/1 for success/failure.

This function stops arrivals being over weighted because they are reported more than once.  There are a number of situations, as described below:
Each phase structure has 2 fields specifically related to duplicate elimination:

The value of pref_rd starts out set to a value input from data (or equal to rdid if such data is not available).  In the ISC database an algorithm is run that recognises duplicate readings.  If such readings exactly duplicate each other then one is deprecated but otherwise the algorithm chooses which is 'preferred' using such criteria as the number of phases included in each reading and whether one reading was reported by the agency responsible for the station.  The rdid of the preferred reading is assigned to the pref_rd field for every phase of both readings.  

mark_duplicates  uses the initial values of pref_rd to pick which phase to prefer between two or more identical phases but it only assigns pref_rd to one phase at a time - allowing one reading to include phases with different pref_rds.  Because location works entirely with phases, rather than with readings, this is not important until phases are printed or the phase table of the database updated, at which time readings are untangled.

Having pref_rd not equal to rdid does not necessarily mean that a phase is a duplicate - just that it was part of a duplicate reading when it was input, as explained above.  This is why the duplicate flag is required, mark_duplicates sets this flag when it changes the value of pref_rd for a phase and it signifies that this phase is an exact duplicate of another phase and that that is why it is not required in the solution (has weight_factor =0).