plot the R/L or Haversine Distance distribution of aftershock sequences of certain mainshoks
-- background events excluded
'''
import matplotlib as mpl
#mpl.use( 'Agg') # uncomment for interactive plotting
import matplotlib.pyplot as plt

import os
import numpy as np
#------------------------------my modules--------------------------------------
import src.data_utils as data_utils
import src.seis_utils as seis_utils
from src.EqCat import *
import src.plot_hist as myplot

eqCat = EqCat()  # original catalog
asCat = EqCat()
#=================================0==============================================
#                            dir, file, params
#================================================================================
dir_in = '%s/data' % (os.path.expanduser('.'))
file_in = 'hs_1981_2018_all.mat'

#file_b  = '%s_b_Mc_D.txt'%(fileIn.split('.')[0])
dPar = {
    'aMc':
    np.array([2.5, 2.6, 3.0, 3.5,
              4.0]),  #np.array([3.0, 4.0]),np.array( [2.0, 2.5, 3.0, 3.5]
    # fractal dimension and b for eq. (1)
    'D': 1.6,  #1.6  TODO: - these values should be constrained independently
    'b': 1.0,
Beispiel #2
0
@author: tgoebel
'''
import matplotlib as mpl
mpl.use('Agg')
import numpy as np

import os
import matplotlib.pyplot as plt

#----------------------my modules--------------------------------------------------------
import src.data_utils as data_utils
#import src.clustering as clustering
from src.EqCat import *

eqCat = EqCat()  # original catalog
eqCatMc = EqCat()  # this catalog will be modified with each Mc iteration

#=================================1==============================================
#                            dir, file, params
#================================================================================
data_dir = 'data'
plot_dir = 'plots'
file_in = 'hs_1981_2011_all.mat'
clust_file = file_in.replace('all.mat', 'clusters.mat')

#=================================1==============================================
#          dir, file, params
#================================================================================

