Catalogue Homogenization


In [9]:
%matplotlib inline
import os
import numpy as np
import matplotlib.pyplot as plt
import eqcat.parsers.isf_catalogue_reader as icr
import eqcat.catalogue_query_tools as cqt

In [10]:
raw_file = "Marmaries-catalogue1.txt"
rejection_keywords = ["mining", "geothermal", "explosion", "quarry", "reservoir", "induced", "rockburst"]
reader = icr.ISFReader(raw_file, rejection_keywords=rejection_keywords)
catalogue = reader.read_file("TUR", "ISC")

In [11]:
for event in reader.rejected_catalogue.events[:10]:
    print event.id, event.description, event.comment


72858 Turkey Radiated energy from the P-wave first-motion solution:  1.0+/-0.1X10**13Nm/10
Fault plane solution: P waves. NP1:phi_s305,delta_58,zeta_-90.  NP2:phi_s125,delta_32,zeta_-90. Principal axes: T Plg13,Azm35; P
 Plg77,Azm215.  The focal mechanism is poorly controlled and corresponds to normal faulting. The  preferred fault plane is not determined.
Mo=5.4X10**18Nm (PPT
 Dinar  area. About 600 buildings destroyed at Evciler. Felt in much of western Turkey as  far west as Izmir and as far north as Bursa and
 Yalova.
Moment tensor solution: s46, scale 10**18Nm; Mrr-1.30;  MTheta_Theta_0.72; Mphi_phi_0.59; MrTheta_0.10; Mrphi_-0.07;  MTheta_phi_-0.69.
 Depth 8km; Principal axes: T 1.35,Plg3,Azm42; N  -0.04,Plg1,Azm312; P -1.31,Plg87,Azm207; Best double couple: M01.3X10**18Nm; 
 NP1:phi_s133,delta_42,zeta_-89. NP2:phi_s312,delta_48,zeta_-91.
#MOMTENS sc    M0 fCLVD    MRR    MTT    MPP    MRT    MTP    MPR NST1 NST2 Author   
#             eM0 eCLVD    eRR    eTT    ePP    eRT    eTP    ePR NCO1 NCO2 Duration 
#        18 1.300       -1.300  0.720  0.590  0.100 -0.690 -0.070           NEIC     
#                                                                                    
#FAULT_PLANE Typ Strike   Dip    Rake  NP  NS Plane Author   
#            BDC 133.00 42.00  -89.00               NEIC     
+                312.00 48.00  -91.00                        
#PRINAX sc  T_val T_azim  T_pl  B_val B_azim  B_pl  P_val P_azim  P_pl Author   
#       18  1.350  42.00  3.00 -0.040 312.00  1.00 -1.310 207.00 87.00 NEIC     
Hypocentre not reviewed by the ISC
=4.9+/-3.4X10**18Nm. Fault plane solution  NP1:phi_s165,delta_39,zeta_-54. NP2:phi_s302,delta_59,zeta_-65. Principal  Axes: T Plg11,Azm50;
 N Plg22,Azm316; P Plg65,Azm165.
#MOMTENS sc    M0 fCLVD    MRR    MTT    MPP    MRT    MTP    MPR NST1 NST2 Author   
#             eM0 eCLVD    eRR    eTT    ePP    eRT    eTP    ePR NCO1 NCO2 Duration 
#        18 4.720       -4.220  2.580  1.640  1.750 -1.730 -1.630   60      HRVD     
#                        0.060  0.080  0.060  0.250  0.070  0.250   41          4.00 
#FAULT_PLANE Typ Strike   Dip    Rake  NP  NS Plane Author   
#            BDC 125.00 30.00  -94.00               HRVD     
+                310.00 60.00  -88.00                        
#PRINAX sc  T_val T_azim  T_pl  B_val B_azim  B_pl  P_val P_azim  P_pl Author   
#       18  4.550  38.00 15.00  0.330 129.00  2.00 -4.880 227.00 75.00 HRVD     
Readings from ERZ have been deleted from the comprehensive bulletin for this event as the wrong station code had been used.
#AUTHOR Yalcinkaya,E. , Alptekin,O.                                                      
#TITLE  Numerical 2D modeling of site response in Dinar Graben, Southwest Turkey, and    
+       comparison with observations                                                     
#AUTHOR Erberik,M.A.                                                                     
#TITLE  Generation of fragility curves for Turkish masonry buildings considering         
+       in-plane failure modes                                                           
#AUTHOR Fukahata,Y. , Wright,T.J.                                                        
#TITLE  A non-linear geodetic data inversion using ABIC for slip distribution on a       
+       fault with an unknown dip angle                                                  
#AUTHOR IsmetKanli,A. , Tildy,P. , Prónay,Z. , Pinar,A. , Hermann,L.                    
#TITLE  Vs30 mapping and soil classification for seismic site effect evaluation in       
+       Dinar region, SW Turkey                                                          
#AUTHOR Şengezer,B. , Ansal,A. , Bilen,Ö.                                              
#TITLE  Evaluation of parameters affecting earthquake damage by decision tree techniques 
#AUTHOR Yalcinkaya,E. , Alptekin,O.                                                      
#TITLE  Contributions of basin-edge-induced surface waves to site effect in the Dinar    
+       basin, Southwestern Turkey                                                       
#AUTHOR Demirtaş,R. , Karakisa,S. , Yilmaz,R.                                           
#TITLE  The October 1, 1995 Dinar earthquake (MI=5.9
#AUTHOR Anderson,J.G. , Zeng,Y. , Sucuoglu,H.                                            
#TITLE  Analysis of Accelerations from the 1 October 1995 Dinar, Turkey, Earthquake      
#AUTHOR Sucuoğlu,H. , Anderson,J.G. , Zeng,Y.                                           
#TITLE  Predicting Intensity and Damage Distribution during the 1995 Dinar, Turkey,      
+       Earthquake with Generated Strong Motion Accelerograms                            
#AUTHOR Wright,T.J. , Parsons,B.E. , Jackson,J.A. , Haynes,M. , Fielding,E.J. ,           
+       England,P.C. , Clarke,P.J.                                                       
#TITLE  Source parameters of the 1 October 1995 Dinar (Turkey
+       interferometry and seismic bodywave modelling                                    
#AUTHOR Öncel,A.O. , Koral,H. , Alptekin,Ö.                                            
#TITLE  The Dinar earthquake (Mw = 6.2; October 1, 1995; Afyon-Turkey
+       hazard of the Dinar-Civril fault                                                 
#AUTHOR Durukal,E. , Erdik,M. , Avci,J. , Yüzügüllü,O. , Alpay,Y. , Avar,B. ,         
+       Zülfikar,C. , Biro,T. , Mert,A.                                                 
#TITLE  Analysis of the strong motion data of the 1995 Dinar, Turkey earthquake          
#AUTHOR Koral,H.                                                                         
#TITLE  Surface rupture and rupture mechanism of the October 1, 1995(Mw = 6.2
+       earthquake, SW Turkey                                                            
#AUTHOR Eyidoǧan,H. , Barka,A.                                                          
#TITLE  The 1 October 1995 Dinar earthquake, SW Turkey                                   
#AUTHOR Yalcınkaya,E. , Alptekin,Ö.                                                    
#TITLE  Relationships among source parameters of aftershocks of the October 1, 1995      
+       Dinar (Turkey
#AUTHOR Utkucu,M. , Pınar,A. , Alptekin,Ö.                                             
#TITLE  A detailed slip model for the 1995, October 1, Dinar, Turkey, earthquake (MS=    
+       6.1
#AUTHOR Leborgne,S. , Madariaga,R. , Farra,V.                                            
#TITLE  Body waveform modeling of east Mediterranean earthquakes at intermediate         
+       distances (17°–30°
#AUTHOR Pınar,A.                                                                        
#TITLE  Source inversion of the October 1, 1995, Dinar earthquake (Ms=6.1
+       model with implications for seismotectonics in SW Turkey                         
#AUTHOR Ansal,A.M. , Iyisan,R. , Güllü,H.                                              
#TITLE  Microtremor Measurements for the Microzonation of Dinar                          
#AUTHOR Bakır,B.S. , Özkan,M.Y. , Cılız,S.                                           
#TITLE  Effects of basin edge on the distribution of damage in 1995 Dinar, Turkey        
+       earthquake                                                                       
#AUTHOR Güllü,H.                                                                       
#TITLE  On the prediction of shear wave velocity at local site of strong ground motion   
+       stations: an application using artificial intelligence                           
#AUTHOR Fox,B.D. , Selby,N.D. , Heyburn,R. , Woodhouse,J.H.                              
#TITLE  Shallow seismic source parameter determination using intermediate-period         
+       surface wave amplitude spectra                                                   
#AUTHOR Ceran,H. , Erberik,M.                                                            
#TITLE  Effect of out-of-plane behavior on seismic fragility of masonry buildings in     
+       Turkey                                                                         
#AUTHOR Yolsal-Çevikbilen,S. , Taymaz,T. , Helvacı,C.                                  
#TITLE  Earthquake Mechanisms in the Gulfs of Gökova, Sığacık, Kuşadası, and the   
+       Simav Region (western Turkey
+       implications                                                                     
#PARAM pP_DEPTH=29+2

13434903 Turkey Beyond depth limits; depth fixed to 0/600 km
DDA confirmed that this event was an explosion by email on 18 March 2011.

16939994 Turkey Mining explosion.
After DDA
Event not reviewed by the ISC

15003480 Turkey Mining explosion.
Event not reviewed by the ISC

15003500 Turkey Mining explosion.
Event not reviewed by the ISC

15004064 Turkey Mining explosion.
Event not reviewed by the ISC

15085241 Turkey Mining explosion.
Event not reviewed by the ISC

15085596 Turkey Mining explosion.
Event not reviewed by the ISC

15085664 Turkey Mining explosion.
Event not reviewed by the ISC

15252777 Turkey Mining explosion.
Event not reviewed by the ISC


In [12]:
# Build HDF5 database
CAT_DB_FILE = "catalogue_db.hdf5"
_ = catalogue.build_dataframe(CAT_DB_FILE)
print "Comment this section out after first use!"


Comment this section out after first use!

In [13]:
CAT_DB_FILE = "catalogue_db.hdf5"
db1 = cqt.CatalogueDB(CAT_DB_FILE)

In [14]:
db1.magnitudes


Out[14]:
eventID originID magnitudeID value sigma magType magAgency
0 16958138 1961785 1961785|PAS|7.00|MS 7.0 0.0 MS PAS
1 914160 1961791 1961791|PAS|6.20|MS 6.2 0.0 MS PAS
2 914008 05951227 05951227|ISC|7.20|MS 7.2 0.1 MS ISC
3 913203 1960505 1960505|PAS|6.50|MS 6.5 0.0 MS PAS
4 911975 1959125 1959125|PAS|6.80|MS 6.8 0.0 MS PAS
5 911975 05951427 05951427|ISC|6.80|MS 6.8 0.1 MS ISC
6 910635 1957587 1957587|PAS|5.80|MS 5.8 0.0 MS PAS
7 909771 1956562 1956562|PAS|6.90|MS 6.9 0.0 MS PAS
8 909771 05951617 05951617|ISC|6.90|MS 6.9 0.1 MS ISC
9 909893 1956719 1956719|PAS|7.90|MS 7.9 0.0 MS PAS
10 909893 05951631 05951631|ISC|6.90|MS 6.9 0.2 MS ISC
11 909918 1956751 1956751|PAS|5.50|MS 5.5 0.0 MS PAS
12 909317 1956009 1956009|PAS|6.20|MS 6.2 0.0 MS PAS
13 908579 1955099 1955099|PAS|6.20|MS 6.2 0.0 MS PAS
14 908579 05951744 05951744|ISC|6.50|MS 6.5 0.3 MS ISC
15 907976 1954329 1954329|PAS|5.80|MS 5.8 0.0 MS PAS
16 908248 1954678 1954678|PAS|5.60|MS 5.6 0.0 MS PAS
17 907584 1953840 1953840|PAS|6.00|MS 6.0 0.0 MS PAS
18 906145 1951702 1951702|PAS|5.60|MS 5.6 0.0 MS PAS
19 906260 1951895 1951895|PAS|5.60|MS 5.6 0.0 MS PAS
20 906433 1952187 1952187|PAS|5.60|MS 5.6 0.0 MS PAS
21 905533 1950642 1950642|PAS|6.80|MS 6.8 0.0 MS PAS
22 905533 05952052 05952052|ISC|6.30|MS 6.3 0.1 MS ISC
23 905543 1950663 1950663|PAS|5.60|MS 5.6 0.0 MS PAS
24 905725 1950977 1950977|PAS|6.00|MS 6.0 0.0 MS PAS
25 905264 1950205 1950205|PAS|6.20|MS 6.2 0.0 MS PAS
26 904162 1948409 1948409|PAS|6.20|MS 6.2 0.0 MS PAS
27 903598 1947561 1947561|PAS|5.80|MS 5.8 0.0 MS PAS
28 902332 1945516 1945516|PAS|5.20|MS 5.2 0.0 MS PAS
29 902170 1945227 1945227|PAS|6.50|MS 6.5 0.0 MS PAS
... ... ... ... ... ... ... ...
116500 607508396 06220778 06220778|IDC|3.90|mb1 3.9 0.1 mb1 IDC
116501 607508396 06220778 06220778|IDC|3.60|mb1mx 3.6 0.1 mb1mx IDC
116502 607508396 06220778 06220778|IDC|3.80|mbtmp 3.8 0.1 mbtmp IDC
116503 607508396 06220778 06220778|IDC|4.00|ML 4.0 0.1 ML IDC
116504 607508396 06120574 06120574|GII|4.00|mb 4.0 0.0 mb GII
116505 607508396 06120574 06120574|GII|3.70|MD 3.7 0.0 MD GII
116506 607508396 06120569 06120569|GFZ|4.30|mb 4.3 0.0 mb GFZ
116507 607508396 06212986 06212986|ISK|4.10|ML 4.1 0.0 ML ISK
116508 607661407 06220836 06220836|IDC|3.30|mb 3.3 0.2 mb IDC
116509 607661407 06220836 06220836|IDC|3.30|mb1 3.3 0.1 mb1 IDC
116510 607661407 06220836 06220836|IDC|3.10|mb1mx 3.1 0.1 mb1mx IDC
116511 607661407 06220836 06220836|IDC|3.60|mbtmp 3.6 0.1 mbtmp IDC
116512 607661407 06220836 06220836|IDC|2.60|MS 2.6 0.2 MS IDC
116513 607661407 06220836 06220836|IDC|2.60|Ms1 2.6 0.2 Ms1 IDC
116514 607661407 06220836 06220836|IDC|2.00|ms1mx 2.0 0.1 ms1mx IDC
116515 607661407 06213017 06213017|ISK|2.90|ML 2.9 0.0 ML ISK
116516 607661517 06220981 06220981|IDC|3.70|mb 3.7 0.2 mb IDC
116517 607661517 06220981 06220981|IDC|3.70|mb1 3.7 0.2 mb1 IDC
116518 607661517 06220981 06220981|IDC|3.40|mb1mx 3.4 0.1 mb1mx IDC
116519 607661517 06220981 06220981|IDC|3.70|mbtmp 3.7 0.2 mbtmp IDC
116520 607661517 06213111 06213111|ISK|3.30|ML 3.3 0.0 ML ISK
116521 607661588 06213173 06213173|ISK|3.30|ML 3.3 0.0 ML ISK
116522 607661588 06221058 06221058|IDC|3.40|mb 3.4 0.2 mb IDC
116523 607661588 06221058 06221058|IDC|3.30|mb1 3.3 0.2 mb1 IDC
116524 607661588 06221058 06221058|IDC|3.00|mb1mx 3.0 0.1 mb1mx IDC
116525 607661588 06221058 06221058|IDC|3.50|mbtmp 3.5 0.2 mbtmp IDC
116526 607677396 06222570 06222570|NEIC|4.20|UK 4.2 0.0 UK NEIC
116527 607708908 06249192 06249192|NAO|3.90|mb 3.9 0.0 mb NAO
116528 607708908 06238676 06238676|NEIC|4.00|UK 4.0 0.0 UK NEIC
116529 607708908 06238662 06238662|GFZ|4.20|mb 4.2 0.0 mb GFZ

233060 rows × 7 columns


In [15]:
temp = db1.origins["eventID"]

In [18]:
# Set up the configuration of the limits
outlier_fraction = 0.001
llon = np.floor(db1.origins.longitude.quantile(outlier_fraction))
ulon = np.ceil(db1.origins.longitude.quantile(1 - outlier_fraction))
llat = np.floor(db1.origins.latitude.quantile(outlier_fraction))
ulat = np.ceil(db1.origins.latitude.quantile(1 - outlier_fraction))
map_config = {"llon": llon, "ulon": ulon, "llat": llat, "ulat": ulat, 
              "parallel": 5.0, "meridian": 5.0, "resolution": "l"}
cqt.plot_catalogue_map(map_config, db1)



In [19]:
selector = cqt.CatalogueSelector(db1)
turkey_catalogue = selector.select_within_magnitude_range(5,5.5)
cqt.plot_catalogue_map(map_config, turkey_catalogue)



In [20]:
selector = cqt.CatalogueSelector(db1)
turkey_catalogue = selector.select_within_magnitude_range(5,6)
cqt.plot_catalogue_map(map_config, turkey_catalogue)



In [21]:
agency_magnitude_stats = cqt.get_agency_magtype_statistics(db1)


Agency: ISK - 52694 Origins
MD (27100) | ML (11636) | UK (9702) | md (7320) | mL (1454) | mb (90) | Mw (12) | MG (10)
========================================
Agency: ISC - 45980 Origins
mb (7906) | MS (1524) | UK (16)
========================================
Agency: ATH - 38162 Origins
MD (25578) | ML (8484) | md (4398) | mL (4246) | UK (1334) | MG (38) | MS (18) | M (2)
========================================
Agency: CSEM - 32300 Origins
MD (21726) | ML (5998) | mb (850) | Mw (564) | Ms (256) | MW (10) | M (4) | MG (2)
========================================
Agency: NEIC - 21014 Origins
mb (3698) | UK (152) | MS (130) | MSZ (122) | MW (54) | ME (10) | mw (4) | ML (4) | MD (2)
========================================
Agency: DDA - 18870 Origins
Md (7906) | Ml (4670) | MD (4438) | ML (2030) | MW (32) | Mw (6)
========================================
Agency: ISCJB - 10786 Origins
mb (2322) | MS (806)
========================================
Agency: THE - 9856 Origins
ML (8690) | mL (584) | md (62) | MG (8) | Mw (8)
========================================
Agency: IDC - 4914 Origins
mb (4910) | mb1 (4734) | mb1mx (4732) | ML (4100) | mbtmp (4058) | MS (2558) | Ms1 (2484) | ms1mx (2484)
========================================
Agency: NEIS - 3008 Origins
mb (1196) | MS (38) | MSZ (36)
========================================
Agency: HLW - 2888 Origins
Mb (1492) | Ml (1150) | Md (1020) | ML (28)
========================================
Agency: MOS - 2436 Origins
mb (1508) | MS (512) | MB (182) | Mb (182) | UK (84) | Ms (70)
========================================
Agency: NIC - 1994 Origins
ML (2252) | mb (1378) | MW (1122) | mL (30) | Ml (12) | MG (4) | MD (2)
========================================
Agency: EHB - 1298 Origins
No magnitudes corresponding to this agency
========================================
Agency: NAO - 1030 Origins
mb (954) | Mb (78)
========================================
Agency: EIDC - 1010 Origins
mb (1006) | mL (408) | MS (216) | ML (112) | mbmle (80) | msmle (60)
========================================
Agency: BCIS - 906 Origins
UK (142)
========================================
Agency: GII - 828 Origins
MD (400) | mb (284) | ML (194) | Md (82) | Mb (40) | Mw (32) | Mm (12)
========================================
Agency: BJI - 804 Origins
mb (750) | mB (454) | Ms (418) | Msz (242) | Ms7 (172) | MS (64) | mL (2)
========================================
Agency: LAO - 684 Origins
UK (684)
========================================
Agency: USCGS - 656 Origins
mb (622) | MS (20)
========================================
Agency: NSSC - 470 Origins
ML (314) | MD (60) | Mc (48)
========================================
Agency: MED_RCMT - 436 Origins
MW (436)
========================================
Agency: HFS - 342 Origins
mb (302) | MS (124)
========================================
Agency: GFZ - 294 Origins
mb (290) | MW (4)
========================================
Agency: PDG - 244 Origins
ML (106) | mL (28) | MD (12) | Mb (2) | md (2)
========================================
Agency: SOF - 242 Origins
MD (232) | md (10) | ML (8)
========================================
Agency: IASPEI - 230 Origins
mb (108) | ms (28) | ml (10) | MS (6)
========================================
Agency: ROM - 220 Origins
mb (202) | md (6) | UK (2) | MD (2) | mL (2)
========================================
Agency: ISS - 190 Origins
UK (2)
========================================
Agency: HFS2 - 188 Origins
No magnitudes corresponding to this agency
========================================
Agency: LDG - 176 Origins
Mb (164) | Ms (94) | mb (12) | MB (2)
========================================
Agency: ZUR_RMT - 168 Origins
Mw (168)
========================================
Agency: HRVD - 140 Origins
MW (72) | Mw (8)
========================================
Agency: PEK - 116 Origins
MS (24) | MB (8) | UK (8) | Mb (8)
========================================
Agency: SZGRF - 116 Origins
mb (104) | MS (42)
========================================
Agency: JSO - 108 Origins
MD (50) | ML (14) | mL (6)
========================================
Agency: GCMT - 106 Origins
MW (106)
========================================
Agency: SGS - 88 Origins
No magnitudes corresponding to this agency
========================================
Agency: GRAL - 86 Origins
MD (70)
========================================
Agency: CGS - 80 Origins
UK (22)
========================================
Agency: RYD - 72 Origins
md (36) | MD (32)
========================================
Agency: GUTE - 72 Origins
No magnitudes corresponding to this agency
========================================
Agency: BEO - 70 Origins
ML (46) | mb (18) | M (2)
========================================
Agency: SFS - 52 Origins
ML (48)
========================================
Agency: HFS1 - 44 Origins
UK (34)
========================================
Agency: BER - 38 Origins
mb (34) | MS (24)
========================================
Agency: SNSN - 38 Origins
Ml (12)
========================================
Agency: DUSS - 38 Origins
ML (24) | MS (12)
========================================
Agency: BGS - 34 Origins
mb (32) | Mw (12) | MS (4) | Mb (4)
========================================
Agency: CRAAG - 34 Origins
Mb (30) | Mw (2) | ML (2)
========================================
Agency: DJA - 30 Origins
mb (26) | mB (14) | Mwp (4) | Mw (4)
========================================
Agency: ZUR - 28 Origins
mb (16) | ML (6) | MLh (2)
========================================
Agency: TEH - 28 Origins
ML (20)
========================================
Agency: PDA - 26 Origins
mb (14) | Mw (8) | ML (4)
========================================
Agency: SKO - 24 Origins
ML (2) | M (2)
========================================
Agency: STR - 22 Origins
Mb (14) | Ms (6) | UK (4) | md (2)
========================================
Agency: TTG - 18 Origins
mL (12) | MD (4)
========================================
Agency: IGIL - 16 Origins
MS (10) | mb (6) | MW (2)
========================================
Agency: ISN - 16 Origins
ML (14)
========================================
Agency: CANSK - 16 Origins
No magnitudes corresponding to this agency
========================================
Agency: MDD - 16 Origins
mb (16) | Mb (8)
========================================
Agency: PRU - 14 Origins
M (10)
========================================
Agency: ORF - 14 Origins
mb (14) | ML (2)
========================================
Agency: SOME - 14 Origins
mb (14) | Ms (8)
========================================
Agency: TIR - 14 Origins
Ml (2) | Md (2)
========================================
Agency: USGS - 14 Origins
MB (8) | MWW (4) | mb (2) | MWR (2) | MW (2) | MWB (2) | MWC (2)
========================================
Agency: SYO - 10 Origins
MB (10) | MS (6)
========================================
Agency: BUD - 8 Origins
mB (8) | UK (8) | M (8) | mb (8) | MLv (6)
========================================
Agency: LIB - 8 Origins
ML (8)
========================================
Agency: KISR - 8 Origins
mb (6) | MB (2)
========================================
Agency: IPRG - 8 Origins
mL (8) | ML (4)
========================================
Agency: VIE - 8 Origins
Mb (12) | mb (8) | ML (4)
========================================
Agency: IPEC - 8 Origins
No magnitudes corresponding to this agency
========================================
Agency: KSA - 6 Origins
UK (2)
========================================
Agency: IST - 6 Origins
No magnitudes corresponding to this agency
========================================
Agency: TIF - 6 Origins
No magnitudes corresponding to this agency
========================================
Agency: DSN - 6 Origins
mb (6)
========================================
Agency: DHMR - 4 Origins
mb (4)
========================================
Agency: EBM - 4 Origins
No magnitudes corresponding to this agency
========================================
Agency: IGS - 4 Origins
UK (4)
========================================
Agency: CNRM - 4 Origins
ml (2) | ML (2)
========================================
Agency: AWI - 4 Origins
No magnitudes corresponding to this agency
========================================
Agency: VSI - 4 Origins
mL (4)
========================================
Agency: BKK - 4 Origins
mB (4) | UK (4) | M (4) | mb (4) | Mwp (2) | MLv (2)
========================================
Agency: INMG - 4 Origins
mb (4)
========================================
Agency: VAO - 2 Origins
mb (2)
========================================
Agency: PRA - 2 Origins
UK (14)
========================================
Agency: EAF - 2 Origins
No magnitudes corresponding to this agency
========================================
Agency: BGR - 2 Origins
mb (4) | Ms (2)
========================================
Agency: X - 2 Origins
No magnitudes corresponding to this agency
========================================
Agency: DMN - 2 Origins
No magnitudes corresponding to this agency
========================================
Agency: PPT - 2 Origins
Ms (2)
========================================
Agency: EPSI - 2 Origins
No magnitudes corresponding to this agency
========================================
Agency: UPP - 2 Origins
UK (18)
========================================
Agency: HRVD_LR - 2 Origins
MW (2)
========================================
Agency: BUL - 2 Origins
No magnitudes corresponding to this agency
========================================
Agency: IPGP - 2 Origins
Mw (2)
========================================
Agency: AAE - 2 Origins
No magnitudes corresponding to this agency
========================================
Agency: TRI - 2 Origins
No magnitudes corresponding to this agency
========================================
Agency: DBN - 2 Origins
No magnitudes corresponding to this agency
========================================
Agency: SHL - 2 Origins
No magnitudes corresponding to this agency
========================================
Agency: AAA - 2 Origins
M (2)
========================================

In [22]:
cqt.mine_agency_magnitude_combinations(db1,agency_magnitude_stats,200,no_case=True)


Out[22]:
OrderedDict()

In [23]:
# place ipynb in same folder as 
file_name = "AgencyPairs.txt"
pairs = np.genfromtxt(file_name, dtype="S64,S64,S64,S64,S64,S64,S64,i,S64")


---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-23-316df3825912> in <module>()
      1 # place ipynb in same folder as
      2 file_name = "AgencyPairs.txt"
----> 3 pairs = np.genfromtxt(file_name, dtype="S64,S64,S64,S64,S64,S64,S64,i,S64")

/usr/local/src/python/anaconda3/envs/py27/lib/python2.7/site-packages/numpy/lib/npyio.pyc in genfromtxt(fname, dtype, comments, delimiter, skiprows, skip_header, skip_footer, converters, missing, missing_values, filling_values, usecols, names, excludelist, deletechars, replace_space, autostrip, case_sensitive, defaultfmt, unpack, usemask, loose, invalid_raise)
   1342         if isinstance(fname, basestring):
   1343             if sys.version_info[0] == 2:
-> 1344                 fhd = iter(np.lib._datasource.open(fname, 'rbU'))
   1345             else:
   1346                 fhd = iter(np.lib._datasource.open(fname, 'rb'))

/usr/local/src/python/anaconda3/envs/py27/lib/python2.7/site-packages/numpy/lib/_datasource.pyc in open(path, mode, destpath)
    145 
    146     ds = DataSource(destpath)
--> 147     return ds.open(path, mode)
    148 
    149 

/usr/local/src/python/anaconda3/envs/py27/lib/python2.7/site-packages/numpy/lib/_datasource.pyc in open(self, path, mode)
    494             return _file_openers[ext](found, mode=mode)
    495         else:
--> 496             raise IOError("%s not found." % path)
    497 
    498 

IOError: AgencyPairs.txt not found.

In [ ]:
# have a peek at the data
pairs[:5]

In [ ]:
# parse the data and look at sets
agencies1 = [pair[1][1:-1].replace('_','') for pair in pairs]
mags1 = [pair[2][:-1].upper() for pair in pairs]
agencies2 = [pair[4][1:-1].replace('_','') for pair in pairs]
mags2 = [pair[5][:-1].upper() for pair in pairs]
nums_shared = [pair[7] for pair in pairs]

print set(mags1)
print set(mags2)
print list(set(mags1) - set(mags2))
print list(set(mags2) - set(mags1))

print set(agencies1)
print set(agencies2)
print list(set(agencies1) - set(agencies2))
print list(set(agencies2) - set(agencies1))

In [ ]:
# prioritize magnitudes and print pairs in order of size of overlap
mag_priority = ['MW','Mw']
tex_format = '%s%s/"%s, %s"[input] -> [edge label={%d}] %s%s/"%s, %s"[input];'

data = zip(agencies1, mags1, agencies2, mags2, nums_shared)
data = list(set(data))
data = sorted(data, key=lambda pair: pair[4], reverse=True)

for i, m1 in enumerate(mag_priority):
    for m2 in mag_priority[i:]:
        for agency1, mag1, agency2, mag2, n_shared in data:
            if (mag1 == m1 and mag2 == m2) or (mag1 == m2 and mag2 == m1):
                if mag_priority.index(m1) >= mag_priority.index(m2):
                    print tex_format % (agency1, mag1, agency1, mag1, n_shared,
                                        agency2, mag2, agency2, mag2)
                else:
                    print tex_format % (agency2, mag2, agency2, mag2, n_shared,
                                        agency1, mag1, agency1, mag1)

In [ ]:
ISK_MD_CSEM_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("CSEM", "MW"), ("NIC", "MW"), no_case=True)
#_ = cqt.plot_agency_magnitude_density(ISK_MD_CSEM_MD)
#cqt.plot_catalogue_map(map_config, query3_cat)

In [ ]:
ISK_MD_CSEM_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("ISK", "MD"), ("CSEM", "MD"), no_case=True)

regressor1 = cqt.CatalogueRegressor(ISK_MD_CSEM_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
ISK_MD_ATH_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("NIC", "MW"), ("NIC", "MW"), no_case=True)
_ = cqt.plot_agency_magnitude_density(ISK_MD_ATH_MD)

In [ ]:
ISK_MD_ATH_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("NIC", "MW"), ("NIC", "MW"), no_case=True)

regressor1 = cqt.CatalogueRegressor(ISK_MD_ATH_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
regressor1 = cqt.CatalogueRegressor(ISK_MD_ATH_MD)
results = regressor1.run_regression("2segmentM4.3", [1.0, 1.0, 1.0])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
print regressor1.standard_deviation

In [ ]:
ATH_MD_CSEM_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("ATH", "MD"), ("CSEM", "MD"), no_case=True)
_ = cqt.plot_agency_magnitude_density(ATH_MD_CSEM_MD)

In [ ]:
ATH_MD_CSEM_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("ATH", "MD"), ("CSEM", "MD"), no_case=True)

