Skip to content
Snippets Groups Projects
Commit e639a2c7 authored by Travis Rivers's avatar Travis Rivers Committed by Jeremy M Fee
Browse files

fixing a mess

parent 9db4fbeb
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ class IMFJSONWriter(object):
formatted_timeseries = json.dumps(
file_dict, ensure_ascii=True, separators=(",", ":")
).encode("utf8")
out.write(str(formatted_timeseries))
out.write(formatted_timeseries)
def _format_data(self, timeseries, channels, stats):
"""Format all data lines.
......
......@@ -3,6 +3,7 @@ from __future__ import absolute_import, unicode_literals
import os
import flask
from . import data
from . import database
from . import login
from . import session
......@@ -17,6 +18,7 @@ def create_app():
database.init_app(app)
login.init_app(app)
session.init_app(app)
data.init_app(app)
# add default route
@app.route("/")
......
from datetime import datetime
from flask import Blueprint, Flask, jsonify, render_template, request, Response
from obspy import UTCDateTime
from geomagio.edge import EdgeFactory
from geomagio.iaga2002 import IAGA2002Writer
from geomagio.imfjson import IMFJSONWriter
blueprint = Blueprint('data', __name__)
def init_app(app: Flask):
global blueprint
app.register_blueprint(blueprint)
@blueprint.route('/data', methods=['GET'])
def get_data():
query_params = request.args
url = request.url
if not query_params:
return render_template('usage.html')
query = parse_query(query_params)
timeseries = get_timeseries(query)
return format_timeseries(timeseries, query)
def parse_query(query):
"""Parse request arguments into a set of parameters
Parameters
----------
query: Immutable Dict
request.args object
Returns
-------
params: dictionary
query parameters dictionary
Raises
------
WebServiceException
if any parameters are not supported.
"""
params = {}
# Get end time
if not query.get('endtime'):
now = datetime.now()
today = UTCDateTime(
now.year,
now.month,
now.day,
0)
end_time = today
params['End Time'] = end_time
else:
params['End Time'] = UTCDateTime(query.get('endtime'))
# Get start time
if not query.get('starttime'):
start_time = UTCDateTime(params['End Time']) - (24 * 60 * 60 - 1)
params['Start Time'] = UTCDateTime(start_time)
else:
params['Start Time'] = UTCDateTime(query.get('starttime'))
# Get sampling period
params['Sampling Period'] = query.get('sampling_period')
if params['Sampling Period'] == '1':
params['Sampling Period'] = 'second'
if params['Sampling Period'] == '60':
params['Sampling Period'] = 'minute'
# Get format
if query.get('format'):
params['Format'] = query.get('format')
else:
params['Format'] = 'iaga2002'
# Get observatory
params['Observatory'] = query.get('observatory')
# Get channels
channels = query.get('channels').split(',')
params['Channels'] = channels
# Get data type
params['Type'] = query.get('type')
validate_parameters(params)
return params
def validate_parameters(params):
"""Verify that parameters are valid.
Parameters
----------
params: dict
dictionary of parsed query parameters
Raises
------
WebServiceException
if any parameters are not supported.
"""
valid_data_types = ['variation', 'adjusted',
'quasi-definitive', 'definitive']
valid_formats = ['iaga2002', 'json']
valid_sampling_periods = ['second', 'minute']
if len(params['Channels']) > 4 and params['Format'] == 'iaga2002':
raise WebServiceException(
'No more than four elements allowed for Iaga2002 format.')
if params['Start Time'] > params['End Time']:
raise WebServiceException('Start time must be before end time.')
if params['Type'] not in valid_data_types:
raise WebServiceException('Bad data type: ' + params['Type'] +
'. Valid values are: ' + ', '.join(valid_data_types) + '.')
if params['Sampling Period'] not in valid_sampling_periods:
raise WebServiceException('Bad sampling_period value: ' + params['Sampling Period'] +
'. Valid values are: 1, 60.')
if params['Format'] not in valid_formats:
raise WebServiceException('Bad format value: ' + params['Format'] +
'. Valid values are: ' + ', '.join(valid_formats))
def get_timeseries(query):
"""
Parameters
----------
query: dict
dictionary of parsed query parameters
Returns
-------
obspy.core.Stream
timeseries object with requested data
"""
factory = EdgeFactory()
timeseries = factory.get_timeseries(
query['Start Time'], query['End Time'], query['Observatory'], query['Channels'],
query['Type'], query['Sampling Period'])
return timeseries
def format_timeseries(timeseries, query):
"""Formats timeseries into JSON or IAGA data
Parameters
----------
obspy.core.Stream
timeseries object with requested data
query: dict
dictionary of parsed query parameters
Returns
-------
unicode
IAGA2002 or JSON formatted string.
"""
if query['Format'] == 'json':
json_output = IMFJSONWriter.format(timeseries, query['Channels'])
return json_output
else:
iaga_output = IAGA2002Writer.format(timeseries, query['Channels'])
iaga_output = Response(iaga_output, mimetype="text / plain")
return iaga_output
class WebServiceException(Exception):
"""Base class for exceptions thrown by web services."""
pass
......@@ -41,8 +41,13 @@ class Metadata(db.Model):
comment = 'automatic adjusted matrix',
priority = 1,
value = {
<<<<<<< HEAD
'parameters' => {'x': 1, 'y': 2, 'z': 3}
'matrix' => [ ... ]
=======
'parameters': {'x': 1, 'y': 2, 'z': 3}
'matrix': [ ... ]
>>>>>>> master
}
)
```
......
p {
font-weight: bold;
}
/* Import your custom theme */
.hazdev-site-header {
background-color: #1b3c43;
height: 100px;
position: relative;
}
/* position usgs logo over background. */
.hazdev-site-header > .hazdev-site-logo {
/* bottom padding of 0 + overflow: hidden + image height 140% = hide "science for a changing world" on small screens. */
display: block;
height: 30px;
left: 0;
overflow: hidden;
padding: 14px 14px 0;
position: absolute;
top: 0;
}
.hazdev-site-header > .hazdev-site-logo > img {
height: 140%;
border: none;
}
hazdev-template-cooperator {
display: none;
height: 100%;
left: 136px;
overflow: hidden;
padding-left: 1em;
position: absolute;
}
/* visually hide navigation jumplink. */
.hazdev-jumplink-navigation {
display: block;
left: -9999px;
position: absolute;
top: 0;
}
@media screen and (min-width: 768px) {
/* make banner larger on large screens. */
/* also adjust size of usgs logo */
/*width: 157px;
*/
.hazdev-site-header {
background-color: #1b3c43;
background-position: 186px 0;
background-repeat: no-repeat;
background-size: auto 100%;
height: 90px;
/* 1.5 line-height on 1em text, with 0.25em padding top/bottom */
margin-bottom: 1em;
}
.hazdev-site-header > .hazdev-site-logo {
height: 100%;
padding: 0;
}
.hazdev-site-header > .hazdev-site-logo > img {
height: 100%;
padding: 1em;
}
hazdev-template-cooperator {
background-image: none;
display: block;
left: 186px;
padding-left: 0;
}
}
@media print {
/** Only show USGS logo when printing, requires background colors... */
[role='banner'] {
background-color: #fff;
height: 0;
margin: 0;
padding: 0;
visibility: hidden;
width: 100%;
}
[role='banner']:after {
color: #333;
content: 'U.S. Geological Survey - National Geomagnetism Program';
display: block;
visibility: visible;
}
[role='main'] {
padding: 1em 0 0 !important;
}
}
.site-commonnav {
display: block;
font-size: 0.88em;
margin: 4em 0 0;
padding: 2em 1em;
position: relative;
}
.site-commonnav > .hazdev-site-logo {
display: block;
height: 56px;
margin-bottom: 2em;
width: 152px;
}
.site-commonnav > .hazdev-site-logo > img {
height: 100%;
border: none;
}
.interior-nav,
.common-nav,
.social-nav,
.space-between {
margin: 1em 0 0;
}
.interior-nav > a,
.common-nav > a,
.social-nav > a,
.space-between > a {
color: #fff;
display: inline-block;
margin: 0.5em 1em 0.5em 0;
}
.interior-nav > a:hover,
.common-nav > a:hover,
.social-nav > a:hover,
.space-between > a:hover,
.interior-nav > a:visited,
.common-nav > a:visited,
.social-nav > a:visited,
.space-between > a:visited,
.interior-nav > a:active,
.common-nav > a:active,
.social-nav > a:active,
.space-between > a:active {
color: #fff;
}
@media print {
.site-commonnav {
display: none;
}
}
.space-between {
border-top: 1px solid #eee;
}
@media screen and (min-width: 1000px) {
.space-between {
display: flex;
justify-content: space-between;
}
}
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="2353.326px" height="869.157px" viewBox="40.233 28.698 2353.326 869.157"
enable-background="new 40.233 28.698 2353.326 869.157" xml:space="preserve">
<g>
<g>
<path fill="#FFFFFF" d="M1135.755,38.678v425.73c0,89.8-50.726,184.595-203.721,184.595c-138.031,0-204.552-71.51-204.552-184.595
V38.678h125.561v417.414c0,74.001,31.595,103.109,77.328,103.109c54.881,0,79.823-36.592,79.823-103.109V38.678H1135.755z"/>
<path fill="#FFFFFF" d="M1339.936,649.003c-155.496,0-184.599-91.467-177.949-195.406h125.556
c0,57.382,2.496,105.603,71.52,105.603c42.403,0,63.19-27.445,63.19-68.182c0-108.098-252.779-114.749-252.779-293.523
c0-93.96,44.903-168.798,197.898-168.798c122.23,0,182.931,54.881,174.619,180.441h-122.234c0-44.905-7.483-90.638-58.209-90.638
c-40.734,0-64.849,22.452-64.849,64.027c0,113.918,252.772,103.938,252.772,292.686
C1549.471,630.71,1435.551,649.003,1339.936,649.003z"/>
<path fill="#FFFFFF" d="M2184.02,649.003c-155.49,0-184.587-91.467-177.94-195.406h125.56c0,57.382,2.493,105.603,71.508,105.603
c42.403,0,63.196-27.445,63.196-68.182c0-108.098-252.775-114.749-252.775-293.523c0-93.96,44.896-168.798,197.896-168.798
c122.225,0,182.93,54.881,174.618,180.441h-122.233c0-44.905-7.483-90.638-58.207-90.638c-40.744,0-64.859,22.452-64.859,64.027
c0,113.918,252.778,103.938,252.778,292.686C2393.559,630.71,2279.643,649.003,2184.02,649.003z"/>
<path fill="#FFFFFF" d="M1784.048,415.29h73.913v132.473l-6.15,2.289c-19.133,6.652-41.58,11.645-62.363,11.645
c-71.511,0-89.805-33.264-89.805-221.18c0-116.414,0-222.015,78.154-222.015c60.824,0,73.641,41.034,74.764,90.638h125.063
c1.013-116.497-74.022-180.441-192.34-180.441c-205.374,0-212.865,153.831-212.865,305.165
c0,227.834,24.701,316.231,235.906,316.231c48.979,0,126.957-11.053,162.979-20.906c2.161-0.592,6.061-2.982,6.061-6.088
c0-16.369,0-298.385,0-298.385h-193.316V415.29L1784.048,415.29z"/>
</g>
<g>
<path fill="#FFFFFF" d="M71.261,823.148c-1.235,4.83-2.007,9.451-1.25,12.805c0.962,3.355,3.755,5.039,9.63,5.039
s11.714-3.779,13.231-10.91c4.774-22.457-48.337-17.414-41.154-51.201c4.862-22.871,28.995-29.793,48.089-29.793
c20.142,0,36.345,9.65,29.805,32.516h-28.956c1.562-7.344,1.661-11.742-0.034-13.633c-1.491-1.891-3.916-2.305-7.066-2.305
c-6.503,0-10.964,4.193-12.483,11.322c-3.567,16.793,48.65,15.945,41.426,49.939c-3.928,18.465-21.98,32.316-46.53,32.316
c-25.808,0-41.631-6.508-33.665-36.096H71.261L71.261,823.148z"/>
<path fill="#FFFFFF" d="M197.855,788.951c3.344-15.732,0.475-20.98-8.758-20.98c-12.589,0-16.003,11.113-20.684,33.154
c-6.873,32.309-5.617,39.232,5.294,39.232c9.234,0,15.424-8.387,18.367-22.242h29.587c-6.112,28.746-24.271,41.131-51.967,41.131
c-38.189,0-38.274-23.293-31.226-56.449c6.153-28.949,15.616-53.709,54.645-53.709c27.277,0,40.218,12.172,34.329,39.863H197.855z
"/>
<path fill="#FFFFFF" d="M258.718,857.146h-29.586l22.528-105.961h29.584L258.718,857.146z M289.914,710.39l-4.951,23.289H255.38
l4.95-23.289H289.914z"/>
<path fill="#FFFFFF" d="M1643.192,857.146h-29.579l22.526-105.961h29.582L1643.192,857.146z M1674.395,710.39l-4.951,23.289
h-29.583l4.949-23.289H1674.395z"/>
<path fill="#FFFFFF" d="M315.804,808.888c-2.677,12.586-6.271,31.469,6.735,31.469c10.491,0,14.729-10.068,16.605-18.883h30.003
c-2.87,11.545-8.656,20.98-17.172,27.492c-8.306,6.5-19.6,10.279-33.451,10.279c-38.186,0-38.271-23.293-31.223-56.449
c6.154-28.949,15.615-53.709,54.643-53.709c39.869,0,38.785,25.805,30.509,59.801H315.804z M346.394,792.306
c2.185-10.281,5.729-24.963-8.332-24.963c-13.636,0-16.819,15.945-18.739,24.963H346.394z"/>
<path fill="#FFFFFF" d="M428.255,761.886h0.419c7.884-9.449,16.569-12.799,27.693-12.799c14.054,0,24.651,8.391,21.53,23.076
l-18.066,84.982h-29.583l15.523-73.02c2.003-9.447,1.887-16.785-7.554-16.785c-9.442,0-12.683,7.338-14.688,16.785l-15.523,73.02
H378.42l22.526-105.961h29.584L428.255,761.886z"/>
<path fill="#FFFFFF" d="M545.704,788.951c3.343-15.732,0.473-20.98-8.761-20.98c-12.592,0-16.004,11.113-20.688,33.154
c-6.868,32.309-5.612,39.232,5.298,39.232c9.236,0,15.425-8.387,18.366-22.242h29.587c-6.113,28.746-24.269,41.131-51.968,41.131
c-38.188,0-38.275-23.293-31.228-56.449c6.157-28.949,15.618-53.709,54.645-53.709c27.277,0,40.219,12.172,34.329,39.863H545.704z
"/>
<path fill="#FFFFFF" d="M613.292,808.888c-2.677,12.586-6.273,31.469,6.736,31.469c10.489,0,14.73-10.068,16.604-18.883h30.005
c-2.87,11.545-8.655,20.98-17.173,27.492c-8.307,6.5-19.603,10.279-33.451,10.279c-38.188,0-38.273-23.293-31.224-56.449
c6.153-28.949,15.613-53.709,54.64-53.709c39.868,0,38.789,25.805,30.513,59.801H613.292z M643.884,792.306
c2.184-10.281,5.727-24.963-8.333-24.963c-13.639,0-16.816,15.945-18.734,24.963H643.884z"/>
<path fill="#FFFFFF" d="M794.142,729.271c-11.779-0.836-15.277,3.777-17.556,14.482l-2.103,7.432h13.848l-3.879,18.252h-13.849
l-18.646,87.709h-29.583l18.644-87.709h-13.221l3.882-18.252h13.431c5.94-26.502,11.266-41.219,42.646-41.219
c3.567,0,6.876,0.207,10.402,0.424L794.142,729.271z"/>
<path fill="#FFFFFF" d="M784.778,802.796c6.154-28.949,15.614-53.709,54.642-53.709c39.028,0,37.961,24.76,31.807,53.709
c-7.048,33.156-17.035,56.449-55.225,56.449C777.815,859.246,777.731,835.953,784.778,802.796z M841.994,801.125
c4.687-22.041,6-33.154-6.586-33.154c-12.591,0-16.006,11.113-20.688,33.154c-6.868,32.309-5.612,39.232,5.298,39.232
C830.926,840.357,835.126,833.433,841.994,801.125z"/>
<path fill="#FFFFFF" d="M924.263,751.185l-2.897,13.637h0.421c8.043-12.17,18.872-15.734,30.832-15.734l-5.62,26.434
c-25.664-1.672-29.295,13.432-31.523,23.92l-12.269,57.707h-29.583l22.527-105.961h28.112V751.185z"/>
<path fill="#FFFFFF" d="M1065.27,837.421c-1.389,6.506-1.977,13.221-2.729,19.725h-27.484l1.729-14.059h-0.421
c-8.615,10.91-18.33,16.158-31.131,16.158c-20.563,0-24.859-15.318-20.938-33.787c7.45-35.035,34.831-36.508,62.229-36.09
l1.739-8.178c1.916-9.027,2.042-15.525-8.661-15.525c-10.28,0-12.77,7.756-14.552,16.154h-28.959
c2.723-12.803,8.447-20.984,16.399-25.811c7.784-5.033,17.839-6.924,29.169-6.924c37.558,0,38.95,16.16,34.845,35.459
L1065.27,837.421z M1013.521,824.199c-1.606,7.561-2.312,16.793,7.344,16.793c17.414,0,19.683-23.504,22.136-35.041
C1028.179,806.578,1017.537,805.32,1013.521,824.199z"/>
<path fill="#FFFFFF" d="M1182.38,788.951c3.346-15.732,0.476-20.98-8.756-20.98c-12.592,0-16.006,11.113-20.688,33.154
c-6.868,32.309-5.611,39.232,5.302,39.232c9.231,0,15.424-8.387,18.364-22.242h29.588c-6.112,28.746-24.269,41.131-51.968,41.131
c-38.189,0-38.272-23.293-31.227-56.449c6.155-28.949,15.613-53.709,54.643-53.709c27.276,0,40.218,12.172,34.331,39.863H1182.38z
"/>
<path fill="#FFFFFF" d="M1396.655,837.421c-1.382,6.506-1.968,13.221-2.724,19.725h-27.482l1.729-14.059h-0.421
c-8.619,10.91-18.337,16.158-31.135,16.158c-20.562,0-24.862-15.318-20.938-33.787c7.454-35.035,34.837-36.508,62.23-36.09
l1.743-8.178c1.911-9.027,2.036-15.525-8.66-15.525c-10.285,0-12.771,7.756-14.559,16.154h-28.961
c2.727-12.803,8.452-20.984,16.402-25.811c7.785-5.033,17.834-6.924,29.173-6.924c37.554,0,38.944,16.16,34.846,35.459
L1396.655,837.421z M1344.912,824.199c-1.6,7.561-2.312,16.793,7.348,16.793c17.416,0,19.681-23.504,22.137-35.041
C1359.57,806.578,1348.927,805.32,1344.912,824.199z"/>
<path fill="#FFFFFF" d="M1461.602,761.886h0.422c7.875-9.449,16.568-12.799,27.691-12.799c14.053,0,24.65,8.391,21.531,23.076
l-18.064,84.982h-29.598l15.536-73.02c2.003-9.447,1.878-16.785-7.557-16.785c-9.448,0-12.688,7.338-14.688,16.785l-15.527,73.02
h-29.584l22.526-105.961h29.589L1461.602,761.886z"/>
<path fill="#FFFFFF" d="M1614.947,751.185l-23.456,110.365c-1.567,7.344-7.304,36.305-48.009,36.305
c-22.035,0-39.715-5.67-34.857-31.482h28.962c-0.938,4.408-1.113,8.188,0.239,10.705c1.307,2.73,4.354,4.201,8.974,4.201
c7.344,0,12.384-6.93,14.658-17.631l4.323-20.352h-0.422c-6.145,8.182-15.429,12.379-25.084,12.379
c-32.52,0-24.719-29.791-19.635-53.717c4.959-23.287,11.661-52.871,42.506-52.871c10.494,0,18.534,4.611,20.64,14.477h0.415
l2.63-12.379H1614.947z M1554.86,837.421c10.702,0,14.536-11.121,19.31-33.57c4.949-23.295,6.708-36.508-4.197-36.508
c-11.127,0-14.66,7.758-21.533,40.076C1546.342,817.283,1540.589,837.421,1554.86,837.421z"/>
<path fill="#FFFFFF" d="M1713.985,761.886h0.415c7.884-9.449,16.57-12.799,27.691-12.799c14.059,0,24.653,8.391,21.533,23.076
l-18.062,84.982h-29.594l15.526-73.02c2.007-9.447,1.887-16.785-7.553-16.785c-9.446,0-12.686,7.338-14.694,16.785l-15.515,73.02
h-29.589l22.527-105.961h29.582L1713.985,761.886z"/>
<path fill="#FFFFFF" d="M1867.33,751.185l-23.466,110.365c-1.556,7.344-7.293,36.305-48.005,36.305
c-22.026,0-39.709-5.67-34.85-31.482h28.958c-0.942,4.408-1.109,8.188,0.239,10.705c1.308,2.73,4.358,4.201,8.975,4.201
c7.345,0,12.374-6.93,14.655-17.631l4.319-20.352h-0.415c-6.145,8.182-15.429,12.379-25.08,12.379
c-32.521,0-24.726-29.791-19.638-53.717c4.948-23.287,11.654-52.871,42.506-52.871c10.486,0,18.529,4.611,20.632,14.477h0.412
l2.637-12.379H1867.33z M1807.24,837.421c10.699,0,14.531-11.121,19.303-33.57c4.953-23.295,6.721-36.508-4.191-36.508
c-11.123,0-14.664,7.758-21.529,40.076C1798.725,817.283,1792.972,837.421,1807.24,837.421z"/>
<path fill="#FFFFFF" d="M1913.507,751.185h29.39l-2.429,79.732h0.412l35.265-79.732h31.428l0.398,79.732h0.412l32.242-79.732
h28.357l-50.256,105.961h-31.032l-3.033-70.287h-0.415l-35.464,70.287h-31.439L1913.507,751.185z"/>
<path fill="#FFFFFF" d="M2063.021,802.796c6.162-28.949,15.621-53.709,54.647-53.709c39.028,0,37.963,24.76,31.801,53.709
c-7.036,33.156-17.028,56.449-55.224,56.449C2056.062,859.246,2055.975,835.953,2063.021,802.796z M2120.247,801.125
c4.678-22.041,5.997-33.154-6.592-33.154c-12.593,0-15.999,11.113-20.684,33.154c-6.873,32.309-5.618,39.232,5.296,39.232
C2109.179,840.357,2113.374,833.433,2120.247,801.125z"/>
<path fill="#FFFFFF" d="M2204.189,751.185l-2.898,13.637h0.427c8.037-12.17,18.871-15.734,30.824-15.734l-5.618,26.434
c-25.658-1.672-29.296,13.432-31.52,23.92l-12.271,57.707h-29.582l22.528-105.961h28.11V751.185z"/>
<path fill="#FFFFFF" d="M1290.979,749.087c-11.125,0-19.81,3.35-27.689,12.799h-0.418l10.944-51.496h-29.589l-31.194,146.756
h29.583l15.522-73.02c2.007-9.445,5.248-16.783,14.688-16.783c9.441,0,9.562,7.338,7.553,16.783l-15.523,73.02h29.586
l18.063-84.98C1315.631,757.478,1305.036,749.087,1290.979,749.087z"/>
<polygon fill="#FFFFFF" points="2253.523,710.39 2222.329,857.146 2251.908,857.146 2283.104,710.39 "/>
<path fill="#FFFFFF" d="M2352.381,710.39l-10.812,50.869h-0.415c-4.168-9.029-10.846-12.172-21.553-12.172
c-29.791,0-35.952,32.938-40.5,54.342c-4.646,21.824-12.918,55.816,17.72,55.816c11.329,0,20.271-3.57,27.913-13.854h0.424
l-2.498,11.754h28.113l31.193-146.756H2352.381L2352.381,710.39z M2332.645,803.22c-5.662,26.648-9.907,37.771-19.978,37.771
c-10.709,0-10.237-11.123-4.568-37.771c4.505-21.195,7.419-35.877,20.222-35.877
C2340.488,767.343,2337.154,782.025,2332.645,803.22z"/>
</g>
<path fill="#FFFFFF" d="M203.474,239.716l2.103,2.02c58.821,49.265,122.312,44.486,170.67,12.332
c30.496-20.284,168.388-111.981,246.33-163.811V38.492H41.683v136.705C77.088,169.069,134.151,175.078,203.474,239.716z"/>
<path fill="#FFFFFF" d="M422.01,467.153l-68.618-65.809c-9.63-8.786-17.884-15.225-19.66-16.594
c-56.077-39.381-108.36-27.417-130.901-19.028c-6.828,2.74-13.343,6.453-17.959,9.351L41.683,470.858v173.543h580.893V519.509
C609.828,527.613,531.131,570.189,422.01,467.153z"/>
<path fill="#FFFFFF" d="M198.344,255.241c-3.101-2.883-6.533-5.966-9.585-8.481c-68.605-53.08-133.416-27.105-147.077-20.62v59.741
l33.604-22.646c0,0,51.801-38.424,132.407,0.976L198.344,255.241z"/>
<path fill="#FFFFFF" d="M278.565,332.388c-3.016-2.668-6.053-5.421-9.121-8.32c-60.854-51.499-119.679-38.412-144.087-29.36
c-6.906,2.756-13.505,6.521-18.16,9.444l-6.592,4.411h-0.003l-58.919,39.414v61.521l109.59-73.846c0,0,51.196-37.977,130.99,0.282
L278.565,332.388z"/>
<path fill="#FFFFFF" d="M622.658,396.804c-22.844,15.398-46.074,31.052-55.317,37.243c-20.657,13.84-68.479,48.14-148.067,10.101
l9.354,8.981c3.5,3.175,7.758,6.828,12.424,10.406c57.164,42.714,118.246,36.576,164.04,6.231
c6.344-4.201,12.135-8.06,17.567-11.688V396.804z"/>
<path fill="#FFFFFF" d="M622.658,273.587c-50.169,33.741-117.878,79.276-130.598,87.796c-20.655,13.84-69.187,48.59-147.077,11.382
l9.015,8.662c1.025,0.945,2.047,1.873,3.076,2.847l-0.051,0.06l0,0l0.051-0.057c60.461,51.168,127.048,43.335,172.731,12.829
c25.76-17.2,62.381-41.961,92.851-62.614L622.658,273.587L622.658,273.587z"/>
<path fill="#FFFFFF" d="M622.658,151.031c-72.346,48.476-191.05,128.009-205.424,137.641
c-20.849,13.967-69.966,49.24-146.875,12.516l9.349,8.985c5.564,5.038,13.049,11.317,20.978,16.504
c53.228,34,108.948,27.997,154.298-2.287c32.594-21.765,112.771-75.06,167.675-111.541L622.658,151.031L622.658,151.031z"/>
</g>
</svg>
......@@ -10,8 +10,8 @@
</head>
<body>
<nav>
{% if current_user.is_authenticated %}
Logged in as {{ current_user.email }}
{% if current_user.is_authenticated %} Logged in as {{ current_user.email
}}
<a href="{{ url_for('login.logout') }}">Log Out</a>
{% else %}
<a href="{{ url_for('login.login') }}">Log In</a>
......
{% extends '_template.html' %}
{% block header %}
{% extends '_template.html' %} {% block header %}
<h1>{% block title %}Hello{% endblock %}</h1>
{% endblock %}
{% block content %}
{% endblock %} {% block content %}
<p>This is the page when logged in</p>
{{ current_user.to_dict() | tojson }}
{% endblock %}
{{ current_user.to_dict() | tojson }} {% endblock %}
{% extends '_template.html' %} {% block header %}
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='usage.css') }}"/>
{% endblock %} {% block content %}
<header role="banner" class="hazdev-site-header">
<a
class="hazdev-site-logo"
href="https://www.usgs.gov/"
title="U.S. Geological Survey"
>
<img src="/static/usgs-logo.svg" alt="U.S. Geological Survey logo" />
</a>
<a class="hazdev-jumplink-navigation" href="#site-sectionnav">
Jump to Navigation
</a>
<ng-content></ng-content>
</header>
<div class="views-field views-field-field-intro"> <div class="field-content lead pane-border"><p><strong>Example Requests</strong><br /></p><dl><dt>BOU observatory data for current UTC day in IAGA2002 format</dt>
<dd><a href="http://geomag.usgs.gov/ws/edge/?id=BOU">http://geomag.usgs.gov/ws/edge/?id=BOU</a></dd>
<dt>BOU observatory data for current UTC day in JSON format</dt>
<dd><a href="http://geomag.usgs.gov/ws/edge/?id=BOU&amp;format=json">http://geomag.usgs.gov/ws/edge/?id=BOU&amp;format=json</a></dd>
<dt>BOU electric field data for current UTC day in IAGA2002 format</dt>
<dd><a href="http://geomag.usgs.gov/ws/edge/?id=BOU&amp;elements=E-N,E-E">http://geomag.usgs.gov/ws/edge/?id=BOU&amp;elements=E-N,E-E</a></dd>
</dl><p><a href="/natural-hazards/geomagnetism/science/more-examples">See more examples</a></p>
</div> </div>
<div class="views-field views-field-field-science-tab-intro"> <div class="field-content"></div> </div>
<div class="views-field views-field-field-science-object-body"> <div class="field-content"><div class="tex2jax"><p><strong>Request Limits</strong></p>
<p>To ensure availability for users, the web service restricts the amount of data that can be retrieved in one request. The amount of data requested is computed as follows, where an interval is the number of seconds between start time and end time:</p>
<p>samples = count(elements) * interval / sampling_period</p>
<p><strong>Limits by the output format</strong></p>
<p><strong>json</strong></p>
<ul><li>172800 samples = 4 elements * 12 hours * 3600 samples/hour.</li>
</ul><p><strong>iaga2002</strong></p>
<ul><li>345600 samples = 4 elements * 24 hours * 3600 samples/hour.</li>
<li>NOTE: while the json format supports fewer total samples per request, users may request fewer elements to retrieve longer intervals.</li>
</ul><p><strong>Parameters</strong></p>
<p><strong>id</strong></p>
<ul><li>Observatory code. Required.</li>
<li>Valid values: BDT, BOU, TST, BRW, BRT, BSL, CMO, CMT, DED, DHT, FRD, FRN, GUA, HON, NEW, SHU, SIT, SJG, TUC, USGS, BLC, BRD, CBB, EUA, FCC, IQA, MEA, OTT, RES, SNK, STJ, VIC, YKC, HAD, HER, KAK</li>
</ul><p><strong>starttime</strong></p>
<ul><li>Time of first requested data.</li>
<li>Default: start of current UTC day</li>
<li>Format: ISO8601 (YYYY-MM-DDTHH:MM:SSZ)</li>
<li>Example: 2018-08-06T22:10:14Z</li>
</ul><p><strong>endtime</strong></p>
<ul><li>Time of last requested data.</li>
<li>Default: starttime + 24 hours</li>
<li>Format: ISO8601 (YYYY-MM-DDTHH:MM:SSZ)</li>
<li>Example: 2018-08-06T22:10:14Z</li>
</ul><p><strong>elements</strong></p>
<ul><li>Comma separated list of requested elements.</li>
<li>Default: X,Y,Z,F</li>
<li>Valid values: D, DIST, DST, E, E-E, E-N, F, G, H, SQ, SV, UK1, UK2, UK3, UK4, X, Y, Z</li>
</ul><p><strong>sampling_period</strong></p>
<ul><li>Interval in seconds between values.</li>
<li>Default: 60</li>
<li>Valid values: 1, 60, 3600</li>
</ul><p><strong>type</strong></p>
<ul><li>Type of data.</li>
<li>Default: variation Valid values: variation, adjusted, quasi-definitive,definitive</li>
<li>NOTE: the USGS web service also supports specific EDGE location codes. For example: R0 is "internet variation",R1 is "satellite variation".</li>
</ul><p><strong>format</strong></p>
<ul><li>Output format.</li>
<li>Default: iaga2002</li>
<li>Valid values: iaga2002, json.</li>
</ul></div></div> </div>
<footer class="site-commonnav">
<a class="hazdev-site-logo" href="/" title="U.S. Geological Survey">
<img src="/static/usgs-logo.svg" alt="U.S. Geological Survey logo" />
</a>
<div class="interior-nav">
<a href="https://www.doi.gov/">
U.S. Department of the Interior
</a>
<a href="https://www.usgs.gov/">
U.S. Geological Survey
</a>
</div>
<div class="space-between">
<div class="common-nav">
<a href="https://www.doi.gov/privacy">
DOI Privacy Policy
</a>
<a href="https://www.usgs.gov/policies-and-notices">
Legal
</a>
<a href="https://www.usgs.gov/sitemap">
Site Map
</a>
<a href="https://answers.usgs.gov/">
Contact USGS
</a>
</div>
</div>
</footer></body>
</html>
{% endblock %}
\ No newline at end of file
# A generic, single database configuration.
[alembic]
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
from __future__ import with_statement
import logging
from logging.config import fileConfig
from sqlalchemy import engine_from_config
from sqlalchemy import pool
from alembic import context
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
logger = logging.getLogger('alembic.env')
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
from flask import current_app
config.set_main_option(
'sqlalchemy.url', current_app.config.get(
'SQLALCHEMY_DATABASE_URI').replace('%', '%%'))
target_metadata = current_app.extensions['migrate'].db.metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
# this callback is used to prevent an auto-migration from being generated
# when there are no changes to the schema
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
if getattr(config.cmd_opts, 'autogenerate', False):
script = directives[0]
if script.upgrade_ops.is_empty():
directives[:] = []
logger.info('No changes in schema detected.')
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args
)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment