def graph(request): hums = Measurement.objects.filter(process_info__name='Lab Hum.') cfinger = Measurement.objects.filter(process_info__name='ColdFinger Temp.') coolant = Measurement.objects.filter(process_info__name='Coolant Temp.') pneumatic = Measurement.objects.filter(process_info__name='Pressure') pneumatic2 = Measurement.objects.filter(process_info__name='Pressure2') pis = ProcessInfo.objects humidity_units = pis.get(name='Lab Hum.').units coolant_units = pis.get(name='Coolant Temp.').units coldfinger_units = pis.get(name='ColdFinger Temp.').units pneumatic_units = pis.get(name='Pressure').units pneumatic2_units = pis.get(name='Pressure2').units post, form = get_post(request) context = {'date_selector_form': form, 'tempgraph': make_temp_graph(post)} s = (('humgraph', hums, 'Humidity', 'Humidity ({})'.format(humidity_units)), ('pneugraph', pneumatic, 'Pneumatics (Lab)', 'Pressure ({})'.format(pneumatic_units)), ('pneugraph2', pneumatic2, 'Pneumatics (Building)', 'Pressure ({})'.format(pneumatic2_units)), ('coolgraph', coolant, 'Coolant', 'Temp ({})'.format(coolant_units)), ('cfgraph', cfinger, 'ColdFinger', 'Temp ({})'.format(coldfinger_units))) for key, table, title, ytitle in s: context[key] = make_bokeh_graph(get_data(table, post), title, ytitle) return render(request, 'status/graph.html', context)
def all_temps(request): post, form = get_post(request) hums = Measurement.objects.filter(process_info__name='Lab Hum.') humidity_units = ProcessInfo.objects.get(name='Lab Hum.').units hums2 = Measurement.objects.filter(process_info__name='Lab Hum. 2') humidity_units2 = ProcessInfo.objects.get(name='Lab Hum. 2').units context = {'tempgraph': make_temp_graph(post), 'humgraph': make_bokeh_graph(get_data(hums, post), 'Humidity', 'Humidity ({})'.format(humidity_units)), 'sensehat_hum': make_bokeh_graph(get_data(hums2, post), 'Humidity 2', 'Humidity ({})'.format(humidity_units2)), 'date_selector_form': form} for tag, name, title in (('sensehat_temp1', 'Lab Temp. 2', 'Sensehat Temp1'), ('tprobe_temp3', 'Lab Temp. 3', 'TProbe Temp3'), ('tprobe_temp4', 'Lab Temp. 4', 'TProbe Temp4'), ('tprobe_temp5', 'Lab Temp. 5', 'TProbe Temp5'), ('tprobe_temp6', 'Lab Temp. 6', 'TProbe Temp6')): context[tag] = make_temp_graph(post, name=name, title=title) return render(request, 'status/all_temps.html', context)
def render_spectrometer_status(request, name, oname): template_name = name cname = name.capitalize() oname = oname.capitalize() decabin_temp = Measurement.objects.filter(process_info__name='{}DecabinTemp'.format(cname)) trap = Measurement.objects.filter(process_info__name='{}TrapCurrent'.format(cname)) emission = Measurement.objects.filter(process_info__name='{}Emission'.format(cname)) peakcenter = Measurement.objects.filter(process_info__name='{}PeakCenter'.format(cname)) post, form = get_post(request) decabin_temp_data = get_data(decabin_temp, post) trap_data = get_data(trap, post) emission_data = get_data(emission, post) peakcenter_data = get_data(peakcenter, post) # decabin_temp_data = decabin_temp.filter(pub_date__gte=post).all() # trap_data = trap.filter(pub_date__gte=post).all() # emission_data = emission.filter(pub_date__gte=post).all() pis = ProcessInfo.objects decabin_temp_units = pis.get(name='{}DecabinTemp'.format(cname)).units spectrometer_values = [make_spectrometer_dict(cname), make_spectrometer_dict(oname)] context = {'date_selector_form': form, 'tempgraph': make_temp_graph(post), 'decabintempgraph': make_bokeh_graph(decabin_temp_data, 'DecaBin Temperature', 'Temp ({})'.format( decabin_temp_units)), 'trapgraph': make_bokeh_graph(trap_data, 'Trap', 'uA'), 'emissiongraph': make_bokeh_graph(emission_data, 'Emission', 'uA'), 'peakcentergraph': make_bokeh_graph(peakcenter_data, 'PeakCenter', 'DAC (V)'), 'spectrometer_values': spectrometer_values} return render(request, 'status/{}.html'.format(template_name), context)
def make_timeseries_graph(post, name, label, unitlabel): pis = ProcessInfo.objects vs = Measurement.objects.filter(process_info__name=name) units = pis.get(name=name).units data = get_data(vs, post) return make_bokeh_graph(data, label, unitlabel.format(units))