Ejemplo n.º 1
0
def _console_script(argv=None):
    """
    Console script to convert LCHEAPO data to basic SDS with drift correction
    Data should be in station_data_path/{STATION_NAME}/*.raw.lch
    """
    from argparse import ArgumentParser

    parser = ArgumentParser(prog="obsinfo-make_LCHEAPO-park_scripts",
                            description=__doc__)
    parser.add_argument("network_file", help="Network information file")
    parser.add_argument("input_dir",
                        help="Base path containing station directories")
    parser.add_argument("output_dir",
                        default="2_miniseed_basic",
                        help="directory in which to put fixed data and "
                        "SDS directory")
    parser.add_argument("--suffix",
                        default="",
                        help="suffix for script filename")
    parser.add_argument("-v",
                        "--verbose",
                        action="store_true",
                        help="increase verbosity")
    parser.add_argument("-q",
                        "--quiet",
                        action="store_true",
                        help="run silently")
    args = parser.parse_args()

    if not args.quiet:
        print("Creating LC2SDS process scripts, ", end="", flush=True)
    # READ IN NETWORK INFORMATION
    network = oi_network(args.network_file)
    sta_list = [name for name in network.stations.keys()]
    if not args.quiet:
        print("network {}, stations {}".format(network.network_info.code,
                                               ', '.join(sta_list)))

    for name, station in network.stations.items():
        # station_dir = os.path.join(args.station_data_path, name)
        script = process_script(station, args.input_dir, args.output_dir)
        fname = f"process_{name}{args.suffix}.sh"
        if args.verbose:
            print(f" ... writing file {fname}", flush=True)
        with open(fname, "w") as f:
            f.write(script)
            f.close()
    if not args.verbose and not args.quiet:
        print("")
Ejemplo n.º 2
0
def _console_script(argv=None):
    """
    Console-level processing script
    
    requires SDPCHAIN programs msdrift and ms2sds, and IRIS program msmod
    
    Currently usese 'SDS_corrected' and 'SDS_uncorrected' as default SDS directories
    Would be better to use ../SDS_[un]corrected so that all data are together,
    but ms2sds is not yet capable of putting data in an existing SDS directory
    
    """
    from argparse import ArgumentParser

    parser = ArgumentParser( prog='obsinfo-make_process_scripts_SDPCHAIN',description=__doc__)
    parser.add_argument( 'network_file', help='Network information file')
    parser.add_argument( 'station_data_path', help='Base path containing stations data')
    parser.add_argument( 'sdpchain_path', help='Path to SDPCHAIN software')
    parser.add_argument( '-i', '--input_dir', default='2_miniseed_basic',
        help='subdirectory of station_data_path/{STATION}/ containing input *.mseed files')
    parser.add_argument( '-o', '--output_mseed_dir', default='3_miniseed_corr',
        help='subdirectory of station_data_path/{STATION}/ to put corrected *.mseed files')
    parser.add_argument( '--SDS_corr_dir', default='SDS_corrected',
        help='subdirectory of station_data_path/{STATION}/ for SDS structure of corrected data')
    parser.add_argument( '--SDS_uncorr_dir', default='SDS_uncorrected',
        help='subdirectory of station_data_path/{STATION}/ for SDS structure of uncorrected data')
    parser.add_argument( '-d', '--msdrift_dir', default='MSDRIFT',
        help='subdirectory of sdpchain_path/ containing msdrift program')
    parser.add_argument( '-s', '--ms2sds_dir', default='MS2SDS',
        help='subdirectory of sdpchain_path/ containing ms2sds program')
    parser.add_argument( '-m', '--msmod_path', default='',
        help='full path to msmod program')
    parser.add_argument( '-v', '--verbose',action="store_true",
        help='increase output verbosiy')
    parser.add_argument( '-q', '--quiet',action="store_true",
        help='run silently')
    args = parser.parse_args()
    
    # CONSTRUCT PATHS
    msdrift_path=os.path.join(args.sdpchain_path,args.msdrift_dir)
    ms2sds_path=os.path.join(args.sdpchain_path,args.ms2sds_dir)
    
    # READ IN NETWORK INFORMATION
    if not args.quiet:
        print(f"Creating SDPCHAIN process scripts, ",end="")
    network=oi_network(args.network_file)
    if not args.quiet:
        print(f"network {network.network_info.code}, stations ",end="")
        if args.verbose:
            print("")

    first_time=True
    for name,station in network.stations.items():
        if not args.quiet:
            if args.verbose:
                print(f"\t{name}",end="")
            else:
                if first_time:
                    print(f"{name}",end="")
                else:
                    print(f", {name}", end="")
        station_dir=os.path.join(args.station_data_path,name)
        script=process_script(station,station_dir,
                                msdrift_path,
                                ms2sds_path,
                                input_mseed_dir=args.input_dir,
                                output_mseed_dir=args.output_mseed_dir,
                                SDS_uncorr_dir=args.SDS_uncorr_dir,
                                SDS_corr_dir=args.SDS_corr_dir,
                                include_header=False,
                                msmod_path=args.msmod_path)
        fname='process_'+name+'_SDPCHAIN.sh'
        if args.verbose:
            print(f" ... writing file {fname}")
        with open(fname,'w') as f:
            f.write(f'#!/bin/bash\n\n')
            f.write('#'+'='*60 + '\n')
            f.write(f'echo "Running SDPCHAIN processes on station {name}"\n')
            f.write('#'+'='*60 + '\n')
            f.write(script)
            f.write('\n')
            f.close()
        first_time=False
    if not args.verbose and not args.quiet:
        print("")
Ejemplo n.º 3
0
def _console_script(argv=None):
    """
    Create a bash-script to convert LCHEAPO data to basic miniSEED
    Data should be in station_data_path/{STATION_NAME}/{input_dir}/*.fix.lch
    
    requires O Dewee program lc2ms, and IRIS program msmod
    
    """
    from argparse import ArgumentParser

    parser = ArgumentParser(prog='obsinfo-make_process_scripts_LC2MS',
                            description=__doc__)
    parser.add_argument('network_file', help='Network information file')
    parser.add_argument('station_data_path',
                        help='Base path containing stations data')
    parser.add_argument('lc2ms_path', help='Path to lc2ms software')
    parser.add_argument(
        '-i',
        '--input_dir',
        default='1_proprietary',
        help=
        'subdirectory of station_data_path/{STATION}/ containing input *.raw.lch files'
    )
    parser.add_argument(
        '-o',
        '--output_dir',
        default='2_miniseed_basic',
        help=
        'subdirectory of station_data_path/{STATION}/ to put output *.mseed files'
    )
    parser.add_argument('-v',
                        '--verbose',
                        action="store_true",
                        help='increase output verbosity')
    parser.add_argument('-q',
                        '--quiet',
                        action="store_true",
                        help='run silently')
    args = parser.parse_args()

    if not args.quiet:
        print(f"Creating  LC2MS   process scripts, ", end="", flush=True)
    # READ IN NETWORK INFORMATION
    network = oi_network(args.network_file)
    if not args.quiet:
        print(f"network {network.network_info.code}, stations ",
              end="",
              flush=True)
        if args.verbose:
            print("")

    first_time = True
    for name, station in network.stations.items():
        if not args.quiet:
            if args.verbose:
                print(f"\t{name}", end="")
            else:
                if first_time:
                    print(f"{name}", end="", flush=True)
                else:
                    print(f", {name}", end="", flush=True)
        station_dir = os.path.join(args.station_data_path, name)
        script = process_script(station,
                                station_dir,
                                args.lc2ms_path,
                                lcheapo_dir=args.input_dir,
                                input_dir=args.output_dir,
                                include_header=False)
        fname = 'process_' + name + '_LC2MS.sh'
        if args.verbose:
            print(f" ... writing file {fname}", flush=True)
        with open(fname, 'w') as f:
            f.write('#!/bin/bash\n\n')
            f.write('#' + '=' * 60 + '\n')
            f.write(f'echo "Running LC2MS processes on station {name}"\n')
            f.write('#' + '=' * 60 + '\n')
            f.write(script)
            f.write('\n')
            f.close()
        first_time = False
    if not args.verbose and not args.quiet:
        print("")
