Exemple #1
0
def distance(ctx, filterid, comp, ampli, show, outfile):
    """Plots the REFs of all pairs vs distance"""
    if ctx.obj['MSNOISE_custom']:
        from distance import main
    else:
        from ..plots.distance import main
    main(filterid, comp, ampli, show, outfile)
Exemple #2
0
def plot_psd(ctx, seed_id):
    """Plots the PSD and spectrogram based on NPZ files"""
    from ..plots.ppsd import main
    net,sta,loc,chan = seed_id.split(".")
    main(net, sta, loc, chan, time_of_weekday=None,
         period_lim=(0.02, 50.0), cmap="viridis",
         color_lim=None, show=True)
Exemple #3
0
def data_availability(ctx, show, outfile):
    """Plots the Data Availability vs time"""
    if ctx.obj['MSNOISE_custom']:
        from data_availability import main
    else:
        from ..plots.data_availability import main
    main(show, outfile)
Exemple #4
0
def distance(ctx, filterid, comp,  ampli, show, outfile):
    """Plots the REFs of all pairs vs distance"""
    if ctx.obj['MSNOISE_custom']:
        from distance import main
    else:
        from ..plots.distance import main
    main(filterid, comp, ampli, show, outfile)
Exemple #5
0
def station_map(ctx, show, outfile):
    """Plots the station map (very very basic)"""
    if ctx.obj['MSNOISE_custom']:
        from station_map import main
    else:
        from ..plots.station_map import main
    main(show, outfile)
Exemple #6
0
def data_availability(ctx, show, outfile):
    """Plots the Data Availability vs time"""
    if ctx.obj['MSNOISE_custom']:
        from data_availability import main
    else:
        from ..plots.data_availability import main
    main(show, outfile)
Exemple #7
0
def station_map(ctx, show, outfile):
    """Plots the station map (very very basic)"""
    if ctx.obj['MSNOISE_custom']:
        from station_map import main
    else:
        from ..plots.station_map import main
    main(show, outfile)
Exemple #8
0
def populate(fromda):
    """Rapidly scan the archive filenames and find Network/Stations"""
    if fromda:
        logging.info("Overriding workflow...")
        from ..msnoise_table_def import DataAvailability
        from ..api import update_station
        db = connect()
        stations = db.query(DataAvailability.net, DataAvailability.sta). \
            group_by(DataAvailability.net, DataAvailability.sta)

        for net, sta in stations:
            print('Adding:', net, sta)
            X = 0.0
            Y = 0.0
            altitude = 0.0
            coordinates = 'UTM'
            instrument = 'N/A'
            update_station(db,
                           net,
                           sta,
                           X,
                           Y,
                           altitude,
                           coordinates=coordinates,
                           instrument=instrument)
    else:
        from ..s002populate_station_table import main
        main()
Exemple #9
0
def mwcs(ctx, sta1, sta2, filterid, comp, mov_stack, show, outfile):
    """Plots the mwcs results between sta1 and sta2 (parses the CCFs)\n
    STA1 and STA2 must be provided with this format: NET.STA !"""
    if ctx.obj['MSNOISE_custom']:
        from mwcs import main
    else:
        from ..plots.mwcs import main
    main(sta1, sta2, filterid, comp, mov_stack, show, outfile)
Exemple #10
0
def dtt(ctx, sta1, sta2, filterid, day, comp, mov_stack, show, outfile):
    """Plots a graph of dt against t\n
    STA1 and STA2 must be provided with this format: NET.STA !"""
    if ctx.obj['MSNOISE_custom']:
        from dtt import main
    else:
        from ..plots.dtt import main
    main(sta1, sta2, filterid, comp, day, mov_stack, show, outfile)
Exemple #11
0
def config_gui():
    """
    Run the deprecated configuration GUI tool.  Please use the configuration
    web interface using 'msnoise admin' instead.
    """
    from ..s001configurator import main
    click.echo("Let's Configure MSNoise !")
    main()
Exemple #12
0
def interferogram(ctx, sta1, sta2, filterid, comp, mov_stack, show, outfile):
    """Plots the interferogram between sta1 and sta2 (parses the CCFs)\n
    STA1 and STA2 must be provided with this format: NET.STA !"""
    if ctx.obj['MSNOISE_custom']:
        from interferogram import main
    else:
        from ..plots.interferogram import main
    main(sta1, sta2, filterid, comp, mov_stack, show, outfile)
