Commit e2ad857e authored by Kris Vanneste's avatar Kris Vanneste
Browse files

Added 'selected' argument to get_events method of BelshakeDB.

Updated get_event and get_events methods of BelshakeDB to new 'is_selected' column in events table of database.

git-svn-id: https://svn.seismo.oma.be/svn/seismo/hazard/belshakelib/trunk@8906 40b490c5-b4d9-47cb-8714-9bef99b524d5
parent d8517757
......@@ -2655,12 +2655,13 @@ class BelshakeDB:
recs = list(self.query(table_clause, column_clause,
where_clause=where_clause))
if len(recs) == 1:
rec = {k: v for (k, v) in recs[0].items() if not k in ('operator', 'lastmod')}
rec = {k: v for (k, v) in recs[0].items()
if not k in ('operator', 'lastmod', 'is_selected')}
return Event(db=self, **rec)
def get_events(self, with_stations=None, with_data=None, with_imt=None,
event_type='', start_time=None, end_time=None,
Mmin=None, Mmax=None, Mtype='ML'):
Mmin=None, Mmax=None, Mtype='ML', selected=True):
"""
Retrieve all events from Belshake database
......@@ -2715,6 +2716,8 @@ class BelshakeDB:
where_clause.append('%s >= %f' % (Mtype, Mmin))
if Mmax:
where_clause.append('%s <= %f' % (Mtype, Mmax))
if selected is not None:
where_clause.append('is_selected = %d' % selected)
having_clause = []
group_clause = ''
if with_imt is not None:
......@@ -2755,7 +2758,8 @@ class BelshakeDB:
having_clause=having_clause, where_clause=where_clause,
group_clause=group_clause, order_clause=order_clause,
verbose=self.verbose):
rec = {k: v for (k, v) in rec.items() if not k in ('operator', 'lastmod')}
rec = {k: v for (k, v) in rec.items()
if not k in ('operator', 'lastmod', 'is_selected')}
events.append(Event(db=self, **rec))
return events
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment