# Path: apasvo/_version.py

# 
# Path: apasvo/utils/clt.py
# def float_secs_2_string_date(x, starttime=datetime.datetime.utcfromtimestamp(0)):
# def print_msg(msg):
# def query_yes_no_all_quit(question, default="yes"):
# def query_custom_answers(question, answers, default=None):
#     def __init__(self, name, data, align=ALIGN.RIGHT, fmt='%.6g'):
#     def __init__(self, *columns):
#     def get_row(self, i=None):
#     def get_line(self):
#     def join_n_wrap(self, char, elements):
#     def get_rows(self):
#     def __str__(self):
#     def __init__(self, minValue=0, maxValue=100, totalWidth=12):
#     def updateAmount(self, newAmount=0):
#     def __str__(self):
# class ALIGN:
# class Column():
# class Table:
# class ProgressBar:
#     LEFT, RIGHT = '-', ''
# 
# Path: apasvo/utils/parse.py
# def filein(arg):
# def positive_float(arg):
# def positive_int(arg):
# def non_negative_int(arg):
# def percentile(arg):
# def fraction(arg):
#     def __call__(self, parser, namespace, values, option_string=None):
#     def _fopen(self, fname):
#     def __init__(self, *args, **kwargs):
#     def convert_arg_line_to_args(self, line):
# class GlobInputFilenames(argparse.Action):
# class CustomArgumentParser(argparse.ArgumentParser):
# 
# Path: apasvo/utils/futils.py
# def istextfile(filename, blocksize=512):
# def is_little_endian():
# def read_in_chunks(file_object, chunk_size=1024):
# def read_txt_in_chunks(file_object, n=1024, comments='#'):
# def getSize(f):
# def get_delimiter(fileobject, lines=16):
# def get_sample_rate(filename, max_header_lines=64, comments='#'):
# def copytree(src, dst, symlinks=False, ignore=None):
# 
# Path: apasvo/utils/formats/rawfile.py
# class RawFile(object):
# class BinFile(RawFile):
# class TextFile(RawFile):
#     def __init__(self):
#     def read(self):
#     def read_in_blocks(self, block_size):
#     def write(self, array):
#     def __init__(self, filename, dtype='float64', byteorder='native'):
#     def read(self, **kwargs):
#     def read_in_blocks(self, block_size=1024):
#     def write(self, array, **kwargs):
#     def __init__(self, filename, dtype='float64', byteorder='native'):
#     def read(self, **kwargs):
#     def read_in_blocks(self, block_size=1024):
#     def write(self, array, **kwargs):
# def get_file_handler(filename, fmt='', dtype='float64', byteorder='native', **kwargs):
# 
# Path: apasvo/picking/eqgenerator.py
# def gutenberg_richter(b=1.0, size=1, m_min=2.0, m_max=None):
# def generate_artificial_earthquake(tmax, t0, fs, P_signal_db, P_noise_db,
#                                    bfirls=None, low_period=50., high_period=10.,
#                                    bandwidth=4., overlap=1., f_low=2.,
#                                    f_high=18., low_amp=.2, high_amp=.1):
# def generate_seismic_earthquake(tmax, t0, fs, P_signal_db, low_period,
#                                    high_period, bandwidth, overlap,
#                                    f_low, f_high, low_amp, high_amp):
# def generate_seismic_noise(tmax, fs, P_noise_db, bfirls=None):
#     def __init__(self, bfirls=None, fs=50.0, P_noise_db=0.0,
#                  low_period=50.0, high_period=10.0, bandwidth=4.0,
#                  overlap=1.0, f_low=2.0, f_high=18.0,
#                  low_amp=0.2, high_amp=0.1, **kwargs):
#     def load_noise_coefficients(self, fileobj, dtype='float64',
#                                 byteorder='native'):
#     def generate_events(self, t_average, t_max, b=1.0,
#                                m_min=2.0, m_max=7.0):
#     def generate_nevents(self, t_average, event_n, b=1.0,
#                                m_min=2.0, m_max=7.0):
#     def generate_earthquake(self, t_max, t0, p_eq):
#     def generate_noise(self, eq):
#     L = int(tmax * fs) + 1
#     L = int(tmax * fs) + 1
# class EarthquakeGenerator(object):


import argparse
import os
import sys
from apasvo._version import __version__
from apasvo.utils import clt, parse, futils
from apasvo.utils.formats import rawfile
from apasvo.picking import eqgenerator
    # Configure generator
    clt.print_msg("Configuring generator... ")
    generator = eqgenerator.EarthquakeGenerator(**kwargs)
    clt.print_msg("Done\n")
    # Load noise coefficients
    if gen_noise_coefficients:
        if futils.istextfile(gen_noise_coefficients):
            f = open(gen_noise_coefficients, 'r')
        else:
            f = open(gen_noise_coefficients, 'rb')
        clt.print_msg("Loading noise coefficients from %s... " %
                         f.name)
        generator.load_noise_coefficients(f, dtype=datatype,
                                          byteorder=byteorder)
        clt.print_msg("Done\n")
    # Process input files
    basename, ext = os.path.splitext(output)
    filename_out = output
    # If a list of input files containing seismic data
    # is provided, generate a new output signal for each one of
    # the files by adding background noise.
    if FILEIN:
        fileno = 0
        for f in FILEIN:
            # Read input signal
            fin_handler = rawfile.get_file_handler(f, dtype=datatype,
                                                   byteorder=byteorder)
            clt.print_msg("Loading seismic signal from %s... " %
                          fin_handler.filename)
            signal = fin_handler.read()

# Path: apasvo/_version.py

