@@ -12,6 +12,7 class ExpDetail(Document): | |||||
12 | date = DateTimeField() |
|
12 | date = DateTimeField() | |
13 | last_time = FloatField() |
|
13 | last_time = FloatField() | |
14 | interval = IntField() |
|
14 | interval = IntField() | |
|
15 | tag = StringField(max_length=40) | |||
15 |
|
16 | |||
16 | def plots(self): |
|
17 | def plots(self): | |
17 | return PlotMeta.objects(exp_detail=self) |
|
18 | return PlotMeta.objects(exp_detail=self) | |
@@ -30,3 +31,10 class PlotData(Document): | |||||
30 | 'indexes': ["plot", "+time"] |
|
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 | margin: 0; |
|
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 | .text-blue { |
|
66 | .text-blue { | |
58 | color: #003A8E; |
|
67 | color: #003A8E; | |
59 | } |
|
68 | } | |
@@ -72,6 +81,8 main { | |||||
72 |
|
81 | |||
73 | .legend { |
|
82 | .legend { | |
74 | list-style: none; |
|
83 | list-style: none; | |
|
84 | padding-left: 1rem; | |||
|
85 | padding-top: 1rem; | |||
75 | } |
|
86 | } | |
76 |
|
87 | |||
77 | .legend span { |
|
88 | .legend span { | |
@@ -106,16 +117,8 main { | |||||
106 | font-size: 0.8rem; |
|
117 | font-size: 0.8rem; | |
107 | } |
|
118 | } | |
108 |
|
119 | |||
109 | .bc-icons { |
|
120 | .tools-date { | |
110 | color: #898989; |
|
121 | font-size: 0.8rem; | |
111 | } |
|
|||
112 |
|
||||
113 | .bc-icons .breadcrumb-item+.breadcrumb-item::before { |
|
|||
114 | content: none; |
|
|||
115 | } |
|
|||
116 |
|
||||
117 | .bc-icons .breadcrumb-item.active { |
|
|||
118 | color: #00addc; |
|
|||
119 | } |
|
122 | } | |
120 |
|
123 | |||
121 | /* cards */ |
|
124 | /* cards */ |
@@ -87,7 +87,6 class PcolorBuffer { | |||||
87 | }; |
|
87 | }; | |
88 | var iDiv = document.createElement('div'); |
|
88 | var iDiv = document.createElement('div'); | |
89 | iDiv.id = 'plot-' + i; |
|
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 | this.n = this.n + 1; |
|
91 | this.n = this.n + 1; | |
93 | this.div.appendChild(iDiv); |
|
92 | this.div.appendChild(iDiv); | |
@@ -104,10 +103,13 class PcolorBuffer { | |||||
104 | if (this.metadata.zmin) { trace.zmin = this.metadata.zmin } |
|
103 | if (this.metadata.zmin) { trace.zmin = this.metadata.zmin } | |
105 | if (this.metadata.zmax) { trace.zmax = this.metadata.zmax } |
|
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 | if ('titles' in this.metadata){ |
|
109 | if ('titles' in this.metadata){ | |
108 |
layout.title = this.metadata.titles[i] + ' - ' + t |
|
110 | layout.title = this.metadata.titles[i] + ' - ' + tm.toLocaleString(); | |
109 | }else{ |
|
111 | }else{ | |
110 |
layout.title = 'Ch ' + i + ' - ' + t |
|
112 | layout.title = 'Ch ' + i + ' - ' + tm.toLocaleString(); | |
111 | } |
|
113 | } | |
112 |
|
114 | |||
113 | var conf = { |
|
115 | var conf = { | |
@@ -128,6 +130,16 class PcolorBuffer { | |||||
128 | } |
|
130 | } | |
129 | $('#id_ymin').val(Math.min(...this.metadata.yrange)); |
|
131 | $('#id_ymin').val(Math.min(...this.metadata.yrange)); | |
130 | $('#id_ymax').val(Math.max(...this.metadata.yrange)); |
|
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 | getSize() { |
|
145 | getSize() { | |
@@ -315,13 +327,10 class Pcolor { | |||||
315 | }; |
|
327 | }; | |
316 | var iDiv = document.createElement('div'); |
|
328 | var iDiv = document.createElement('div'); | |
317 | iDiv.id = 'plot-' + i; |
|
329 | iDiv.id = 'plot-' + i; | |
318 |
iDiv.className += iDiv.className ? ' col-md- |
|
330 | iDiv.className += iDiv.className ? ' col-md-6' : 'col-md-6'; | |
319 | this.n = this.n + 1; |
|
331 | this.n = this.n + 1; | |
320 | this.div.appendChild(iDiv); |
|
332 | this.div.appendChild(iDiv); | |
321 | this.divs.push(iDiv.id); |
|
333 | this.divs.push(iDiv.id); | |
322 | var iDiv = document.createElement('div'); |
|
|||
323 | iDiv.className = 'col-md-1'; |
|
|||
324 | this.div.appendChild(iDiv); |
|
|||
325 | var trace1 = { |
|
334 | var trace1 = { | |
326 | z: data['data'][i], |
|
335 | z: data['data'][i], | |
327 | y: data.metadata.yrange, |
|
336 | y: data.metadata.yrange, | |
@@ -370,6 +379,17 class Pcolor { | |||||
370 | $('#id_ymax').val(Math.max(...this.metadata.yrange)); |
|
379 | $('#id_ymax').val(Math.max(...this.metadata.yrange)); | |
371 | $('#id_xmin').val(Math.min(...this.metadata.xrange)); |
|
380 | $('#id_xmin').val(Math.min(...this.metadata.xrange)); | |
372 | $('#id_xmax').val(Math.max(...this.metadata.xrange)); |
|
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 | plot(obj) { |
|
395 | plot(obj) { | |
@@ -488,14 +508,8 class ScatterBuffer { | |||||
488 | } |
|
508 | } | |
489 |
|
509 | |||
490 | var label; |
|
510 | var label; | |
491 | //if (data.metadata.localtime == true){ |
|
|||
492 |
|
|
511 | label = "[LT]"; | |
493 |
|
512 | |||
494 | //} |
|
|||
495 | //else{ |
|
|||
496 | // label = "[UTC]"; |
|
|||
497 | //} |
|
|||
498 |
|
||||
499 | var layout = { |
|
513 | var layout = { | |
500 | height: 300, |
|
514 | height: 300, | |
501 | title: t.slice(-1).toLocaleString(), |
|
515 | title: t.slice(-1).toLocaleString(), | |
@@ -536,8 +550,17 class ScatterBuffer { | |||||
536 | showTips: true |
|
550 | showTips: true | |
537 | }; |
|
551 | }; | |
538 | Plotly.newPlot('plot', traces, layout, conf); |
|
552 | Plotly.newPlot('plot', traces, layout, conf); | |
539 | $('#id_ymin').val(Math.min(...this.metadata.yrange)); |
|
553 | ||
540 | $('#id_ymax').val(Math.max(...this.metadata.yrange)); |
|
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 | getSize() { |
|
566 | getSize() { |
@@ -26,13 +26,16 | |||||
26 | {% include "header_igp.html" %} |
|
26 | {% include "header_igp.html" %} | |
27 | <div class="container"> |
|
27 | <div class="container"> | |
28 | <!-- main --> |
|
28 | <!-- main --> | |
29 | <div class="d-flex" id="wrapper"> |
|
|||
30 | <main role="main"> |
|
29 | <main role="main"> | |
31 | <h1 class="titulo">{{title}}</h1> |
|
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 | </main> |
|
37 | </main> | |
34 | </div> |
|
38 | </div> | |
35 | </div> |
|
|||
36 | <!-- footer --> |
|
39 | <!-- footer --> | |
37 | {% include "footer_igp.html" %} |
|
40 | {% include "footer_igp.html" %} | |
38 | <!-- This part put block modal which is used to change parameters of my plot --> |
|
41 | <!-- This part put block modal which is used to change parameters of my plot --> |
@@ -2,22 +2,41 | |||||
2 | {% load static%} |
|
2 | {% load static%} | |
3 | {% block extra-header %} |
|
3 | {% block extra-header %} | |
4 | {% endblock %} |
|
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}} <span class="badge badge-primary text-left">{{tag.n | stringformat:"02d"}} </span></a> | |||
|
9 | {% endfor %} | |||
|
10 | </nav> | |||
|
11 | {% endblock %} | |||
5 | {% block content %} |
|
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 | <div class="row"> |
|
30 | <div class="row"> | |
8 | <ul class="legend"> |
|
31 | <ul class="legend"> | |
9 | <li> |
|
32 | <li>Time format: 24h (UTC-5)</li> | |
10 |
|
|
33 | <li><i class="fas fa-circle text-success"></i><span>Instrument online</span></li> | |
11 | </li> |
|
34 | <li><i class="fas fa-circle text-warning"></i><span>Instrument delayed</span></li> | |
12 | <li> |
|
35 | <li><i class="fas fa-circle text-danger"></i><span>Instrument offline</span></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> |
|
|||
18 | </ul> |
|
36 | </ul> | |
19 | </div> |
|
37 | </div> | |
20 | {% endblock content %} |
|
38 | {% endif %} | |
|
39 | {% endblock %} | |||
21 | {% block script %} |
|
40 | {% block script %} | |
22 | <script> |
|
41 | <script> | |
23 | function pad(num) { |
|
42 | function pad(num) { | |
@@ -29,9 +48,7 | |||||
29 | var hours = Math.floor(minutes/60) |
|
48 | var hours = Math.floor(minutes/60) | |
30 | minutes = minutes%60; |
|
49 | minutes = minutes%60; | |
31 | return pad(hours)+":"+pad(minutes)+":"+pad(secs); |
|
50 | return pad(hours)+":"+pad(minutes)+":"+pad(secs); | |
32 | } |
|
51 | } | |
33 | $("#loader").css("display", "none"); |
|
|||
34 |
|
||||
35 | /* This part create a new socket named "socket" to comunicate |
|
52 | /* This part create a new socket named "socket" to comunicate | |
36 | if there is new data we could be able to change some attributes of a class*/ |
|
53 | if there is new data we could be able to change some attributes of a class*/ | |
37 | var socket = new WebSocket('ws://' + window.location.host +'/ws/main/'); |
|
54 | var socket = new WebSocket('ws://' + window.location.host +'/ws/main/'); | |
@@ -45,15 +62,15 | |||||
45 | var code = data['code']; |
|
62 | var code = data['code']; | |
46 | console.log(code); |
|
63 | console.log(code); | |
47 | var value = data['value']; |
|
64 | var value = data['value']; | |
48 |
var time = moment(new Date(data['time']*1000)).format(' |
|
65 | var time = moment(new Date(data['time']*1000)).format('HH:mm:ss'); | |
49 |
|
66 | |||
50 | /*This conditional ask if value(send by server) is online, and if it is then |
|
67 | /*This conditional ask if value(send by server) is online, and if it is then | |
51 | change value to online in div with id="#alert_"+code*/ |
|
68 | change value to online in div with id="#alert_"+code*/ | |
52 |
|
69 | |||
53 | $("#date_"+code).text("Last data: "+time); |
|
70 | $("#date_"+code).text("Last data: "+time); | |
54 |
$("#card_"+code).removeClass().addClass("card m |
|
71 | $("#card_"+code).removeClass().addClass("card m-1 box-shadow text-"+value+" border-"+value); | |
55 | $("#card_header_"+code).removeClass().addClass("card-header text-white bg-"+value); |
|
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 | if (socket.readyState == WebSocket.OPEN) { |
|
76 | if (socket.readyState == WebSocket.OPEN) { |
@@ -1,24 +1,26 | |||||
1 |
{% extends 'base.html' %} {% load static %} {% load bootstrap4 %} |
|
1 | {% extends 'base.html' %} {% load static %} {% load bootstrap4 %} | |
2 | <div class="bc-icons"> |
|
2 | ||
3 | <nav aria-label="breadcrumb"> |
|
3 | {% block sidebar_content %} | |
4 | <ol class="breadcrumb bg-transparent mb-0 p-0"> |
|
4 | <h5>{{name}}</h5> | |
5 | {% for item in menu_list %} |
|
5 | <nav class="nav flex-column"> | |
6 | <li class="breadcrumb-item">{{item}} |
|
6 | {% for plot in plots %} | |
7 | {% if forloop.last is False %}<i class="fas fa-caret-right mx-2" aria-hidden="true"></i>{% endif %}</li> |
|
7 | <a class="nav-link" href="{% url 'url-plot' code plot.plot %}">{{plot.name}}</a> | |
8 |
|
|
8 | {% endfor %} | |
9 | </ol> |
|
9 | </nav> | |
10 | </nav> |
|
10 | {% endblock %} | |
11 | </div> |
|
11 | ||
|
12 | {% block content %} | |||
12 | <div class="row justify-content-center"> |
|
13 | <div class="row justify-content-center"> | |
13 |
<div id="loader" class=" |
|
14 | <div id="loader" class="m-5 loader"></div> | |
14 | </div> |
|
15 | </div> | |
15 | <div id="plot" {%if meta.metadata.type == 'pcolor' %}class="row"{%endif%}> |
|
16 | <div id="plot" {%if meta.metadata.type == 'pcolor' %}class="row"{%endif%}> | |
16 | {% if image %} |
|
17 | {% if image %} | |
17 | <img id="image" class="img-fluid"/> |
|
18 | <img id="image" class="img-fluid"/> | |
18 | {% endif %} |
|
19 | {% endif %} | |
19 | </div> |
|
20 | </div> | |
|
21 | {% endblock content %} | |||
20 |
|
22 | |||
21 | {% endblock content %} {% block modal %} |
|
23 | {% block modal %} | |
22 | <!-- Modal --> |
|
24 | <!-- Modal --> | |
23 | {% if setup_form %} |
|
25 | {% if setup_form %} | |
24 | <div class="modal fade" id="setup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> |
|
26 | <div class="modal fade" id="setup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> |
@@ -9,34 +9,99 | |||||
9 | <h5 class="card-title">Sky noise</h5> |
|
9 | <h5 class="card-title">Sky noise</h5> | |
10 | <p class="card-text">Sky brightness at 50 MHz, useful for antenna calibrations and measure radar's sensitivity. |
|
10 | <p class="card-text">Sky brightness at 50 MHz, useful for antenna calibrations and measure radar's sensitivity. | |
11 | </p> |
|
11 | </p> | |
12 | <div class="input-group input-group-sm"> |
|
12 | <input type="date" class="form-control tools-date" id="skynoise-date" placeholder="dd/mm/yy" | |
13 | <div class="input-group-prepend"> |
|
13 | aria-describedby="validationTooltipSkynoiseDate" value="{% now 'Y-m-d' %}" required> | |
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> |
|
|||
19 | <div class="invalid-tooltip"> |
|
14 | <div class="invalid-tooltip"> | |
20 | Please enter a valid date. |
|
15 | Please enter a valid date. | |
21 | </div> |
|
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 | data-image="{% url 'url_skynoise' %}">Go</a> |
|
18 | data-image="{% url 'url_skynoise' %}">Go</a> | |
24 | </div> |
|
|||
25 | </div> |
|
19 | </div> | |
26 | </div> |
|
20 | </div> | |
|
21 | ||||
27 | <div class="card text-justify"> |
|
22 | <div class="card text-justify"> | |
28 | <img src="{% static 'images/kp.png' %}" class="card-img-top" alt="..."> |
|
|||
29 | <div class="card-body"> |
|
23 | <div class="card-body"> | |
30 |
<h5 class="card-title"> |
|
24 | <h5 class="card-title">Over JRO</h5> | |
31 | <p class="card-text">The K-index, are used to characterize the magnitude of geomagnetic storms. Kp is an excellent |
|
25 | <p class="card-text">Main antenna radiation pattern for several experiments. | |
32 | indicator of disturbances in the Earth's magnetic field (<a |
|
26 | ||
33 | href="https://www.swpc.noaa.gov/products/planetary-k-index" target="_blank">NOAA/SWPC</a>).</p> |
|
27 | <input type="date" class="form-control form-control-sm tools-date" id="overjro-date" placeholder="dd/mm/yy" | |
34 | <a class="btn btn-primary" data-toggle="modal" href="#toolModal" data-title="Kp Index" |
|
28 | aria-describedby="validationTooltipOverJRODate" value="{% now 'Y-m-d' %}" required> | |
35 | data-image="https://services.swpc.noaa.gov/images/planetary-k-index.gif">Go</a> |
|
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 | </div> |
|
101 | </div> | |
37 | </div> |
|
102 | </div> | |
|
103 | ||||
38 | </div> |
|
104 | </div> | |
39 | <br><br> |
|
|||
40 |
|
105 | |||
41 | <!-- Modal --> |
|
106 | <!-- Modal --> | |
42 | <div class="modal fade" id="toolModal" tabindex="-1" role="dialog" aria-labelledby="toolModalTitle" aria-hidden="true"> |
|
107 | <div class="modal fade" id="toolModal" tabindex="-1" role="dialog" aria-labelledby="toolModalTitle" aria-hidden="true"> |
@@ -1,12 +1,14 | |||||
1 | from django.conf.urls import url |
|
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 | urlpatterns = [ |
|
5 | urlpatterns = [ | |
6 | url(r'^$', main, name='url_main'), |
|
6 | url(r'^$', main, name='url_main'), | |
|
7 | url(r'^experiment/(?P<tag>[-\w]+)/$', main, name='url_main'), | |||
7 | url(r'^tools/$', tools, name='url_tools'), |
|
8 | url(r'^tools/$', tools, name='url_tools'), | |
8 | url(r'^tools/skynoise.png$', plot_skynoise, name='url_skynoise'), |
|
9 | url(r'^tools/skynoise.png$', plot_skynoise, name='url_skynoise'), | |
|
10 | url(r'^tools/overjro.png$', plot_overjro, name='url_overjro'), | |||
9 | url(r'^reports/$', reports, name='url_reports'), |
|
11 | url(r'^reports/$', reports, name='url_reports'), | |
10 | url(r'^about/$', about, name='url_about'), |
|
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 | zmin = forms.CharField(initial=10) |
|
68 | zmin = forms.CharField(initial=10) | |
69 |
|
69 | |||
70 | # Create your views here. |
|
70 | # Create your views here. | |
71 | def main(request): |
|
71 | def main(request, tag=None): | |
72 |
|
72 | |||
73 | kwargs = {} |
|
73 | kwargs = {} | |
74 | date = request.GET.get('date', datetime.now().strftime('%d-%m-%Y')) |
|
74 | date = request.GET.get('date', datetime.now().strftime('%d-%m-%Y')) | |
75 | exps = ExpDetail.objects(date=datetime.strptime(date, '%d-%m-%Y')) |
|
75 | exps = ExpDetail.objects(date=datetime.strptime(date, '%d-%m-%Y')) | |
76 | experiments = [] |
|
|||
77 |
|
76 | |||
|
77 | tmp = {} | |||
78 | for exp in exps: |
|
78 | for exp in exps: | |
79 | dum = {} |
|
79 | label = exp.tag.lower().strip() if exp.tag else 'other' | |
80 | dum['code'] = exp.experiment.code |
|
80 | if label in tmp: | |
81 | dum['plots'] = [] |
|
81 | tmp[label] += 1 | |
82 | dum['name'] = exp.experiment.name |
|
82 | else: | |
83 | dt = datetime.now() |
|
83 | tmp[label] = 1 | |
84 |
|
84 | tags = [] | ||
85 | t = time.mktime(dt.timetuple()) |
|
85 | ||
86 | t -= 5*60*60 |
|
86 | for key, value in tmp.items(): | |
87 |
|
87 | if tag == key: | ||
88 | if (t-exp['last_time']) > 6*exp['interval']: |
|
88 | tags.append({'name': key, 'n': tmp[key], 'active': 'active'}) | |
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'] |
|
|||
98 | else: |
|
89 | else: | |
99 | status = 'Online' |
|
90 | tags.append({'name': key, 'n': tmp[key]}) | |
100 | clase = 'alertas-online' |
|
91 | ||
101 | style = 'success' |
|
92 | kwargs['tags'] = tags | |
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) |
|
|||
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 | kwargs['date'] = date |
|
135 | kwargs['date'] = date | |
113 | kwargs['experiments'] = experiments |
|
136 | ||
114 | kwargs['title'] = 'Realtime Experiments at JRO' |
|
137 | kwargs['title'] = 'Realtime Experiments at JRO' | |
|
138 | kwargs['sidebar'] = True | |||
115 |
|
139 | |||
116 | return render(request, 'home.html', kwargs) |
|
140 | return render(request, 'home.html', kwargs) | |
117 |
|
141 | |||
@@ -152,7 +176,7 def plot(request, code=None, plot=None): | |||||
152 | exp = Experiment.objects.get(code=int(code)) |
|
176 | exp = Experiment.objects.get(code=int(code)) | |
153 | detail = ExpDetail.objects.get(experiment=exp, date=datetime.strptime(date, '%d-%m-%Y')) |
|
177 | detail = ExpDetail.objects.get(experiment=exp, date=datetime.strptime(date, '%d-%m-%Y')) | |
154 | meta = PlotMeta.objects.get(exp_detail=detail, plot=plot) |
|
178 | meta = PlotMeta.objects.get(exp_detail=detail, plot=plot) | |
155 |
|
179 | |||
156 | kwargs = { |
|
180 | kwargs = { | |
157 | 'code': code, |
|
181 | 'code': code, | |
158 | 'plot': plot, |
|
182 | 'plot': plot, | |
@@ -160,9 +184,15 def plot(request, code=None, plot=None): | |||||
160 | 'date': date, |
|
184 | 'date': date, | |
161 | 'id': meta.pk, |
|
185 | 'id': meta.pk, | |
162 | 'realtime': realtime, |
|
186 | 'realtime': realtime, | |
163 | 'title': 'Realtime', |
|
187 | 'title': 'Realtime Experiments at JRO', | |
164 | 'menu_list': [exp.name, meta.plot.replace('_', ' ').title()] |
|
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 | # Logic to show my views |
|
196 | # Logic to show my views | |
167 | if meta.metadata['type'] == 'pcolorbuffer': |
|
197 | if meta.metadata['type'] == 'pcolorbuffer': | |
168 | kwargs['setup_form'] = RTISetupForm() |
|
198 | kwargs['setup_form'] = RTISetupForm() | |
@@ -189,9 +219,22 def plot_skynoise(request): | |||||
189 | if date is None: |
|
219 | if date is None: | |
190 | date = datetime.now() |
|
220 | date = datetime.now() | |
191 | else: |
|
221 | else: | |
192 |
date = datetime.strptime(date, '% |
|
222 | date = datetime.strptime(date, '%Y-%m-%d') | |
193 |
|
223 | |||
194 | data = skynoise_plot(date.year, date.month, date.day) |
|
224 | data = skynoise_plot(date.year, date.month, date.day) | |
195 | response = HttpResponse(data.getvalue(), content_type='image/png') |
|
225 | response = HttpResponse(data.getvalue(), content_type='image/png') | |
196 |
|
226 | |||
197 | return response |
|
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 | import time |
|
9 | import time | |
10 | import zmq |
|
10 | import zmq | |
11 | import mongoengine |
|
11 | import mongoengine | |
|
12 | import django | |||
12 | from threading import Thread |
|
13 | from threading import Thread | |
13 |
|
14 | |||
14 | sys.path.append(os.environ.get('APP_DIR', '../')) |
|
15 | sys.path.append(os.environ.get('APP_DIR', '../')) | |
15 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "realtime.settings") |
|
16 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "realtime.settings") | |
|
17 | django.setup() | |||
16 |
|
18 | |||
17 | from plotter.models import Experiment, ExpDetail, PlotMeta, PlotData |
|
19 | from plotter.models import Experiment, ExpDetail, PlotMeta, PlotData | |
18 |
|
20 | |||
@@ -44,6 +46,7 def loaddata(): | |||||
44 | def update(buffer): |
|
46 | def update(buffer): | |
45 | dt = datetime.utcfromtimestamp(buffer['time']) |
|
47 | dt = datetime.utcfromtimestamp(buffer['time']) | |
46 | interval = buffer['metadata'].pop('interval') |
|
48 | interval = buffer['metadata'].pop('interval') | |
|
49 | tag = buffer['metadata'].pop('tag') if 'tag' in buffer['metadata'] else '' | |||
47 | exp = Experiment.objects.get(code=buffer['code']) |
|
50 | exp = Experiment.objects.get(code=buffer['code']) | |
48 |
|
51 | |||
49 | detail = ExpDetail.objects(experiment=exp, date=dt.date()).modify( |
|
52 | detail = ExpDetail.objects(experiment=exp, date=dt.date()).modify( | |
@@ -52,7 +55,8 def update(buffer): | |||||
52 | set__experiment=exp, |
|
55 | set__experiment=exp, | |
53 | set__date=dt.date(), |
|
56 | set__date=dt.date(), | |
54 | set__last_time = buffer['time'], |
|
57 | set__last_time = buffer['time'], | |
55 | set__interval = interval |
|
58 | set__interval = interval, | |
|
59 | set__tag = tag, | |||
56 | ) |
|
60 | ) | |
57 |
|
61 | |||
58 | label = buffer['plot'].replace(' ', '_').lower() |
|
62 | label = buffer['plot'].replace(' ', '_').lower() |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now