#!/usr/bin/env python # stdlib imports import sys import os.path import argparse import logging from gmprocess.subcommands.lazy_loader import LazyLoader # local imports log = LazyLoader("log", globals(), "gmprocess.utils.logging") argmod = LazyLoader("argmod", globals(), "gmprocess.utils.args") streamcollection = LazyLoader( "streamcollection", globals(), "gmprocess.core.streamcollection" ) readmod = LazyLoader("readmod", globals(), "gmprocess.io.read") read_directory = LazyLoader("read_directory", globals(), "gmprocess.io.read_directory") class CustomFormatter( argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter ): pass FORMATS = [ "AH", "GSE2", "MSEED", "PICKLE",
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import logging import shutil from glob import glob from gmprocess.subcommands.lazy_loader import LazyLoader base = LazyLoader("base", globals(), "gmprocess.subcommands.base") class CleanModule(base.SubcommandModule): """Clean (i.e., remove) project data.""" command_name = "clean" arguments = [ { "short_flag": "-a", "long_flag": "--all", "help": "Remove all project files except raw data.", "default": False, "action": "store_true", }, { "long_flag": "--raw", "help": "Remove all raw directories.", "default": False, "action": "store_true",
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import logging from gmprocess.subcommands.lazy_loader import LazyLoader np = LazyLoader("np", globals(), "numpy") spint = LazyLoader("spint", globals(), "scipy.interpolate") gmt = LazyLoader("gmt", globals(), "mapio.gmt") ob = LazyLoader("ob", globals(), "obspy.geodetics.base") oqgeo = LazyLoader("oqgeo", globals(), "openquake.hazardlib.geo.geodetic") rupt = LazyLoader("rupt", globals(), "impactutils.rupture") ps2ff = LazyLoader("ps2ff", globals(), "ps2ff") arg_dicts = LazyLoader("arg_dicts", globals(), "gmprocess.subcommands.arg_dicts") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") utils = LazyLoader("utils", globals(), "gmprocess.utils") rupt_utils = LazyLoader("rupt_utils", globals(), "gmprocess.utils.rupture_utils") ws = LazyLoader("ws", globals(), "gmprocess.io.asdf.stream_workspace") station_summary = LazyLoader("station_summary", globals(), "gmprocess.metrics.station_summary") confmod = LazyLoader("confmod", globals(), "gmprocess.utils.config") M_PER_KM = 1000 class ComputeStationMetricsModule(base.SubcommandModule):
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import logging from gmprocess.subcommands.lazy_loader import LazyLoader arg_dicts = LazyLoader("arg_dicts", globals(), "gmprocess.subcommands.arg_dicts") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") ws = LazyLoader("ws", globals(), "gmprocess.io.asdf.stream_workspace") const = LazyLoader("const", globals(), "gmprocess.utils.constants") sm_utils = LazyLoader("sm_utils", globals(), "gmprocess.utils.export_shakemap_utils") confmod = LazyLoader("confmod", globals(), "gmprocess.utils.config") class ExportShakeMapModule(base.SubcommandModule): """Export files for ShakeMap input.""" command_name = "export_shakemap" aliases = ("shakemap",) arguments = [ arg_dicts.ARG_DICTS["eventid"], arg_dicts.ARG_DICTS["textfile"], arg_dicts.ARG_DICTS["label"], { "short_flag": "-x", "long_flag": "--expand-imts", "help": ( "Use expanded IMTs. Currently this only means all the "
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import logging from gmprocess.subcommands.lazy_loader import LazyLoader distributed = LazyLoader("distributed", globals(), "dask.distributed") arg_dicts = LazyLoader("arg_dicts", globals(), "gmprocess.subcommands.arg_dicts") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") const = LazyLoader("const", globals(), "gmprocess.utils.constants") ws = LazyLoader("ws", globals(), "gmprocess.io.asdf.stream_workspace") processing = LazyLoader("processing", globals(), "gmprocess.waveform_processing.processing") confmod = LazyLoader("confmod", globals(), "gmprocess.utils.config") class ProcessWaveformsModule(base.SubcommandModule): """Process waveform data.""" command_name = "process_waveforms" aliases = ("process", ) # Note: do not use the ARG_DICT entry for label because the explanation is # different here. arguments = [ arg_dicts.ARG_DICTS["eventid"], arg_dicts.ARG_DICTS["textfile"],
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import logging from gmprocess.subcommands.lazy_loader import LazyLoader distributed = LazyLoader("distributed", globals(), "dask.distributed") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") arg_dicts = LazyLoader("arg_dicts", globals(), "gmprocess.subcommands.arg_dicts") ws = LazyLoader("ws", globals(), "gmprocess.io.asdf.stream_workspace") report = LazyLoader("report", globals(), "gmprocess.io.report") plot = LazyLoader("plot", globals(), "gmprocess.utils.plot") const = LazyLoader("const", globals(), "gmprocess.utils.constants") class GenerateReportModule(base.SubcommandModule): """Generate summary report (latex required).""" command_name = "generate_report" aliases = ("report",) arguments = [ arg_dicts.ARG_DICTS["eventid"], arg_dicts.ARG_DICTS["textfile"], arg_dicts.ARG_DICTS["label"], arg_dicts.ARG_DICTS["num_processes"], ]
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import logging from gmprocess.subcommands.lazy_loader import LazyLoader configobj = LazyLoader("configobj", globals(), "configobj") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") const = LazyLoader("const", globals(), "gmprocess.utils.constants") projects = LazyLoader("projects", globals(), "gmprocess.subcommands.projects") class InitModule(base.SubcommandModule): """ Initialize the current directory as a gmprocess project directory. """ command_name = "init" arguments = [] def main(self, gmrecords): """ Initialize the current directory as a gmprocess project directory. Args: gmrecords:
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import logging from gmprocess.subcommands.lazy_loader import LazyLoader distributed = LazyLoader("distributed", globals(), "dask.distributed") arg_dicts = LazyLoader("arg_dicts", globals(), "gmprocess.subcommands.arg_dicts") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") constants = LazyLoader("constants", globals(), "gmprocess.utils.constants") assemble_utils = LazyLoader( "assemble_utils", globals(), "gmprocess.utils.assemble_utils" ) class AssembleModule(base.SubcommandModule): """Assemble raw data and organize it into an ASDF file.""" command_name = "assemble" arguments = [ arg_dicts.ARG_DICTS["eventid"], arg_dicts.ARG_DICTS["textfile"], arg_dicts.ARG_DICTS["overwrite"], arg_dicts.ARG_DICTS["num_processes"], ]
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys from abc import ABC, abstractmethod import logging from gmprocess.subcommands.lazy_loader import LazyLoader base_utils = LazyLoader("base_utils", globals(), "gmprocess.utils.base_utils") confmod = LazyLoader("confmod", globals(), "gmprocess.utils.config") class SubcommandModule(ABC): """gmprocess base module.""" @property @abstractmethod def command_name(self): """ Name of subcommand: string, all lowercase. """ raise NotImplementedError """Tuple class variable of subcommand aliases. """ aliases = () def __init__(self): """Dictionary instance variable to track files created by module.""" self.files_created = {}
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import logging from gmprocess.subcommands.lazy_loader import LazyLoader arg_dicts = LazyLoader("arg_dicts", globals(), "gmprocess.subcommands.arg_dicts") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") distributed = LazyLoader("distributed", globals(), "dask.distributed") ws = LazyLoader("ws", globals(), "gmprocess.io.asdf.stream_workspace") station_summary = LazyLoader( "station_summary", globals(), "gmprocess.metrics.station_summary" ) const = LazyLoader("const", globals(), "gmprocess.utils.constants") class ComputeWaveformMetricsModule(base.SubcommandModule): """Compute waveform metrics.""" command_name = "compute_waveform_metrics" aliases = ("wm",) arguments = [ arg_dicts.ARG_DICTS["eventid"], arg_dicts.ARG_DICTS["textfile"], arg_dicts.ARG_DICTS["label"], arg_dicts.ARG_DICTS["overwrite"], arg_dicts.ARG_DICTS["num_processes"], ]
#!/usr/bin/env python # stdlib imports import os.path import argparse from collections import OrderedDict import sys import warnings import textwrap import logging from gmprocess.subcommands.lazy_loader import LazyLoader # third party imports pd = LazyLoader("pd", globals(), "pandas") # local imports readmod = LazyLoader("readmod", globals(), "gmprocess.io.read") argmod = LazyLoader("argmod", globals(), "gmprocess.utils.args") stationtrace = LazyLoader("stationtrace", globals(), "gmprocess.core.stationtrace") confmod = LazyLoader("confmod", globals(), "gmprocess.utils.config") COLUMNS = [ "Filename", "Format", "Process Level", "Start Time", "End Time", "Duration (s)", "Network",
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import platform import re import logging import shutil from gmprocess.subcommands.lazy_loader import LazyLoader distributed = LazyLoader("distributed", globals(), "dask.distributed") ryaml = LazyLoader("yaml", globals(), "ruamel.yaml") pkg_resources = LazyLoader("pkg_resources", globals(), "pkg_resources") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") constants = LazyLoader("constants", globals(), "gmprocess.utils.constants") prompt = LazyLoader("prompt", globals(), "gmprocess.utils.prompt") # Regular expression for checking valid email re_email = r"^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$" class ProjectsModule(base.SubcommandModule): """ Manage gmrecords projects. """ command_name = "projects" aliases = ("proj", )
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import shutil from distutils.dir_util import copy_tree import logging import zipfile import tarfile from gmprocess.subcommands.lazy_loader import LazyLoader arg_dicts = LazyLoader("arg_dicts", globals(), "gmprocess.subcommands.arg_dicts") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") class ImportModule(base.SubcommandModule): """Import data for an event into the project data directory.""" command_name = "import" arguments = [ arg_dicts.ARG_DICTS["eventid"], { "short_flag": "-p", "long_flag": "--path", "help": ("Path to file or directory containing data to import."), "type": str, "default": None, }, ]
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import copy import importlib import pkgutil import inspect import argparse import logging from gmprocess.subcommands.lazy_loader import LazyLoader configobj = LazyLoader("configobj", globals(), "configobj") setuptools_scm = LazyLoader("setuptools_scm", globals(), "setuptools_scm") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") config = LazyLoader("config", globals(), "gmprocess.utils.config") const = LazyLoader("const", globals(), "gmprocess.utils.constants") log_utils = LazyLoader("log_utils", globals(), "gmprocess.utils.logging") projmod = LazyLoader("projmod", globals(), "gmprocess.subcommands.projects") init = LazyLoader("init", globals(), "gmprocess.subcommands.init") VERSION = setuptools_scm.get_version(root=os.path.join(os.pardir, os.pardir), relative_to=__file__) class GMrecordsApp(object): """Main driver app for gmrpocess command-line interface.
#!/usr/bin/env python # -*- coding: utf-8 -*- import logging from gmprocess.subcommands.lazy_loader import LazyLoader arg_dicts = LazyLoader("arg_dicts", globals(), "gmprocess.subcommands.arg_dicts") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") download = LazyLoader("download", globals(), "gmprocess.subcommands.download") import_data = LazyLoader("import_data", globals(), "gmprocess.subcommands.import_data") assemble = LazyLoader("assemble", globals(), "gmprocess.subcommands.assemble") process_waveforms = LazyLoader("process_waveforms", globals(), "gmprocess.subcommands.process_waveforms") compute_station_metrics = LazyLoader( "compute_station_metrics", globals(), "gmprocess.subcommands.compute_station_metrics", ) compute_waveform_metrics = LazyLoader( "compute_waveform_metrics", globals(), "gmprocess.subcommands.compute_waveform_metrics", ) export_metric_tables = LazyLoader( "export_metric_tables", globals(), "gmprocess.subcommands.export_metric_tables") export_shakemap = LazyLoader("export_shakemap", globals(), "gmprocess.subcommands.export_shakemap")
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import logging from gmprocess.subcommands.lazy_loader import LazyLoader arg_dicts = LazyLoader("arg_dicts", globals(), "gmprocess.subcommands.arg_dicts") base = LazyLoader("base", globals(), "gmprocess.subcommands.base") ws = LazyLoader("ws", globals(), "gmprocess.io.asdf.stream_workspace") const = LazyLoader("const", globals(), "gmprocess.utils.constants") tables = LazyLoader("tables", globals(), "gmprocess.utils.tables") class ExportMetricTablesModule(base.SubcommandModule): """Export metric tables.""" command_name = "export_metric_tables" aliases = ("mtables", ) arguments = [ arg_dicts.ARG_DICTS["eventid"], arg_dicts.ARG_DICTS["textfile"], arg_dicts.ARG_DICTS["label"], arg_dicts.ARG_DICTS["output_format"], arg_dicts.ARG_DICTS["overwrite"], ] def main(self, gmrecords):
#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys from abc import ABC, abstractmethod import logging from gmprocess.subcommands.lazy_loader import LazyLoader base_utils = LazyLoader("base_utils", globals(), "gmprocess.utils.base_utils") class SubcommandModule(ABC): """gmprocess base module.""" @property @abstractmethod def command_name(self): """ Name of subcommand: string, all lowercase. """ raise NotImplementedError """Tuple class variable of subcommand aliases. """ aliases = () def __init__(self): """Dictionary instance variable to track files created by module.""" self.files_created = {}