dPar = {
Beispiel #3
0
@author: Litong Huang
'''
import matplotlib as mpl
mpl.use( 'Agg') # uncomment for interactive plotting

import os
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import matplotlib.colors as co
import src.data_utils as data_utils
import src.seis_utils as seis_utils
from src.EqCat import *
from selector.getLanders import getLanders

eqCat   = EqCat() # original catalog
eqCatMc = EqCat() # this catalog wil be modfied with each Mc iteration
catChild=  EqCat()
catParent= EqCat()
#=================================1==============================================
#                            dir, file, params
#================================================================================
dir_in = '%s/data'%( os.path.expanduser('.'))
file_in= 'hs_1981_2018_all.mat'
map_filename = 'plots/'
fault_file = 'data/CA_faults.all.dat'
#file_b  = '%s_b_Mc_D.txt'%(fileIn.split('.')[0])
dPar  = {   'aMc'         :  np.array( [2.5,3.0,3.5,4.0]),#np.array([3.0, 4.0]),np.array( [2.0, 2.5, 3.0, 3.5]
            # fractal dimension and b for eq. (1)
            'D'           : 1.6, #1.6  TODO: - these values should be contrained independently
            'b'           : 1.0,
@author: Thomas Goebel University of Memphis
'''
import matplotlib as mpl
#mpl.use( 'Agg')
import matplotlib.pyplot as plt

import numpy as np
import os

#------------------------------my modules--------------------------------------
import src.data_utils as dataIO
import src.clustering as clustering
from src.EqCat import *

eqCat = EqCat()  # original catalog
eqCatMc = EqCat()  # this catalog will be modified with each Mc iteration
catChild = EqCat()
catParent = EqCat()

#=================================1==============================================
#                            dir, file, params
#================================================================================
data_dir = 'data'
plot_dir = 'plots'
file_in = 'hs_1981_2011_all.mat'

dPar = {
    'a_Mc': np.array([3.0, 4.0]),  #np.array( [2.0, 2.5, 3.0, 3.5]),
    #separate clustered and background
    'eta_0': -5.0,
Beispiel #5
0
@author: tgoebel
'''
#------------------------------------------------------------------------------
import matplotlib as mpl
#mpl.use( 'Agg') # turn off interactive plot
import matplotlib.pyplot as plt
import numpy as np
import scipy.io
import os

#------------------------------my modules--------------------------------------
import src.clustering as clustering
import src.data_utils as data_utils
from   src.EqCat import *

eqCat   = EqCat( ) # original cat
ranCat  = EqCat()  # randomized, Poissonian catalog
eqCatMc = EqCat()  # catalog above completeness
np.random.seed( 123456)
#=================================1==============================================
#                            dir, file, params
#================================================================================
dir_in = 'data'
file_in= 'hs_1981_2011_all.mat'

#file_b  = '%s_b_Mc_D.txt'%(fileIn.split('.')[0])
dPar  = {   'aMc'         :  np.array([3.0, 4.0]), #np.array( [2.0, 2.5, 3.0, 3.5]),
            # fractal dimension and b for eq. (1)
            'D'           : 1.6, # TODO: - these values should be constrained based on the data
            'b'           : 1.0, # use: https://github.com/tgoebel/magnitude-distribution for b-value
Beispiel #6
0
@author: tgoebel
'''
import matplotlib as mpl

mpl.use('Agg')  # uncomment for interactive plotting

import os
import numpy as np
import matplotlib.pyplot as plt
import scipy.io
#------------------------------my modules--------------------------------------
import src.data_utils as data_utils
import src.clustering as clustering
from src.EqCat import *

eqCat = EqCat()  # original catalog
eqCatMc = EqCat()  # this catalog wil be modfied with each Mc iteration
catChild = EqCat()
catParent = EqCat()
#=================================1==============================================
#                            dir, file, params
#================================================================================
dir_in = '%s/data' % (os.path.expanduser('.'))
file_in = 'hs_1981_2018_all.mat'

#file_b  = '%s_b_Mc_D.txt'%(fileIn.split('.')[0])
dPar = {
    'a_Mc': np.array([2.5, 3.0, 3.5, 4.0]),  #np.array([3.0, 4.0]),
    # fractal dimension and b for eq. (1)
    'D': 1.8,  #1.6  TODO: - these values should be constrained independently
    'b': 1.0,
Beispiel #7
0
'''
plot the R/L or Haversine Distance distribution of aftershock sequences of certain mainshoks
-- background events excluded
'''
import matplotlib as mpl
mpl.use('Agg')  # uncomment for interactive plotting

import os
import numpy as np
#------------------------------my modules--------------------------------------
import src.data_utils as data_utils
import src.seis_utils as seis_utils
from src.EqCat import *
import src.plot_hist as myplot

eqCat = EqCat()  # original catalog
#=================================0==============================================
#                            dir, file, params
#================================================================================
dir_in = '%s/data' % (os.path.expanduser('.'))
file_in = 'hs_1981_2018_all.mat'

#file_b  = '%s_b_Mc_D.txt'%(fileIn.split('.')[0])
dPar = {
    'aMc':
    np.array([2.5, 2.6, 3.0, 3.5,
              4.0]),  #np.array([3.0, 4.0]),np.array( [2.0, 2.5, 3.0, 3.5]
    # fractal dimension and b for eq. (1)
    'D': 1.6,  #1.6  TODO: - these values should be contrained independently
    'b': 1.0,
    #=================plotting==============
@author:Thomas Goebel, University of Memphis
'''
import matplotlib as mpl
#mpl.use( 'Agg') # uncomment for interactive plotting
import matplotlib.pyplot as plt

import os
import numpy as np
#------------------------------my modules--------------------------------------
import src.data_utils as data_utils
import src.seis_utils as seis_utils
from src.EqCat import *
import src.plot_hist as myplot

eqCat = EqCat()  # original catalog
asCat = EqCat()
#=================================0==============================================
#                            dir, file, params
#================================================================================
dir_in = '%s/data' % (os.path.expanduser('.'))
file_in = 'hs_1981_2018_all.mat'

#file_b  = '%s_b_Mc_D.txt'%(fileIn.split('.')[0])
dPar = {
    'aMc':
    np.array([2.5, 2.6, 3.0, 3.5,
              4.0]),  #np.array([3.0, 4.0]),np.array( [2.0, 2.5, 3.0, 3.5]
    # fractal dimension and b for eq. (1)
    'D': 1.6,  #1.6  TODO: - these values should be constrained independently
    'b': 1.0,
- save as .mat binary for fast data I/O

@author: tgoebel
'''
#------------------------------------------------------------------------------
import matplotlib.pyplot as plt
import numpy as np
import scipy.io
import os
from src.seis_utils import *

#import src.dataIO_utils
#------------------------------my modules--------------------------------------
from src.EqCat import *

eqCat = EqCat()

#=================================1==============================================
#                            dir, file, params
#================================================================================
dir_in = 'data'
file_in = 'hs_1981_2018_all.txt'
#file_in = 'test_HS.txt'

#=================================2==============================================
#                            load data
#================================================================================
os.chdir(dir_in)
eqCat.loadEqCat(file_in, 'HS_reloc', removeColumn=[24, 25, 26])

print(eqCat.size())
Beispiel #10
0
def getMajor(curr_Mc,**kwargs):
    """
    :param curr_Mc: low-cut magnitude
    :return:
        - aCluster: list of clusters
          each cluster is a catalog contains a major shock and its offsprings
          'sel_p','sel_c' is used to select related NND data in aNND
        - aNND: nearest neighbor distance
          'aEqID_p': parent's ID of the pair
          'aEqID_c': child's ID of the pair
    """
    import numpy as np
    import os

    # ------------------------------my modules--------------------------------------
    import sys
    sys.path.append('/auto/home/lhuang/PycharmProjects/clustering-analysis-master')
    import src.data_utils as data_utils


    eqCat = EqCat()  # original catalog
    eqCatMc = EqCat()  # this catalog will be modified with each Mc iteration

    # =================================1==============================================
    #                            dir, file, params
    # ================================================================================
    data_dir = './data' # Todo: .. or .
    file_in = 'hs_1981_2018_all.mat'

    eqCat.loadMatBin(os.path.join(data_dir, file_in))
    eqCat.toCart_coordinates()
    eqCatMc.copy(eqCat)
    if 'min' in kwargs.keys():
        min = kwargs['min']
    else:
        min = 6.0
    if 'max' in kwargs.keys():
        max = kwargs['max']
    else:
        max = None
    eqCatMc.selectEvents(min,max,'Mag')

    # load nearest neighbor distances
    NND_file = './data/%s_NND_Mc_%.1f_HD.mat' % (file_in.split('.')[0], curr_Mc)# Todo: .. or .
    dNND = data_utils.loadmat(NND_file)  # ,  struct_as_record=True)

    aCluster = np.array([])
    for i in list(range(eqCatMc.size())):
        cat = EqCat()
        cat.copy(eqCat)
        sel_c = dNND['aEqID_p'] == eqCatMc.data['N'][i]
        sel_p = dNND['aEqID_c'] == eqCatMc.data['N'][i]
        sel = np.logical_or(sel_p,sel_c)
        cat.selEventsFromID(dNND['aEqID_c'][sel],repeats=True)
        cat.data['sel_p'] = sel_p
        cat.data['sel_c'] = sel_c
        aCluster=np.append(aCluster,cat)
        print("major earthquake:%.1f"%cat.data['Time'][0],"mag:",cat.data['Mag'][0])
    print("Total Ms: %d" % aCluster.shape[0])
    return aCluster,dNND
Beispiel #11
0
dPar = {'Mc':2.5,
        'minMag':4.0, # minimum magnitude of mainshocks
        'maxMag':8.0, # maximum magnitude of mainshocks
        'k': 2,
        'HD_binsize':0.05,
        'lambda_binsize':0.08,
        # fitting coefficient
        'n':-1.35, 'c':1.0,
        'q':0.35, 'd':1.2,'gamma':0.6,
         }

# =================================1==============================================
#                            load catalog and select
# ================================================================================
eqcat = EqCat()

mins = np.arange(3.5,7.0,0.5) # TODO: min 2.6, 3.0, 3.5
maxs = mins + 0.5
a_MS_mag = []  # average mainshock magnitude of each set
a_AS_dist = [] # aftershock haversine distance distribution of each set

# load earthquake set, mainshocks [min,max]
for min,max in zip(mins,maxs):
    aCluster, dNND = getMajor(dPar['Mc'], min=min, max=max)
    aMag = np.zeros(len(aCluster))
    aDist = np.array([])
    sel = aMag >= 0
    for i,cluster in enumerate(aCluster):
        aMag[i] = cluster.data['Mag'][0]
        sel_c = cluster.data['sel_c']  # offspring
Beispiel #12
0
'''
import matplotlib as mpl

mpl.use('Agg')  # uncomment for interactive plotting

import sys
sys.path.append('/auto/home/lhuang/PycharmProjects/clustering-analysis-master')
import numpy as np
import matplotlib.pyplot as plt
from src.EqCat import *
from selector.getBigEQ import getMajor
from selector.getLanders import getLanders
from src.plot_major import *
import scipy.io

eqCat = EqCat()  # original catalog
eqCatMc = EqCat()  # this catalog wil be modfied with each Mc iteration
catChild = EqCat()
catParent = EqCat()
# =================================1==============================================
#                            dir, file, params
# ================================================================================
map_filename = 'plots/'
fault_file = 'data/CA_faults.all.dat'
# file_b  = '%s_b_Mc_D.txt'%(fileIn.split('.')[0])
dPar = {
    'aMc':
    np.array([2.5]),  # np.array([3.0, 4.0]),np.array( [2.0, 2.5, 3.0, 3.5]
    # fractal dimension and b for eq. (1)
    'D': 1.6,  # 1.6  TODO: - these values should be contrained independently
    'b': 1.0,
Beispiel #13
0
def getLanders():
    eqCat = EqCat()  # original catalog
    eqCatMc = EqCat()  # this catalog will be modified with each Mc iteration
    catLanders = EqCat()
    catCoso = EqCat()

    # =================================1==============================================
    #                            dir, file, params
    # ================================================================================
    data_dir = '../data'
    plot_dir = '../plots'
    file_in = 'hs_1981_2011_all.mat'

    dPar = {
        'a_Mc': np.array([3.0, 4.0]),  # np.array( [2.0, 2.5, 3.0, 3.5]),
        # separate clustered and background
        'eta_0': -5.0,
        'testPlot': True,
        'D':
        1.6,  # 1.6  TODO: - these values should be contrained independently
        'b': 1.0,
    }

    curr_Mc = dPar['a_Mc'][0]
    # =================================2==============================================
    #                            load data, select events
    # ================================================================================
    eqCat.loadMatBin(os.path.join(data_dir, file_in))
    print('total no. of events', eqCat.size())
    eqCat.selectEvents(curr_Mc, None, 'Mag')
    #eqCat.toCart_coordinates()
    # eqCat.selector( tmin, tmax, 'Time')
    print('no. of events after initial selection', eqCat.size())

    catLanders.copy(eqCat)
    catCoso.copy(eqCat)

    catLanders.selectEvents(7.0, None, 'Mag')
    catLanders.selectEvents(34, 35, 'Lat')
    catLanders.selectEvents(-117, -116, 'Lon')
    catLanders.selectEvents(1992, 1993, 'Time')
    #print("===========Landers Info============\n",catLanders.data)

    catCoso.selectEvents(catLanders.data['Time'][0],
                         catLanders.data['Time'][0] + 0.1, 'Time')
    catCoso.selectEvents(-118.5, -117, 'Lon')
    catCoso.selectEvents(35.5, 36.5, 'Lat')
    #print("===========Coso Info===============\nLon\tLat\tMag\tTime\t")
    #for lon,lat,mag,time in zip(catCoso.data['Lon'],catCoso.data['Lat'],catCoso.data['Mag'],catCoso.data['Time']):
    #    print("%.3f\t%.3f\t%.2f\t%.8f\t"%(lon,lat,mag,time))

    aEta = np.array([])
    aT = np.array([])
    aR = np.array([])

    catAll = EqCat()
    catAll.merge(catLanders, catCoso)
    catAll.toCart_coordinates()

    #print(catAll.data)

    for x, y, time in zip(catAll.data['X'][1:], catAll.data['Y'][1:],
                          catAll.data['Time'][1:]):
        x = catAll.data['X'][0]
        y = catAll.data['Y'][0] + 3
        t = (time - catAll.data['Time'][0]) * 10**(-dPar['b'] *
                                                   catAll.data['Mag'][0] / 2)
        print("distance:", ((x - catAll.data['X'][0])**2 +
                            (y - catAll.data['Y'][0])**2)**0.5)
        r = ((x - catAll.data['X'][0])**2 + (y - catAll.data['Y'][0])**2)**(
            dPar['D'] / 2) * 10**(-dPar['b'] * catAll.data['Mag'][0] / 2)
        eta = r * t
        aEta = np.append(aEta, np.log10(eta))
        aT = np.append(aT, np.log10(t))
        aR = np.append(aR, np.log10(r))
    print("===========Neareast Neighbor Distance===============\nr\tt\teta\t")
    for r, t, eta in zip(
            aR, aT, aEta
    ):  #(catCoso.data['Time']-catLanders.data['Time'][0])*365.25*24*3600
        print("%f\t%f\t%f" % (r, t, eta))

    return catAll, aT, aR, aEta
Beispiel #14
0
@author: tgoebel - Thomas Goebel University of Memphis
'''
import matplotlib as mpl
mpl.use( 'Agg') # uncomment for interactive plotting

import os
import numpy as np
import matplotlib.pyplot as plt

#------------------------------my modules-------------------------------------- 
import src.data_utils as dataIO
import src.clustering as clustering
from src.EqCat import *

eqCat   = EqCat() # original catalog
eqCatMc = EqCat() # this catalog will be modified with each Mc iteration
catChild=  EqCat()
catParent= EqCat()

#=================================1==============================================
#                            dir, file, params
#================================================================================
data_dir = 'data'
plot_dir = 'plots'
file_in  = 'hs_1981_2011_all.mat'

dPar  = {   'a_Mc'        :  np.array([3.0, 4.0]), #np.array( [2.0, 2.5, 3.0, 3.5]),
            #separate clustered and background
            'eta_0'       : -5.0, # run 2_eta_0.py and
                                  # if file exists: default = load this value from ASCII file
TODO: - implement geo-referenced plotting with Basemap


@author: tgoebel
'''
#------------------------------------------------------------------------------
import matplotlib.pyplot as plt
import numpy as np
import scipy.io
import os, sys

#------------------------------my modules--------------------------------------
#import src.dataIO_utils as dataUtils
from src.EqCat import *

eqCat = EqCat()

#print dir( dataUtils)
#=================================1==============================================
#                            dir, file, params
#================================================================================
dir_in = 'data'
file_in = 'hs_1981_2011_all.mat'
#xmin, xmax = -122, -114
#ymin, ymax = 34, 38
Mmin, Mmax = 3, None
tmin, tmax = 1990, 2018

#=================================2==============================================
#                            load data, select events
#================================================================================
@author: tgoebel
'''
#------------------------------------------------------------------------------
import matplotlib as mpl
mpl.use('Agg')  # turn off interactive plot
import matplotlib.pyplot as plt
import numpy as np
import scipy.io
import os

#------------------------------my modules--------------------------------------
import src.clustering as clustering
from src.EqCat import *

eqCat = EqCat()

#print dir( dataUtils)
#=================================1==============================================
#                            dir, file, params
#================================================================================
dir_in = '%s/data' % (os.path.expanduser('.'))
file_in = 'hs_1981_2018_all.mat'

#file_b  = '%s_b_Mc_D.txt'%(fileIn.split('.')[0])
dPar = {
    'aMc':
    np.array([3.1, 3.2, 3.3, 3.4, 3.6, 3.7, 3.8,
              3.9]),  #np.array([3.0, 4.0]),np.array( [2.0, 2.5, 3.0, 3.5]
    # fractal dimension and b for eq. (1)
    'D': 1.6,  #1.6  TODO: - these values should be contrained independently
'''

import matplotlib as mpl
mpl.use('Agg')  # uncomment for interactive plotting

import os
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
#import matplotlib.colors as co
import src.data_utils as data_utils
#import src.seis_utils as seis_utils
from src.EqCat import *
#from selector.getBigEQ import getMajor

eqCat = EqCat()  # original catalog
eqCatMc = EqCat()  # this catalog wil be modfied with each Mc iteration
catChild = EqCat()
catParent = EqCat()
# =================================1==============================================
#                            dir, file, params
# ================================================================================
fault_file = 'data/CA_faults.all.dat'
# file_b  = '%s_b_Mc_D.txt'%(fileIn.split('.')[0])
plottype = 'time' # TODO: change here for different plot purpose. or 'eta'
dPar = {'aMc': np.array([2.5]),  # np.array([3.0, 4.0]),np.array( [2.0, 2.5, 3.0, 3.5]
        # fractal dimension and b for eq. (1)
        'D': 1.6,  # 1.6  TODO: - these values should be contrained independently
        'b': 1.0,
        # =================map plotting==========
        'minlon': -124, 'minlat': 30,