seisnn.sql.Client¶
- class seisnn.sql.Client(database, echo=False)[source]¶
Bases:
object
Client for sql database
- __init__(database, echo=False)[source]¶
Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(database[, echo])Initialize self.
add_inventory
(geom)Add geometry data from geometry dict.
add_pick
(time, station, phase, tag, snr)add_sfile_events
(events, tag[, …])Add event data form catalog.
clear_table
(table)Delete full table from database.
get_distinct_items
(table, column)Returns a query of unique items.
get_events
([from_time, to_time, west, east, …])Returns query from event table.
get_exclude_items
(table, column, exclude)Returns a query of exclude items.
get_inventories
([station, network])Returns query from inventory table.
get_matched_list
(wildcard_list, table, column)Gets wildcard match list in column.
get_picks
([from_time, to_time, station, …])Returns query from pick table.
get_table_class
(table)Returns related class from dict.
get_tfrecord
([network, station, path, …])Returns query from tfrecord table.
get_waveform
([from_time, to_time, station, …])Returns query from waveform table.
read_GDMSstations
(nsta)read_hyp
(hyp, network)Add geometry data from .HYP file.
read_kml_placemark
(kml, network)Add geometry data from .KML file.
read_tfrecord_header
(tfr_list)Sync header into SQL database from tfrecord dataset.
remove_duplicates
(table, match_columns)Removes duplicates data in given table.
replace_sql_wildcard
(string)Replaces posix wildcard characters to SQL wildcard characters.
Provide a transactional scope around a series of operations.
- add_inventory(geom)[source]¶
Add geometry data from geometry dict.
- Parameters
geom (dict) – Geometry dict.
network (str) – Output network name.
- add_sfile_events(events, tag, remove_duplicates=True)[source]¶
Add event data form catalog.
- Parameters
catalog (str) – Catalog name.
tag (str) – Pick tag.
remove_duplicates (bool) – Removes duplicates in event table.
- get_distinct_items(table, column)[source]¶
Returns a query of unique items.
- Parameters
table (str) – Target table name.
column (str) – Target column name.
- Return type
list
- Returns
A list of query.
- get_events(from_time=None, to_time=None, west=None, east=None, south=None, north=None, from_depth=None, to_depth=None)[source]¶
Returns query from event table.
- Parameters
from_time (str) – From time.
to_time (str) – To time.
west – From West.
east – To East.
south – From South.
north – To North.
from_depth – From depth.
to_depth – To depth.
- Return type
sqlalchemy.orm.query.Query
- Returns
A Query.
- get_exclude_items(table, column, exclude)[source]¶
Returns a query of exclude items.
- Parameters
table (str) – Target table name.
column (str) – Target column name.
exclude – Exclude list.
- Return type
list
- Returns
A list of query.
- get_inventories(station=None, network=None)[source]¶
Returns query from inventory table.
- Parameters
station (str) – Station name.
network (str) – Network name.
- Return type
sqlalchemy.orm.query.Query
- Returns
A Query.
- get_matched_list(wildcard_list, table, column)[source]¶
Gets wildcard match list in column.
- Parameters
wildcard_list (str/list) –
table (str) – Table name.
column (str) – Column name.
- Returns
- get_picks(from_time=None, to_time=None, station=None, phase=None, tag=None)[source]¶
Returns query from pick table.
- Parameters
from_time (str) – From time.
to_time (str) – To time.
station (str) – Station name.
phase (str) – Phase name.
tag (str) – Catalog tag.
- Return type
sqlalchemy.orm.query.Query
- Returns
A Query.
- static get_table_class(table)[source]¶
Returns related class from dict.
- Parameters
table (str) – Keywords: inventory, event, pick, waveform.
- Returns
SQL table class.
- get_tfrecord(network=None, station=None, path=None, from_date=None, to_date=None, column=None)[source]¶
Returns query from tfrecord table.
- Parameters
station (str) – Station name.
- Return type
sqlalchemy.orm.query.Query
- Returns
A Query.
- get_waveform(from_time=None, to_time=None, station=None, tfrecord=None)[source]¶
Returns query from waveform table.
Note
If from_time or to_time is within the waveform, the waveform will be select.
- Parameters
from_time (str) – Get which waveform endtime after from_time.
to_time (str) – Get which waveform starttime after to_time.
station (str/list) – Station name.
tfrecord (str/list) – TFRecord path.
- Return type
sqlalchemy.orm.query.Query
- Returns
A Query.
- read_hyp(hyp, network)[source]¶
Add geometry data from .HYP file.
seisnn.io.read_hyp wrap up.
- Parameters
hyp (str) – STATION0.HYP file.
network (str) – Output network name.
- read_kml_placemark(kml, network)[source]¶
Add geometry data from .KML file.
seisnn.io.read_kml_placemark wrap up.
- Parameters
kml (str) – Google Earth .KML file.
network (str) – Output network name.
- read_tfrecord_header(tfr_list)[source]¶
Sync header into SQL database from tfrecord dataset.
- Parameters
tfr_list – TFRecord list.
- remove_duplicates(table, match_columns)[source]¶
Removes duplicates data in given table.
- Parameters
table (str) – Target table.
match_columns (list) – List of column names. If all columns matches, then marks it as a duplicate data.