regressor1 = cqt.CatalogueRegressor(ATH_MD_CSEM_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
CSEM_MD_DDA_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("CSEM", "MD"), ("DDA", "MD"), no_case=True)
_ = cqt.plot_agency_magnitude_density(CSEM_MD_DDA_MD)

In [ ]:
CSEM_MD_DDA_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("CSEM", "MD"), ("DDA", "MD"), no_case=True)

regressor1 = cqt.CatalogueRegressor(CSEM_MD_DDA_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
ISK_MD_DDA_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("ISK", "MD"), ("DDA", "MD"), no_case=True)
_ = cqt.plot_agency_magnitude_density(ISK_MD_DDA_MD)

In [ ]:
ISK_MD_DDA_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("ISK", "MD"), ("DDA", "MD"), no_case=True)

regressor1 = cqt.CatalogueRegressor(ISK_MD_DDA_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
ATH_MD_DDA_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("ATH", "MD"), ("DDA", "MD"), no_case=True)
_ = cqt.plot_agency_magnitude_density(ATH_MD_DDA_MD)

In [ ]:
ATH_MD_DDA_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("DDA", "MD"), ("ATH", "MD"), no_case=True)

regressor1 = cqt.CatalogueRegressor(ATH_MD_DDA_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
regressor1b = cqt.CatalogueRegressor(ATH_MD_DDA_MD)
results = regressor1b.run_regression("exponential", [1.0, 1.0, 1.0])
regressor1b.results.pprint()
regressor1b.plot_model(overlay=False)
print regressor1b.standard_deviation

In [ ]:
DDA_MD_HLW_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("DDA", "MD"), ("HLW", "MD"), no_case=True)
_ = cqt.plot_agency_magnitude_density(DDA_MD_HLW_MD)

