Skip to content

Design Architecture

David Shi edited this page Apr 16, 2017 · 3 revisions

// TODO

apiworker.py -- the fetcher and database manager

This file serves as a worker thread that fetches and retrieves data from the respective sources and uploads them to the SQLite database stored locally. For Discharge and Gage Height, this serves as a cache to save time and speed up display. For Rainfall, this can be used additionally as a history.

We construct our USGS queries with string concatenation and construct/format the data with the ORM tool, pony.

grapher.py -- the visualizer

Using matplotlib, there's a simple plot() function that takes in two lists, one for X and one for Y points, plots them together and assumes order. There's additional parameters to adjust time frame and some other calculations to smooth out the points.

descriptor.py -- the text generator

To familiarize the data, we've included some analogies to help the user visualize the magnitude of a particular value. At one point, descriptor generated random text, but the design now has it generate all possible text with the front end cycling through the text randomly. To obtain the text, app.py includes a route /descriptor that returns json. The structure of the json is a dictionary with the keys as the type of description and the values as a list of all possible text associated with that key.