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 (default value) or the value given by the user. Note that duplicate amplitude phases to be deleted might requre a large time difference since they might have been picked at different times. 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 merge event can be merged into several main events if the time differece allow this.

The locality line from 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.

All the events from repective input files that have a time match are wrttien out again in separate files with added name 'used'. These two files will then have the same events from two different sources and can e.g. be used to compare location for the same events from two different sources either by plotting with EPIMAP or using COMPARE_HYP.

Example run:

c:\seismo\WOR>merge_s
  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 . :
collect.out
  File to be merged into main
epi.out
  Max time difference for event to be appended, def(enter)=50s
20
  Delete duplicate phases: 0=no, 1: from merge file (default enter), 2:from main file

  Maximum difference for phase to be deleted, default is 0.1 s (enter)

  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
 Output file of events used from main is merge_s_main_used.out
 Output file of events used from merge is merge_s_merge_used.out
c:\seismo\WOR>

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.