In [ ]:
DDA_MD_HLW_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("DDA", "MD"), ("HLW", "MD"), no_case=True)

regressor1 = cqt.CatalogueRegressor(DDA_MD_HLW_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
regressor1 = cqt.CatalogueRegressor(DDA_MD_HLW_MD)
results = regressor1.run_regression("2segmentM4.3", [1.0, 1.0, 1.0])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
print regressor1.standard_deviation

In [ ]:
DDA_MD_HLW_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("ISC", "MB"), ("ATH", "MD"), no_case=True)

In [ ]:
DDA_MD_HLW_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("ISC", "MB"), ("ATH", "MD"), no_case=True)

regressor1 = cqt.CatalogueRegressor(DDA_MD_HLW_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
DDA_MD_HLW_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("ISC", "MB"), ("ISK", "MD"), no_case=True)

In [ ]:
DDA_MD_HLW_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("ISC", "MB"), ("ISK", "MD"), no_case=True)

regressor1 = cqt.CatalogueRegressor(DDA_MD_HLW_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
DDA_MD_HLW_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("NEIC", "MB"), ("ATH", "MD"), no_case=True)

In [ ]:
DDA_MD_HLW_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("NEIC", "MB"), ("ATH", "MD"), no_case=True)

regressor1 = cqt.CatalogueRegressor(DDA_MD_HLW_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
DDA_MD_HLW_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("NEIC", "MB"), ("ISK", "MD"), no_case=True)

