##// END OF EJS Templates
Better navigation, sidebar, update jroplots #TODO OverJRO
Juan C. Espinoza -
r39:b80dda8fb07c
parent child
Show More
@@ -12,6 +12,7 class ExpDetail(Document):
12 12 date = DateTimeField()
13 13 last_time = FloatField()
14 14 interval = IntField()
15 tag = StringField(max_length=40)
15 16
16 17 def plots(self):
17 18 return PlotMeta.objects(exp_detail=self)
@@ -30,3 +31,10 class PlotData(Document):
30 31 'indexes': ["plot", "+time"]
31 32 }
32 33
34 class Exp(models.Model):
35
36 name = models.CharField(max_length=60)
37 code = models.IntegerField()
38
39 def __str__(self):
40 return self.name
@@ -54,6 +54,15 main {
54 54 margin: 0;
55 55 }
56 56
57 #sidebar a {
58 color: gray;
59 padding: 0.1rem;
60 }
61
62 #sidebar h5 {
63 color:#333;
64 }
65
57 66 .text-blue {
58 67 color: #003A8E;
59 68 }
@@ -72,6 +81,8 main {
72 81
73 82 .legend {
74 83 list-style: none;
84 padding-left: 1rem;
85 padding-top: 1rem;
75 86 }
76 87
77 88 .legend span {
@@ -106,16 +117,8 main {
106 117 font-size: 0.8rem;
107 118 }
108 119
109 .bc-icons {
110 color: #898989;
111 }
112
113 .bc-icons .breadcrumb-item+.breadcrumb-item::before {
114 content: none;
115 }
116
117 .bc-icons .breadcrumb-item.active {
118 color: #00addc;
120 .tools-date {
121 font-size: 0.8rem;
119 122 }
120 123
121 124 /* cards */
@@ -87,7 +87,6 class PcolorBuffer {
87 87 };
88 88 var iDiv = document.createElement('div');
89 89 iDiv.id = 'plot-' + i;
90 //iDiv.className += iDiv.className ? ' col-lg-6 col-md-6 col-sm-12' : 'col-lg-6 col-md-12 col-sm-12';
91 90 this.zbuffer.push([]);
92 91 this.n = this.n + 1;
93 92 this.div.appendChild(iDiv);
@@ -104,10 +103,13 class PcolorBuffer {
104 103 if (this.metadata.zmin) { trace.zmin = this.metadata.zmin }
105 104 if (this.metadata.zmax) { trace.zmax = this.metadata.zmax }
106 105
106 var tm = new Date(this.last * 1000);
107 tm.setTime( tm.getTime() + tm.getTimezoneOffset()*60*1000 );
108
107 109 if ('titles' in this.metadata){
108 layout.title = this.metadata.titles[i] + ' - ' + this.last.toLocaleString();
110 layout.title = this.metadata.titles[i] + ' - ' + tm.toLocaleString();
109 111 }else{
110 layout.title = 'Ch ' + i + ' - ' + this.last.toLocaleString();
112 layout.title = 'Ch ' + i + ' - ' + tm.toLocaleString();
111 113 }
112 114
113 115 var conf = {
@@ -128,6 +130,16 class PcolorBuffer {
128 130 }
129 131 $('#id_ymin').val(Math.min(...this.metadata.yrange));
130 132 $('#id_ymax').val(Math.max(...this.metadata.yrange));
133 if (this.metadata.zmin) {
134 $('#id_zmin').val(this.metadata.zmin);
135 } else {
136 $('#id_zmin').val(Math.min(...values.data[0][0]));
137 }
138 if (this.metadata.zmax) {
139 $('#id_zmax').val(this.metadata.zmax);
140 } else {
141 $('#id_zmax').val(Math.max(...values.data[0][0]));
142 }
131 143 }
132 144
133 145 getSize() {
@@ -315,13 +327,10 class Pcolor {
315 327 };
316 328 var iDiv = document.createElement('div');
317 329 iDiv.id = 'plot-' + i;
318 iDiv.className += iDiv.className ? ' col-md-5' : 'col-md-5';
330 iDiv.className += iDiv.className ? ' col-md-6' : 'col-md-6';
319 331 this.n = this.n + 1;
320 332 this.div.appendChild(iDiv);
321 333 this.divs.push(iDiv.id);
322 var iDiv = document.createElement('div');
323 iDiv.className = 'col-md-1';
324 this.div.appendChild(iDiv);
325 334 var trace1 = {
326 335 z: data['data'][i],
327 336 y: data.metadata.yrange,
@@ -370,6 +379,17 class Pcolor {
370 379 $('#id_ymax').val(Math.max(...this.metadata.yrange));
371 380 $('#id_xmin').val(Math.min(...this.metadata.xrange));
372 381 $('#id_xmax').val(Math.max(...this.metadata.xrange));
382
383 if (this.metadata.zmin) {
384 $('#id_zmin').val(this.metadata.zmin);
385 } else {
386 $('#id_zmin').val(Math.min(...data.data[0][0]));
387 }
388 if (this.metadata.zmax) {
389 $('#id_zmax').val(this.metadata.zmax);
390 } else {
391 $('#id_zmax').val(Math.max(...data.data[0][0]));
392 }
373 393 }
374 394
375 395 plot(obj) {
@@ -488,14 +508,8 class ScatterBuffer {
488 508 }
489 509
490 510 var label;
491 //if (data.metadata.localtime == true){
492 511 label = "[LT]";
493 512
494 //}
495 //else{
496 // label = "[UTC]";
497 //}
498
499 513 var layout = {
500 514 height: 300,
501 515 title: t.slice(-1).toLocaleString(),
@@ -536,8 +550,17 class ScatterBuffer {
536 550 showTips: true
537 551 };
538 552 Plotly.newPlot('plot', traces, layout, conf);
539 $('#id_ymin').val(Math.min(...this.metadata.yrange));
540 $('#id_ymax').val(Math.max(...this.metadata.yrange));
553
554 if (this.metadata.ymin) {
555 $('#id_ymin').val(this.metadata.ymin);
556 } else {
557 $('#id_ymin').val(layout.yaxis.range[0]);
558 }
559 if (this.metadata.ymax) {
560 $('#id_ymax').val(this.metadata.ymax);
561 } else {
562 $('#id_ymax').val(layout.yaxis.range[1]);
563 }
541 564 }
542 565
543 566 getSize() {
@@ -26,13 +26,16
26 26 {% include "header_igp.html" %}
27 27 <div class="container">
28 28 <!-- main -->
29 <div class="d-flex" id="wrapper">
30 29 <main role="main">
31 30 <h1 class="titulo">{{title}}</h1>
32 {% block content %}{% endblock content %}
31 <div class="row">
32 {%if sidebar %}
33 <div id="sidebar" class="col-md-3 col-12">{% block sidebar_content %}{% endblock sidebar_content %}</div>
34 {% endif %}
35 <div {% if sidebar %}class="col-md-9 col-12"{% else %}class="col-12"{% endif %}>{% block content %}{% endblock content %}</div>
36 </div>
33 37 </main>
34 38 </div>
35 </div>
36 39 <!-- footer -->
37 40 {% include "footer_igp.html" %}
38 41 <!-- This part put block modal which is used to change parameters of my plot -->
@@ -2,22 +2,41
2 2 {% load static%}
3 3 {% block extra-header %}
4 4 {% endblock %}
5 {% block sidebar_content %}
6 <nav class="nav flex-column">
7 {% for tag in tags %}
8 <a class="nav-link {{tag.active}}" href="{% url 'url_main' tag.name %}">{{tag.name | title}} &nbsp; <span class="badge badge-primary text-left">{{tag.n | stringformat:"02d"}} </span></a>
9 {% endfor %}
10 </nav>
11 {% endblock %}
5 12 {% block content %}
6 {% include 'cartas.html' %}
13 <div class="row">
14 {% for exp in experiments %}
15 <div class="col-12 col-sm-6 col-md-4 col-lg-3 p-1">
16 <div id="card_{{exp.code}}" class="card m-1 box-shadow text-{{exp.style}} border-{{exp.style}}">
17 <div id="card_header_{{exp.code}}" class="card-header bg-{{exp.style}} text-white">{{exp.name}}</div>
18 <div id="card_body_{{exp.code}}" class="card-body">
19 <div id="date_{{exp.code}}">Last data: {{exp.date | date:"H:i:s" }}</div>
20 {% for plot in exp.plots %}
21 <a class="btn btn-outline-{{exp.style}} mt-1" href="{% url 'url-plot' exp.code plot.plot %}" role="button">{{plot.name}}</a>
22 {% endfor %}
23 <a class="btn btn-outline-{{exp.style}} mt-1" role="button">Hola</a>
24 </div>
25 </div>
26 </div>
27 {% endfor %}
28 </div>
29 {% if experiments %}
7 30 <div class="row">
8 31 <ul class="legend">
9 <li>
10 <i class="fas fa-circle text-success"></i><span>Instrument online</span>
11 </li>
12 <li>
13 <i class="fas fa-circle text-warning"></i><span>Instrument delayed</span>
14 </li>
15 <li>
16 <i class="fas fa-circle text-danger"></i><span>Instrument offline</span>
17 </li>
32 <li>Time format: 24h (UTC-5)</li>
33 <li><i class="fas fa-circle text-success"></i><span>Instrument online</span></li>
34 <li><i class="fas fa-circle text-warning"></i><span>Instrument delayed</span></li>
35 <li><i class="fas fa-circle text-danger"></i><span>Instrument offline</span></li>
18 36 </ul>
19 37 </div>
20 {% endblock content %}
38 {% endif %}
39 {% endblock %}
21 40 {% block script %}
22 41 <script>
23 42 function pad(num) {
@@ -29,9 +48,7
29 48 var hours = Math.floor(minutes/60)
30 49 minutes = minutes%60;
31 50 return pad(hours)+":"+pad(minutes)+":"+pad(secs);
32 }
33 $("#loader").css("display", "none");
34
51 }
35 52 /* This part create a new socket named "socket" to comunicate
36 53 if there is new data we could be able to change some attributes of a class*/
37 54 var socket = new WebSocket('ws://' + window.location.host +'/ws/main/');
@@ -45,15 +62,15
45 62 var code = data['code'];
46 63 console.log(code);
47 64 var value = data['value'];
48 var time = moment(new Date(data['time']*1000)).format('hh:mm:ss a');
65 var time = moment(new Date(data['time']*1000)).format('HH:mm:ss');
49 66
50 67 /*This conditional ask if value(send by server) is online, and if it is then
51 68 change value to online in div with id="#alert_"+code*/
52 69
53 70 $("#date_"+code).text("Last data: "+time);
54 $("#card_"+code).removeClass().addClass("card mb-4 box-shadow text-"+value+" border-"+value);
71 $("#card_"+code).removeClass().addClass("card m-1 box-shadow text-"+value+" border-"+value);
55 72 $("#card_header_"+code).removeClass().addClass("card-header text-white bg-"+value);
56 $("#card_body_"+code).find("a").removeClass().addClass("btn btn-outline-"+value);
73 $("#card_body_"+code).find("a").removeClass().addClass("btn mt-1 btn-outline-"+value);
57 74 };
58 75
59 76 if (socket.readyState == WebSocket.OPEN) {
@@ -1,24 +1,26
1 {% extends 'base.html' %} {% load static %} {% load bootstrap4 %} {% block content %}
2 <div class="bc-icons">
3 <nav aria-label="breadcrumb">
4 <ol class="breadcrumb bg-transparent mb-0 p-0">
5 {% for item in menu_list %}
6 <li class="breadcrumb-item">{{item}}
7 {% if forloop.last is False %}<i class="fas fa-caret-right mx-2" aria-hidden="true"></i>{% endif %}</li>
8 {% endfor %}
9 </ol>
10 </nav>
11 </div>
1 {% extends 'base.html' %} {% load static %} {% load bootstrap4 %}
2
3 {% block sidebar_content %}
4 <h5>{{name}}</h5>
5 <nav class="nav flex-column">
6 {% for plot in plots %}
7 <a class="nav-link" href="{% url 'url-plot' code plot.plot %}">{{plot.name}}</a>
8 {% endfor %}
9 </nav>
10 {% endblock %}
11
12 {% block content %}
12 13 <div class="row justify-content-center">
13 <div id="loader" class="col-sm-2 loader"></div>
14 <div id="loader" class="m-5 loader"></div>
14 15 </div>
15 16 <div id="plot" {%if meta.metadata.type == 'pcolor' %}class="row"{%endif%}>
16 17 {% if image %}
17 18 <img id="image" class="img-fluid"/>
18 19 {% endif %}
19 20 </div>
21 {% endblock content %}
20 22
21 {% endblock content %} {% block modal %}
23 {% block modal %}
22 24 <!-- Modal -->
23 25 {% if setup_form %}
24 26 <div class="modal fade" id="setup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
@@ -9,34 +9,99
9 9 <h5 class="card-title">Sky noise</h5>
10 10 <p class="card-text">Sky brightness at 50 MHz, useful for antenna calibrations and measure radar's sensitivity.
11 11 </p>
12 <div class="input-group input-group-sm">
13 <div class="input-group-prepend">
14 <span class="input-group-text" id="validationTooltipSkynoiseDate"><i class="fas fa-calendar"
15 aria-hidden="true"></i></span>
16 </div>
17 <input type="text" class="form-control" id="skynoise-date" placeholder="dd/mm/yy"
18 aria-describedby="validationTooltipSkynoiseDate" value="{% now 'd-m-Y' %}" required>
12 <input type="date" class="form-control tools-date" id="skynoise-date" placeholder="dd/mm/yy"
13 aria-describedby="validationTooltipSkynoiseDate" value="{% now 'Y-m-d' %}" required>
19 14 <div class="invalid-tooltip">
20 15 Please enter a valid date.
21 16 </div>
22 <a class="btn btn-primary" data-toggle="modal" href="#toolModal" data-title="Sky Noise"
17 <a class="btn btn-primary m-1" data-toggle="modal" href="#toolModal" data-title="Sky Noise"
23 18 data-image="{% url 'url_skynoise' %}">Go</a>
24 </div>
25 19 </div>
26 20 </div>
21
27 22 <div class="card text-justify">
28 <img src="{% static 'images/kp.png' %}" class="card-img-top" alt="...">
29 23 <div class="card-body">
30 <h5 class="card-title">Kp Index</h5>
31 <p class="card-text">The K-index, are used to characterize the magnitude of geomagnetic storms. Kp is an excellent
32 indicator of disturbances in the Earth's magnetic field (<a
33 href="https://www.swpc.noaa.gov/products/planetary-k-index" target="_blank">NOAA/SWPC</a>).</p>
34 <a class="btn btn-primary" data-toggle="modal" href="#toolModal" data-title="Kp Index"
35 data-image="https://services.swpc.noaa.gov/images/planetary-k-index.gif">Go</a>
24 <h5 class="card-title">Over JRO</h5>
25 <p class="card-text">Main antenna radiation pattern for several experiments.
26
27 <input type="date" class="form-control form-control-sm tools-date" id="overjro-date" placeholder="dd/mm/yy"
28 aria-describedby="validationTooltipOverJRODate" value="{% now 'Y-m-d' %}" required>
29 <div class="invalid-tooltip">
30 Please enter a valid date.
31 </div>
32 <select name="experiment" class="form-control form-control-sm">
33 <option value="-1">Experiment:</option>
34 <option value="-1">------------------</option>
35 <option value="20">Vertical Drifts</option>
36 <option value="[21,22]">East West 1996</option>
37 <option value="[25,26]">East West 2003</option>
38 <option value="23">Differential Phase 2000</option>
39 <option value="24">Differential Phase 2004 High Alt</option>
40 <option value="27">Differential Phase 2005 - 2006</option>
41 <option value="[28,29]">DEWD 2005</option>
42 <option value="2710">DVD 2006 - 2008</option>
43 <option value="-1">------------------</option>
44 <option value="10">Oblique ISR On-Axis</option>
45 <option value="11">Oblique ISR 4.5</option>
46 <option value="12">Oblique ISR 6.0S</option>
47 <option value="13">Oblique ISR 3.0N</option>
48 <option value="-1">------------------</option>
49 <option value="[30,31]">JULIA CP2</option>
50 <option value="32">JULIA CP3</option>
51 <option value="35">JULIA V (2005-2006)</option>
52 <option value="[33,34]">JULIA EW 2003</option>
53 <option value="[35,36]">JULIA EW (2006-2007)</option>
54 <option value="-1">------------------</option>
55 <option value="0">Modulo Rx</option>
56 <option value="1">1/16 Rx</option>
57 <option value="2">1/4 Rx</option>
58 <option value="3">All Rx</option>
59 <option value="-1">------------------</option>
60 <option value="40">EW Imaging 1996</option>
61 <option value="41">EW Imaging 2003</option>
62 <option value="43">EW Imaging 2006-2008</option>
63 <option value="-1">------------------</option>
64 <option value="50">MST North (Fritts)</option>
65 <option value="51">MST West (Fritts)</option>
66 <option value="52">MST South (Fritts)</option>
67 <option value="53">MST East (Fritts)</option>
68 <option value="-1">------------------</option>
69 <option value="54">Vertical (Yellow Cables)</option>
70 </select>
71 <br>
72 <p class="card-text">Choose object:
73 <div class="form-check card-text">
74 <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
75 <label class="form-check-label" for="inlineCheckbox1">B Field</label><br>
76 <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
77 <label class="form-check-label" for="inlineCheckbox1">Sun</label><br>
78 <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
79 <label class="form-check-label" for="inlineCheckbox1">Moon</label><br>
80 <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
81 <label class="form-check-label" for="inlineCheckbox1">Hydra</label><br>
82 <input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
83 <label class="form-check-label" for="inlineCheckbox1">Galaxy Center</label>
84 </div>
85 </p>
86 </div>
87 <a class="btn btn-primary m-1" data-toggle="modal" href="#toolModal" data-title="Over JRO"
88 data-image="{% url 'url_overjro' %}">Go</a>
89 </div>
90
91 <div class="card text-justify">
92 <img src="{% static 'images/kp.png' %}" class="card-img-top" alt="...">
93 <div class="card-body">
94 <h5 class="card-title">Kp Index</h5>
95 <p class="card-text">The K-index, are used to characterize the magnitude of geomagnetic storms. Kp is an excellent
96 indicator of disturbances in the Earth's magnetic field (<a
97 href="https://www.swpc.noaa.gov/products/planetary-k-index" target="_blank">NOAA/SWPC</a>).</p>
98 <a class="btn btn-primary" data-toggle="modal" href="#toolModal" data-title="Kp Index"
99 data-image="https://services.swpc.noaa.gov/images/planetary-k-index.gif">Go</a>
100 </div>
36 101 </div>
37 102 </div>
103
38 104 </div>
39 <br><br>
40 105
41 106 <!-- Modal -->
42 107 <div class="modal fade" id="toolModal" tabindex="-1" role="dialog" aria-labelledby="toolModalTitle" aria-hidden="true">
@@ -1,12 +1,14
1 1 from django.conf.urls import url
2 from .views import main, plot, tools, plot_skynoise, reports, about
2 from .views import main, plot, tools, plot_skynoise, reports, about, plot_overjro
3 3
4 4
5 5 urlpatterns = [
6 6 url(r'^$', main, name='url_main'),
7 url(r'^experiment/(?P<tag>[-\w]+)/$', main, name='url_main'),
7 8 url(r'^tools/$', tools, name='url_tools'),
8 9 url(r'^tools/skynoise.png$', plot_skynoise, name='url_skynoise'),
10 url(r'^tools/overjro.png$', plot_overjro, name='url_overjro'),
9 11 url(r'^reports/$', reports, name='url_reports'),
10 12 url(r'^about/$', about, name='url_about'),
11 url(r'^(?P<code>[0-9]+)/(?P<plot>[-\w]+)/$', plot, name='url-plot'),
13 url(r'^plot/(?P<code>[0-9]+)/(?P<plot>[-\w]+)/$', plot, name='url-plot'),
12 14 ]
@@ -68,50 +68,74 class SPCSetupForm(forms.Form):
68 68 zmin = forms.CharField(initial=10)
69 69
70 70 # Create your views here.
71 def main(request):
71 def main(request, tag=None):
72 72
73 73 kwargs = {}
74 74 date = request.GET.get('date', datetime.now().strftime('%d-%m-%Y'))
75 75 exps = ExpDetail.objects(date=datetime.strptime(date, '%d-%m-%Y'))
76 experiments = []
77 76
77 tmp = {}
78 78 for exp in exps:
79 dum = {}
80 dum['code'] = exp.experiment.code
81 dum['plots'] = []
82 dum['name'] = exp.experiment.name
83 dt = datetime.now()
84
85 t = time.mktime(dt.timetuple())
86 t -= 5*60*60
87
88 if (t-exp['last_time']) > 6*exp['interval']:
89 status = 'Offline'
90 clase = 'alertas-offline'
91 style = 'danger'
92 lastDataDate = exp['last_time']
93 elif (t-exp['last_time']) > 3*exp['interval']:
94 status = 'Delayed'
95 clase = 'alertas-delayed'
96 style = 'warning'
97 lastDataDate = exp['last_time']
79 label = exp.tag.lower().strip() if exp.tag else 'other'
80 if label in tmp:
81 tmp[label] += 1
82 else:
83 tmp[label] = 1
84 tags = []
85
86 for key, value in tmp.items():
87 if tag == key:
88 tags.append({'name': key, 'n': tmp[key], 'active': 'active'})
98 89 else:
99 status = 'Online'
100 clase = 'alertas-online'
101 style = 'success'
102 lastDataDate = exp['last_time']
103
104 dum['status'] = status
105 dum['class'] = clase
106 dum['style']= style
107 dum['date']= datetime.utcfromtimestamp(lastDataDate)
108 for plot in exp.plots():
109 dum['plots'].append({'plot': plot.plot, 'name': plot.plot.replace('_', ' ').title(), 'id':plot.id})
110 experiments.append(dum)
90 tags.append({'name': key, 'n': tmp[key]})
91
92 kwargs['tags'] = tags
111 93
94 if tag:
95 experiments = []
96 for exp in exps:
97 label = exp.tag.lower().strip() if exp.tag else 'other'
98 if label != tag:
99 continue
100 dum = {}
101 dum['code'] = exp.experiment.code
102 dum['plots'] = []
103 dum['name'] = exp.experiment.name
104 dt = datetime.now()
105
106 t = time.mktime(dt.timetuple())
107 t -= 5*60*60
108
109 if (t-exp['last_time']) > 6*exp['interval']:
110 status = 'Offline'
111 clase = 'alertas-offline'
112 style = 'danger'
113 lastDataDate = exp['last_time']
114 elif (t-exp['last_time']) > 3*exp['interval']:
115 status = 'Delayed'
116 clase = 'alertas-delayed'
117 style = 'warning'
118 lastDataDate = exp['last_time']
119 else:
120 status = 'Online'
121 clase = 'alertas-online'
122 style = 'success'
123 lastDataDate = exp['last_time']
124
125 dum['status'] = status
126 dum['class'] = clase
127 dum['style']= style
128 dum['date']= datetime.utcfromtimestamp(lastDataDate)
129 for plot in exp.plots():
130 dum['plots'].append({'plot': plot.plot, 'name': plot.plot.replace('_', ' ').title(), 'id':plot.id})
131 experiments.append(dum)
132
133 kwargs['experiments'] = experiments
134
112 135 kwargs['date'] = date
113 kwargs['experiments'] = experiments
136
114 137 kwargs['title'] = 'Realtime Experiments at JRO'
138 kwargs['sidebar'] = True
115 139
116 140 return render(request, 'home.html', kwargs)
117 141
@@ -152,7 +176,7 def plot(request, code=None, plot=None):
152 176 exp = Experiment.objects.get(code=int(code))
153 177 detail = ExpDetail.objects.get(experiment=exp, date=datetime.strptime(date, '%d-%m-%Y'))
154 178 meta = PlotMeta.objects.get(exp_detail=detail, plot=plot)
155
179
156 180 kwargs = {
157 181 'code': code,
158 182 'plot': plot,
@@ -160,9 +184,15 def plot(request, code=None, plot=None):
160 184 'date': date,
161 185 'id': meta.pk,
162 186 'realtime': realtime,
163 'title': 'Realtime',
164 'menu_list': [exp.name, meta.plot.replace('_', ' ').title()]
187 'title': 'Realtime Experiments at JRO',
188 'name' : exp.name,
189 'sidebar': True,
190 'plots': []
165 191 }
192
193 for plt in detail.plots():
194 kwargs['plots'].append({'plot': plt.plot, 'name': plt.plot.replace('_', ' ').title()})
195
166 196 # Logic to show my views
167 197 if meta.metadata['type'] == 'pcolorbuffer':
168 198 kwargs['setup_form'] = RTISetupForm()
@@ -189,9 +219,22 def plot_skynoise(request):
189 219 if date is None:
190 220 date = datetime.now()
191 221 else:
192 date = datetime.strptime(date, '%d-%m-%Y')
222 date = datetime.strptime(date, '%Y-%m-%d')
193 223
194 224 data = skynoise_plot(date.year, date.month, date.day)
195 225 response = HttpResponse(data.getvalue(), content_type='image/png')
196 226
197 227 return response
228
229 def plot_overjro(request):
230
231 date = request.GET.get('date', None)
232 if date is None:
233 date = datetime.now()
234 else:
235 date = datetime.strptime(date, '%Y-%m-%d')
236
237 data = skynoise_plot(date.year, date.month, date.day)
238 response = HttpResponse(data.getvalue(), content_type='image/png')
239
240 return response No newline at end of file
@@ -9,10 +9,12 from datetime import datetime
9 9 import time
10 10 import zmq
11 11 import mongoengine
12 import django
12 13 from threading import Thread
13 14
14 15 sys.path.append(os.environ.get('APP_DIR', '../'))
15 16 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "realtime.settings")
17 django.setup()
16 18
17 19 from plotter.models import Experiment, ExpDetail, PlotMeta, PlotData
18 20
@@ -44,6 +46,7 def loaddata():
44 46 def update(buffer):
45 47 dt = datetime.utcfromtimestamp(buffer['time'])
46 48 interval = buffer['metadata'].pop('interval')
49 tag = buffer['metadata'].pop('tag') if 'tag' in buffer['metadata'] else ''
47 50 exp = Experiment.objects.get(code=buffer['code'])
48 51
49 52 detail = ExpDetail.objects(experiment=exp, date=dt.date()).modify(
@@ -52,7 +55,8 def update(buffer):
52 55 set__experiment=exp,
53 56 set__date=dt.date(),
54 57 set__last_time = buffer['time'],
55 set__interval = interval
58 set__interval = interval,
59 set__tag = tag,
56 60 )
57 61
58 62 label = buffer['plot'].replace(' ', '_').lower()
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now