28.2 Merge events near in time and delete duplicate phases, MERGE_S

This program works in a similar way as ASSOCI, however with a better control of the merging.

The program can merge two files or a data base and a file. The two inputs are main input and merge input. The main input can be a data base or a file while merge input only can be a file. The merge input file is merged into the main input and the merged file written to an output file. None of the inputs are changed.

Events from the merge file is compared to events in the main input and merged if within user given time difference.

Duplicate phases are deleted if from same station with a time difference of less than 0.1 s. There is no check for component since some input sources, like from ISC, have no component. The user can specify if the phase from main input or merge input will be deleted. Normally the whole phase name is compared, but there is an option to use only the first letter. This can be used if two agencies use different upper and lower case like PN or Pn so only the first letter can be compared. However, this does not apply to SPEC phases since only used in SEISAN and we do not want to confuse S with SPEC.

For spectral phases, also component is used since that is always given. The spectral averages are taken from the main input. If no averages in main but in merge, they are taken from the merge input. So spectral averages might not be a correct representation of SPEC lines are merged, but that will be fixed with next update.

The first header and ID line will come from the main input file. The Id line from the merge file is converted to a comment line.

The locality line form main is kept and if there is a locality line in merge file, it is renamed from LOCALITY: to MER-LOCA:

Both inputs must be in chronological order, if not the program stops. Input from a data base (or using e.g. a collect from a data base) might therefore require can update with new ID lines.

Input can be old or Nordic2 format but output is the one set up by the SEISAN.DEF.

There is no check for distance id.

All events from main input is written out again and events from merge file that does not match in time can optionally be put in main output file or in a separate file.

Example run:

  Main data base or file to merge into - select one:

     SEISAN default data base or                     :Enter
     Alternative data base, give 1-5 letter code or  :
     Local index file, name must start with index or :
     Local data base, write ,, or                    :
     Filename for one file, min. 6 chars or with a . :
  File to be merged into main
  Max time difference for event to be appended, def(enter)=50s
  Delete duplicate phases: 0=no, 1: from merge file (default enter), 2:from main file

  Put all events from file to merge in output file y,n=default (enter)

  Compare whole phase name (enter) or only first letter (f)

Main:  1996  7 1  142 19.8 L  Merge:  1996  7 1  144 19.8 L dif=         -120.0
Main:  1996  7 1  759 36.0 L  Merge:  1996  7 1  144 19.8 L dif=        22516.2
Main:  1996  7 1  759 36.0 L  Merge:  1996  7 1  759 38.0 L dif=           -2.0 *Appended*
Main:  1996  7 1  8 3 16.1 L  Merge:  1996  7 1  759 38.0 L dif=          218.1
Main:  1996  7 1  8 3 16.1 L  Merge:  1996  7 1  8 3 16.1 L dif=            0.0 *Appended*
Main:  1996  7 1 1040 53.8 L  Merge:  1996  7 1  8 3 16.1 L dif=         9457.7
Main:  1996  7 1 1040 53.8 L  Merge:  1996  7 1 1044 45.3 L dif=         -231.5
Main:  1996  7 1 1044 55.3 L  Merge:  1996  7 1 1044 45.3 L dif=           10.0 *Appended*
End of s-file

 Number of events in main input file or data base           5
 Number of events in merge input file                       4
 Number of events appended                                  3
 Number of deleted phases                                  32
 Output file name is append_s.out
 Output file of not appended events is append_s_not.out


Note how the reading advances in each file one by one and each line compares two events with the difference given. The time differences are are calculated from the first header line for each event.

Peter Voss : Tue Jun 8 13:38:42 UTC 2021