NordicSearch¶
This module contains all commands for searching the database for events with given criteria. The most important function here is searchNordic and most other functions and classes are here just to support it.
Functions and Classes¶
-
class
BetweenValues(search_type, value_lower, value_upper)¶ Command for determining if a value falls exactly between the given values.
Variables: -
getQuery()¶ Functiong for creating the query for the command
-
-
class
Command(command_type, search_type)¶ Class for command that is returned by string2Command.
Variables: command_type (int) – Type of command. -
getQuery()¶ Functiong for creating the query for the command
-
-
class
ExactlyValue(search_type, value)¶ Command for determining if the value is exactly the given value.
Variables: -
getQuery()¶ Functiong for creating the query for the command
-
-
class
NordicSearch¶ Class for searching events from database with multiple criteria.
-
addSearchBetween(search_type, search_val_low, search_val_upp)¶ Add SearchBetween criteria to the NordicSearch object.
Parameters:
-
addSearchExactly(search_type, search_val)¶ Add SearchExactly criteria to the NordicSearch object.
Parameters:
-
addSearchOver(search_type, search_val)¶ Add SearchOver criteria to the NordicSearch object.
Parameters:
-
addSearchUnder(search_type, search_val)¶ Add SearchUnder criteria to the NordicSearch object.
Parameters:
-
clear()¶ Clear all criteria from NordicSearch object
-
getCriteriaAmount()¶ Return the amount of criteria in the NordicSearch
-
getCriteriaString()¶ Get all criteria in a formatted string for printing purposes.
-
searchEventIdAndDate(db_conn=None)¶ Search for all event ids and their dates that fit to the criteria given to the NordicSearch and return them
Returns: a list of event_ids and dates
-
searchEventIds(db_conn=None)¶ Search for all event ids that fit to the criteria given to the NordicSearch and return them.
Returns: a list of event ids
-
searchEventRoots(db_conn=None)¶ Search for event root ids that have events that fit to the criteria given to the NordicSearch and return them. :returns: a list of event root ids
-
searchEvents(db_conn=None)¶ Search for all the events that fit to the criteria given to the NordicSearch and return them.
Returns: array of NordicEvent objects
-
-
class
OverValue(search_type, value)¶ Command for determining if the value is over or equal to the Commands value
Variables: -
getQuery()¶ Functiong for creating the query for the command
-
-
class
UnderValue(search_type, value)¶ Command for determining if the value is lower or equal to the Commands value
Variables: -
getQuery()¶ Functiong for creating the query for the command
-
-
searchEvents(latitude=None, longitude=None, distance=100.0, magnitude=-9.0, magnitude_diff=2.0, date=None, date_diff=-9.0)¶ Search all events close to a location close to a point.
Parameters: - latitude (float) – latitude coordinate of the point
- longitude (float) – longitude coordinate of the point
- distance (float) – distance from the point in kilometers
- magnitude (float) – magnitude of the event
- magnitude_diff (float) – maximum allowed magnitude difference of the event. Set negative value for searching exactly for a magnitude
- date (date) – date of the event
Paran float date_diff: maximum allowed date difference from date in days. Set negative value for searching exactly at the date
-
searchSameEvents(nordic_event)¶ Function for searching and returning all events that are the same compared to the event given by the user.
Parameters: nordic_event (NordicEvent) – Event for which the search is done for Returns: List of NordicEventthat are indentical to the event
-
searchSimilarEvents(nordic_event, time_diff=5, latitude_diff=50, longitude_diff=50, magnitude_diff=0.2)¶ Function for searching and returning all events that are considered similar to the event given by user.
Default conditions for similarity:
-Events must occur not more than 5 seconds apart from each other -Events must be 0.2 deg maximum apart from each other in latitude, and 0.5 deg in longitude -Events must have magnitude difference of 0.5 maximumParameters: - nordic_event (NordicEvent) – Event for which the search is done for
- time_diff (float) – maximum time difference in seconds
- latitude_diff (float) – maximum latitude difference in degrees
- longitude_diff (float) – maximum longitude difference in degrees
- magnitude_diff (float) – maximum magnitude difference
Returns: Array of
NordicEventthat fit to the search criteria