In [ ]:
DDA_MD_HLW_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("NEIC", "MB"), ("ISK", "MD"), no_case=True)

regressor1 = cqt.CatalogueRegressor(DDA_MD_HLW_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
DDA_MD_HLW_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("NIC", "MW"), ("NIC", "MW"), no_case=True)

In [ ]:
DDA_MD_HLW_MD, query4_cat = cqt.get_agency_magnitude_pairs(db1, ("NEIC", "MS"), ("CSEM", "MS"), no_case=True)

regressor1 = cqt.CatalogueRegressor(DDA_MD_HLW_MD)
results = regressor1.run_regression("polynomial", [1.02, -0.18])
regressor1.results.pprint()
regressor1.plot_model(overlay=False)
s=regressor1.standard_deviation

print "Model standard deviation is"
print(s)

In [ ]:
DDA_MD_HLW_MD, query3_cat = cqt.get_agency_magnitude_pairs(db1, ("ISK", "MD"), ("NIC", "MW"), no_case=True)

In [ ]:
# origin rules

origin_rules = [
    ("1900/10/01 - 2015/10/01", ["ZUR_RMT","HRVD","NIC","CSEM","MED_RCMT","NEIC","ATH","ISK","ISC","IDC","DDA","ISCJB","IDC","MOS"])
]

