.. _merge: Merge Databases =============== Program ``merge_stdb`` ---------------------- Description ----------- Merge multiple ``StDb`` database files together. Performs a rudimentary check for mulitple keys. Usage ----- .. code-block:: $ merge_stdb -h Usage: merge_stdb [options] [additional station pickle files] Helper program to merge multiple station database files together. Options: -h, --help show this help message and exit -v, --verbose Enable more verbose output. Default is quiet (no prompts). -O, --overwrite Ovewrite output file if it already exists. Default behaviour quits with warning. -o ONAME, --output-file=ONAME Specify output file name. Defaults to the input file with '.apd' added to the end. -a, --ascii Specify to write ascii Pickle files instead of binary. Ascii are larger file size, but more likely to be system independent. Example ------- Assume we have already created a StDb database named ``ta_list.pkl`` using the example in :ref:`query`. Now create a second StDb database by querying the FDSN archive for stations in the CN network in the same region. Send the prompt to a stdb.log file. .. note:: This could have been performed during the first call to :ref:`query` with the option ``-N TA,CN`` - this is just for illustration .. code-block:: none $ query_fdsn_stdb -C BH? -N CN --minlat=60 --maxlat=65 --minlon=-135 --maxlon=-120 --start=2017-01-01 cn_list >> stdb.log List the content of cn_list.pkl: .. code-block:: none $ ls_stdb cn_list Listing Station Pickle: cn_list.pkl CN.WHY -------------------------------------------------------------------------- 1) CN.WHY Station: CN WHY Alternate Networks: None Channel: BH ; Location: -- Lon, Lat, Elev: 60.65970, -134.88251, 1.273 StartTime: 1994-10-03 00:00:00 EndTime: 2599-12-31 23:59:59 Status: open Polarity: 1 Azimuth Correction: 0.000000 Merge ``ta_list.pkl`` and ``cn_list.pkl`` into a new file called ``merged_list.pkl``: .. code-block:: none $ merge_stdb -o merged_list ta_list cn_list .. code-block:: none $ ls_stdb merged_list Listing Station Pickle: merged_list.pkl TA.M31M -------------------------------------------------------------------------- 1) TA.M31M Station: TA M31M Alternate Networks: None Channel: BH ; Location: -- Lon, Lat, Elev: 62.20240, -134.39059, 0.639 StartTime: 2015-10-17 00:00:00 EndTime: 2599-12-31 23:59:59 Status: open Polarity: 1 Azimuth Correction: 0.000000 TA.N32M -------------------------------------------------------------------------- 2) TA.N32M Station: TA N32M Alternate Networks: None Channel: BH ; Location: -- Lon, Lat, Elev: 61.15120, -133.08180, 0.816 StartTime: 2016-05-11 00:00:00 EndTime: 2599-12-31 23:59:59 Status: open Polarity: 1 Azimuth Correction: 0.000000 TA.P33M -------------------------------------------------------------------------- 3) TA.P33M Station: TA P33M Alternate Networks: None Channel: BH ; Location: -- Lon, Lat, Elev: 60.21140, -132.81740, 1.066 StartTime: 2015-10-15 00:00:00 EndTime: 2599-12-31 23:59:59 Status: open Polarity: 1 Azimuth Correction: 0.000000 CN.WHY -------------------------------------------------------------------------- 4) CN.WHY Station: CN WHY Alternate Networks: None Channel: BH ; Location: -- Lon, Lat, Elev: 60.65970, -134.88251, 1.273 StartTime: 1994-10-03 00:00:00 EndTime: 2599-12-31 23:59:59 Status: open Polarity: 1 Azimuth Correction: 0.000000