|
1 | NO CONTENT: new file 100644, binary diff hidden |
@@ -3,23 +3,9 | |||
|
3 | 3 | {% load main_tags %} |
|
4 | 4 | |
|
5 | 5 | {% block content %} |
|
6 | <style> | |
|
7 | </style> | |
|
8 | 6 | |
|
9 | 7 | <div id="PictureOverJRODown" style="float: right"> |
|
10 | <img id="imgMainDown" src="{% url 'url_plot_down_beam' beam.abs_conf.id beam.id %}" alt="Error in Parameters" style="width:360px;height:270px;"> | |
|
11 | <img id="imgLoaderDown" src="{% static 'images/loading_loading.gif' %}" alt="Error in Parameters" width="50" height="50" align="left"> | |
|
12 | ||
|
8 | <img id="imgMainDown" src="{% url 'url_plot_beam' beam.abs_conf.id beam.id 'down' %}" alt="Error ploting..." style="width:360px;height:360px; background-image: url({% static 'images/loader.gif' %});background-repeat: no-repeat;background-position: 50% 50%;"> | |
|
13 | 9 | </div> |
|
14 | 10 | |
|
15 | <script> | |
|
16 | ||
|
17 | $('#imgMainDown').hide(); | |
|
18 | $('#imgLoaderDown').show(); | |
|
19 | $('#imgMainDown').load(function(){ | |
|
20 | $('#imgLoaderDown').hide(); | |
|
21 | $('#imgMainDown').show(); | |
|
22 | }); | |
|
23 | //window.onload = function () { alert("It's loaded!") } | |
|
24 | </script> | |
|
25 | 11 | {% endblock %} |
@@ -42,7 +42,7 | |||
|
42 | 42 | <script> |
|
43 | 43 | {% for abs_beam in abs_beams %} |
|
44 | 44 | $("#bt_beam{{ forloop.counter }}").click(function() { |
|
45 | document.location = "{% url 'url_plot_abs_pattern' abs_beam.abs_conf.id abs_beam.id %}"; | |
|
45 | document.location = "{% url 'url_plot_abs_patterns' abs_beam.abs_conf.id abs_beam.id %}"; | |
|
46 | 46 | }); |
|
47 | 47 | {% endfor %} |
|
48 | 48 | //function ChangeColor() { |
@@ -3,23 +3,9 | |||
|
3 | 3 | {% load main_tags %} |
|
4 | 4 | |
|
5 | 5 | {% block content %} |
|
6 | <style> | |
|
7 | </style> | |
|
8 | 6 | |
|
9 | 7 | <div id="PictureOverJROUp" style="float: right"> |
|
10 | <img id="imgMain" src="{% url 'url_plot_up_beam' beam.abs_conf.id beam.id %}" alt="Error in Parameters" style="width:360px;height:270px;"> | |
|
11 | <img id="imgLoader" src="{% static 'images/loading_loading.gif' %}" alt="Error in Parameters" width="50" height="50"> | |
|
12 | ||
|
8 | <img id="imgMain" src="{% url 'url_plot_beam' beam.abs_conf.id beam.id 'up' %}" alt="Error ploting..." style="width:360px;height:360px; background-image: url({% static 'images/loader.gif' %});background-repeat: no-repeat;background-position: 50% 50%;"> | |
|
13 | 9 | </div> |
|
14 | 10 | |
|
15 | <script> | |
|
16 | ||
|
17 | $('#imgMain').hide(); | |
|
18 | $('#imgLoader').show(); | |
|
19 | $('#imgMain').load(function(){ | |
|
20 | $('#imgLoader').hide(); | |
|
21 | $('#imgMain').show(); | |
|
22 | }); | |
|
23 | ||
|
24 | </script> | |
|
25 | 11 | {% endblock %} |
@@ -9,9 +9,8 urlpatterns = ( | |||
|
9 | 9 | #url(r'^(?P<id_conf>-?\d+)/import/$', views.dev_conf_import, name='url_import_abs_conf'), |
|
10 | 10 | #url(r'^(?P<id_conf>-?\d+)/export/$', views.dev_conf_export, name='url_export_abs_conf'), |
|
11 | 11 | url(r'^(?P<id_conf>-?\d+)/plot/$', views.plot_patterns, name='url_plot_abs_patterns'), |
|
12 | url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/$', views.plot_pattern, name='url_plot_abs_pattern'), | |
|
13 |
url(r'^(?P<id_conf>-?\d+)/plot |
|
|
14 | url(r'^(?P<id_conf>-?\d+)/plot_down_beam/(?P<id_beam>-?\d+)/$', views.plot_downpattern, name='url_plot_down_beam'), | |
|
12 | url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/$', views.plot_patterns, name='url_plot_abs_patterns'), | |
|
13 | url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/(?P<antenna>[\w\-]+)/pattern.png$', views.plot_pattern, name='url_plot_beam'), | |
|
15 | 14 | url(r'^(?P<id_conf>-?\d+)/add_beam/$', views.add_beam, name='url_add_abs_beam'), |
|
16 | 15 | url(r'^(?P<id_conf>-?\d+)/beam/(?P<id_beam>-?\d+)/delete/$', views.remove_beam, name='url_remove_abs_beam'), |
|
17 | 16 | url(r'^(?P<id_conf>-?\d+)/beam/(?P<id_beam>-?\d+)/edit/$', views.edit_beam, name='url_edit_abs_beam'), |
@@ -18,13 +18,15 class ColorTable: | |||
|
18 | 18 | self.table = table |
|
19 | 19 | #set to path for data folder, file: col_koki.dat |
|
20 | 20 | if filepath==None: |
|
21 | filepath= './data/' | |
|
21 | filepath= './apps/abs/utils/data/' | |
|
22 | 22 | self.filepath = filepath |
|
23 | 23 | |
|
24 | 24 | def readTable(self): |
|
25 | 25 | if self.table>0: |
|
26 | 26 | if self.table==1: |
|
27 | f = open(os.path.join(self.filepath,'col_koki.dat'),'rb') | |
|
27 | ||
|
28 | f = open(os.path.join(self.filepath, './col_koki.dat') ,'rb') | |
|
29 | ||
|
28 | 30 | |
|
29 | 31 | #f = open('./col_koki.dat','rb') |
|
30 | 32 |
@@ -47,10 +47,11 class AntPatternPlot: | |||
|
47 | 47 | -------------------- |
|
48 | 48 | Created by Freddy Galindo, ROJ, 06 October 2009. |
|
49 | 49 | """ |
|
50 | self.figure = None | |
|
51 | pass | |
|
52 | 50 | |
|
53 | def contPattern(self,iplot=0,gpath='',filename='',mesg='',amp=None ,x=None ,y=None ,getCut=None,title=''): | |
|
51 | self.fig = matplotlib.pyplot.figure(figsize=(8,8), facecolor='white') | |
|
52 | self.ax = self.fig.add_subplot(111) | |
|
53 | ||
|
54 | def contPattern(self,iplot=0,gpath='',filename='',mesg='',amp=None ,x=None ,y=None ,getCut=None,title='', save=True): | |
|
54 | 55 | """ |
|
55 | 56 | contPattern plots a contour map of the antenna pattern. |
|
56 | 57 | |
@@ -81,34 +82,34 class AntPatternPlot: | |||
|
81 | 82 | labels = range(5) |
|
82 | 83 | for i in numpy.arange(5):labels[i] = str(numpy.int(tmp[i])) |
|
83 | 84 | |
|
84 | if iplot==0: | |
|
85 | xsize = 8.0 | |
|
86 | if matplotlib.get_backend()=='QT4Agg':xsize = 6.0 | |
|
87 | ysize = 8.0 | |
|
88 | self.figure = matplotlib.pyplot.figure(num=2,figsize=(xsize,ysize)) | |
|
89 | matplotlib.pyplot.clf() | |
|
90 | 85 | |
|
91 | 86 | colors = ((0,0,1.),(0,170/255.,0),(127/255.,1.,0),(1.,109/255.,0),(128/255.,0,0)) |
|
92 |
CS = |
|
|
87 | CS = self.ax.contour(x,y,amp.transpose(),levels,colors=colors) | |
|
93 | 88 | fmt = {} |
|
94 |
for l,s in zip(CS.levels,labels): |
|
|
95 | ||
|
96 | matplotlib.pyplot.annotate('Ng',xy=(-0.05,1.04),xytext=(0.01,0.962),xycoords='axes fraction',arrowprops=dict(facecolor='black', width=1.,shrink=0.2),fontsize=15.) | |
|
97 | matplotlib.pyplot.annotate(mesg,xy=(0,0),xytext=(0.01,0.01),xycoords='figure fraction') | |
|
98 | matplotlib.pyplot.clabel(CS,CS.levels,inline=True,fmt=fmt,fontsize=10) | |
|
99 | matplotlib.pyplot.xlim(xmin,xmax) | |
|
100 | matplotlib.pyplot.ylim(ymin,ymax) | |
|
101 | matplotlib.pyplot.title("Total Pattern" + title) | |
|
102 | matplotlib.pyplot.xlabel("West to South") | |
|
103 |
|
|
|
104 | matplotlib.pyplot.grid(True) | |
|
105 | print "SAVE_FIG" | |
|
106 | print gpath | |
|
107 | print filename | |
|
89 | for l,s in zip(CS.levels,labels): | |
|
90 | fmt[l] = s | |
|
91 | ||
|
92 | self.ax.annotate('Ng',xy=(-0.05,1.04),xytext=(0.01,0.962),xycoords='axes fraction',arrowprops=dict(facecolor='black', width=1.,shrink=0.2),fontsize=15.) | |
|
93 | self.ax.annotate(mesg,xy=(0,0),xytext=(0.01,0.01),xycoords='figure fraction') | |
|
94 | self.ax.clabel(CS,CS.levels,inline=True,fmt=fmt,fontsize=10) | |
|
95 | self.ax.set_xlim(xmin,xmax) | |
|
96 | self.ax.set_ylim(ymin,ymax) | |
|
97 | self.ax.set_title("Total Pattern: " + title) | |
|
98 | self.ax.set_xlabel("West to South") | |
|
99 | self.ax.set_ylabel("West to North") | |
|
100 | self.ax.grid(True) | |
|
101 | ||
|
102 | if save: | |
|
108 | 103 | save_fig = os.path.join(gpath,filename) |
|
109 |
|
|
|
104 | self.fig.savefig(save_fig,format='png') | |
|
105 | ||
|
106 | ||
|
107 | ||
|
108 | def close(self): | |
|
109 | ||
|
110 | matplotlib.pyplot.close(self.fig) | |
|
110 | 111 | |
|
111 | def plotRaDec(self,gpath=None,filename=None,jd=2452640.5,ra_obs=None,xg=None,yg=None,x=None,y=None): | |
|
112 | def plotRaDec(self,gpath=None,filename=None,jd=2452640.5,ra_obs=None,xg=None,yg=None,x=None,y=None, save=True): | |
|
112 | 113 | """ |
|
113 | 114 | plotRaDec draws right ascension and declination lines on a JRO plane. This function |
|
114 | 115 | must call after conPattern. |
@@ -131,9 +132,9 class AntPatternPlot: | |||
|
131 | 132 | """ |
|
132 | 133 | |
|
133 | 134 | # Finding RA of observatory for a specific date |
|
134 |
if ra_obs |
|
|
135 |
if xg |
|
|
136 |
if yg |
|
|
135 | if ra_obs is None:ra_obs = numpy.array([23.37060849]) | |
|
136 | if xg is None:xg = numpy.array([0.62918474,-0.77725579,0.]) | |
|
137 | if yg is None:yg = numpy.array([0.77700346,0.62898048,0.02547905]) | |
|
137 | 138 | |
|
138 | 139 | # Getting HA and DEC axes |
|
139 | 140 | mindec = -28; maxdec = 4; incdec = 2. |
@@ -142,8 +143,8 class AntPatternPlot: | |||
|
142 | 143 | minha = -20; maxha = 20; incha = 2. |
|
143 | 144 | nha = numpy.int((maxha - minha)/incha) + 1 |
|
144 | 145 | |
|
145 | mcosx = numpy.zeros((nha,ndec)) | |
|
146 | mcosy = numpy.zeros((nha,ndec)) | |
|
146 | #mcosx = numpy.zeros((nha,ndec)) | |
|
147 | #mcosy = numpy.zeros((nha,ndec)) | |
|
147 | 148 | |
|
148 | 149 | ha_axes = numpy.reshape(numpy.arange(nha)*incha + minha,(nha,1)) |
|
149 | 150 | ones_dec = numpy.reshape(numpy.zeros(ndec) + 1,(ndec,1)) |
@@ -188,14 +189,14 class AntPatternPlot: | |||
|
188 | 189 | idec0 = numpy.int((-14 - mindec)/incdec) |
|
189 | 190 | |
|
190 | 191 | colorgrid = (1.,109/255.,0) |
|
191 |
|
|
|
192 | self.ax.plot(mcosx.transpose(),mcosy.transpose(),color=colorgrid,linestyle='--') | |
|
192 | 193 | for idec in numpy.arange(ndec): |
|
193 | 194 | if idec != idec0: |
|
194 | 195 | valx = (mcosx[idec,iha0]<=xmax) & (mcosx[idec,iha0]>=xmin) |
|
195 | 196 | valy = (mcosy[idec,iha0]<=ymax) & (mcosy[idec,iha0]>=ymin) |
|
196 | 197 | if valx & valy: |
|
197 | 198 | text = str(numpy.int(mindec + incdec*idec))+'$^o$' |
|
198 |
|
|
|
199 | self.ax.text(mcosx[idec,iha0],mcosy[idec,iha0],text) | |
|
199 | 200 | |
|
200 | 201 | matplotlib.pyplot.plot(mcosx,mcosy,color=colorgrid,linestyle='--') |
|
201 | 202 | for iha in numpy.arange(nha): |
@@ -204,15 +205,72 class AntPatternPlot: | |||
|
204 | 205 | valy = (mcosy[idec0,iha]<=ymax) & (mcosy[idec0,iha]>=ymin) |
|
205 | 206 | if valx & valy: |
|
206 | 207 | text = str(4*numpy.int(minha + incha*iha))+"'" |
|
207 |
|
|
|
208 | self.ax.text(mcosx[idec0,iha],mcosy[idec0,iha],text) | |
|
208 | 209 | |
|
209 | matplotlib.pyplot.xlim(xmin,xmax) | |
|
210 | matplotlib.pyplot.ylim(ymin,ymax) | |
|
210 | if save: | |
|
211 | save_fig = os.path.join(gpath,filename) | |
|
212 | matplotlib.pyplot.savefig(save_fig,format='png') | |
|
213 | ||
|
214 | ||
|
215 | def plotBField(self,gpath,filename,dcos,alpha, nlon, nlat, dcosxrange, dcosyrange, heights, alpha_i, save=True): | |
|
216 | """ | |
|
217 | plotBField draws the magnetic field in a directional cosines plot. | |
|
211 | 218 |
|
|
219 | Parameters | |
|
220 | ---------- | |
|
221 | dcos = An 4-dimensional array giving the directional cosines of the magnetic field | |
|
222 | over the desired place. | |
|
223 | alpha = An 3-dimensional array giving the angle of the magnetic field over the desi- | |
|
224 | red place. | |
|
225 | nlon = An integer to specify the number of elements per longitude. | |
|
226 | nlat = An integer to specify the number of elements per latitude. | |
|
227 | dcosxrange = A 2-element array giving the range of the directional cosines in the | |
|
228 | "x" axis. | |
|
229 | dcosyrange = A 2-element array giving the range of the directional cosines in the | |
|
230 | "y" axis. | |
|
231 | heights = An array giving the heights (km) where the magnetic field will be modeled By default the magnetic field will be computed at 100, 500 and 1000km. | |
|
232 | alpha_i = Angle to interpolate the magnetic field. | |
|
233 | Modification History | |
|
234 | -------------------- | |
|
235 | Converted to Python by Freddy R. Galindo, ROJ, 07 October 2009. | |
|
236 | """ | |
|
237 | ||
|
238 | handles = [] | |
|
239 | objects = [] | |
|
240 | colors = ['k','m','c','b','g','r','y'] | |
|
241 | marker = ['-+','-*','-D','-x','-s','->','-o','-^'] | |
|
242 | ||
|
243 | alpha_location = numpy.zeros((nlon,2,heights.size)) | |
|
244 | ||
|
245 | for ih in numpy.arange(heights.size): | |
|
246 | alpha_location[:,0,ih] = dcos[:,0,ih,0] | |
|
247 | for ilon in numpy.arange(nlon): | |
|
248 | myx = (alpha[ilon,:,ih])[::-1] | |
|
249 | myy = (dcos[ilon,:,ih,0])[::-1] | |
|
250 | tck = scipy.interpolate.splrep(myx,myy,s=0) | |
|
251 | mydcosx = scipy.interpolate.splev(alpha_i,tck,der=0) | |
|
252 | ||
|
253 | myx = (alpha[ilon,:,ih])[::-1] | |
|
254 | myy = (dcos[ilon,:,ih,1])[::-1] | |
|
255 | tck = scipy.interpolate.splrep(myx,myy,s=0) | |
|
256 | mydcosy = scipy.interpolate.splev(alpha_i,tck,der=0) | |
|
257 | alpha_location[ilon,:,ih] = numpy.array([mydcosx, mydcosy]) | |
|
258 | ||
|
259 | ||
|
260 | ObjFig, = self.ax.plot(alpha_location[:,0,ih],alpha_location[:,1,ih], | |
|
261 | marker[ih % 8],color=colors[numpy.int(ih/8)],ms=4.5,lw=0.5) | |
|
262 | handles.append(ObjFig) | |
|
263 | objects.append(numpy.str(heights[ih]) + ' km') | |
|
264 | ||
|
265 | self.ax.legend(handles,objects,loc="lower right", numpoints=1, handlelength=0.3, | |
|
266 | handletextpad=0.02, borderpad=0.3, labelspacing=0.1) | |
|
267 | ||
|
268 | if save: | |
|
212 | 269 | save_fig = os.path.join(gpath,filename) |
|
213 | 270 | matplotlib.pyplot.savefig(save_fig,format='png') |
|
214 | 271 | |
|
215 | 272 | |
|
273 | ||
|
216 | 274 | class BFieldPlot: |
|
217 | 275 | def __init__(self): |
|
218 | 276 | """ |
@@ -10,6 +10,7 import numpy | |||
|
10 | 10 | import numpy.fft |
|
11 | 11 | import scipy.linalg |
|
12 | 12 | import scipy.special |
|
13 | from StringIO import StringIO | |
|
13 | 14 | #import Numeric |
|
14 | 15 | |
|
15 | 16 | import Misc_Routines |
@@ -20,7 +21,7 import Astro_Coords | |||
|
20 | 21 | |
|
21 | 22 | class JroPattern(): |
|
22 | 23 | def __init__(self,pattern=0,path=None,filename=None,nptsx=101,nptsy=101,maxphi=5,fftopt=0, \ |
|
23 | getcut=0,dcosx=None,dcosy=None,eomwl=6,airwl=4): | |
|
24 | getcut=0,dcosx=None,dcosy=None,eomwl=6,airwl=4, **kwargs): | |
|
24 | 25 | """ |
|
25 | 26 | JroPattern class creates an object to represent the useful parameters for beam mode- |
|
26 | 27 | lling of the Jicamarca VHF radar. |
@@ -60,6 +61,7 class JroPattern(): | |||
|
60 | 61 | |
|
61 | 62 | |
|
62 | 63 | # Getting antenna configuration. |
|
64 | if filename: | |
|
63 | 65 | setup = JroAntSetup.ReturnSetup(path=path,filename=filename,pattern=pattern) |
|
64 | 66 | |
|
65 | 67 | ues = setup["ues"] |
@@ -67,9 +69,18 class JroPattern(): | |||
|
67 | 69 | gaintx = setup["gaintx"] |
|
68 | 70 | gainrx = setup["gainrx"] |
|
69 | 71 | justrx = setup["justrx"] |
|
72 | self.title = setup["title"] | |
|
73 | else: | |
|
74 | ues = kwargs["ues"] | |
|
75 | phase = kwargs["phases"] | |
|
76 | gaintx = kwargs["gain_tx"] | |
|
77 | gainrx = kwargs["gain_rx"] | |
|
78 | justrx = kwargs["just_rx"] | |
|
79 | self.title = kwargs.get("title", "JRO Pattern") | |
|
70 | 80 | |
|
71 | 81 | # Defining attributes for JroPattern class. |
|
72 | 82 | # Antenna configuration |
|
83 | ||
|
73 | 84 | self.uestx = ues |
|
74 | 85 | self.phasetx = phase |
|
75 | 86 | self.gaintx = gaintx |
@@ -105,13 +116,13 class JroPattern(): | |||
|
105 | 116 | self.norpattern = None |
|
106 | 117 | self.maxpattern = None |
|
107 | 118 | |
|
108 | self.title = setup["title"] | |
|
119 | ||
|
109 | 120 | |
|
110 | 121 | self.getPattern() |
|
111 | 122 | |
|
112 | 123 | def getPattern(self): |
|
113 | 124 | """ |
|
114 |
getpattern method returns the model |
|
|
125 | getpattern method returns the modeled total antenna pattern and its mean position. | |
|
115 | 126 | |
|
116 | 127 | Return |
|
117 | 128 | ------ |
@@ -342,12 +353,18 class JroPattern(): | |||
|
342 | 353 | yindex = iy*(self.getcut==0) + ix*(self.getcut==1) |
|
343 | 354 | |
|
344 | 355 | argx = ar[0,0]*self.dcosx[ix] - lr[0,0] |
|
356 | if argx == 0.0: | |
|
357 | junkx = nr[0,0] | |
|
358 | else: | |
|
345 | 359 | junkx = numpy.sin(0.5*self.kk*nr[0,0]*argx)/numpy.sin(0.5*self.kk*argx) |
|
346 | if argx == 0.0: junkx = nr[0,0] | |
|
360 | ||
|
347 | 361 | |
|
348 | 362 | argy = ar[1,0]*self.dcosy[yindex] - lr[1,0] |
|
363 | if argy == 0.0: | |
|
364 | junky = nr[1,0] | |
|
365 | else: | |
|
349 | 366 | junky = numpy.sin(0.5*self.kk*nr[1,0]*argy)/numpy.sin(0.5*self.kk*argy) |
|
350 | if argy == 0.0: junky = nr[1,0] | |
|
367 | ||
|
351 | 368 | |
|
352 | 369 | dipole[ix,iy] = junkx*junky |
|
353 | 370 | |
@@ -530,8 +547,8 class BField(): | |||
|
530 | 547 | nfields = 1 |
|
531 | 548 | |
|
532 | 549 | grid_res = 0.5 |
|
533 | nlon = numpy.int(maglimits[2] - maglimits[0])/grid_res + 1 | |
|
534 | nlat = numpy.int(maglimits[3] - maglimits[1])/grid_res + 1 | |
|
550 | nlon = int(numpy.int(maglimits[2] - maglimits[0])/grid_res + 1) | |
|
551 | nlat = int(numpy.int(maglimits[3] - maglimits[1])/grid_res + 1) | |
|
535 | 552 | |
|
536 | 553 | location = numpy.zeros((nlon,nlat,2)) |
|
537 | 554 | mlon = numpy.atleast_2d(numpy.arange(nlon)*grid_res + maglimits[0]) |
@@ -941,10 +958,10 class overJroShow: | |||
|
941 | 958 | # __tmpDir = 'overJro/tempReports' |
|
942 | 959 | # __serverdocspath = '/Users/dsuarez/Pictures' |
|
943 | 960 | # __tmpDir = 'overjro' |
|
944 |
__serverdocspath = |
|
|
945 |
__tmpDir = |
|
|
961 | __serverdocspath = '' | |
|
962 | __tmpDir = '' | |
|
946 | 963 | |
|
947 | def __init__(self): | |
|
964 | def __init__(self, title=''): | |
|
948 | 965 | self.year = None |
|
949 | 966 | self.month = None |
|
950 | 967 | self.dom = None |
@@ -971,12 +988,18 class overJroShow: | |||
|
971 | 988 | self.time_mag = None |
|
972 | 989 | self.main_dec = None |
|
973 | 990 | self.ObjC = None |
|
974 |
self.ptitle = |
|
|
991 | self.ptitle = title | |
|
975 | 992 | self.path4plotname = None |
|
976 | 993 | self.plotname0 = None |
|
977 | 994 | self.plotname1 = None |
|
978 | 995 | self.plotname2 = None |
|
979 | 996 | self.scriptHeaders = 0 |
|
997 | self.glat = -11.95 | |
|
998 | self.glon = -76.8667 | |
|
999 | self.UT = 5 #timezone | |
|
1000 | ||
|
1001 | self.glat = -11.951481 | |
|
1002 | self.glon = -76.874383 | |
|
980 | 1003 | # self.outputHead('Show Plot') |
|
981 | 1004 | # self.printBody() |
|
982 | 1005 | |
@@ -1180,8 +1203,6 class overJroShow: | |||
|
1180 | 1203 | |
|
1181 | 1204 | # Defining plot filenames |
|
1182 | 1205 | self.path4plotname = os.path.join(self.__serverdocspath,self.__tmpDir) |
|
1183 | print "PATH4" | |
|
1184 | print os.path.join(self.__serverdocspath,self.__tmpDir) | |
|
1185 | 1206 | self.plotname0 = 'over_jro_0_%i.png'% (time.time()) #plot pattern & objects |
|
1186 | 1207 | self.plotname1 = 'over_jro_1_%i.png'% (time.time()) #plot antenna cuts |
|
1187 | 1208 | self.plotname2 = 'over_jro_2_%i.png'% (time.time()) #plot sky noise |
@@ -1206,6 +1227,70 class overJroShow: | |||
|
1206 | 1227 | self.yg = numpy.dot(self.MT3.transpose(),numpy.array([0,1,0])) |
|
1207 | 1228 | self.zg = numpy.dot(self.MT3.transpose(),numpy.array([0,0,1])) |
|
1208 | 1229 | |
|
1230 | def plotPattern2(self, date, phases, gain_tx, gain_rx, ues, just_rx): | |
|
1231 | # Plotting Antenna patterns. | |
|
1232 | ||
|
1233 | self.initParameters() | |
|
1234 | self.doy = datetime.datetime(date.year,date.month,date.day).timetuple().tm_yday | |
|
1235 | self.junkjd = TimeTools.Time(self.year,self.month,self.dom).change2julday() | |
|
1236 | self.junklst = TimeTools.Julian(self.junkjd).change2lst(longitude=self.glon) | |
|
1237 | self.ra_obs = self.junklst*Misc_Routines.CoFactors.h2d | |
|
1238 | ||
|
1239 | date = TimeTools.Time(date.year,date.month,date.day).change2strdate(mode=2) | |
|
1240 | ||
|
1241 | mesg = 'Over Jicamarca: ' + date[0] | |
|
1242 | ||
|
1243 | ObjAnt = JroPattern(pattern=0, | |
|
1244 | filename=None, | |
|
1245 | path=None, | |
|
1246 | nptsx=self.nptsx, | |
|
1247 | nptsy=self.nptsy, | |
|
1248 | #maxphi=self.maxphi, | |
|
1249 | fftopt=self.fftopt, | |
|
1250 | phases=numpy.array(phases), | |
|
1251 | gain_tx=numpy.array(gain_tx), | |
|
1252 | gain_rx=numpy.array(gain_rx), | |
|
1253 | ues=numpy.array(ues), | |
|
1254 | just_rx=just_rx | |
|
1255 | ) | |
|
1256 | ||
|
1257 | dum = Graphics_OverJro.AntPatternPlot() | |
|
1258 | ||
|
1259 | dum.contPattern(iplot=0, | |
|
1260 | gpath=self.path4plotname, | |
|
1261 | filename=self.plotname0, | |
|
1262 | mesg=mesg, | |
|
1263 | amp=ObjAnt.norpattern, | |
|
1264 | x=ObjAnt.dcosx, | |
|
1265 | y=ObjAnt.dcosy, | |
|
1266 | getCut=ObjAnt.getcut, | |
|
1267 | title=self.ptitle, | |
|
1268 | save=False) | |
|
1269 | ||
|
1270 | ||
|
1271 | dum.plotRaDec(gpath=self.path4plotname, | |
|
1272 | filename=self.plotname0, | |
|
1273 | jd=self.junkjd, | |
|
1274 | ra_obs=self.ra_obs, | |
|
1275 | xg=self.xg, | |
|
1276 | yg=self.yg, | |
|
1277 | x=ObjAnt.dcosx, | |
|
1278 | y=ObjAnt.dcosy, | |
|
1279 | save=False) | |
|
1280 | ||
|
1281 | ObjB = BField(self.year,self.doy,1,self.heights) | |
|
1282 | [dcos, alpha, nlon, nlat] = ObjB.getBField() | |
|
1283 | ||
|
1284 | dum.plotBField('', '',dcos,alpha,nlon,nlat, | |
|
1285 | self.dcosxrange, | |
|
1286 | self.dcosyrange, | |
|
1287 | ObjB.heights, | |
|
1288 | ObjB.alpha_i, | |
|
1289 | save=False) | |
|
1290 | ||
|
1291 | return dum.fig | |
|
1292 | ||
|
1293 | ||
|
1209 | 1294 | def plotPattern(self): |
|
1210 | 1295 | # Plotting Antenna patterns. |
|
1211 | 1296 | npatterns = numpy.size(self.pattern) |
@@ -1230,10 +1315,8 class overJroShow: | |||
|
1230 | 1315 | |
|
1231 | 1316 | title += ObjAnt.title |
|
1232 | 1317 | # Plotting Contour Map |
|
1233 | print "Antes de la creacion" | |
|
1234 |
self.path4plotname = '/home/ |
|
|
1235 | print self.path4plotname | |
|
1236 | print self.plotname0 | |
|
1318 | ||
|
1319 | self.path4plotname = '/home/jespinoza/workspace/radarsys/trunk/webapp/apps/abs/static/images' | |
|
1237 | 1320 | dum = Graphics_OverJro.AntPatternPlot() |
|
1238 | 1321 | dum.contPattern(iplot=ii, |
|
1239 | 1322 | gpath=self.path4plotname, |
@@ -1246,8 +1329,6 class overJroShow: | |||
|
1246 | 1329 | title=title) |
|
1247 | 1330 | # title=ObjAnt.title) |
|
1248 | 1331 | # self.ptitle = ObjAnt.title |
|
1249 | if ii==0: | |
|
1250 | self.figure = dum.figure | |
|
1251 | 1332 | |
|
1252 | 1333 | if ii != (npatterns-1): |
|
1253 | 1334 | title += '+' |
@@ -1267,7 +1348,14 class overJroShow: | |||
|
1267 | 1348 | |
|
1268 | 1349 | self.ptitle = title |
|
1269 | 1350 | |
|
1270 | Graphics_OverJro.AntPatternPlot().plotRaDec(gpath=self.path4plotname,filename=self.plotname0,jd=self.junkjd, ra_obs=self.ra_obs, xg=self.xg, yg=self.yg, x=ObjAnt.dcosx, y=ObjAnt.dcosy) | |
|
1351 | Graphics_OverJro.AntPatternPlot().plotRaDec(gpath=self.path4plotname, | |
|
1352 | filename=self.plotname0, | |
|
1353 | jd=self.junkjd, | |
|
1354 | ra_obs=self.ra_obs, | |
|
1355 | xg=self.xg, | |
|
1356 | yg=self.yg, | |
|
1357 | x=ObjAnt.dcosx, | |
|
1358 | y=ObjAnt.dcosy) | |
|
1271 | 1359 | |
|
1272 | 1360 | self.dcosx = ObjAnt.dcosx |
|
1273 | 1361 | |
@@ -1616,8 +1704,7 class overJroShow: | |||
|
1616 | 1704 | self.plotSkyNoise() |
|
1617 | 1705 | |
|
1618 | 1706 | def getPlot(self): |
|
1619 | print "GETPLot" | |
|
1620 | print os.path.join(self.__serverdocspath,self.__tmpDir,self.plotname0) | |
|
1707 | ||
|
1621 | 1708 | return os.path.join(self.__serverdocspath,self.__tmpDir,self.plotname0) |
|
1622 | 1709 | |
|
1623 | 1710 | |
@@ -1627,6 +1714,41 if __name__ == '__main__': | |||
|
1627 | 1714 | # This script only calls the init function of the class overJroShow() |
|
1628 | 1715 | # All work is done by the init function |
|
1629 | 1716 | |
|
1630 | newOverJro = overJroShow() | |
|
1631 | newOverJro.initParametersCGI() | |
|
1632 | newOverJro.execute() | |
|
1717 | phases = numpy.array([[2.0,0.0,1.5,1.5,1.0,1.0,1.0,0.5], | |
|
1718 | [2.0,2.5,2.5,3.5,0.5,1.0,1.0,1.0], | |
|
1719 | [2.5,2.5,1.0,1.0,0.5,0.5,0.5,0.5], | |
|
1720 | [1.0,1.0,1.0,1.0,0.5,0.5,0.5,1.0], | |
|
1721 | [0.5,0.5,0.5,0.5,0.5,0.0,0.0,0.0], | |
|
1722 | [0.5,0.5,1.0,0.5,0.0,0.0,0.0,0.0], | |
|
1723 | [0.5,0.5,0.5,1.0,0.0,0.0,0.0,0.0], | |
|
1724 | [0.5,0.5,0.5,0.5,0.0,0.0,0.0,0.0]]) | |
|
1725 | ||
|
1726 | gain_tx = numpy.array([[0,0,0,0,0,0,0,0], | |
|
1727 | [0,0,0,0,0,0,0,0], | |
|
1728 | [0,0,0,0,0,0,0,0], | |
|
1729 | [0,0,0,0,0,0,0,0], | |
|
1730 | [0,0,0,0,1,1,1,1], | |
|
1731 | [0,0,0,0,0,0,0,0], | |
|
1732 | [0,0,0,0,0,0,0,0], | |
|
1733 | [0,0,0,0,0,0,0,0]]) | |
|
1734 | ||
|
1735 | gain_rx = numpy.array([[0,0,0,0,0,0,0,0], | |
|
1736 | [0,0,1,0,0,0,0,0], | |
|
1737 | [0,0,1,0,0,0,0,0], | |
|
1738 | [0,0,0,0,0,0,0,0], | |
|
1739 | [0,0,0,0,0,0,0,0], | |
|
1740 | [0,0,0,0,0,0,0,0], | |
|
1741 | [0,0,0,0,0,0,0,0], | |
|
1742 | [0,0,0,0,0,0,0,0]]) | |
|
1743 | ||
|
1744 | jro = overJroShow() | |
|
1745 | ||
|
1746 | fig = jro.plotPattern2(datetime.datetime.today(), | |
|
1747 | phases=phases, | |
|
1748 | gain_tx=gain_tx, | |
|
1749 | gain_rx=gain_rx, | |
|
1750 | ues=numpy.array([0.0,0.0,0.0,0.0]), | |
|
1751 | just_rx=0) | |
|
1752 | ||
|
1753 | fig.savefig('./pat.png') | |
|
1754 |
@@ -315,55 +315,23 def remove_beam(request, id_conf, id_beam): | |||
|
315 | 315 | |
|
316 | 316 | |
|
317 | 317 | |
|
318 | def plot_patterns(request, id_conf): | |
|
318 | def plot_patterns(request, id_conf, id_beam=None): | |
|
319 | 319 | |
|
320 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) | |
|
321 | beams_list = ast.literal_eval(conf.beams) | |
|
322 | i = 1 | |
|
323 | beams = [] | |
|
324 | for b in beams_list: | |
|
325 | beam = ABSBeam.objects.get(pk=beams_list['beam'+str(i)]) | |
|
326 | beams.append(beam) | |
|
327 | i=i+1 | |
|
328 | ||
|
329 | ###### SIDEBAR ###### | |
|
330 | 320 | kwargs = {} |
|
331 | ||
|
332 | kwargs['dev_conf'] = conf.device | |
|
333 | kwargs['id_dev'] = conf.device | |
|
334 | kwargs['id_conf'] = conf.id | |
|
335 | kwargs['abs_beams'] = beams | |
|
336 | kwargs['title'] = 'ABS Patterns' | |
|
337 | kwargs['suptitle'] = conf.name | |
|
338 | kwargs['no_sidebar'] = True | |
|
339 | ||
|
340 | return render(request, 'abs_patterns.html', kwargs) | |
|
341 | ||
|
342 | ||
|
343 | def plot_pattern(request, id_conf, id_beam): | |
|
344 | ||
|
345 | 321 |
conf |
|
322 | beams = ABSBeam.objects.filter(abs_conf=conf) | |
|
323 | ||
|
324 | if id_beam: | |
|
346 | 325 |
beam |
|
326 | kwargs['beam'] = beam | |
|
347 | 327 | |
|
348 | #Lista de Beams de la configuracion con su respectivo ID | |
|
349 | beams_list = ast.literal_eval(conf.beams) | |
|
350 | i = 1 | |
|
351 | #Lista de Objetos ABSBeams en el 0rden de su respectiva configuracion | |
|
352 | beams = [] | |
|
353 | for b in beams_list: | |
|
354 | beam = ABSBeam.objects.get(pk=beams_list['beam'+str(i)]) | |
|
355 | beams.append(beam) | |
|
356 | i=i+1 | |
|
357 | 328 | |
|
358 | 329 | ###### SIDEBAR ###### |
|
359 | beam = get_object_or_404(ABSBeam, pk=id_beam) | |
|
360 | kwargs = {} | |
|
361 | 330 | |
|
362 | 331 | kwargs['dev_conf'] = conf.device |
|
363 | 332 | kwargs['id_dev'] = conf.device |
|
364 | 333 | kwargs['id_conf'] = conf.id |
|
365 | 334 | kwargs['abs_beams'] = beams |
|
366 | kwargs['beam'] = beam | |
|
367 | 335 | kwargs['title'] = 'ABS Patterns' |
|
368 | 336 | kwargs['suptitle'] = conf.name |
|
369 | 337 | kwargs['no_sidebar'] = True |
@@ -371,112 +339,27 def plot_pattern(request, id_conf, id_beam): | |||
|
371 | 339 | return render(request, 'abs_patterns.html', kwargs) |
|
372 | 340 | |
|
373 | 341 | |
|
342 | def plot_pattern(request, id_conf, id_beam, antenna): | |
|
374 | 343 | |
|
375 | def plot_uppattern(request, id_conf, id_beam): | |
|
376 | ||
|
377 | from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas | |
|
344 | if antenna=='down': | |
|
345 | sleep(3) | |
|
378 | 346 | |
|
379 | 347 |
conf |
|
380 | 348 |
beam |
|
381 | 349 | |
|
382 |
|
|
|
383 | ||
|
384 | just_rx = 0 | |
|
385 | ||
|
386 | only_rx = json.loads(beam.only_rx) | |
|
387 | if only_rx['up'] == True: | |
|
388 | just_rx = 1 | |
|
350 | name = conf.experiment.name | |
|
389 | 351 | |
|
390 | antenna = ast.literal_eval(beam.antenna) | |
|
391 | objAntenna = json.dumps(antenna['antenna_up']) | |
|
392 | antenna_up = ''.join(str(i) for i in objAntenna) | |
|
393 | phase_tx = antenna_up.replace(' ','') | |
|
352 | just_rx = 1 if json.loads(beam.only_rx)[antenna] else 0 | |
|
353 | phases = json.loads(beam.antenna)['antenna_{}'.format(antenna)] | |
|
354 | gain_tx = json.loads(beam.tx)[antenna] | |
|
355 | gain_rx = json.loads(beam.rx)[antenna] | |
|
356 | ues = json.loads(beam.ues)[antenna] | |
|
394 | 357 | |
|
395 | tx = ast.literal_eval(beam.tx) | |
|
396 | tx = json.dumps(tx['up']) | |
|
397 | tx = ''.join(str(i) for i in tx) | |
|
398 | gain_tx = tx.replace(' ','') | |
|
358 | newOverJro = overJroShow(name) | |
|
359 | fig = newOverJro.plotPattern2(datetime.today(), phases, gain_tx, gain_rx, ues, just_rx) | |
|
399 | 360 | |
|
400 | rx = ast.literal_eval(beam.rx) | |
|
401 | rx = json.dumps(rx['up']) | |
|
402 | rx = ''.join(str(i) for i in rx) | |
|
403 | gain_rx = rx.replace(' ','') | |
|
404 | ||
|
405 | ues = json.dumps(beam.get_up_ues) | |
|
406 | ues = ''.join(str(i) for i in ues) | |
|
407 | ues_tx = ues.replace(' ','') | |
|
408 | ||
|
409 | #sleep(1) | |
|
410 | ||
|
411 | overjro = OverJRO() | |
|
412 | overjro.setParameters(settings.MEDIA_ROOT, exp_name, phase_tx, gain_tx, gain_rx, ues_tx, just_rx) | |
|
413 | contentFile = overjro.setTextContent() | |
|
414 | finalpath = overjro.saveFile(contentFile) | |
|
415 | ||
|
416 | currentdate = datetime.today() | |
|
417 | newOverJro = overJroShow() | |
|
418 | newOverJro.setInputParameters(settings.MEDIA_ROOT, currentdate, finalpath) | |
|
419 | newOverJro.setupParameters() | |
|
420 | newOverJro.execute() | |
|
421 | path = newOverJro.getPlot() | |
|
422 | path= "apps/abs/media/"+path | |
|
423 | ||
|
424 | ||
|
425 | canvas=FigureCanvas(newOverJro.figure) | |
|
426 | 361 | response=HttpResponse(content_type='image/png') |
|
427 | canvas.print_png(response) | |
|
428 | return response | |
|
429 | 362 | |
|
430 | def plot_downpattern(request, id_conf, id_beam): | |
|
363 | fig.canvas.print_png(response) | |
|
431 | 364 | |
|
432 | sleep(4) | |
|
433 | from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas | |
|
434 | ||
|
435 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) | |
|
436 | beam = get_object_or_404(ABSBeam, pk=id_beam) | |
|
437 | ||
|
438 | exp_name = conf.experiment.name | |
|
439 | ||
|
440 | just_rx = 0 | |
|
441 | ||
|
442 | only_rx = json.loads(beam.only_rx) | |
|
443 | if only_rx['down'] == True: | |
|
444 | just_rx = 1 | |
|
445 | ||
|
446 | antenna = ast.literal_eval(beam.antenna) | |
|
447 | objAntenna = json.dumps(antenna['antenna_down']) | |
|
448 | antenna_down = ''.join(str(i) for i in objAntenna) | |
|
449 | phase_tx = antenna_down.replace(' ','') | |
|
450 | ||
|
451 | tx = ast.literal_eval(beam.tx) | |
|
452 | tx = json.dumps(tx['down']) | |
|
453 | tx = ''.join(str(i) for i in tx) | |
|
454 | gain_tx = tx.replace(' ','') | |
|
455 | ||
|
456 | rx = ast.literal_eval(beam.rx) | |
|
457 | rx = json.dumps(rx['down']) | |
|
458 | rx = ''.join(str(i) for i in rx) | |
|
459 | gain_rx = rx.replace(' ','') | |
|
460 | ||
|
461 | ues = json.dumps(beam.get_down_ues) | |
|
462 | ues = ''.join(str(i) for i in ues) | |
|
463 | ues_tx = ues.replace(' ','') | |
|
464 | ||
|
465 | overjro = OverJRO() | |
|
466 | overjro.setParameters(settings.MEDIA_ROOT, exp_name, phase_tx, gain_tx, gain_rx, ues_tx, just_rx) | |
|
467 | contentFile = overjro.setTextContent() | |
|
468 | finalpath = overjro.saveFile(contentFile) | |
|
469 | ||
|
470 | currentdate = datetime.today() | |
|
471 | newOverJro = overJroShow() | |
|
472 | newOverJro.setInputParameters(settings.MEDIA_ROOT, currentdate, finalpath) | |
|
473 | newOverJro.setupParameters() | |
|
474 | newOverJro.execute() | |
|
475 | path = newOverJro.getPlot() | |
|
476 | path= "apps/abs/media/"+path | |
|
477 | ||
|
478 | ||
|
479 | canvas=FigureCanvas(newOverJro.figure) | |
|
480 | response=HttpResponse(content_type='image/png') | |
|
481 | canvas.print_png(response) | |
|
482 | 365 | return response |
General Comments 0
You need to be logged in to leave comments.
Login now