SieveComP
  • Home
  • Installation
  • TOML Schema

Tutorials

  • Python API Quickstart
  • SeisComP SQL Queries Introduction
    • 1. Making queries to the database
  • Optimizing Duplicates Search
  • Polygon validation
  • SieveComP: Advanced Usage
  • Generating TOML files with AI

Interfaces & Apps

  • Command Line Interface (CLI)
  • Streamlit Web Application
  • API Reference
SieveComP
  • Tutorials
  • SeisComP SQL Queries Introduction
  • Edit on KenethGarcia/SieveComP

This notebook was developed by Keneth Garcia. Source and license info are on GitHub.

In [2]:
Copied!
import pandas as pd
import pandas as pd

SeisComP SQL Queries Introduction¶

This notebook is an introduction to the SQL queries in SeisComP systems. It is intended to be used as a reference for the SieveComP package in order to build the SQL files received by its API. To further information about the SieveComP package, please refer to the GitHub repository.

1. Making queries to the database¶

Probably one of the most important aspects in the use of SieveComP is the ability to make queries to SeisComP databases. This is a very important aspect because it allows us to extract the data that we need to perform the analysis. In the package, the pymysql library is used to make queries to the database. You can read more about this library here.

Let's start by importing the library:

In [1]:
Copied!
import pymysql
import pymysql

pymsql requires the following parameters to connect to the database:

  • host: the host of the database
  • user: the user to connect to the database
  • password: the password of the user
  • database: the name of the database
  • port: the port of the database

In this case, if you define correctly the connection parameters to SieveComP, the package will be able to connect to the database and make queries. The following code snippet shows how to connect to the database:

In [3]:
Copied!
connection = pymysql.connect(host="host", # This is the IP address of the database
                             user="consulta", # This is the user to connect to the database
                             password="consulta", # This is the password of the user
                             database="seiscomp3", # This is the name of the database
                             port = 3306) # This is the port of the database
