Ejemplo n.º 1
0
EXAMPLE 6 - Area selection
"""

from os.path import dirname

from geoist.catalog import Catalogue as Cat
from geoist.catalog import Exploration as Exp
from geoist.catalog import Selection as Sel
from geoist.catalog import MapTools as Map
from geoist.catalog import CatUtils as Ct

pathname = dirname(__file__)
print(pathname+"/data/isc-rev-africa-select.bin")
#-----------------------------------------------------------------------------------------
# Import catalogue
Db1 = Cat.Database()
Db1.Load(pathname+'/data/isc-rev-africa-select.bin')

#-----------------------------------------------------------------------------------------
# Filtering by polygon

# As WKT Format or List
CASE = 1


if CASE == 1:
  p = [(20.,-20.),(40.,-20.),(40.,0.),(20.,0.)]
  Db2 = Sel.AreaSelect(Db1,p)
  P = Ct.Polygon()
  P.Load(p)
Ejemplo n.º 2
0
from os.path import dirname
from geoist.catalog import Catalogue as cat
from geoist.catalog import Exploration as exp
import geoist.catalog.QCreport as qc
import geoist.others.fetch_data as data
import geoist as gi
from geoist.others.fetch_data import _retrieve_file as downloadurl

## 下载地震目录
url = data.ispec_catalog_url
filename = '2020-03-25CENC-M4.7.dat'
localpath = downloadurl(url + filename, filename)
print(localpath)  #文件路径

db2 = cat.Database('2020-03-25CENC-M4.7')
# header = ['Year', 'Month','Day','Hour','Minute','Second','Latitude','Longitude', 'Depth','MagType','MagSize','Log']
# db2.Import0(localpath, Header = header, Delimiter= ' ', flag = False)

db2.Import0('D:/MyWorks/geoist/geoist/catalog/data/us2010-2012.csv')
#header = ['time', 'latitude','longitude', 'depth','mag','magType','type']
#db2.Import0('D:/MyWorks/geoist/geoist/catalog/data/us2010-2012-1.csv') #, Header=header)
#db2.Size()
#db2.Events[2]
db2.Info()
exp.MagTimePlot(db2)

#print(gi.EXAMPLES_PATH, gi.DATA_PATH, gi.TEMP_PATH)
##gi.__verison__
##gi.log.info('test')
#pathname,prefix = qc.create_figures_new(qc.qcinit(), catalog_file = 'us2010-2012.csv')
Ejemplo n.º 3
0
"""
MANUAL CREATION OF AN EARTHQUAKE DATABASE
"""

from geoist.catalog import Catalogue as Cat
Db = Cat.Database('First Test', 'NOTE: Just a test')

L = [{
    'Year': 1960
}, {
    'Year': 1961,
    'Month': 12,
    'Latitude': 10.,
    'Longitude': 20.
}, {
    'Year': 1962,
    'Month': 12,
    'Day': 3,
    'Hour': 5,
    'Minute': 20,
    'Second': 10
}]

M = [{
    'MagCode': 'AAA',
    'MagSize': 5,
    'MagError': 0.1,
    'MagType': 'Mw'
}, {
    'MagCode': 'XXX',
    'MagSize': 7,
Ejemplo n.º 4
0
"""
EXAMPLE 5 - CATALOGUE MERGING
"""
from os.path import dirname
from geoist.catalog import Catalogue as Cat
from geoist.catalog import Selection as Sel
from geoist.catalog import MagRules as MR

#-----------------------------------------------------------------------------------------
# Import Catalogues
pathname = dirname(__file__)
Db1 = Cat.Database()
Db1.Load(pathname + '/data/isc-rev-africa-select.bin')

Db2 = Cat.Database()
Db2.Load(pathname + '/data/isc-gem-v3.bin')

#-----------------------------------------------------------------------------------------
# Duplicate findings

# Between Catalogues
Db3, Log = Sel.MergeDuplicate(Db1,
                              Db2,
                              Twin=60.,
                              Swin=50.,
                              Log=1,
                              Owrite=False)

# Within a catalogue
Log = Sel.MergeDuplicate(Db1, Twin=60., Swin=50., Log=1)
Ejemplo n.º 5
0
from geoist.catalog import Exploration as Exp
from geoist.catalog import MapTools as Map
from geoist.catalog import Selection as Sel
from geoist.catalog import Seismicity as Sem
from geoist.catalog import Declusterer as Declus
from geoist.catalog import Smoothing as Sm
from geoist.catalog import CatUtils as Ct
#-----------------------------------------------------------------------------------------
pathname = dirname(__file__)
H = [
    'Id', '', 'Year', 'Month', 'Day', 'Hour', 'Minute', 'Second', 'Longitude',
    'Latitude', '', '', '', 'Depth', 'DepError', 'MagSize', 'MagError', '', '',
    '', '', '', '', '', '', ''
]

Db = Cat.Database('ISC-GEM')
Db.Import(pathname + '/data/isc-gem-v3.csv',
          Header=H,
          SkipLine=1,
          Delimiter=',')

Db.SetField('LocCode', 'ISC-GEM')
Db.SetField('MagCode', 'ISC-GEM')
Db.SetField('MagType', 'MW')
#-----------------------------------------------------------------------------------------
# Search Area (China) using internal filter
lon = [70, 135]
lat = [15, 55]
#地震筛选
Db.Filter('Latitude', lat[0], Opr='>=')
Db.Filter('Latitude', lat[1], Opr='<=')
Ejemplo n.º 6
0
"""
EXAMPLE 4 - READING CSV CATALOGUE
"""
from os.path import dirname
import numpy as np
from geoist.catalog import Catalogue as Cat
from geoist.catalog import Exploration as Exp
from geoist.catalog import MapTools as Map
from geoist.catalog import Selection as Sel
from geoist.catalog import Seismicity as Sem
from geoist.catalog import Declusterer as Declus
from geoist.catalog import Smoothing as Sm
#-----------------------------------------------------------------------------------------
# 1) STANDARD FORMAT
pathname = dirname(__file__)
Db = Cat.Database('ISC-Africa')
Db.Import(pathname+'/data/isc-rev-africa-select.csv')

#-----------------------------------------------------------------------------------------
# 2) ARBITRARY FORMAT (USER DEFINED)

H = ['Id','','Year','Month','Day','Hour','Minute','Second',
     'Longitude','Latitude','','','','Depth','DepError',
     'MagSize','MagError','','','','','','','','','']

Db = Cat.Database('ISC-GEM')
Db.Import(pathname+'/data/isc-gem-v3.csv',Header=H,
                                SkipLine=1,
                                Delimiter=',')

Db.SetField('Prime',True)
Ejemplo n.º 7
0
from geoist.others.fetch_data import _retrieve_file as downloadurl
from geoist.others.fetch_data import usgs_catalog
from geoist.catalog import Catalogue as cat
from geoist.catalog import QCmulti as cp
from geoist.catalog import QCreport as qc
from geoist.catalog import Smoothing as sm
from geoist.catalog import Selection as sel
from geoist.catalog import CatUtils as ct
from geoist.catalog import MapTools as mapt
from geoist.catalog import Exploration as exp
#import pdb

usgsfile = 'usgsca.csv'
localpath2 = usgs_catalog(usgsfile, '1970-01-01', '2020-01-01', '15','55','70','135',minmag = '5')
print(localpath2) 
dbusgs = cat.Database(usgsfile)
dbusgs.Import0(localpath2)
dbusgs.Info()

#平滑地震目录
#pdb.set_trace()
p = [(90.,20.),(90.,40.),(105.,40.),(105.,20.),(90.,20.)]
db3 = sel.AreaSelect(dbusgs,p)
P = ct.Polygon()
P.Load(p)

x1,y1,z1 = exp.GetHypocenter(db3)
wkt = ct.XYToWkt(P.x, P.y)
xsm, ysm, asm = sm.SmoothMFD(db3, 1., wkt, Delta=0.5)
cfg1 = {'Bounds': [90., 20., 105., 40.],
        'FigSize': [10., 12.],
Ejemplo n.º 8
0
# pathname = dirname(__file__)
# print(pathname)
url = data.ispec_catalog_url
print(url)
filename = '2020-03-25CENC-M4.7.dat'
localpath = downloadurl(url + filename, filename)
print(localpath)  #文件路径

## 下载USGS地震目录
## 参考:https://earthquake.usgs.gov/fdsnws/event/1/
usgsfile = 'usgscat2.csv'
localpath2 = usgs_catalog(
    usgsfile, '2014-01-01',
    '2014-01-02')  #, '-90','90','-180','180',minmag = '5')
print(localpath2)
dbusgs = cat.Database(usgsfile)
dbusgs.Import0(localpath2)
dbusgs.Info()

## 建立地震目录数据库
catname = 'CENCM4.7'
db2 = cat.Database(catname)
header = [
    'Year', 'Month', 'Day', 'Hour', 'Minute', 'Second', 'Latitude',
    'Longitude', 'Depth', 'MagType', 'MagSize', 'Log'
]
db2.Import0(localpath, Header=header, Delimiter=' ', flag=False)
db2.Info()

db2.SetField('LocCode', 'CENC')
db2.SetField('MagCode', 'CENC4.7')
Ejemplo n.º 9
0
"""
EXAMPLE 8 - Sort catalogue
"""
from os.path import dirname
from geoist.catalog import Catalogue as Cat
from geoist.catalog import Exploration as Exp

#-----------------------------------------------------------------------------------------
# Import catalogue
pathname = dirname(__file__)
Db1 = Cat.Database()
Db1.Load(pathname + '/data/isc-rev-africa-select.bin')

#-----------------------------------------------------------------------------------------
# Randomly shuffling catalogue (for testing)

import numpy as np
Ind = np.random.randint(0, Db1.Size(), Db1.Size())

Db2 = Cat.Database('Unsorted')
for I in Ind:
    Db2.Events.append(Db1.Events[I])

#-----------------------------------------------------------------------------------------
# Sorting again

Db2.Sort()
print('Cat Sort!')