Skip to content
Snippets Groups Projects
Commit 80145c98 authored by Coda Phillips's avatar Coda Phillips
Browse files

Finish up the interpreter

parent 75d2ebfa
No related branches found
No related tags found
No related merge requests found
...@@ -2,21 +2,64 @@ import netCDF4 ...@@ -2,21 +2,64 @@ import netCDF4
import pandas as pd import pandas as pd
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import mpld3
from aeri_tools.io.dmv.housekeeping import get_all_housekeeping from aeri_tools.io.dmv.housekeeping import get_all_housekeeping
from main import files_to_update from main import files_to_update
from glob import glob from glob import glob
import os import os
import flask
from flask import render_template
from datetime import datetime
app = flask.Flask(__name__)
global_ftp_dir = None
@app.route('/')
def index():
ae_dirs = glob(os.path.join(global_ftp_dir, 'AE*/*.qc'))
ae_dirs = [a.lstrip('/') for a in ae_dirs]
return flask.render_template('index.html', ae_dirs=ae_dirs)
@app.route('/qc/<path:qc_path>')
def qc_day(qc_path):
qc_path = '/'+qc_path
cxs_path = qc_path.replace('.qc','B1.CXS')
sum_path = qc_path.replace('.qc','.SUM')
cxs = get_all_housekeeping(cxs_path)
frame = cxs.combine_first(get_all_housekeeping(sum_path))
frame = frame.combine_first(get_qc_frame(qc_path))
plots = []
for qc_variable in ([
'ABBapexTemp',
'ABBtopTemp',
'ABBbottomTemp',
'HBBapexTemp',
'HBBtopTemp',
'HBBbottomTemp',
'calibrationAmbientTemp']):
plot = plot_variable_qc(frame, qc_variable)
if plot is not None:
plots.append(plot)
return flask.render_template('qc.html', qc_path=qc_path, plots=plots)
def save_plot(filename): def save_plot(filename):
print('saving {}'.format(filename)) print('saving {}'.format(filename))
plt.savefig(filename, transparent=True) plt.savefig(filename, transparent=True)
def plot_variable_qc(frame, loc, filename): def plot_variable_qc(frame, loc, filename=None):
qc_loc = 'qc_' + loc qc_loc = 'qc_' + loc
if sum(frame[qc_loc]) > 0: if sum(frame[qc_loc]) > 0:
plt.figure() fig = plt.figure(figsize=(50,5))
plot_outliers(frame, frame[qc_loc] == 0, loc) plot_outliers(frame, frame[qc_loc] == 0, loc)
save_plot(filename) if filename is not None:
save_plot(filename)
else:
return mpld3.fig_to_html(fig)
def plot_outliers(frame, qc_mask, loc): def plot_outliers(frame, qc_mask, loc):
if (~qc_mask).any(): if (~qc_mask).any():
...@@ -60,8 +103,13 @@ if __name__ == '__main__': ...@@ -60,8 +103,13 @@ if __name__ == '__main__':
import argparse import argparse
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('ftp') parser.add_argument('ftp')
parser.add_argument('--serve', action='store_true')
args = parser.parse_args() args = parser.parse_args()
generate_all_plots(args.ftp) if not args.serve:
generate_all_plots(args.ftp)
else:
global_ftp_dir = args.ftp
app.run(debug=True)
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<ul>
{% for d in ae_dirs %}
<a href="/qc/{{d}}"><li>/{{d}}</li></a>
{% endfor %}
</ul>
</body
</html>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>{{qc_path}}</h1>
{% for plot in plots %}
{{plot|safe}}
{% endfor %}
</body
</html>
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