In [ ]:
# Magnitude rules

def CSEM_MW_NIC_MW(magnitude):
    return magnitude

def CSEM_MW_NIC_MW_sigma(magnitude):
    return 0.0

def ISCJB_MS_CSEM_MS(magnitude):
    return 1.135*magnitude-0.765

def ISCJB_MS_CSEM_MS_sigma(magnitude):
    return 0.26369784

def NEIC_MS_CSEM_MS(magnitude):
    return 1.076*magnitude-0.458

def NEIC_MS_CSEM_MS_sigma(magnitude):
    return 0.0648769

def IDC_MS_CSEM_MS(magnitude):
    return 1.242*magnitude-1.087

def IDC_MS_CSEM_MS_sigma(magnitude):
    return 0.314273

def MOS_MS_CSEM_MS(magnitude):
    return 1.276*magnitude-1.328

def MOS_MS_CSEM_MS_sigma(magnitude):
    return 0.33142032

def ATH_MD_NIC_MW(magnitude):
    return 0.937*magnitude-0.224

def ATH_MD_NIC_MW_sigma(magnitude):
    return 0.32

def ISC_MB_IDC_MB(magnitude):
    return 0.801*magnitude+0.667

def ISC_MB_IDC_MB_sigma(magnitude):
    return 0.1563