Ejemplo n.º 4
0
def _console_script(argv=None):
    """
    Create a bash-script to convert LCHEAPO data to basic miniSEED
    Data should be in station_data_path/{STATION_NAME}/{input_dir}/*.fix.lch

    requires O Dewee program lc2ms, and IRIS program msmod

    """
    from argparse import ArgumentParser

    parser = ArgumentParser(prog="obsinfo-make_process_scripts_LC2MS",
                            description=__doc__)
    parser.add_argument("network_file", help="Network information file")
    parser.add_argument("station_data_path",
                        help="Base path containing stations data")
    parser.add_argument("distrib_path",
                        help="Path to lcheapo software distribution")
    parser.add_argument(
        "-i",
        "--input_dir",
        default=".",
        help=
        "subdirectory of station_data_path/{STATION}/ containing input *.raw.lch files",
    )
    parser.add_argument(
        "-o",
        "--output_dir",
        default="2_miniseed_basic",
        help=
        "subdirectory of station_data_path/{STATION}/ to put output *.mseed files",
    )
    parser.add_argument("--suffix",
                        default="_LC2MS",
                        help="suffix for script filename")
    parser.add_argument("--append",
                        action="store_true",
                        help="append to existing script file")
    parser.add_argument("-v",
                        "--verbose",
                        action="store_true",
                        help="increase output verbosity")
    parser.add_argument("--no_header",
                        action="store_true",
                        help="do not include a script header")
    parser.add_argument("-q",
                        "--quiet",
                        action="store_true",
                        help="run silently")
    args = parser.parse_args()

    if not args.quiet:
        print(f"Creating  LC2MS   process scripts, ", end="", flush=True)
    # READ IN NETWORK INFORMATION
    network = oi_network(args.network_file)
    if not args.quiet:
        print(f"network {network.network_info.code}, stations ",
              end="",
              flush=True)
        if args.verbose:
            print("")

    first_time = True
    for name, station in network.stations.items():
        if not args.quiet:
            if args.verbose:
                print(f"\t{name}", end="")
            else:
                if first_time:
                    print(f"{name}", end="", flush=True)
                else:
                    print(f", {name}", end="", flush=True)
        station_dir = os.path.join(args.station_data_path, name)
        script = process_script(
            station,
            station_dir,
            args.distrib_path,
            input_dir=args.input_dir,
            output_dir=args.output_dir,
            include_header=not args.no_header,
        )
        fname = "process_" + name + args.suffix + ".sh"
        if args.verbose:
            print(f" ... writing file {fname}", flush=True)
        if args.append:
            write_mode = "a"
        else:
            write_mode = "w"
        with open(fname, write_mode) as f:
            # f.write('#'+'='*60 + '\n')
            f.write(script)
            f.close()
        first_time = False
    if not args.verbose and not args.quiet:
        print("")
Ejemplo n.º 5
0
def _console_script(argv=None):
    """
    Console-level processing script

    requires SDPCHAIN programs msdrift and ms2sds, and IRIS program msmod

    Currently usese 'SDS_corrected' and 'SDS_uncorrected' as default SDS directories
    Would be better to use ../SDS_[un]corrected so that all data are together,
    but ms2sds is not yet capable of putting data in an existing SDS directory

    """
    from argparse import ArgumentParser

    parser = ArgumentParser(prog="obsinfo-make_process_scripts_SDPCHAIN",
                            description=__doc__)
    parser.add_argument("network_file", help="Network information file")
    parser.add_argument("station_data_path",
                        help="Base path containing station data")
    parser.add_argument("distrib_dir",
                        help="Path to SDPCHAIN software",
                        default="/opt/sdpchain")
    parser.add_argument(
        "-i",
        "--input_dir",
        default="miniseed_basic",
        help=
        "subdirectory of station_data_path/{STATION}/ containing input *.mseed files",
    )
    parser.add_argument(
        "-o",
        "--corrected_dir",
        default="miniseed_corrected",
        help=
        "subdirectory of station_data_path/{STATION}/ to put corrected *.mseed files",
    )
    parser.add_argument(
        "--SDS_corr_dir",
        default="SDS_corrected",
        help=
        "subdirectory of station_data_path/{STATION}/ for SDS structure of corrected data",
    )
    parser.add_argument(
        "--SDS_uncorr_dir",
        default="SDS_uncorrected",
        help=
        "subdirectory of station_data_path/{STATION}/ for SDS structure of uncorrected data",
    )
    parser.add_argument("--suffix",
                        default="_SDPCHAIN",
                        help="suffix for script filename")
    parser.add_argument("--append",
                        action="store_true",
                        help="append to existing script file")
    parser.add_argument("-v",
                        "--verbose",
                        action="store_true",
                        help="increase output verbosiy")
    parser.add_argument("--no_header",
                        action="store_true",
                        help="do not include file header")
    parser.add_argument("-q",
                        "--quiet",
                        action="store_true",
                        help="run silently")
    args = parser.parse_args()

    # READ IN NETWORK INFORMATION
    if not args.quiet:
        print(f"Creating SDPCHAIN process scripts, ", end="")
    network = oi_network(args.network_file)
    if not args.quiet:
        print(f"network {network.network_info.code}, stations ", end="")
        if args.verbose:
            print("")

    first_time = True
    for name, station in network.stations.items():
        if not args.quiet:
            if args.verbose:
                print(f"\t{name}", end="")
            else:
                if first_time:
                    print(f"{name}", end="")
                else:
                    print(f", {name}", end="")
        station_dir = os.path.join(args.station_data_path, name)
        script = process_script(
            station,
            station_dir,
            distrib_dir=args.distrib_dir,
            input_dir=args.input_dir,
            corrected_dir=args.corrected_dir,
            SDS_uncorr_dir=args.SDS_uncorr_dir,
            SDS_corr_dir=args.SDS_corr_dir,
            include_header=not args.no_header,
        )
        fname = "process_" + name + args.suffix + ".sh"
        if args.verbose:
            print(f" ... writing file {fname}", flush=True)
        if args.append:
            write_mode = "a"
        else:
            write_mode = "w"
        with open(fname, write_mode) as f:
            f.write(script)
            f.close()
        first_time = False
    if not args.verbose and not args.quiet:
        print("")
