##// END OF EJS Templates
Se resolvió plot pattern de ABS
Renato Huallpa -
r390:5670a70fd8d1
parent child
Show More
@@ -18,8 +18,8 TZ=America/Lima
18 18 DOCKER_DATA=/data/dockers/radarsys/
19 19 LOCAL_IP=192.168.1.128
20 20
21 MQTT_SERVER=10.10.10.200
22 # MQTT_SERVER = 192.168.100.5
21 # MQTT_SERVER=10.10.10.200
22 MQTT_SERVER = 192.168.100.5
23 23 MQTT_PORT = 1883
24 24 MQTT_KEEPALIVE = 3660
25 25
@@ -339,6 +339,7 class ABSConfiguration(Configuration):
339 339 try:
340 340 #self.write_device()
341 341 send_task('task_change_beam', [self.id],)
342 print("*************************RUNNING ABS**************************",flush=True)
342 343 self.message = 'ABS running'
343 344
344 345 except Exception as e:
@@ -356,6 +357,7 class ABSConfiguration(Configuration):
356 357 self.device.status = 2
357 358 self.device.save()
358 359 self.message = 'ABS has been stopped.'
360 print("*************************STOPPED ABS**************************",flush=True)
359 361 self.save()
360 362
361 363 return True
@@ -2,10 +2,6
2 2 {% load django_bootstrap5 %}
3 3 {% load main_tags %}
4 4
5 {% block content %}
5 <img id="imgMainDown" src="{% url 'url_plot_beam' beam.abs_conf.id beam.id 'down' %}" alt="Error ploting..." style="width: 250px;height:250px; background-image: url({% static 'images/loader.gif' %});background-repeat: no-repeat;background-position: 50% 50%;">
6 6
7 <div id="PictureOverJRODown" style="float: right">
8 <img id="imgMainDown" src="{% url 'url_plot_beam' beam.abs_conf.id beam.id 'down' %}" alt="Error ploting..." style="width:340px;height:340px; background-image: url({% static 'images/loader.gif' %});background-repeat: no-repeat;background-position: 50% 50%;">
9 </div>
10 7
11 {% endblock %}
@@ -122,7 +122,12
122 122 font-size: 95%;
123 123 }
124 124
125
125 .image_plot {
126 border: 2px solid #00334d;
127 display: inline-block;
128 vertical-align: 50px;
129 margin-left: 10px;
130 }
126 131
127 132 .abs_rx tr:nth-last-child(1){
128 133 border-bottom: 0px solid #00334d;
@@ -373,9 +378,16
373 378 </tr>
374 379 </table>
375 380
376 {% if not edit %}
377 {% include "abs_uppattern_img.html" %}
378 {% endif %}
381 <table class="image_plot">
382 <tr>
383 <td>
384 {% if not edit %}
385 {% include "abs_uppattern_img.html" %}
386 {% endif %}
387 <!-- <img id="imgMains" src="{% url 'url_plot_beam' beam.abs_conf.id beam.id 'up' %}" alt="Error ploting..." style="width: 250px;height:250px; background-image: url({% static 'images/loader.gif' %});background-repeat: no-repeat;background-position: 50% 50%;"> -->
388 </td>
389 </tr>
390 </table>
379 391
380 392 <br>
381 393
@@ -597,9 +609,15
597 609 </tr>
598 610 </table>
599 611
600 {% if not edit %}
601 {% include "abs_downpattern_img.html" %}
602 {% endif %}
612 <table class="image_plot">
613 <tr>
614 <td>
615 {% if not edit %}
616 {% include "abs_downpattern_img.html" %}
617 {% endif %}
618 </td>
619 </tr>
620 </table>
603 621
604 622 <br>
605 623
@@ -36,7 +36,7
36 36 <script>
37 37 {% for abs_beam in abs_beams %}
38 38 $("#bt_beam{{ forloop.counter }}").click(function() {
39 document.location = "{% url 'url_plot_abs_patterns' abs_beam.abs_conf.id abs_beam.id %}";
39 document.location = "{% url 'url_plot_abs_patterns2' abs_beam.abs_conf.id abs_beam.id %}";
40 40 });
41 41 {% endfor %}
42 42 //function ChangeColor() {
@@ -2,10 +2,4
2 2 {% load django_bootstrap5 %}
3 3 {% load main_tags %}
4 4
5 {% block content %}
6
7 <div id="PictureOverJROUp" style="float: right">
8 <img id="imgMain" src="{% url 'url_plot_beam' beam.abs_conf.id beam.id 'up' %}" alt="Error ploting..." style="width:340px;height:340px; background-image: url({% static 'images/loader.gif' %});background-repeat: no-repeat;background-position: 50% 50%;">
9 </div>
10
11 {% endblock %}
5 <img id="imgMainUp" src="{% url 'url_plot_beam' beam.abs_conf.id beam.id 'up' %}" alt="Error ploting..." style="width: 250px;height:250px; background-image: url({% static 'images/loader.gif' %});background-repeat: no-repeat;background-position: 50% 50%;">
@@ -10,8 +10,8 urlpatterns = (
10 10 #url(r'^(?P<id_conf>-?\d+)/status/', views.abs_conf, {'status_request':True},name='url_status_abs_conf'),
11 11 path('<int:id_conf>/change_beam/<int:id_beam>/', views.send_beam, name='url_send_beam'),
12 12 path('<int:id_conf>/plot/', views.plot_patterns, name='url_plot_abs_patterns'),
13 path('<int:id_conf>/plot/<int:id_beam>/', views.plot_patterns, name='url_plot_abs_patterns'),
14 path('<int:id_conf>/plot/<int:id_beam>/<int:antenna>/pattern.png', views.plot_pattern, name='url_plot_beam'),
13 path('<int:id_conf>/plot/<int:id_beam>/', views.plot_patterns, name='url_plot_abs_patterns2'),
14 path('<int:id_conf>/plot/<int:id_beam>/<slug:antenna>/pattern.png/', views.plot_pattern, name='url_plot_beam'),
15 15 path('<int:id_conf>/add_beam/', views.add_beam, name='url_add_abs_beam'),
16 16 path('<int:id_conf>/beam/<int:id_beam>/delete/', views.remove_beam, name='url_remove_abs_beam'),
17 17 path('<int:id_conf>/beam/<int:id_beam>/edit/', views.edit_beam, name='url_edit_abs_beam'),
@@ -79,7 +79,7 class AntPatternPlot:
79 79 levels = numpy.array([1e-3,1e-2,1e-1,0.5,1.0])
80 80 tmp = numpy.round(10*numpy.log10(levels),decimals=1)
81 81 labels = []
82 for i in numpy.arange(5):labels.append(str(numpy.int(tmp[i])))
82 for i in numpy.arange(5):labels.append(str(int(tmp[i])))
83 83
84 84
85 85 colors = ((0,0,1.),(0,170/255.,0),(127/255.,1.,0),(1.,109/255.,0),(128/255.,0,0))
@@ -137,10 +137,10 class AntPatternPlot:
137 137
138 138 # Getting HA and DEC axes
139 139 mindec = -28; maxdec = 4; incdec = 2.
140 ndec = numpy.int((maxdec - mindec)/incdec) + 1
140 ndec = int((maxdec - mindec)/incdec) + 1
141 141
142 142 minha = -20; maxha = 20; incha = 2.
143 nha = numpy.int((maxha - minha)/incha) + 1
143 nha = int((maxha - minha)/incha) + 1
144 144
145 145 #mcosx = numpy.zeros((nha,ndec))
146 146 #mcosy = numpy.zeros((nha,ndec))
@@ -184,8 +184,8 class AntPatternPlot:
184 184 if noval[0].size>0:mcosy[noval] = numpy.nan
185 185
186 186 # Plotting HA and declination grid.
187 iha0 = numpy.int((0 - minha)/incha)
188 idec0 = numpy.int((-14 - mindec)/incdec)
187 iha0 = int((0 - minha)/incha)
188 idec0 = int((-14 - mindec)/incdec)
189 189
190 190 colorgrid = (1.,109/255.,0)
191 191 self.ax.plot(mcosx.transpose(),mcosy.transpose(),color=colorgrid,linestyle='--')
@@ -194,7 +194,7 class AntPatternPlot:
194 194 valx = (mcosx[idec,iha0]<=xmax) & (mcosx[idec,iha0]>=xmin)
195 195 valy = (mcosy[idec,iha0]<=ymax) & (mcosy[idec,iha0]>=ymin)
196 196 if valx & valy:
197 text = str(numpy.int(mindec + incdec*idec))+'$^o$'
197 text = str(int(mindec + incdec*idec))+'$^o$'
198 198 self.ax.text(mcosx[idec,iha0],mcosy[idec,iha0],text)
199 199
200 200 matplotlib.pyplot.plot(mcosx,mcosy,color=colorgrid,linestyle='--')
@@ -203,7 +203,7 class AntPatternPlot:
203 203 valx = (mcosx[idec0,iha]<=xmax) & (mcosx[idec0,iha]>=xmin)
204 204 valy = (mcosy[idec0,iha]<=ymax) & (mcosy[idec0,iha]>=ymin)
205 205 if valx & valy:
206 text = str(4*numpy.int(minha + incha*iha))+"'"
206 text = str(4*int(minha + incha*iha))+"'"
207 207 self.ax.text(mcosx[idec0,iha],mcosy[idec0,iha],text)
208 208
209 209 if save:
@@ -257,9 +257,9 class AntPatternPlot:
257 257
258 258
259 259 ObjFig, = self.ax.plot(alpha_location[:,0,ih],alpha_location[:,1,ih],
260 marker[ih % 8],color=colors[numpy.int(ih/8)],ms=4.5,lw=0.5)
260 marker[ih % 8],color=colors[int(ih/8)],ms=4.5,lw=0.5)
261 261 handles.append(ObjFig)
262 objects.append(numpy.str(heights[ih]) + ' km')
262 objects.append(str(heights[ih]) + ' km')
263 263
264 264 self.ax.legend(handles,objects,loc="lower right", numpoints=1, handlelength=0.3,
265 265 handletextpad=0.02, borderpad=0.3, labelspacing=0.1)
@@ -329,9 +329,9 class BFieldPlot:
329 329
330 330
331 331 ObjFig, = matplotlib.pyplot.plot(alpha_location[:,0,ih],alpha_location[:,1,ih], \
332 marker[ih % 8],color=colors[numpy.int(ih/8)],ms=4.5,lw=0.5)
332 marker[ih % 8],color=colors[int(ih/8)],ms=4.5,lw=0.5)
333 333 handles.append(ObjFig)
334 objects.append(numpy.str(heights[ih]) + ' km')
334 objects.append(str(heights[ih]) + ' km')
335 335
336 336 matplotlib.pyplot.xlim(dcosxrange[0],dcosxrange[1])
337 337 matplotlib.pyplot.ylim(dcosyrange[0],dcosyrange[1])
@@ -468,7 +468,7 class CelestialObjectsPlot:
468 468
469 469 index = numpy.mean(tod_0[val]) - minlev
470 470 index = (index*(maxcol - mincol)/(maxlev - minlev)) + mincol
471 index = numpy.int(index)
471 index = int(index)
472 472 figobjects, = matplotlib.pyplot.plot(dcosx[val],dcosy[val],marker[io-1],\
473 473 lw=1,ms=7,mew=0,color=tuple(colortable[:,index]))
474 474 handles.append(figobjects)
@@ -235,6 +235,7 class JroPattern():
235 235 --------------------
236 236 Developed by Jorge L. Chau.
237 237 Converted to Python by Freddy R. Galindo, ROJ, 20 September 2009.
238 Updated to Django 4.1.5 and Python 3.9.16 by Renato Huallpa M. March 2023.
238 239 """
239 240
240 241 if rx==1:
@@ -290,7 +291,7 class JroPattern():
290 291
291 292 fft_phase = fft_phase*CoFactors.d2r
292 293
293 pattern = numpy.abs(numpy.fft.fft2(fft_gain*numpy.exp(numpy.complex(0,1)*fft_phase)))**2
294 pattern = numpy.abs(numpy.fft.fft2(fft_gain*numpy.exp(complex(0,1)*fft_phase)))**2
294 295 pattern = numpy.fft.fftshift(pattern)
295 296
296 297 xvals = numpy.where((dcosx>=(numpy.min(self.dcosx))) & (dcosx<=(numpy.max(self.dcosx))))
@@ -416,6 +417,7 class JroPattern():
416 417 --------------------
417 418 Developed by Jorge L. Chau.
418 419 Converted to Python by Freddy R. Galindo, ROJ, 20 September 2009.
420 Updated to Django 4.1.5 and Python 3.9.16 by Renato Huallpa M. March 2023.
419 421 """
420 422
421 423 pos = self.eomwl*self.__readAttenuation()
@@ -429,7 +431,7 class JroPattern():
429 431 yindex = iy*(self.getcut==0) + ix*(self.getcut==1)
430 432 phasex = posx*self.dcosx[ix]
431 433 phasey = posy*self.dcosy[yindex]
432 tmp = gain*numpy.exp(numpy.complex(0,1.)*(self.kk*(phasex+phasey)+phase))
434 tmp = gain*numpy.exp(complex(0,1.)*(self.kk*(phasex+phasey)+phase))
433 435 module[ix,iy] = tmp.sum()
434 436
435 437 return module
@@ -468,8 +470,9 class JroPattern():
468 470 yy1 = self.dcosy[numpy.min(nny):numpy.max(nny)+1]
469 471
470 472 # fitting data into the main beam.
471 import gaussfit
472 params = gaussfit.fitgaussian(mm1)
473 #import apps.abs.utils.gaussfit as gaussfit
474 from .gaussfit import fitgaussian
475 params = fitgaussian(mm1)
473 476
474 477 # Tranforming from indexes to axis' values
475 478 xcenter = xx1[0] + (((xx1[xx1.size-1] - xx1[0])/(xx1.size -1))*(params[1]))
@@ -569,8 +572,8 class BField():
569 572 nfields = 1
570 573
571 574 grid_res = 0.5
572 nlon = int(numpy.int(maglimits[2] - maglimits[0])/grid_res + 1)
573 nlat = int(numpy.int(maglimits[3] - maglimits[1])/grid_res + 1)
575 nlon = int(int(maglimits[2] - maglimits[0])/grid_res + 1)
576 nlat = int(int(maglimits[3] - maglimits[1])/grid_res + 1)
574 577
575 578 location = numpy.zeros((nlon,nlat,2))
576 579 mlon = numpy.atleast_2d(numpy.arange(nlon)*grid_res + maglimits[0])
@@ -629,7 +632,7 class BField():
629 632 rr = numpy.zeros((heights.size,3))
630 633 rgc = numpy.zeros((heights.size,3))
631 634
632 ObjGeodetic = Astro_Coords.Geodetic(gdlat,gdalt)
635 ObjGeodetic = Geodetic(gdlat,gdalt)
633 636 [gclat,gcalt] = ObjGeodetic.change2geocentric()
634 637
635 638 gclat = gclat*numpy.pi/180.
@@ -1362,7 +1365,7 class overJroShow:
1362 1365
1363 1366 vect_polar = Misc_Routines.Vector(numpy.array(vect_geo),direction=1).Polar2Rect()
1364 1367
1365 [ra,dec,ha] = Astro_Coords.AltAz(vect_polar[1],vect_polar[0],self.junkjd).change2equatorial()
1368 [ra,dec,ha] = AltAz(vect_polar[1],vect_polar[0],self.junkjd).change2equatorial()
1366 1369
1367 1370 print('Main beam position (HA(min), DEC(degrees)): %f %f')%(ha*4.,dec)
1368 1371
@@ -1421,7 +1424,7 class overJroShow:
1421 1424
1422 1425 vect_polar = Misc_Routines.Vector(vect_geo,direction=1).Polar2Rect()
1423 1426
1424 [ra,dec,ha] = Astro_Coords.AltAz(vect_polar[1,:],vect_polar[0,:],self.junkjd).change2equatorial()
1427 [ra,dec,ha] = AltAz(vect_polar[1,:],vect_polar[0,:],self.junkjd).change2equatorial()
1425 1428
1426 1429 val = numpy.where(ha>=180)
1427 1430
@@ -1609,7 +1612,7 class overJroShow:
1609 1612
1610 1613 julian = Time(year,month,dom).change2julday()
1611 1614
1612 [powr,time, lst] = Astro_Coords.CelestialBodies().skyNoise(julian)
1615 [powr,time, lst] = CelestialBodies().skyNoise(julian)
1613 1616
1614 1617 SkyNoisePlot([year,month,dom],powr,time,lst).getPlot(self.path4plotname,self.plotname2)
1615 1618
@@ -291,12 +291,13 class JARSConfiguration(Configuration):
291 291 self.device.status = payload['status']
292 292 self.device.save()
293 293 self.message = payload['message']
294 print("------STOP JARS------",flush=True)
294 295 except Exception as e:
295 296 self.device.status = 0
296 297 self.message = str(e)
297 298 self.device.save()
298 299 return False
299
300
300 301 return True
301 302
302 303 def read_device(self):
@@ -318,6 +319,10 class JARSConfiguration(Configuration):
318 319 if self.device.status == 3:
319 320 self.message = 'Could not configure device. Software Acquisition is running'
320 321 return False
322
323 print("------ JARS WRITING ------",flush=True)
324 self.device.status = 5 #Busy
325 print("STATUS:", self.device.status,flush=True)
321 326
322 327 data = self.experiment.parms_to_dict()
323 328 #print(data)
@@ -335,6 +340,7 class JARSConfiguration(Configuration):
335 340 return False
336 341
337 342 json_data = json.dumps(data)
343 print("STATUS:", self.device.status,flush=True)
338 344
339 345 try:
340 346 payload = self.request('write', 'post', json=json_data)
@@ -343,13 +349,14 class JARSConfiguration(Configuration):
343 349 self.device.save()
344 350 if self.device.status == 1:
345 351 return False
352 print("------ JARS WRITED ------",flush=True)
346 353
347 354 except Exception as e:
348 355 self.device.status = 0
349 356 self.message = str(e)
350 357 self.device.save()
351 358 return False
352
359 print("FINAL STATUS:", self.device.status,flush=True)
353 360 return True
354 361
355 362 def start_device(self):
@@ -368,7 +375,7 class JARSConfiguration(Configuration):
368 375 self.message = str(e)
369 376 self.device.save()
370 377 return False
371
378 print("------START JARS------",flush=True)
372 379 return True
373 380
374 381 def get_log(self):
@@ -30,7 +30,7 class Command(BaseCommand):
30 30 # print("RADR", rad)
31 31 radar_id=rad["id"]
32 32 # print("RADR_",radar_id)
33 radar_start_scheduler(campaign.id,radar_id)
33 radar_write_start_scheduler(campaign.id,radar_id)
34 34 print(campaign.name, "\t\t Campaign already running")
35 35
36 36 else:
@@ -43,10 +43,9 class Command(BaseCommand):
43 43 else:
44 44 print(campaign.name,"\t\t\t Campaign already stooped")
45 45
46 def radar_start_scheduler(id_camp,id_radar):
46 def radar_write_start_scheduler(id_camp,id_radar):
47 47 campaign = get_object_or_404(Campaign, pk=id_camp)
48 48 experiments = campaign.get_experiments_by_radar(id_radar)[0]['experiments']
49 now = datetime.now()
50 49 # print(campaign)
51 50 # print(experiments)
52 51 for exp in experiments:
@@ -62,7 +61,7 def radar_start_scheduler(id_camp,id_radar):
62 61 if exp.status == 2:
63 62 print('\t\t\t {} \t\tExperiment started'.format(exp))
64 63 if exp.status == 4:
65 print('\t\t\t {} \t\tExperiment with state uknown, please reset'.format(exp))
64 print('\t\t\t {} \t\tExperiment with state uknown, please reset (Stop and start manually)'.format(exp))
66 65 exp.save()
67 66
68 67 def radar_stop_scheduler(id_camp,id_radar,id_experiment):
@@ -62,6 +62,7 DEV_STATES = (
62 62 (2, 'Configured'),
63 63 (3, 'Running'),
64 64 (4, 'Unknown'),
65 (5, 'Busy')
65 66 )
66 67
67 68 DEV_TYPES = (
@@ -766,18 +767,21 class Configuration(PolymorphicModel):
766 767 def stop_device(self):
767 768
768 769 self.message = 'Function not implemented'
770 print("BUENAS SEÑALES??? NO LO CREO2",flush=True)
769 771 return False
770 772
771 773
772 774 def start_device(self):
773 775
774 776 self.message = 'Function not implemented'
777 print("BUENAS SEÑALES??? NO LO CREO",flush=True)
775 778 return False
776 779
777 780
778 781 def write_device(self, parms):
779 782
780 783 self.message = 'Function not implemented'
784 print("BUENAS SEÑALES??? NO LO CREO3",flush=True)
781 785 return False
782 786
783 787 def write_device_mqtt(self, parms):
General Comments 0
You need to be logged in to leave comments. Login now