def NIC_ML_NIC_MW(magnitude):
    return 0.767*magnitude+0.572

def NIC_ML_NIC_MW_sigma(magnitude):
    return 0.24669

def DDA_ML_NIC_ML(magnitude):
    return 0.789*magnitude+0.754

def DDA_ML_NIC_ML_sigma(magnitude):
    return 0.2613

def ISC_MS_CSEM_MS(magnitude):
    return 1.092*magnitude-0.586

def ISC_MS_CSEM_MS_sigma(magnitude):
    return 0.2254

def CSEM_MS_CSEM_MW(magnitude):
    return 0.867*magnitude+1.088

def CSEM_MS_CSEM_MW_sigma(magnitude):
    return 0.33265

def IDC_MB_NIC_MW(magnitude):
    return 0.751*magnitude+0.705

def IDC_MB_NIC_MW_sigma(magnitude):
    return 0.23665

def CSEM_ML_NIC_ML(magnitude):
    return 0.699*magnitude+1.234

def CSEM_ML_NIC_ML_sigma(magnitude):
    return 0.2567972

def DDA_MD_ATH_MD(magnitude):
    return 0.954*magnitude+0.327

def DDA_MD_ATH_MD_sigma(magnitude):
    return 0.232736

def ISK_ML_NIC_ML(magnitude):
    return 0.755*magnitude+0.931