Ejemplo n.º 6
0
def _console_script(argv=None):
    """
    Console-level processing script
    
    requires SDPCHAIN programs msdrift and ms2sds, and IRIS program msmod
    
    Currently usese 'SDS_corrected' and 'SDS_uncorrected' as default SDS directories
    Would be better to use ../SDS_[un]corrected so that all data are together,
    but ms2sds is not yet capable of putting data in an existing SDS directory
    
    """
    from argparse import ArgumentParser

    parser = ArgumentParser(prog='obsinfo-make_SDPCHAIN_scripts',
                            description=__doc__)
    parser.add_argument('network_file', help='Network information file')
    parser.add_argument('station_data_path',
                        help='Base path containing station data')
    parser.add_argument('distrib_dir',
                        help='Path to SDPCHAIN software',
                        default='/opt/sdpchain')
    parser.add_argument(
        '-i',
        '--input_dir',
        default='miniseed_basic',
        help=
        'subdirectory of station_data_path/{STATION}/ containing input *.mseed files'
    )
    parser.add_argument(
        '-o',
        '--corrected_dir',
        default='miniseed_corrected',
        help=
        'subdirectory of station_data_path/{STATION}/ to put corrected *.mseed files'
    )
    parser.add_argument(
        '--SDS_corr_dir',
        default='SDS_corrected',
        help=
        'subdirectory of station_data_path/{STATION}/ for SDS structure of corrected data'
    )
    parser.add_argument(
        '--SDS_uncorr_dir',
        default='SDS_uncorrected',
        help=
        'subdirectory of station_data_path/{STATION}/ for SDS structure of uncorrected data'
    )
    parser.add_argument('--suffix',
                        default='_SDPCHAIN',
                        help='suffix for script filename')
    parser.add_argument('--append',
                        action="store_true",
                        help='append to existing script file')
    parser.add_argument('-v',
                        '--verbose',
                        action="store_true",
                        help='increase output verbosiy')
    parser.add_argument('--no_header',
                        action="store_true",
                        help='do not include file header')
    parser.add_argument('-q',
                        '--quiet',
                        action="store_true",
                        help='run silently')
    args = parser.parse_args()

    # READ IN NETWORK INFORMATION
    if not args.quiet:
        print(f"Creating SDPCHAIN process scripts, ", end="")
    network = oi_network(args.network_file)
    if not args.quiet:
        print(f"network {network.network_info.code}, stations ", end="")
        if args.verbose:
            print("")

    first_time = True
    for name, station in network.stations.items():
        if not args.quiet:
            if args.verbose:
                print(f"\t{name}", end="")
            else:
                if first_time:
                    print(f"{name}", end="")
                else:
                    print(f", {name}", end="")
        station_dir = os.path.join(args.station_data_path, name)
        script = process_script(station,
                                station_dir,
                                distrib_dir=args.distrib_dir,
                                input_dir=args.input_dir,
                                corrected_dir=args.corrected_dir,
                                SDS_uncorr_dir=args.SDS_uncorr_dir,
                                SDS_corr_dir=args.SDS_corr_dir,
                                include_header=not args.no_header)
        fname = 'process_' + name + args.suffix + '.sh'
        if args.verbose:
            print(f" ... writing file {fname}", flush=True)
        if args.append:
            write_mode = 'a'
        else:
            write_mode = 'w'
        with open(fname, write_mode) as f:
            f.write(script)
            f.close()
        first_time = False
    if not args.verbose and not args.quiet:
        print("")