connection = pymysql.connect(host="host", # This is the IP address of the database user="consulta", # This is the user to connect to the database password="consulta", # This is the password of the user database="seiscomp3", # This is the name of the database port = 3306) # This is the port of the database

Now, with the connection established, let's continue with the queries to the database. Here we will use pandas to store the results of the queries in a DataFrame. You can read more about pandas here. In particular, the method read_sql allows us to read the results of a query directly into a DataFrame. This function requires as argument the query and the connection to the database. The queries can be a little bit complex, but in general, they are simple. For example, the following query retrieves the first 10 rows of the table event:

IMPORTANT: These examples shows how to use simple queries to retrieve data from SeisComP databases. You can use this or more complex queries to retrieve the data that you need in SieveComP. The queries can be stored in a SQL file and then read by the package to make the queries to the database. You can read more about this in the Quick Start Guide.

In [4]:
Copied!
first_rows = pd.read_sql("SELECT * FROM Event LIMIT 10", connection)
first_rows
first_rows = pd.read_sql("SELECT * FROM Event LIMIT 10", connection) first_rows
/tmp/ipykernel_195685/2234305722.py:1: UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy.
  first_rows = pd.read_sql("SELECT * FROM Event LIMIT 10", connection)
Out[4]:
_oid _parent_oid _last_modified preferredOriginID preferredMagnitudeID preferredFocalMechanismID type typeCertainty creationInfo_agencyID creationInfo_agencyURI creationInfo_author creationInfo_authorURI creationInfo_creationTime creationInfo_creationTime_ms creationInfo_modificationTime creationInfo_modificationTime_ms creationInfo_version creationInfo_used
0 29559 1 2019-11-06 21:21:24 Origin/20190909143640.863655.24590 not locatable None SGC scevent@seismo1.sgc.gov.co 2019-09-09 14:36:42 978907 2019-09-09 14:36:46 942007 1
1 29640 1 2020-07-02 02:21:00 Origin/20200702021350.171199.32126 Magnitude/20200702021355.68288.32141 earthquake known SGC scevent@seismo1.sgc.gov.co 2019-10-08 16:07:34 653869 2020-07-02 02:21:00 310350 1
2 29677 1 2019-11-06 21:21:26 Origin/20191012024903.583651.24617 Origin/20191012024903.583651.24617/netMag/M_MLr not locatable None SGC scevent@seismo1.sgc.gov.co 2019-10-12 02:49:06 714833 2019-10-12 02:49:11 951105 1
3 29692 1 2019-11-06 21:21:26 Origin/20190627042043.551154.67046 not locatable None SGC scevent@seismo1.sgc.gov.co 2019-06-27 04:20:45 741769 2019-06-27 04:21:00 653778 1
4 29714 1 2019-11-06 21:21:27 Origin/20191027142312.060071.28611 not locatable None SGC scevent@seismo1.sgc.gov.co 2019-10-27 14:23:13 833223 2019-10-27 14:23:18 117956 1
5 29753 1 2019-11-06 21:21:28 Origin/20190121225848.08277.28626 Origin/20190121225848.08277.28626/netMag/MLr_1 not locatable None SGC scevent@seismo1.sgc.gov.co 2019-01-21 22:59:47 348172 2019-01-21 22:59:59 819730 1
6 29833 1 2019-11-06 21:21:28 Origin/20190925222014.846412.29097 Magnitude/20190925222019.394472.29119 earthquake None SGC scevent@seismo1.sgc.gov.co 2019-09-25 22:20:37 985825 2019-09-25 22:20:45 965266 1
7 29959 1 2020-03-09 02:10:57 Origin/20200309020742.410254.29323 Origin/20200309020742.410254.29323/netMag/MLr_vmm earthquake None SGC scevent@seismo1.sgc.gov.co 2019-02-23 23:35:48 976405 2020-03-09 02:10:57 416999 1
8 29974 1 2019-11-06 21:21:29 Origin/20190105184418.332764.26121 not locatable None SGC scevent@seismo1.sgc.gov.co 2019-01-05 18:44:59 766620 2019-01-05 18:45:03 17305 1
9 29992 1 2019-11-06 21:21:30 Origin/20190624162317.1448.32471 not locatable None SGC scevent@seismo1.sgc.gov.co 2019-06-24 16:22:03 476884 2019-06-24 16:23:23 532405 1

And the last 20 rows of the table event, containing the last 20 events processed by analysts or automatic systems:

In [5]:
Copied!
last_rows = pd.read_sql("SELECT * FROM Event ORDER BY _oid DESC LIMIT 20", connection)
last_rows
last_rows = pd.read_sql("SELECT * FROM Event ORDER BY _oid DESC LIMIT 20", connection) last_rows
/tmp/ipykernel_195685/1991027600.py:1: UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy.
  last_rows = pd.read_sql("SELECT * FROM Event ORDER BY _oid DESC LIMIT 20", connection)
Out[5]:
_oid _parent_oid _last_modified preferredOriginID preferredMagnitudeID preferredFocalMechanismID type typeCertainty creationInfo_agencyID creationInfo_agencyURI creationInfo_author creationInfo_authorURI creationInfo_creationTime creationInfo_creationTime_ms creationInfo_modificationTime creationInfo_modificationTime_ms creationInfo_version creationInfo_used
0 633610554 1 2025-08-12 23:36:21 Origin/20250812233605.819527.46282 not locatable known SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:36:18 372107 2025-08-12 23:36:21 633731 1
1 633610419 1 2025-08-12 23:35:19 Origin/20250812233511.533994.53101 Magnitude/20250812233515.188878.53124 not locatable None SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:35:16 43346 2025-08-12 23:35:19 542466 1
2 633610346 1 2025-08-12 23:35:15 Origin/20250812233507.851261.46243 Origin/20250812233507.851261.46243/netMag/MLr_4 not locatable known SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:35:08 768591 2025-08-12 23:35:15 688798 1
3 633610253 1 2025-08-12 23:34:09 Origin/20250812233402.331887.46220 Origin/20250812233402.331887.46220/netMag/MLr_1 not locatable known SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:34:03 449447 2025-08-12 23:34:09 75962 1
4 633610135 1 2025-08-12 23:31:46 Origin/20250812233123.881697.52992 Magnitude/20250812233126.718427.53018 earthquake known SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:31:41 295673 2025-08-12 23:31:45 992078 1
5 633609982 1 2025-08-12 23:31:36 Origin/20250812233117.899044.46133 Origin/20250812233117.899044.46133/netMag/MLr_3 not locatable known SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:31:29 416582 2025-08-12 23:31:36 220675 1
6 633609837 1 2025-08-12 23:29:59 Origin/20250812232952.474829.46112 Origin/20250812232952.474829.46112/netMag/MLr_1 not locatable known SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:29:54 158534 2025-08-12 23:29:59 724817 1
7 633609767 1 2025-08-12 23:28:29 Origin/20250812232822.092534.52906 Magnitude/20250812232825.178991.52926 not locatable None SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:28:26 149250 2025-08-12 23:28:29 332250 1
8 633609587 1 2025-08-12 23:24:20 Origin/20250812232412.627409.52871 Magnitude/20250812232416.128604.52883 not locatable None SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:24:16 909874 2025-08-12 23:24:20 350769 1
9 633609513 1 2025-08-12 23:23:28 Origin/20250812232322.65917.52841 Magnitude/20250812232325.056193.52853 not locatable None SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:23:25 797413 2025-08-12 23:23:28 755931 1
10 633609417 1 2025-08-12 23:22:32 Origin/20250812232209.698501.45943 Magnitude/20250812232214.096975.45967 earthquake known SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:22:26 302192 2025-08-12 23:22:32 211794 1
11 633609270 1 2025-08-12 23:21:24 Origin/20250812232118.514376.52758 Magnitude/20250812232120.721067.52778 not locatable None SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:21:21 697504 2025-08-12 23:21:24 908941 1
12 633609145 1 2025-08-12 23:20:02 Origin/20250812231954.474169.52727 Magnitude/20250812231957.463885.52741 not locatable None SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:19:58 607393 2025-08-12 23:20:02 42574 1
13 633609004 1 2025-08-12 23:18:01 Origin/20250812231755.773849.52690 Magnitude/20250812231757.704439.52710 not locatable None SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:17:58 478245 2025-08-12 23:18:01 243127 1
14 633608772 1 2025-08-12 23:16:18 Origin/20250812231601.689435.45827 Magnitude/20250812231605.569104.45847 not locatable known SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:16:15 840408 2025-08-12 23:16:18 657927 1
15 633608608 1 2025-08-12 23:14:55 Origin/20250812231446.04069.52628 Magnitude/20250812231448.73383.52645 not locatable None SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:14:49 500165 2025-08-12 23:14:55 684699 1
16 633608320 1 2025-08-12 23:14:00 NLL.20250812231335.70038.45709 Magnitude/20250812231341.054428.45763 earthquake known SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:13:20 844229 2025-08-12 23:14:00 318372 1
17 633608057 1 2025-08-12 23:13:20 Origin/20250812231312.752314.52442 Magnitude/20250812231315.343325.52462 not locatable None SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:13:16 305714 2025-08-12 23:13:20 280922 1
18 633607686 1 2025-08-12 23:07:29 Origin/20250812230653.190767.45465 Magnitude/20250812230711.60938.45490 not locatable known SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:07:24 728743 2025-08-12 23:07:29 988957 1
19 633607572 1 2025-08-12 23:09:24 Origin/20250812230900.165647.52367 Magnitude/20250812230903.611898.52403 earthquake known SGC scevent@seismo1.sgc.gov.co 2025-08-12 23:05:51 61131 2025-08-12 23:09:24 554283 1

As you can notice, the table have the following columns:

In [6]:
Copied!
print([i for i in last_rows.columns])
print([i for i in last_rows.columns])
['_oid', '_parent_oid', '_last_modified', 'preferredOriginID', 'preferredMagnitudeID', 'preferredFocalMechanismID', 'type', 'typeCertainty', 'creationInfo_agencyID', 'creationInfo_agencyURI', 'creationInfo_author', 'creationInfo_authorURI', 'creationInfo_creationTime', 'creationInfo_creationTime_ms', 'creationInfo_modificationTime', 'creationInfo_modificationTime_ms', 'creationInfo_version', 'creationInfo_used']

But, how we can access to more global parameters, such as the uncertainty of the location of the events? This information is stored in the table Origin. The following query retrieves the last 10 rows of the table Origin:

In [7]:
Copied!
origin_example = pd.read_sql("SELECT * FROM Origin ORDER BY _oid DESC LIMIT 10", connection)
origin_example
origin_example = pd.read_sql("SELECT * FROM Origin ORDER BY _oid DESC LIMIT 10", connection) origin_example
/tmp/ipykernel_195685/2707394094.py:1: UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy.
  origin_example = pd.read_sql("SELECT * FROM Origin ORDER BY _oid DESC LIMIT 10", connection)
Out[7]:
_oid _parent_oid _last_modified time_value time_value_ms time_uncertainty time_lowerUncertainty time_upperUncertainty time_confidenceLevel time_pdf_variable_content ... creationInfo_agencyID creationInfo_agencyURI creationInfo_author creationInfo_authorURI creationInfo_creationTime creationInfo_creationTime_ms creationInfo_modificationTime creationInfo_modificationTime_ms creationInfo_version creationInfo_used
0 633610507 1 2025-08-12 23:36:07 2025-08-12 22:36:00 0 None None None None None ... SGC gerard@proc2 2025-08-12 23:36:05 819545 2025-08-12 23:36:07 251204 1
1 633610394 1 2025-08-12 23:35:16 2025-08-12 18:53:35 0 None None None None None ... SGC william@proc3 2025-08-12 23:35:11 534031 2025-08-12 23:35:15 893877 1
2 633610341 1 2025-08-12 23:35:08 2025-08-12 22:36:17 0 None None None None None ... SGC gerard@proc2 2025-08-12 23:35:07 851280 2025-08-12 23:35:08 746934 1
3 633610248 1 2025-08-12 23:34:03 2025-08-12 22:26:40 0 None None None None None ... SGC gerard@proc2 2025-08-12 23:34:02 331907 2025-08-12 23:34:03 346976 1
4 633610039 1 2025-08-12 23:31:41 2025-08-12 18:38:51 200000 None None None None None ... SGC william@proc3 2025-08-12 23:31:23 883261 2025-08-12 23:31:41 141161 1
5 633609936 1 2025-08-12 23:31:19 2025-08-12 22:06:18 0 None None None None None ... SGC gerard@proc2 2025-08-12 23:31:17 899062 2025-08-12 23:31:19 146814 1
6 633609832 1 2025-08-12 23:29:54 2025-08-12 22:05:22 0 None None None None None ... SGC gerard@proc2 2025-08-12 23:29:52 474852 2025-08-12 23:29:54 58514 1
7 633609742 1 2025-08-12 23:28:26 2025-08-12 18:34:07 0 None None None None None ... SGC william@proc3 2025-08-12 23:28:22 92571 2025-08-12 23:28:26 12143 1
8 633609574 1 2025-08-12 23:24:16 2025-08-12 18:37:08 0 None None None None None ... SGC william@proc3 2025-08-12 23:24:12 627447 2025-08-12 23:24:16 802933 1
9 633609500 1 2025-08-12 23:23:25 2025-08-12 18:28:20 0 None None None None None ... SGC william@proc3 2025-08-12 23:23:22 659207 2025-08-12 23:23:25 690683 1

10 rows × 82 columns

This table contains all the required columns to create an origin in SeisComP3. Usually the main columns used to analyze any event in SeisComP are the following:

  • _oid: the unique identifier of the origin
  • time_value: the origin time of the event
  • latitude_value: the latitude of the event
  • latitude_uncertainty: the uncertainty of the latitude
  • longitude_value: the longitude of the event
  • longitude_uncertainty: the uncertainty of the longitude
  • depth_value: the depth of the event
  • depth_uncertainty: the uncertainty of the depth
  • methodID: the method used to calculate the origin
  • earthModelID: the earth model used to calculate the origin
  • quality_associatedPhaseCount: the number of TOTAL associated phases
  • quality_usedPhaseCount: the number of used phases for localization
  • quality_usedStationCount: the number of used stations for localization
  • quality_azimuthalGap: the azimuthal gap of the localization
  • creationInfo_author: the author of the origin, i.e. the analyst who created the origin
  • creationInfo_creationTime: the creation time of the origin

WARNING: The table Origin contains all the origins without any filter. It means that, for a unique event, there can be multiple origins. Notice that some _oid have the same time value.

Similar to the Event and Origin tables, there is a lot of information stored in SeisComP databases, depending on the specific network design. You can see all the tables contained in the database by running the following query:

In [8]:
Copied!
# Print all tables contained in the database
tables = pd.read_sql("SHOW TABLES", connection)
tables
# Print all tables contained in the database tables = pd.read_sql("SHOW TABLES", connection) tables
/tmp/ipykernel_195685/3951849789.py:2: UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy.
  tables = pd.read_sql("SHOW TABLES", connection)
Out[8]:
Tables_in_seiscomp3
0 Accelerogram
1 Access
2 Amplitude
3 AmplitudeReference
4 ArclinkRequest
... ...
85 resumenSismos
86 shakemap
87 ultimosSismos
88 view_polarity
89 view_scmtv

90 rows × 1 columns

For example, the table Magnitude contains the magnitude information of the events. The following query retrieves the last 10 rows of the table Magnitude:

In [9]:
Copied!
magnitudes = pd.read_sql("SELECT * FROM Magnitude ORDER BY _oid DESC LIMIT 10", connection)
magnitudes
magnitudes = pd.read_sql("SELECT * FROM Magnitude ORDER BY _oid DESC LIMIT 10", connection) magnitudes
/tmp/ipykernel_195685/1352779174.py:1: UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy.
  magnitudes = pd.read_sql("SELECT * FROM Magnitude ORDER BY _oid DESC LIMIT 10", connection)
Out[9]:
_oid _parent_oid _last_modified magnitude_value magnitude_uncertainty magnitude_lowerUncertainty magnitude_upperUncertainty magnitude_confidenceLevel magnitude_pdf_variable_content magnitude_pdf_probability_content ... creationInfo_agencyID creationInfo_agencyURI creationInfo_author creationInfo_authorURI creationInfo_creationTime creationInfo_creationTime_ms creationInfo_modificationTime creationInfo_modificationTime_ms creationInfo_version creationInfo_used
0 633610527 633610507 2025-08-12 23:36:08 0.043623 0.0 None None None None None ... SGC scmag@seismo1.sgc.gov.co 2025-08-12 23:36:07 607204 None None 1
1 633610524 633610507 2025-08-12 23:36:08 -0.053877 0.0 None None None None None ... SGC scmag@seismo1.sgc.gov.co 2025-08-12 23:36:07 607095 None None 1
2 633610521 633610507 2025-08-12 23:36:08 -0.027677 0.0 None None None None None ... SGC scmag@seismo1.sgc.gov.co 2025-08-12 23:36:07 606894 None None 1
3 633610410 633610394 2025-08-12 23:35:16 -1.011828 0.0 None None None None None ... SGC william@proc3 2025-08-12 23:35:15 188899 None None 1
4 633610408 633610394 2025-08-12 23:35:16 -0.927104 0.0 None None None None None ... SGC william@proc3 2025-08-12 23:35:15 187969 None None 1
5 633610406 633610394 2025-08-12 23:35:16 -0.451504 0.0 None None None None None ... SGC william@proc3 2025-08-12 23:35:15 187482 None None 1
6 633610404 633610394 2025-08-12 23:35:16 -0.687704 0.0 None None None None None ... SGC william@proc3 2025-08-12 23:35:15 186984 None None 1
7 633610402 633610394 2025-08-12 23:35:16 -0.759004 0.0 None None None None None ... SGC william@proc3 2025-08-12 23:35:15 185870 None None 1
8 633610357 633610341 2025-08-12 23:35:09 0.700425 0.0 None None None None None ... SGC scmag@seismo1.sgc.gov.co 2025-08-12 23:35:09 15572 None None 1
9 633610354 633610341 2025-08-12 23:35:09 0.868525 0.0 None None None None None ... SGC scmag@seismo1.sgc.gov.co 2025-08-12 23:35:09 15388 None None 1

10 rows × 27 columns

Summary¶

As you can see, the queries to the database are very simple and can be used to retrieve the data that you need. You can use these queries to build the SQL files that are used by the SieveComP package to make queries to the database. You can also use these queries to retrieve the data that you need for your analysis.

For expert users, the limit is the sky, you can build complex queries to retrieve the data that you need. You can also use these queries to retrieve the data that you need for your analysis. For example, at SGC - RSNC we use the following query (added in the examples folder of the package):

SELECT
    Origin.time_value,  -- Event origin time
    POEv.publicID,  -- Event public ID
    Origin.depth_value,  -- Event depth
    Magnitude.magnitude_value,  -- Event magnitude
    Origin.quality_standardError,  -- Standard error of the origin time
    Origin.depth_uncertainty, -- Uncertainty of the event depth
    Origin.latitude_uncertainty,  -- Uncertainty of the event latitude
    Origin.longitude_uncertainty,  -- Uncertainty of the event longitude
    Origin.quality_associatedPhaseCount,  -- Number of associated phases
    Origin.quality_usedPhaseCount,  -- Number of used phases
    Origin.creationInfo_author,  -- Author of the origin creation info
    Origin.quality_usedStationCount,  -- Number of used stations
    Event.type AS event_type,  -- Event type (e.g., earthquake, explosion)
    Origin.creationInfo_agencyID,  -- Agency ID of the origin creation info
    EventDescription.text,  -- Event description text
    Origin.latitude_value,  -- Event latitude
    Origin.longitude_value,  -- Event longitude
    Magnitude.type AS magnitude_type,  -- Magnitude type (e.g., Mw, ML)
    Origin.methodID,  -- Method ID used for the origin
    Origin.earthModelID,  -- Earth model ID used for the origin
    Comment.text AS comment  -- Comment text (e.g., DESTACADO)
FROM Event AS EvMF
    LEFT JOIN PublicObject AS POEv ON EvMF._oid = POEv._oid
    LEFT JOIN PublicObject AS POOri ON EvMF.preferredOriginID = POOri.publicID
    LEFT JOIN Origin ON POOri._oid = Origin._oid
    LEFT JOIN PublicObject AS POMag ON EvMF.preferredMagnitudeID = POMag.publicID
    LEFT JOIN Magnitude ON Magnitude._oid = POMag._oid
    LEFT JOIN Event ON Event._oid= POEv._oid
    LEFT JOIN EventDescription ON EvMF._oid = EventDescription._parent_oid
    LEFT JOIN Comment ON Comment._parent_oid = EvMF._oid

as the general query to retrieve the information of the events in the SGC - RSNC SeisComP database. This query retrieves the information of the events, where:

  • EvMF is the Event table, which contains the main information about the event, such as the origin time, depth, magnitude, etc.
  • POEv is the PublicObject table, which contains the public ID of the event, which is used to link the Event table with the Origin and Magnitude tables.
  • POOri is the PublicObject table, which contains the public ID of the origin, which is used to link the Origin table with the Event table.
  • Origin is the Origin table, which contains the information about the origin of the event, such as the time, depth, latitude, longitude, etc.
  • POMag is the PublicObject table, which contains the public ID of the magnitude, which is used to link the Magnitude table with the Event table.
  • Magnitude is the Magnitude table, which contains the information about the magnitude of the event, such as the magnitude value, type, etc.
  • EventDescription is the EventDescription table, which contains the description of the event, such as the text description, etc.

In this SQL query, we are selecting the following fields:

  • Origin.time_value: the origin time of the event
  • POEv.publicID: the public ID of the event
  • Origin.depth_value: the depth of the event
  • Magnitude.magnitude_value: the magnitude of the event
  • Origin.quality_standardError: the standard error of the origin
  • Origin.depth_uncertainty: the uncertainty of the depth
  • Origin.latitude_uncertainty: the uncertainty of the latitude
  • Origin.longitude_uncertainty: the uncertainty of the longitude
  • Origin.quality_associatedPhaseCount: the number of associated phases
  • Origin.creationInfo_author: the author of the origin
  • Event.type: the type of the event
  • Origin.creationInfo_agencyID: the agency ID of the origin
  • EventDescription.text: the text description of the event
  • Origin.latitude_value: the latitude of the event
  • Origin.longitude_value: the longitude of the event
  • Magnitude.type: the type of the magnitude
  • Origin.methodID: the method ID of the origin
  • Origin.earthModelID: the earth model ID of the origin

and you can also add an origin time condition to the query, such that the origin time of the event is between a certain time range, at the last part of the query.

Finally, do not forget to close the connection to the database when you are done with your queries. This is important to avoid any issues with the database connection. You can do this by running the following code:

In [ ]:
Copied!
# Close the connection
connection.close()
# Close the connection connection.close()
Previous Next

Built with MkDocs using a theme provided by Read the Docs.
KenethGarcia/SieveComP « Previous Next »