def ISK_ML_NIC_ML_sigma(magnitude):
    return 0.2480

def ISK_MD_ATH_MD(magnitude):
    return 1.085*magnitude-0.147

def ISK_MD_ATH_MD_sigma(magnitude):
    return 0.2346155

def CSEM_MD_ATH_MD(magnitude):
    return 0.929*magnitude+0.286

def CSEM_MD_ATH_MD_sigma(magnitude):
    return 0.151265

In [ ]:
from eqcat.isc_homogenisor import MagnitudeConversionRule, DynamicHomogenisor, HomogenisorPreprocessor

In [ ]:
magnitude_rule_set = [
    MagnitudeConversionRule("HRVD", "MW", CSEM_MW_NIC_MW, CSEM_MW_NIC_MW_sigma),
    MagnitudeConversionRule("ZUR_RMT", "MW", CSEM_MW_NIC_MW, CSEM_MW_NIC_MW_sigma),
    MagnitudeConversionRule("MED_RCMT", "MW", CSEM_MW_NIC_MW, CSEM_MW_NIC_MW_sigma),
    MagnitudeConversionRule("CSEM", "MW", CSEM_MW_NIC_MW, CSEM_MW_NIC_MW_sigma),
    MagnitudeConversionRule("GCMT", "MW", CSEM_MW_NIC_MW, CSEM_MW_NIC_MW_sigma),
    MagnitudeConversionRule("NIC", "MW", CSEM_MW_NIC_MW, CSEM_MW_NIC_MW_sigma),
    MagnitudeConversionRule("NEIC", "MW", CSEM_MW_NIC_MW, CSEM_MW_NIC_MW_sigma),
    MagnitudeConversionRule("ISK", "MW", CSEM_MW_NIC_MW, CSEM_MW_NIC_MW_sigma),
    MagnitudeConversionRule("DDA", "MW", CSEM_MW_NIC_MW, CSEM_MW_NIC_MW_sigma),
    MagnitudeConversionRule("GII", "MW", CSEM_MW_NIC_MW, CSEM_MW_NIC_MW_sigma),
    MagnitudeConversionRule("BGS", "MW", CSEM_MW_NIC_MW, CSEM_MW_NIC_MW_sigma),
    MagnitudeConversionRule("CSEM", "MS", CSEM_MS_CSEM_MW, CSEM_MS_CSEM_MW_sigma),
    MagnitudeConversionRule("ISCJB", "MS", ISCJB_MS_CSEM_MS, ISCJB_MS_CSEM_MS_sigma),
    MagnitudeConversionRule("NEIC", "MS", NEIC_MS_CSEM_MS, NEIC_MS_CSEM_MS_sigma),
    MagnitudeConversionRule("IDC", "MS", IDC_MS_CSEM_MS, IDC_MS_CSEM_MS_sigma),
    MagnitudeConversionRule("ISCJB", "MS", ISCJB_MS_CSEM_MS, ISCJB_MS_CSEM_MS_sigma),
    MagnitudeConversionRule("NEIC", "MS", NEIC_MS_CSEM_MS, NEIC_MS_CSEM_MS_sigma),
    MagnitudeConversionRule("IDC", "MS", IDC_MS_CSEM_MS, IDC_MS_CSEM_MS_sigma),
    MagnitudeConversionRule("MOS", "MS", MOS_MS_CSEM_MS, MOS_MS_CSEM_MS_sigma),
    MagnitudeConversionRule("ATH", "MD", ATH_MD_NIC_MW, ATH_MD_NIC_MW_sigma),
    MagnitudeConversionRule("NIC", "ML", NIC_ML_NIC_MW, NIC_ML_NIC_MW_sigma),
    MagnitudeConversionRule("IDC", "MB", IDC_MB_NIC_MW, IDC_MB_NIC_MW_sigma),
    MagnitudeConversionRule("ISC", "MS", ISC_MS_CSEM_MS, ISC_MS_CSEM_MS_sigma),

    MagnitudeConversionRule("DDA", "MD", DDA_MD_ATH_MD, DDA_MD_ATH_MD_sigma),
    MagnitudeConversionRule("ISK", "MD", ISK_MD_ATH_MD, ISK_MD_ATH_MD_sigma),
    MagnitudeConversionRule("CSEM", "MD", CSEM_MD_ATH_MD, CSEM_MD_ATH_MD_sigma),
    MagnitudeConversionRule("DDA", "ML", DDA_ML_NIC_ML, DDA_ML_NIC_ML_sigma),
    MagnitudeConversionRule("ISC", "MB", ISC_MB_IDC_MB, ISC_MB_IDC_MB_sigma),
    MagnitudeConversionRule("CSEM", "ML", CSEM_ML_NIC_ML, CSEM_ML_NIC_ML_sigma),
    MagnitudeConversionRule("ISK", "ML", ISK_ML_NIC_ML, ISK_ML_NIC_ML_sigma),
    
]

magnitude_rules = [
    ("1900/10/01 - 2015/10/01", magnitude_rule_set)
]

In [ ]:
preprocessor = HomogenisorPreprocessor(rule_type="time")
preprocessed_catalogue = preprocessor.execute(catalogue, origin_rules, magnitude_rules)
homogenisor = DynamicHomogenisor(preprocessed_catalogue, logging=True)

In [ ]:
output_catalogue = homogenisor.homogenise(magnitude_rules, origin_rules)

In [ ]:
homogenisor.dump_log("homogenisation1_logfile.csv")
homogenisor.export_homogenised_to_csv("output_homoge_Marmaris.csv")

In [25]:
(2000 - 500)/12/10


Out[25]:
12

In [ ]: