1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -3,23 +3,9 | |||||
3 | {% load main_tags %} |
|
3 | {% load main_tags %} | |
4 |
|
4 | |||
5 | {% block content %} |
|
5 | {% block content %} | |
6 | <style> |
|
|||
7 | </style> |
|
|||
8 |
|
6 | |||
9 | <div id="PictureOverJRODown" style="float: right"> |
|
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;"> |
|
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%;"> | |
11 | <img id="imgLoaderDown" src="{% static 'images/loading_loading.gif' %}" alt="Error in Parameters" width="50" height="50" align="left"> |
|
|||
12 |
|
||||
13 | </div> |
|
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 | {% endblock %} |
|
11 | {% endblock %} |
@@ -42,7 +42,7 | |||||
42 | <script> |
|
42 | <script> | |
43 | {% for abs_beam in abs_beams %} |
|
43 | {% for abs_beam in abs_beams %} | |
44 | $("#bt_beam{{ forloop.counter }}").click(function() { |
|
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 | {% endfor %} |
|
47 | {% endfor %} | |
48 | //function ChangeColor() { |
|
48 | //function ChangeColor() { |
@@ -3,23 +3,9 | |||||
3 | {% load main_tags %} |
|
3 | {% load main_tags %} | |
4 |
|
4 | |||
5 | {% block content %} |
|
5 | {% block content %} | |
6 | <style> |
|
|||
7 | </style> |
|
|||
8 |
|
6 | |||
9 | <div id="PictureOverJROUp" style="float: right"> |
|
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;"> |
|
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%;"> | |
11 | <img id="imgLoader" src="{% static 'images/loading_loading.gif' %}" alt="Error in Parameters" width="50" height="50"> |
|
|||
12 |
|
||||
13 | </div> |
|
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 | {% endblock %} |
|
11 | {% endblock %} |
@@ -9,9 +9,8 urlpatterns = ( | |||||
9 | #url(r'^(?P<id_conf>-?\d+)/import/$', views.dev_conf_import, name='url_import_abs_conf'), |
|
9 | #url(r'^(?P<id_conf>-?\d+)/import/$', views.dev_conf_import, name='url_import_abs_conf'), | |
10 | #url(r'^(?P<id_conf>-?\d+)/export/$', views.dev_conf_export, name='url_export_abs_conf'), |
|
10 | #url(r'^(?P<id_conf>-?\d+)/export/$', views.dev_conf_export, name='url_export_abs_conf'), | |
11 | url(r'^(?P<id_conf>-?\d+)/plot/$', views.plot_patterns, name='url_plot_abs_patterns'), |
|
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'), |
|
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 |
|
13 | url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/(?P<antenna>[\w\-]+)/pattern.png$', views.plot_pattern, name='url_plot_beam'), | |
14 | url(r'^(?P<id_conf>-?\d+)/plot_down_beam/(?P<id_beam>-?\d+)/$', views.plot_downpattern, name='url_plot_down_beam'), |
|
|||
15 | url(r'^(?P<id_conf>-?\d+)/add_beam/$', views.add_beam, name='url_add_abs_beam'), |
|
14 | url(r'^(?P<id_conf>-?\d+)/add_beam/$', views.add_beam, name='url_add_abs_beam'), | |
16 | url(r'^(?P<id_conf>-?\d+)/beam/(?P<id_beam>-?\d+)/delete/$', views.remove_beam, name='url_remove_abs_beam'), |
|
15 | url(r'^(?P<id_conf>-?\d+)/beam/(?P<id_beam>-?\d+)/delete/$', views.remove_beam, name='url_remove_abs_beam'), | |
17 | url(r'^(?P<id_conf>-?\d+)/beam/(?P<id_beam>-?\d+)/edit/$', views.edit_beam, name='url_edit_abs_beam'), |
|
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 | self.table = table |
|
18 | self.table = table | |
19 | #set to path for data folder, file: col_koki.dat |
|
19 | #set to path for data folder, file: col_koki.dat | |
20 | if filepath==None: |
|
20 | if filepath==None: | |
21 | filepath= './data/' |
|
21 | filepath= './apps/abs/utils/data/' | |
22 | self.filepath = filepath |
|
22 | self.filepath = filepath | |
23 |
|
23 | |||
24 | def readTable(self): |
|
24 | def readTable(self): | |
25 | if self.table>0: |
|
25 | if self.table>0: | |
26 | if self.table==1: |
|
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 | #f = open('./col_koki.dat','rb') |
|
31 | #f = open('./col_koki.dat','rb') | |
30 |
|
32 |
@@ -47,10 +47,11 class AntPatternPlot: | |||||
47 | -------------------- |
|
47 | -------------------- | |
48 | Created by Freddy Galindo, ROJ, 06 October 2009. |
|
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 | contPattern plots a contour map of the antenna pattern. |
|
56 | contPattern plots a contour map of the antenna pattern. | |
56 |
|
57 | |||
@@ -81,34 +82,34 class AntPatternPlot: | |||||
81 | labels = range(5) |
|
82 | labels = range(5) | |
82 | for i in numpy.arange(5):labels[i] = str(numpy.int(tmp[i])) |
|
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 | colors = ((0,0,1.),(0,170/255.,0),(127/255.,1.,0),(1.,109/255.,0),(128/255.,0,0)) |
|
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 | fmt = {} |
|
88 | fmt = {} | |
94 |
for l,s in zip(CS.levels,labels): |
|
89 | for l,s in zip(CS.levels,labels): | |
95 |
|
90 | fmt[l] = s | ||
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.) |
|
91 | ||
97 | matplotlib.pyplot.annotate(mesg,xy=(0,0),xytext=(0.01,0.01),xycoords='figure fraction') |
|
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.) | |
98 | matplotlib.pyplot.clabel(CS,CS.levels,inline=True,fmt=fmt,fontsize=10) |
|
93 | self.ax.annotate(mesg,xy=(0,0),xytext=(0.01,0.01),xycoords='figure fraction') | |
99 | matplotlib.pyplot.xlim(xmin,xmax) |
|
94 | self.ax.clabel(CS,CS.levels,inline=True,fmt=fmt,fontsize=10) | |
100 | matplotlib.pyplot.ylim(ymin,ymax) |
|
95 | self.ax.set_xlim(xmin,xmax) | |
101 | matplotlib.pyplot.title("Total Pattern" + title) |
|
96 | self.ax.set_ylim(ymin,ymax) | |
102 | matplotlib.pyplot.xlabel("West to South") |
|
97 | self.ax.set_title("Total Pattern: " + title) | |
103 |
|
|
98 | self.ax.set_xlabel("West to South") | |
104 | matplotlib.pyplot.grid(True) |
|
99 | self.ax.set_ylabel("West to North") | |
105 | print "SAVE_FIG" |
|
100 | self.ax.grid(True) | |
106 | print gpath |
|
101 | ||
107 | print filename |
|
102 | if save: | |
108 | save_fig = os.path.join(gpath,filename) |
|
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 | plotRaDec draws right ascension and declination lines on a JRO plane. This function |
|
114 | plotRaDec draws right ascension and declination lines on a JRO plane. This function | |
114 | must call after conPattern. |
|
115 | must call after conPattern. | |
@@ -131,9 +132,9 class AntPatternPlot: | |||||
131 | """ |
|
132 | """ | |
132 |
|
133 | |||
133 | # Finding RA of observatory for a specific date |
|
134 | # Finding RA of observatory for a specific date | |
134 |
if ra_obs |
|
135 | if ra_obs is None:ra_obs = numpy.array([23.37060849]) | |
135 |
if xg |
|
136 | if xg is None:xg = numpy.array([0.62918474,-0.77725579,0.]) | |
136 |
if yg |
|
137 | if yg is None:yg = numpy.array([0.77700346,0.62898048,0.02547905]) | |
137 |
|
138 | |||
138 | # Getting HA and DEC axes |
|
139 | # Getting HA and DEC axes | |
139 | mindec = -28; maxdec = 4; incdec = 2. |
|
140 | mindec = -28; maxdec = 4; incdec = 2. | |
@@ -142,8 +143,8 class AntPatternPlot: | |||||
142 | minha = -20; maxha = 20; incha = 2. |
|
143 | minha = -20; maxha = 20; incha = 2. | |
143 | nha = numpy.int((maxha - minha)/incha) + 1 |
|
144 | nha = numpy.int((maxha - minha)/incha) + 1 | |
144 |
|
145 | |||
145 | mcosx = numpy.zeros((nha,ndec)) |
|
146 | #mcosx = numpy.zeros((nha,ndec)) | |
146 | mcosy = numpy.zeros((nha,ndec)) |
|
147 | #mcosy = numpy.zeros((nha,ndec)) | |
147 |
|
148 | |||
148 | ha_axes = numpy.reshape(numpy.arange(nha)*incha + minha,(nha,1)) |
|
149 | ha_axes = numpy.reshape(numpy.arange(nha)*incha + minha,(nha,1)) | |
149 | ones_dec = numpy.reshape(numpy.zeros(ndec) + 1,(ndec,1)) |
|
150 | ones_dec = numpy.reshape(numpy.zeros(ndec) + 1,(ndec,1)) | |
@@ -188,14 +189,14 class AntPatternPlot: | |||||
188 | idec0 = numpy.int((-14 - mindec)/incdec) |
|
189 | idec0 = numpy.int((-14 - mindec)/incdec) | |
189 |
|
190 | |||
190 | colorgrid = (1.,109/255.,0) |
|
191 | colorgrid = (1.,109/255.,0) | |
191 |
|
|
192 | self.ax.plot(mcosx.transpose(),mcosy.transpose(),color=colorgrid,linestyle='--') | |
192 | for idec in numpy.arange(ndec): |
|
193 | for idec in numpy.arange(ndec): | |
193 | if idec != idec0: |
|
194 | if idec != idec0: | |
194 | valx = (mcosx[idec,iha0]<=xmax) & (mcosx[idec,iha0]>=xmin) |
|
195 | valx = (mcosx[idec,iha0]<=xmax) & (mcosx[idec,iha0]>=xmin) | |
195 | valy = (mcosy[idec,iha0]<=ymax) & (mcosy[idec,iha0]>=ymin) |
|
196 | valy = (mcosy[idec,iha0]<=ymax) & (mcosy[idec,iha0]>=ymin) | |
196 | if valx & valy: |
|
197 | if valx & valy: | |
197 | text = str(numpy.int(mindec + incdec*idec))+'$^o$' |
|
198 | text = str(numpy.int(mindec + incdec*idec))+'$^o$' | |
198 |
|
|
199 | self.ax.text(mcosx[idec,iha0],mcosy[idec,iha0],text) | |
199 |
|
200 | |||
200 | matplotlib.pyplot.plot(mcosx,mcosy,color=colorgrid,linestyle='--') |
|
201 | matplotlib.pyplot.plot(mcosx,mcosy,color=colorgrid,linestyle='--') | |
201 | for iha in numpy.arange(nha): |
|
202 | for iha in numpy.arange(nha): | |
@@ -204,15 +205,72 class AntPatternPlot: | |||||
204 | valy = (mcosy[idec0,iha]<=ymax) & (mcosy[idec0,iha]>=ymin) |
|
205 | valy = (mcosy[idec0,iha]<=ymax) & (mcosy[idec0,iha]>=ymin) | |
205 | if valx & valy: |
|
206 | if valx & valy: | |
206 | text = str(4*numpy.int(minha + incha*iha))+"'" |
|
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 | if save: | |
210 | matplotlib.pyplot.ylim(ymin,ymax) |
|
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 | save_fig = os.path.join(gpath,filename) |
|
269 | save_fig = os.path.join(gpath,filename) | |
213 | matplotlib.pyplot.savefig(save_fig,format='png') |
|
270 | matplotlib.pyplot.savefig(save_fig,format='png') | |
214 |
|
271 | |||
215 |
|
272 | |||
|
273 | ||||
216 | class BFieldPlot: |
|
274 | class BFieldPlot: | |
217 | def __init__(self): |
|
275 | def __init__(self): | |
218 | """ |
|
276 | """ |
@@ -10,6 +10,7 import numpy | |||||
10 | import numpy.fft |
|
10 | import numpy.fft | |
11 | import scipy.linalg |
|
11 | import scipy.linalg | |
12 | import scipy.special |
|
12 | import scipy.special | |
|
13 | from StringIO import StringIO | |||
13 | #import Numeric |
|
14 | #import Numeric | |
14 |
|
15 | |||
15 | import Misc_Routines |
|
16 | import Misc_Routines | |
@@ -20,7 +21,7 import Astro_Coords | |||||
20 |
|
21 | |||
21 | class JroPattern(): |
|
22 | class JroPattern(): | |
22 | def __init__(self,pattern=0,path=None,filename=None,nptsx=101,nptsy=101,maxphi=5,fftopt=0, \ |
|
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 | JroPattern class creates an object to represent the useful parameters for beam mode- |
|
26 | JroPattern class creates an object to represent the useful parameters for beam mode- | |
26 | lling of the Jicamarca VHF radar. |
|
27 | lling of the Jicamarca VHF radar. | |
@@ -60,6 +61,7 class JroPattern(): | |||||
60 |
|
61 | |||
61 |
|
62 | |||
62 | # Getting antenna configuration. |
|
63 | # Getting antenna configuration. | |
|
64 | if filename: | |||
63 | setup = JroAntSetup.ReturnSetup(path=path,filename=filename,pattern=pattern) |
|
65 | setup = JroAntSetup.ReturnSetup(path=path,filename=filename,pattern=pattern) | |
64 |
|
66 | |||
65 | ues = setup["ues"] |
|
67 | ues = setup["ues"] | |
@@ -67,9 +69,18 class JroPattern(): | |||||
67 | gaintx = setup["gaintx"] |
|
69 | gaintx = setup["gaintx"] | |
68 | gainrx = setup["gainrx"] |
|
70 | gainrx = setup["gainrx"] | |
69 | justrx = setup["justrx"] |
|
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 | # Defining attributes for JroPattern class. |
|
81 | # Defining attributes for JroPattern class. | |
72 | # Antenna configuration |
|
82 | # Antenna configuration | |
|
83 | ||||
73 | self.uestx = ues |
|
84 | self.uestx = ues | |
74 | self.phasetx = phase |
|
85 | self.phasetx = phase | |
75 | self.gaintx = gaintx |
|
86 | self.gaintx = gaintx | |
@@ -105,13 +116,13 class JroPattern(): | |||||
105 | self.norpattern = None |
|
116 | self.norpattern = None | |
106 | self.maxpattern = None |
|
117 | self.maxpattern = None | |
107 |
|
118 | |||
108 | self.title = setup["title"] |
|
119 | ||
109 |
|
120 | |||
110 | self.getPattern() |
|
121 | self.getPattern() | |
111 |
|
122 | |||
112 | def getPattern(self): |
|
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 | Return |
|
127 | Return | |
117 | ------ |
|
128 | ------ | |
@@ -342,12 +353,18 class JroPattern(): | |||||
342 | yindex = iy*(self.getcut==0) + ix*(self.getcut==1) |
|
353 | yindex = iy*(self.getcut==0) + ix*(self.getcut==1) | |
343 |
|
354 | |||
344 | argx = ar[0,0]*self.dcosx[ix] - lr[0,0] |
|
355 | argx = ar[0,0]*self.dcosx[ix] - lr[0,0] | |
|
356 | if argx == 0.0: | |||
|
357 | junkx = nr[0,0] | |||
|
358 | else: | |||
345 | junkx = numpy.sin(0.5*self.kk*nr[0,0]*argx)/numpy.sin(0.5*self.kk*argx) |
|
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 | argy = ar[1,0]*self.dcosy[yindex] - lr[1,0] |
|
362 | argy = ar[1,0]*self.dcosy[yindex] - lr[1,0] | |
|
363 | if argy == 0.0: | |||
|
364 | junky = nr[1,0] | |||
|
365 | else: | |||
349 | junky = numpy.sin(0.5*self.kk*nr[1,0]*argy)/numpy.sin(0.5*self.kk*argy) |
|
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 | dipole[ix,iy] = junkx*junky |
|
369 | dipole[ix,iy] = junkx*junky | |
353 |
|
370 | |||
@@ -530,8 +547,8 class BField(): | |||||
530 | nfields = 1 |
|
547 | nfields = 1 | |
531 |
|
548 | |||
532 | grid_res = 0.5 |
|
549 | grid_res = 0.5 | |
533 | nlon = numpy.int(maglimits[2] - maglimits[0])/grid_res + 1 |
|
550 | nlon = int(numpy.int(maglimits[2] - maglimits[0])/grid_res + 1) | |
534 | nlat = numpy.int(maglimits[3] - maglimits[1])/grid_res + 1 |
|
551 | nlat = int(numpy.int(maglimits[3] - maglimits[1])/grid_res + 1) | |
535 |
|
552 | |||
536 | location = numpy.zeros((nlon,nlat,2)) |
|
553 | location = numpy.zeros((nlon,nlat,2)) | |
537 | mlon = numpy.atleast_2d(numpy.arange(nlon)*grid_res + maglimits[0]) |
|
554 | mlon = numpy.atleast_2d(numpy.arange(nlon)*grid_res + maglimits[0]) | |
@@ -941,10 +958,10 class overJroShow: | |||||
941 | # __tmpDir = 'overJro/tempReports' |
|
958 | # __tmpDir = 'overJro/tempReports' | |
942 | # __serverdocspath = '/Users/dsuarez/Pictures' |
|
959 | # __serverdocspath = '/Users/dsuarez/Pictures' | |
943 | # __tmpDir = 'overjro' |
|
960 | # __tmpDir = 'overjro' | |
944 |
__serverdocspath = |
|
961 | __serverdocspath = '' | |
945 |
__tmpDir = |
|
962 | __tmpDir = '' | |
946 |
|
963 | |||
947 | def __init__(self): |
|
964 | def __init__(self, title=''): | |
948 | self.year = None |
|
965 | self.year = None | |
949 | self.month = None |
|
966 | self.month = None | |
950 | self.dom = None |
|
967 | self.dom = None | |
@@ -971,12 +988,18 class overJroShow: | |||||
971 | self.time_mag = None |
|
988 | self.time_mag = None | |
972 | self.main_dec = None |
|
989 | self.main_dec = None | |
973 | self.ObjC = None |
|
990 | self.ObjC = None | |
974 |
self.ptitle = |
|
991 | self.ptitle = title | |
975 | self.path4plotname = None |
|
992 | self.path4plotname = None | |
976 | self.plotname0 = None |
|
993 | self.plotname0 = None | |
977 | self.plotname1 = None |
|
994 | self.plotname1 = None | |
978 | self.plotname2 = None |
|
995 | self.plotname2 = None | |
979 | self.scriptHeaders = 0 |
|
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 | # self.outputHead('Show Plot') |
|
1003 | # self.outputHead('Show Plot') | |
981 | # self.printBody() |
|
1004 | # self.printBody() | |
982 |
|
1005 | |||
@@ -1180,8 +1203,6 class overJroShow: | |||||
1180 |
|
1203 | |||
1181 | # Defining plot filenames |
|
1204 | # Defining plot filenames | |
1182 | self.path4plotname = os.path.join(self.__serverdocspath,self.__tmpDir) |
|
1205 | self.path4plotname = os.path.join(self.__serverdocspath,self.__tmpDir) | |
1183 | print "PATH4" |
|
|||
1184 | print os.path.join(self.__serverdocspath,self.__tmpDir) |
|
|||
1185 | self.plotname0 = 'over_jro_0_%i.png'% (time.time()) #plot pattern & objects |
|
1206 | self.plotname0 = 'over_jro_0_%i.png'% (time.time()) #plot pattern & objects | |
1186 | self.plotname1 = 'over_jro_1_%i.png'% (time.time()) #plot antenna cuts |
|
1207 | self.plotname1 = 'over_jro_1_%i.png'% (time.time()) #plot antenna cuts | |
1187 | self.plotname2 = 'over_jro_2_%i.png'% (time.time()) #plot sky noise |
|
1208 | self.plotname2 = 'over_jro_2_%i.png'% (time.time()) #plot sky noise | |
@@ -1206,6 +1227,70 class overJroShow: | |||||
1206 | self.yg = numpy.dot(self.MT3.transpose(),numpy.array([0,1,0])) |
|
1227 | self.yg = numpy.dot(self.MT3.transpose(),numpy.array([0,1,0])) | |
1207 | self.zg = numpy.dot(self.MT3.transpose(),numpy.array([0,0,1])) |
|
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 | def plotPattern(self): |
|
1294 | def plotPattern(self): | |
1210 | # Plotting Antenna patterns. |
|
1295 | # Plotting Antenna patterns. | |
1211 | npatterns = numpy.size(self.pattern) |
|
1296 | npatterns = numpy.size(self.pattern) | |
@@ -1230,10 +1315,8 class overJroShow: | |||||
1230 |
|
1315 | |||
1231 | title += ObjAnt.title |
|
1316 | title += ObjAnt.title | |
1232 | # Plotting Contour Map |
|
1317 | # Plotting Contour Map | |
1233 | print "Antes de la creacion" |
|
1318 | ||
1234 |
self.path4plotname = '/home/ |
|
1319 | self.path4plotname = '/home/jespinoza/workspace/radarsys/trunk/webapp/apps/abs/static/images' | |
1235 | print self.path4plotname |
|
|||
1236 | print self.plotname0 |
|
|||
1237 | dum = Graphics_OverJro.AntPatternPlot() |
|
1320 | dum = Graphics_OverJro.AntPatternPlot() | |
1238 | dum.contPattern(iplot=ii, |
|
1321 | dum.contPattern(iplot=ii, | |
1239 | gpath=self.path4plotname, |
|
1322 | gpath=self.path4plotname, | |
@@ -1246,8 +1329,6 class overJroShow: | |||||
1246 | title=title) |
|
1329 | title=title) | |
1247 | # title=ObjAnt.title) |
|
1330 | # title=ObjAnt.title) | |
1248 | # self.ptitle = ObjAnt.title |
|
1331 | # self.ptitle = ObjAnt.title | |
1249 | if ii==0: |
|
|||
1250 | self.figure = dum.figure |
|
|||
1251 |
|
1332 | |||
1252 | if ii != (npatterns-1): |
|
1333 | if ii != (npatterns-1): | |
1253 | title += '+' |
|
1334 | title += '+' | |
@@ -1267,7 +1348,14 class overJroShow: | |||||
1267 |
|
1348 | |||
1268 | self.ptitle = title |
|
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 | self.dcosx = ObjAnt.dcosx |
|
1360 | self.dcosx = ObjAnt.dcosx | |
1273 |
|
1361 | |||
@@ -1616,8 +1704,7 class overJroShow: | |||||
1616 | self.plotSkyNoise() |
|
1704 | self.plotSkyNoise() | |
1617 |
|
1705 | |||
1618 | def getPlot(self): |
|
1706 | def getPlot(self): | |
1619 | print "GETPLot" |
|
1707 | ||
1620 | print os.path.join(self.__serverdocspath,self.__tmpDir,self.plotname0) |
|
|||
1621 | return os.path.join(self.__serverdocspath,self.__tmpDir,self.plotname0) |
|
1708 | return os.path.join(self.__serverdocspath,self.__tmpDir,self.plotname0) | |
1622 |
|
1709 | |||
1623 |
|
1710 | |||
@@ -1627,6 +1714,41 if __name__ == '__main__': | |||||
1627 | # This script only calls the init function of the class overJroShow() |
|
1714 | # This script only calls the init function of the class overJroShow() | |
1628 | # All work is done by the init function |
|
1715 | # All work is done by the init function | |
1629 |
|
1716 | |||
1630 | newOverJro = overJroShow() |
|
1717 | phases = numpy.array([[2.0,0.0,1.5,1.5,1.0,1.0,1.0,0.5], | |
1631 | newOverJro.initParametersCGI() |
|
1718 | [2.0,2.5,2.5,3.5,0.5,1.0,1.0,1.0], | |
1632 | newOverJro.execute() |
|
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 | kwargs = {} |
|
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 |
conf |
|
321 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) | |
|
322 | beams = ABSBeam.objects.filter(abs_conf=conf) | |||
|
323 | ||||
|
324 | if id_beam: | |||
346 |
beam |
|
325 | beam = get_object_or_404(ABSBeam, pk=id_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 | ###### SIDEBAR ###### |
|
329 | ###### SIDEBAR ###### | |
359 | beam = get_object_or_404(ABSBeam, pk=id_beam) |
|
|||
360 | kwargs = {} |
|
|||
361 |
|
330 | |||
362 | kwargs['dev_conf'] = conf.device |
|
331 | kwargs['dev_conf'] = conf.device | |
363 | kwargs['id_dev'] = conf.device |
|
332 | kwargs['id_dev'] = conf.device | |
364 | kwargs['id_conf'] = conf.id |
|
333 | kwargs['id_conf'] = conf.id | |
365 | kwargs['abs_beams'] = beams |
|
334 | kwargs['abs_beams'] = beams | |
366 | kwargs['beam'] = beam |
|
|||
367 | kwargs['title'] = 'ABS Patterns' |
|
335 | kwargs['title'] = 'ABS Patterns' | |
368 | kwargs['suptitle'] = conf.name |
|
336 | kwargs['suptitle'] = conf.name | |
369 | kwargs['no_sidebar'] = True |
|
337 | kwargs['no_sidebar'] = True | |
@@ -371,112 +339,27 def plot_pattern(request, id_conf, id_beam): | |||||
371 | return render(request, 'abs_patterns.html', kwargs) |
|
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): |
|
344 | if antenna=='down': | |
376 |
|
345 | sleep(3) | ||
377 | from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas |
|
|||
378 |
|
346 | |||
379 |
conf |
|
347 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) | |
380 |
beam |
|
348 | beam = get_object_or_404(ABSBeam, pk=id_beam) | |
381 |
|
349 | |||
382 |
|
|
350 | name = conf.experiment.name | |
383 |
|
||||
384 | just_rx = 0 |
|
|||
385 |
|
||||
386 | only_rx = json.loads(beam.only_rx) |
|
|||
387 | if only_rx['up'] == True: |
|
|||
388 | just_rx = 1 |
|
|||
389 |
|
351 | |||
390 | antenna = ast.literal_eval(beam.antenna) |
|
352 | just_rx = 1 if json.loads(beam.only_rx)[antenna] else 0 | |
391 | objAntenna = json.dumps(antenna['antenna_up']) |
|
353 | phases = json.loads(beam.antenna)['antenna_{}'.format(antenna)] | |
392 | antenna_up = ''.join(str(i) for i in objAntenna) |
|
354 | gain_tx = json.loads(beam.tx)[antenna] | |
393 | phase_tx = antenna_up.replace(' ','') |
|
355 | gain_rx = json.loads(beam.rx)[antenna] | |
|
356 | ues = json.loads(beam.ues)[antenna] | |||
394 |
|
357 | |||
395 | tx = ast.literal_eval(beam.tx) |
|
358 | newOverJro = overJroShow(name) | |
396 | tx = json.dumps(tx['up']) |
|
359 | fig = newOverJro.plotPattern2(datetime.today(), phases, gain_tx, gain_rx, ues, just_rx) | |
397 | tx = ''.join(str(i) for i in tx) |
|
|||
398 | gain_tx = tx.replace(' ','') |
|
|||
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 | response=HttpResponse(content_type='image/png') |
|
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 | return response |
|
365 | return response |
General Comments 0
You need to be logged in to leave comments.
Login now