# 
# Path: apasvo/utils/clt.py
# def float_secs_2_string_date(x, starttime=datetime.datetime.utcfromtimestamp(0)):
# def print_msg(msg):
# def query_yes_no_all_quit(question, default="yes"):
# def query_custom_answers(question, answers, default=None):
#     def __init__(self, name, data, align=ALIGN.RIGHT, fmt='%.6g'):
#     def __init__(self, *columns):
#     def get_row(self, i=None):
#     def get_line(self):
#     def join_n_wrap(self, char, elements):
#     def get_rows(self):
#     def __str__(self):
#     def __init__(self, minValue=0, maxValue=100, totalWidth=12):
#     def updateAmount(self, newAmount=0):
#     def __str__(self):
# class ALIGN:
# class Column():
# class Table:
# class ProgressBar:
#     LEFT, RIGHT = '-', ''
# 
# Path: apasvo/utils/parse.py
# def filein(arg):
# def positive_float(arg):
# def positive_int(arg):
# def non_negative_int(arg):
# def percentile(arg):
# def fraction(arg):
#     def __call__(self, parser, namespace, values, option_string=None):
#     def _fopen(self, fname):
#     def __init__(self, *args, **kwargs):
#     def convert_arg_line_to_args(self, line):
# class GlobInputFilenames(argparse.Action):
# class CustomArgumentParser(argparse.ArgumentParser):
# 
# Path: apasvo/utils/futils.py
# def istextfile(filename, blocksize=512):
# def is_little_endian():
# def read_in_chunks(file_object, chunk_size=1024):
# def read_txt_in_chunks(file_object, n=1024, comments='#'):
# def getSize(f):
# def get_delimiter(fileobject, lines=16):
# def get_sample_rate(filename, max_header_lines=64, comments='#'):
# def copytree(src, dst, symlinks=False, ignore=None):
# 
# Path: apasvo/utils/formats/rawfile.py
# class RawFile(object):
# class BinFile(RawFile):
# class TextFile(RawFile):
#     def __init__(self):
#     def read(self):
#     def read_in_blocks(self, block_size):
#     def write(self, array):
#     def __init__(self, filename, dtype='float64', byteorder='native'):
#     def read(self, **kwargs):
#     def read_in_blocks(self, block_size=1024):
#     def write(self, array, **kwargs):
#     def __init__(self, filename, dtype='float64', byteorder='native'):
#     def read(self, **kwargs):
#     def read_in_blocks(self, block_size=1024):
#     def write(self, array, **kwargs):
# def get_file_handler(filename, fmt='', dtype='float64', byteorder='native', **kwargs):
# 
# Path: apasvo/picking/eqgenerator.py
# def gutenberg_richter(b=1.0, size=1, m_min=2.0, m_max=None):
# def generate_artificial_earthquake(tmax, t0, fs, P_signal_db, P_noise_db,
#                                    bfirls=None, low_period=50., high_period=10.,
#                                    bandwidth=4., overlap=1., f_low=2.,
#                                    f_high=18., low_amp=.2, high_amp=.1):
# def generate_seismic_earthquake(tmax, t0, fs, P_signal_db, low_period,
#                                    high_period, bandwidth, overlap,
#                                    f_low, f_high, low_amp, high_amp):
# def generate_seismic_noise(tmax, fs, P_noise_db, bfirls=None):
#     def __init__(self, bfirls=None, fs=50.0, P_noise_db=0.0,
#                  low_period=50.0, high_period=10.0, bandwidth=4.0,
#                  overlap=1.0, f_low=2.0, f_high=18.0,
#                  low_amp=0.2, high_amp=0.1, **kwargs):
#     def load_noise_coefficients(self, fileobj, dtype='float64',
#                                 byteorder='native'):
#     def generate_events(self, t_average, t_max, b=1.0,
#                                m_min=2.0, m_max=7.0):
#     def generate_nevents(self, t_average, event_n, b=1.0,
#                                m_min=2.0, m_max=7.0):
#     def generate_earthquake(self, t_max, t0, p_eq):
#     def generate_noise(self, eq):
#     L = int(tmax * fs) + 1
#     L = int(tmax * fs) + 1
# class EarthquakeGenerator(object):


# Path: bin/apasvo-generator.py
import argparse
import os
import sys
from apasvo._version import __version__
from apasvo.utils import clt, parse, futils
from apasvo.utils.formats import rawfile
from apasvo.picking import eqgenerator

    # Configure generator
    clt.print_msg("Configuring generator... ")
    generator = eqgenerator.EarthquakeGenerator(**kwargs)
    clt.print_msg("Done\n")
    # Load noise coefficients
    if gen_noise_coefficients:
        if futils.istextfile(gen_noise_coefficients):
            f = open(gen_noise_coefficients, 'r')
        else:
            f = open(gen_noise_coefficients, 'rb')
        clt.print_msg("Loading noise coefficients from %s... " %
                         f.name)
        generator.load_noise_coefficients(f, dtype=datatype,
                                          byteorder=byteorder)
        clt.print_msg("Done\n")
    # Process input files
    basename, ext = os.path.splitext(output)
    filename_out = output
    # If a list of input files containing seismic data
    # is provided, generate a new output signal for each one of
    # the files by adding background noise.
    if FILEIN:
        fileno = 0
        for f in FILEIN:
            # Read input signal
            fin_handler = rawfile.get_file_handler(f, dtype=datatype,
                                                   byteorder=byteorder)
            clt.print_msg("Loading seismic signal from %s... " %
                          fin_handler.filename)
            signal = fin_handler.read()

            clt.print_msg("Done\n")