Skip to content

Commit

Permalink
Added in functions for mapping detections, triggering tweets, and det…
Browse files Browse the repository at this point in the history
…ection/event location comparisons
  • Loading branch information
Megan C Hansen committed May 9, 2018
1 parent 084e55f commit beb011c
Show file tree
Hide file tree
Showing 16 changed files with 722 additions and 307 deletions.
20 changes: 10 additions & 10 deletions bin/event_trigger
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ def print_event(eventdict):
"""
Substitute function for postEvent (to be used for offline testing).
eventdict: Event dictionary with the following fields, all containing STRINGS:
- type Message type (usually 'add')
- id Event id
- source Event source ('us', 'ci', etc.)
- time Event time (20110415173724.011)
- lon Event longitude
- lat Event latitude
- depth Event depth
- mag Event magnitude
- loc Event location (FE Region?)
- uri Event location on USGS NEIC web site.
- type: Message type (usually 'add')
- id: Event id
- source: Event source ('us', 'ci', etc.)
- time: Event time (20110415173724.011)
- lon: Event longitude
- lat: Event latitude
- depth: Event depth
- mag: Event magnitude
- loc: Event location (FE Region?)
- uri: Event location on USGS NEIC web site.
Returns a tuple of (boolean, errormsg).
"""
fmt = '%s %s %s M%s (%s, %s) %s km "%s"'
Expand Down
3 changes: 2 additions & 1 deletion bin/eventmatch_trigger
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def match_event(conn, cur, eventdict):
"""
Checks detection_ext table for detection which matches time and location of event.
Updates event_match table with event and detection ids once a match is found.
conn: Postrgres database connection object.
cur: Postgres database cursor object.
eid: Unique ID string for event.
Expand Down Expand Up @@ -188,7 +189,7 @@ def call_matcher(options):
logger.error("Error caught while creating event dictionary", exc_info=True)

# Connect to database
prefix = 'testDB'
prefix = 'db'
try:
port = config.get('DATABASE',prefix+'_port')
user = config.get('DATABASE',prefix+'_user')
Expand Down
276 changes: 0 additions & 276 deletions bin/quake_mapper

This file was deleted.

2 changes: 1 addition & 1 deletion bin/tweet_fetcher
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ if __name__ == '__main__':
logger = create_logger(logdict)

# Connect to test database
prefix = 'testdb'
prefix = 'db'
port = config.get('DATABASE', prefix+'_port')
user = config.get('DATABASE', prefix+'_user')
dbname = config.get('DATABASE', prefix+'_name')
Expand Down
5 changes: 4 additions & 1 deletion bin/tweet_trigger
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def add_tweet_to_db(eventdict, tweetstring):

try:
cur.execute("insert into tweet_audit (event_id, event_lat, event_lon, event_time, " + \
"magnitude, tweet_time, tweet_string) values (%s, %s, %s, %s, %s, %s, %s);",
"magnitude, tweet_time, tweet_text) values (%s, %s, %s, %s, %s, %s, %s);",
(eid, lat, lon, eventtime, mag, utcnow, tweetstring))
logger.info("Successfully inserted tweet info for event %s into tweet_audit table.", eid)
except Exception as e:
Expand Down Expand Up @@ -310,6 +310,9 @@ def call_tweeter(options):
# If event code is not same as preferred event ID, exit application
if options['code'].lower() != options['preferredID'].lower():
logger.info("Ignoring non-preferred ID '%s'. Exiting", options['code'])
info_string = "Event code is %s, preferred event ID is %s" % (
options['code'].lower(), options['prefferedID'].lower())
logger.info(info_string)
close_all()
sys.exit(0)

Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
- blas=1.1
- bleach=2.0.0
- ca-certificates=2017.11.5
- cartopy=0.16.0
- certifi=2017.11.5
- cycler=0.10.0
- decorator=4.1.2
Expand Down
1 change: 1 addition & 0 deletions environment_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
- blas=1.1
- bleach=2.0.0
- ca-certificates=2017.11.5
- cartopy=0.16.0
- certifi=2017.11.5
- cycler=0.10.0
- dbus=1.10.22
Expand Down
1 change: 1 addition & 0 deletions environment_osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- blas=1.1
- bleach=2.0.0
- ca-certificates=2017.11.5
- cartopy=0.16.0
- certifi=2017.11.5
- cycler=0.10.0
- decorator=4.1.2
Expand Down
12 changes: 12 additions & 0 deletions exampleConfigFiles/map_funcs_config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[SETUP]
# logfile setup
# logging_level is highest message level logger will print in log (i.e. info, warning, error)
logging_level = info
logfile = map_funcs.log

[DATABASE]
db_ip = mydb_ip
db_port = mydb_portnum
db_name = mydb_dbname
db_user = mydb_user
db_password = mydb_password
13 changes: 13 additions & 0 deletions images/images.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{"__comment__": "JSON file specifying the image to use for a given type/name and resolution. Read in by cartopy.mpl.geoaxes.read_user_background_images.",
"satellite_small": {
"__comment__": "Blue Marble Next Generation, July ",
"__source__": "https://neo.sci.gsfc.nasa.gov/view.php?datasetId=BlueMarbleNG-TB",
"__projection__": "PlateCarree",
"high": "satellite_small.jpg"},

"satellite_large": {
"__comment__": "VisibleEarth BlueMarble",
"__source__": "https://www.h-schmidt.net/map/download.html",
"__projection__": "PlateCarree",
"high": "satellite_large.jpg"}
}
Binary file added images/satellite_large.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/satellite_small.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit beb011c

Please sign in to comment.