Exemple #13
0
def mwcs(ctx, sta1, sta2, filterid, comp, mov_stack, show, outfile):
    """Plots the mwcs results between sta1 and sta2 (parses the CCFs)\n
    STA1 and STA2 must be provided with this format: NET.STA !"""
    if ctx.obj['MSNOISE_custom']:
        from mwcs import main
    else:
        from ..plots.mwcs import main
    main(sta1, sta2, filterid, comp, mov_stack, show, outfile)
Exemple #14
0
def interferogram(ctx, sta1, sta2, filterid, comp, mov_stack, show, outfile):
    """Plots the interferogram between sta1 and sta2 (parses the CCFs)\n
    STA1 and STA2 must be provided with this format: NET.STA !"""
    if ctx.obj['MSNOISE_custom']:
        from interferogram import main
    else:
        from ..plots.interferogram import main
    main(sta1, sta2, filterid, comp, mov_stack, show, outfile)
Exemple #15
0
def dtt(ctx, sta1, sta2, filterid, day, comp, mov_stack, show, outfile):
    """Plots a graph of dt against t\n
    STA1 and STA2 must be provided with this format: NET.STA !\n
    DAY must be provided in the ISO format: YYYY-MM-DD"""
    if ctx.obj['MSNOISE_custom']:
        from dtt import main
    else:
        from ..plots.dtt import main
    main(sta1, sta2, filterid, comp, day, mov_stack, show, outfile)
Exemple #16
0
def compute_dtt(interval,sc,ac,comps):
    """Computes the dt/t jobs based on the new MWCS data"""
    if sc:
        from ..s062compute_dttSC import main
    elif ac:
        from ..s063compute_dttSA import main
    else:
        from ..s06compute_dtt import main
    main(interval, comps)
Exemple #17
0
def ccftime(ctx, sta1, sta2, filterid, comp, mov_stack,
            ampli, seismic, show, outfile):
    """Plots the ccf vs time between sta1 and sta2 (parses the dt/t results)\n
    STA1 and STA2 must be provided with this format: NET.STA !"""
    if ctx.obj['MSNOISE_custom']:
        from ccftime import main
    else:
        from ..plots.ccftime import main
    main(sta1, sta2, filterid, comp, mov_stack, ampli, seismic, show, outfile)
Exemple #18
0
def compute_dtt(interval, sc, ac, comps):
    """Computes the dt/t jobs based on the new MWCS data"""
    if sc:
        from ..s062compute_dttSC import main
    elif ac:
        from ..s063compute_dttSA import main
    else:
        from ..s06compute_dtt import main
    main(interval, comps)
Exemple #19
0
def ccftime(ctx, sta1, sta2, filterid, comp, mov_stack,
            ampli, seismic, show, outfile):
    """Plots the ccf vs time between sta1 and sta2 (parses the dt/t results)\n
    STA1 and STA2 must be provided with this format: NET.STA !"""
    if ctx.obj['MSNOISE_custom']:
        from ccftime import main
    else:
        from ..plots.ccftime import main
    main(sta1, sta2, filterid, comp, mov_stack, ampli, seismic, show, outfile)
Exemple #20
0
def test(prefix, content):
    """Runs the test suite, should be executed in an empty folder!"""
    import matplotlib.pyplot as plt
    plt.switch_backend("agg")
    if not content:
        from ..test.tests import main
    else:
        from ..test.content_tests import main
    main(prefix=prefix)
Exemple #21
0
def distance(ctx, filterid, comp, ampli, show, outfile, refilter,
             virtual_source, extra_args):
    """Plots the REFs of all pairs vs distance"""

    if ctx.obj['MSNOISE_custom']:
        from distance import main
    else:
        from ..plots.distance import main
    main(filterid, comp, ampli, show, outfile, refilter, virtual_source,
         **extra_args)
Exemple #22
0
def ccffreq(ctx, sta1, sta2, filterid, comp, mov_stack, ampli, show, outfile,
            refilter, startdate, enddate):
    """Plots the ccf vs freq between sta1 and sta2 (parses the dt/t results)\n
    STA1 and STA2 must be provided with this format: NET.STA !"""
    if ctx.obj['MSNOISE_custom']:
        from ccffreq import main
    else:
        from ..plots.ccffreq import main
    main(sta1, sta2, filterid, comp, mov_stack, ampli, show, outfile, refilter,
         startdate, enddate)
Exemple #23
0
def config(set, sync):
    """This command should now only be used to use the command line to set
    a parameter value in the data base. It used to launch the Configurator but
    the recommended way to configure MSNoise is to use the "msnoise admin" web
    interface."""
    if set:
        from ..default import default
        if not set.count("="):
            click.echo("!! format of the set command is name=value !!")
            return
        name, value = set.split("=")
        if name not in default:
            click.echo("!! unknown parameter %s !!" % name)
            return
        from ..api import connect, update_config
        db = connect()
        update_config(db, name, value)
        db.commit()
        db.close()
        click.echo("Successfully updated parameter %s = %s" % (name, value))
    elif sync:
        import glob
        from ..api import connect, get_config, get_stations, update_station,\
            preload_instrument_responses

        db = connect()
        responses = preload_instrument_responses(db)
        netsta = []
        for id, row in responses.iterrows():
            net, sta, loc, chan = row["channel_id"].split(".")
            netsta.append("%s.%s" % (net, sta))
        responses["netsta"] = netsta

        for station in get_stations(db):
            id = "%s.%s" % (station.net, station.sta)
            coords = responses[responses["netsta"] == id]
            lon = float(coords["longitude"].values[0])
            lat = float(coords["latitude"].values[0])
            update_station(
                db,
                station.net,
                station.sta,
                lon,
                lat,
                0,
                "DEG",
            )
            logging.info("Added coordinates (%.5f %.5f) for station %s.%s" %
                         (lon, lat, station.net, station.sta))
        db.close()

    else:
        from ..s001configurator import main
        click.echo('Let\'s Configure MSNoise !')
        main()
Exemple #24
0
def mwcs(ctx, sta1, sta2, filterid, comp, mov_stack, show, outfile):
    """Plots the mwcs results between sta1 and sta2 (parses the CCFs)\n
    STA1 and STA2 must be provided with this format: NET.STA !"""
    if sta1 > sta2:
        click.echo("Stations STA1 and STA2 must be sorted alphabetically.")
        return
    if ctx.obj['MSNOISE_custom']:
        from mwcs import main
    else:
        from ..plots.mwcs import main
    main(sta1, sta2, filterid, comp, mov_stack, show, outfile)
Exemple #25
0
def timing(ctx, mov_stack, comp, dttname, filterid, pair, all, show, outfile):
    """Plots the timing (parses the dt/t results)\n
    Individual pairs can be plotted extra using the -p flag one or more times.\n
    Example: msnoise plot timing -p ID_KWUI_ID_POSI\n
    Example: msnoise plot timing -p ID_KWUI_ID_POSI -p ID_KWUI_ID_TRWI\n
    Remember to order stations alphabetically !
    """
    if ctx.obj['MSNOISE_custom']:
        from timing import main
    else:
        from ..plots.timing import main
    main(mov_stack, dttname, comp, filterid, pair, all, show, outfile)
Exemple #26
0
def timing(ctx, mov_stack, comp, dttname, filterid, pair, all, show, outfile):
    """Plots the timing (parses the dt/t results)\n
    Individual pairs can be plotted extra using the -p flag one or more times.\n
    Example: msnoise plot timing -p ID_KWUI_ID_POSI\n
    Example: msnoise plot timing -p ID_KWUI_ID_POSI -p ID_KWUI_ID_TRWI\n
    Remember to order stations alphabetically !
    """
    if ctx.obj['MSNOISE_custom']:
        from timing import main
    else:
        from ..plots.timing import main
    main(mov_stack, dttname, comp, filterid, pair, all, show, outfile)
Exemple #27
0
def dtt(ctx, sta1, sta2, filterid, day, comp, mov_stack, show, outfile):
    """Plots a graph of dt against t\n
    STA1 and STA2 must be provided with this format: NET.STA !\n
    DAY must be provided in the ISO format: YYYY-MM-DD"""
    if sta1 > sta2:
        click.echo("Stations STA1 and STA2 must be sorted alphabetically.")
        return
    if ctx.obj['MSNOISE_custom']:
        from dtt import main
    else:
        from ..plots.dtt import main
    main(sta1, sta2, filterid, comp, day, mov_stack, show, outfile)
Exemple #28
0
def spectime(ctx, sta1, sta2, filterid, comp, mov_stack, ampli, show, outfile,
             refilter, extra_args):
    """Plots the ccf's spectrum vs time between sta1 and sta2\n
    STA1 and STA2 must be provided with this format: NET.STA !"""

    if sta1 > sta2:
        click.echo("Stations STA1 and STA2 must be sorted alphabetically.")
        return
    if ctx.obj['MSNOISE_custom']:
        from spectime import main
    else:
        from ..plots.spectime import main
    main(sta1, sta2, filterid, comp, mov_stack, ampli, show, outfile, refilter,
         **extra_args)
Exemple #29
0
def interferogram(ctx, sta1, sta2, filterid, comp, mov_stack, show, outfile,
                  refilter, extra_args):
    """Plots the interferogram between sta1 and sta2 (parses the CCFs)\n
    STA1 and STA2 must be provided with this format: NET.STA !"""

    if sta1 > sta2:
        click.echo("Stations STA1 and STA2 must be sorted alphabetically.")
        return
    if ctx.obj['MSNOISE_custom']:
        from interferogram import main
    else:
        from ..plots.interferogram import main
    main(sta1, sta2, filterid, comp, mov_stack, show, outfile, refilter,
         **extra_args)
Exemple #30
0
def config(set, sync):
    """This command should now only be used to use the command line to set
    a parameter value in the data base. It used to launch the Configurator but
    the recommended way to configure MSNoise is to use the "msnoise admin" web
    interface."""
    if set:
        from ..default import default
        if not set.count("="):
            click.echo("!! format of the set command is name=value !!")
            return
        name, value = set.split("=")
        if name not in default:
            click.echo("!! unknown parameter %s !!" % name)
            return
        from ..api import connect, update_config
        db = connect()
        update_config(db, name, value)
        db.commit()
        db.close()
        click.echo("Successfully updated parameter %s = %s" % (name, value))
    elif sync:
        import glob
        from ..api import connect, get_config, get_stations, update_station,\
            preload_instrument_responses

        db = connect()
        responses = preload_instrument_responses(db)
        netsta = []
        for id, row in responses.iterrows():
            net, sta, loc, chan = row["channel_id"].split(".")
            netsta.append("%s.%s"%(net,sta))
        responses["netsta"] = netsta

        for station in get_stations(db):
            id = "%s.%s" % (station.net, station.sta)
            coords = responses[responses["netsta"] == id]
            lon = float(coords["longitude"].values[0])
            lat = float(coords["latitude"].values[0])
            update_station(db, station.net, station.sta, lon, lat, 0, "DEG", )
            logging.info("Added coordinates (%.5f %.5f) for station %s.%s" %
                        (lon, lat, station.net, station.sta))
        db.close()

    else:
        from ..s001configurator import main
        click.echo('Let\'s Configure MSNoise !')
        main()
Exemple #31
0
def scan_archive(ctx, init, path):
    """Scan the archive and insert into the Data Availability table."""
    if path:
        logging.info("Overriding workflow...")
        from obspy import UTCDateTime
        from ..s01scan_archive import worker
        db = connect()
        startdate = UTCDateTime(get_config(db, "startdate"))
        enddate = UTCDateTime(get_config(db, "enddate"))
        cc_sampling_rate = float(get_config(db, "cc_sampling_rate"))
        db.close()

        worker(sorted(os.listdir(path)), path, startdate, enddate,
               cc_sampling_rate, init=True)
    else:
        from ..s01scan_archive import main
        main(init, threads=ctx.obj['MSNOISE_threads'])
Exemple #32
0
def new_jobs(init, nocc, hpc=""):
    """Determines if new CC jobs are to be defined"""
    if not hpc:
        from ..s02new_jobs import main
        main(init, nocc)
    if hpc:
        from ..api import connect, read_db_inifile
        dbini = read_db_inifile()
        prefix = (dbini.prefix + '_') if dbini.prefix != '' else ''
        left, right = hpc.split(':')
        db = connect()
        db.execute("INSERT INTO {prefix}jobs (pair, day, jobtype, flag) "
                   "SELECT pair, day, '{right_type}', 'T' FROM {prefix}jobs "
                   "WHERE jobtype='{left_type}' AND flag='D';"
                   .format(prefix=prefix, right_type=right, left_type=left))
        db.commit()
        db.close()
Exemple #33
0
def compute_cc_rot(ctx):
    """Computes the CC jobs (based on the "New Jobs" identified)"""
    from ..s03compute_cc import main
    threads = ctx.obj['MSNOISE_threads']
    delay = ctx.obj['MSNOISE_threadsdelay']
    loglevel = ctx.obj['MSNOISE_verbosity']
    if threads == 1:
        main(loglevel=loglevel)
    else:
        from multiprocessing import Process
        processes = []
        for i in range(threads):
            p = Process(target=main, kwargs={"loglevel": loglevel})
            p.start()
            processes.append(p)
            time.sleep(delay)
        for p in processes:
            p.join()
Exemple #34
0
def compute_mwcs(ctx):
    """Computes the MWCS jobs"""
    from ..s05compute_mwcs import main
    threads = ctx.obj['MSNOISE_threads']
    delay = ctx.obj['MSNOISE_threadsdelay']
    loglevel = ctx.obj['MSNOISE_verbosity']
    if threads == 1:
        main(loglevel=loglevel)
    else:
        from multiprocessing import Process
        processes = []
        for i in range(threads):
            p = Process(target=main, kwargs={"loglevel": loglevel})
            p.start()
            processes.append(p)
            time.sleep(delay)
        for p in processes:
            p.join()
Exemple #35
0
def compute_dtt(ctx, interval):
    """Computes the dt/t jobs based on the new MWCS data"""
    from ..s06compute_dtt import main
    threads = ctx.obj['MSNOISE_threads']
    delay = ctx.obj['MSNOISE_threadsdelay']
    loglevel = ctx.obj['MSNOISE_verbosity']
    if threads == 1:
        main(loglevel=loglevel)
    else:
        from multiprocessing import Process
        processes = []
        for i in range(threads):
            p = Process(target=main, kwargs={"loglevel": loglevel})
            p.start()
            processes.append(p)
            time.sleep(delay)
        for p in processes:
            p.join()
Exemple #36
0
def compute_stretching(ctx):
    """[experimental] Computes the stretching based on the new stacked data"""
    from ..stretch import main
    threads = ctx.obj['MSNOISE_threads']
    delay = ctx.obj['MSNOISE_threadsdelay']
    loglevel = ctx.obj['MSNOISE_verbosity']
    if threads == 1:
        main()
    else:
        from multiprocessing import Process
        processes = []
        for i in range(threads):
            p = Process(target=main)
            p.start()
            processes.append(p)
            time.sleep(delay)
        for p in processes:
            p.join()
Exemple #37
0
def compute_psd(ctx, njobs_per_worker):
    """Computes the CC jobs (based on the "New Jobs" identified)"""
    from ..ppsd_compute import main
    threads = ctx.obj['MSNOISE_threads']
    delay = ctx.obj['MSNOISE_threadsdelay']
    loglevel = ctx.obj['MSNOISE_verbosity']
    print(loglevel)
    if threads == 1:
        main(loglevel=loglevel, njobs_per_worker=njobs_per_worker)
    else:
        from multiprocessing import Process
        processes = []
        kwargs = {"loglevel": loglevel, "njobs_per_worker": njobs_per_worker}
        for i in range(threads):
            p = Process(target=main, kwargs=kwargs)
            p.start()
            processes.append(p)
            time.sleep(delay)
        for p in processes:
            p.join()
Exemple #38
0
def config(set):
    """This command launches the Configurator or... TODO"""
    if set:
        from ..default import default
        if not set.count("="):
            click.echo("!! format of the set command is name=value !!")
            return
        name, value = set.split("=")
        if not name in default:
            click.echo("!! unknown parameter %s !!"%name)
            return
        from ..api import connect, update_config
        db = connect()
        update_config(db, name, value)
        db.commit()
        db.close()
        click.echo("Successfully updated parameter %s = %s"%(name,value))
    else:
        from ..s001configurator import main
        click.echo('Let\'s Configure MSNoise !')
        main()
Exemple #39
0
def populate(fromda):
    """Rapidly scan the archive filenames and find Network/Stations"""
    if fromda:
        logging.info("Overriding workflow...")
        from ..msnoise_table_def import DataAvailability
        from ..api import update_station
        db = connect()
        stations = db.query(DataAvailability.net, DataAvailability.sta). \
            group_by(DataAvailability.net, DataAvailability.sta)

        for net, sta in stations:
            print('Adding:', net, sta)
            X = 0.0
            Y = 0.0
            altitude = 0.0
            coordinates = 'UTM'
            instrument = 'N/A'
            update_station(db, net, sta, X, Y, altitude,
                           coordinates=coordinates, instrument=instrument)
    else:
        from ..s002populate_station_table import main
        main()
Exemple #40
0
def stack(ref, mov, step, interval):
    """Stacks the [REF] and/or [MOV] windows"""
    click.secho('Lets STACK !', fg='green')
    from ..s04stack import main
    if ref:
        main('ref', interval)
    if mov:
        main('mov', interval)
    if step:
        main('step', interval)
Exemple #41
0
def stack(ref, mov, step, interval):
    """Stacks the [REF] and/or [MOV] windows"""
    click.secho('Lets STACK !', fg='green')
    from ..s04stack import main
    if ref:
        main('ref', interval)
    if mov:
        main('mov', interval)
    if step:
        main('step', interval)
Exemple #42
0
def compute_mwcs(ctx,sc,ac,comps):
    """Computes the MWCS based on the new stacked data"""
    if sc:
        from ..s052compute_mwcsSC import main
    elif ac:
        from ..s053compute_mwcsAC import main
    else:
        from ..s05compute_mwcs import main
    from multiprocessing import Process
    threads = ctx.obj['MSNOISE_threads']
    processes = []
    for i in range(threads):
        p = Process(target=main(comps))
        p.start()
        processes.append(p)
        time.sleep(1)
    for p in processes:
        p.join()
Exemple #43
0
def compute_mwcs(ctx, sc, ac, comps):
    """Computes the MWCS based on the new stacked data"""
    if sc:
        from ..s052compute_mwcsSC import main
    elif ac:
        from ..s053compute_mwcsAC import main
    else:
        from ..s05compute_mwcs import main
    from multiprocessing import Process
    threads = ctx.obj['MSNOISE_threads']
    processes = []
    for i in range(threads):
        p = Process(target=main(comps))
        p.start()
        processes.append(p)
        time.sleep(1)
    for p in processes:
        p.join()
Exemple #44
0
def stack(ctx, ref, mov, step):
    """Stacks the [REF] or [MOV] windows.
    Computes the STACK jobs.
    """
    click.secho('Lets STACK !', fg='green')
    from ..s04stack import main
    threads = ctx.obj['MSNOISE_threads']
    delay = ctx.obj['MSNOISE_threadsdelay']
    loglevel = ctx.obj['MSNOISE_verbosity']

    if ref and mov:
        click.secho("With MSNoise 1.6, you can't run REF & MOV stacks"
                    "simultaneously, please run them one after the other.")
        sys.exit()

    if threads == 1:
        if ref:
            main('ref', loglevel=loglevel)
        if mov:
            main('mov', loglevel=loglevel)
        if step:
            main('step', loglevel=loglevel)
    else:
        from multiprocessing import Process
        processes = []
        if ref:
            for i in range(threads):
                p = Process(target=main, args=["ref",],
                            kwargs={"loglevel": loglevel})
                p.start()
                processes.append(p)
                time.sleep(delay)
        for p in processes:
            p.join()
        if mov:
            for i in range(threads):
                p = Process(target=main, args=["mov",],
                            kwargs={"loglevel": loglevel})
                p.start()
                processes.append(p)
                time.sleep(delay)
        for p in processes:
            p.join()
        if step:
            for i in range(threads):
                p = Process(target=main, args=["step",],
                            kwargs={"loglevel": loglevel})
                p.start()
                processes.append(p)
                time.sleep(delay)
        for p in processes:
            p.join()
Exemple #45
0
def stack(ref, mov, step, interval,sc,ac):
    """Stacks the [REF] and/or [MOV] windows"""
    click.secho('Lets STACK !', fg='green')
    if sc:
        from ..s042stackSC import main
    elif ac:
        from ..s043stackAC import main
    else:
        from ..s04stack import main
#    from ..s04stack import main
    if ref:
        main('ref', interval)
    if mov:
        main('mov', interval)
    if step:
        main('step', interval)
Exemple #46
0
def config(set, sync):
    """This command should now only be used to use the command line to set
    a parameter value in the data base. It used to launch the Configurator but
    the recommended way to configure MSNoise is to use the "msnoise admin" web
    interface."""
    if set:
        from ..default import default
        if not set.count("="):
            click.echo("!! format of the set command is name=value !!")
            return
        name, value = set.split("=")
        if not name in default:
            click.echo("!! unknown parameter %s !!" % name)
            return
        from ..api import connect, update_config
        db = connect()
        update_config(db, name, value)
        db.commit()
        db.close()
        click.echo("Successfully updated parameter %s = %s" % (name, value))
    elif sync:
        import glob
        from ..api import connect, get_config, get_stations, update_station
        db = connect()
        response_format = get_config(db, 'response_format')
        response_files = glob.glob(os.path.join(get_config(db, 'response_path'), "*"))
        if response_format == "inventory":
            from obspy import read_inventory
            firstinv = True
            metadata = None
            for file in response_files:
                try:
                    inv = read_inventory(file)
                    if firstinv:
                        metadata = inv
                        firstinv = False
                    else:
                        metadata += inv
                except:
                    pass
        elif response_format == "dataless":
            from obspy.io.xseed import Parser
            all_metadata = {}
            for file in response_files:
                metadata = Parser(file)
                tmpinv = metadata.get_inventory()
                for chan in tmpinv["channels"]:
                    all_metadata[chan["channel_id"]] = metadata
        else:
            print("Response Format Not Supported")
            exit()
        for station in get_stations(db):
            id = "%s.%s.00.HHZ" % (station.net, station.sta)
            if response_format == "inventory":
                coords = inv.get_coordinates(id)
            else:

                coords = all_metadata[id].get_coordinates(id)
            update_station(db, station.net, station.sta, coords["longitude"],
                           coords["latitude"], coords["elevation"], "DEG", )
            logging.info("Added coordinates (%.5f %.5f) for station %s.%s" %
                        (coords["longitude"], coords["latitude"],
                         station.net, station.sta))
        db.close()

    else:
        from ..s001configurator import main
        click.echo('Let\'s Configure MSNoise !')
        main()
Exemple #47
0
def bugreport(ctx, sys, modules, env, all):
    """This command launches the Bug Report script."""
    click.echo('Let\'s Bug Report MSNoise !')
    #click.echo('Working on %i threads' % ctx.obj['MSNOISE_threads'])
    from ..bugreport import main
    main(sys, modules, env, all)
Exemple #48
0
def install():
    """This command launches the installer."""
    click.echo('Launching the installer')
    from ..s000installer import main
    main()
Exemple #49
0
def test():
    """Runs the test suite, should be executed in an empty folder!"""
    import matplotlib.pyplot as plt
    plt.switch_backend("agg")
    from ..test.tests import main
    main()
Exemple #50
0
def scan_archive(ctx, init):
    """Scan the archive and insert into the Data Availability table."""
    from ..s01scan_archive import main
    main(init, threads=ctx.obj['MSNOISE_threads'])
Exemple #51
0
def populate():
    """Rapidly scan the archive filenames and find Network/Stations"""
    from ..s002populate_station_table import main
    main()
Exemple #52
0
def new_jobs(init):
    """Determines if new CC jobs are to be defined"""
    from ..s02new_jobs import main
    main(init)
Exemple #53
0
def compute_stretching():
    """[experimental] Computes the stretching based on the new stacked data"""
    from ..stretch import main
    main()
Exemple #54
0
def compute_dtt(interval):
    """Computes the dt/t jobs based on the new MWCS data"""
    from ..s06compute_dtt import main
    main(interval)
Exemple #55
0
def test():
    """Runs the test suite, should be executed in an empty folder!"""
    from ..test.tests import main
    main()
Exemple #56
0
def admin(port):
    from ..msnoise_admin import main
    main(port)