##// END OF EJS Templates
Se corrigen bugs en el eje x de los graficos RTI y CoherenceMap, se reduce el numero de puntos o pixeles en X e Y....
Daniel Valdez -
r471:087ce30f3ac5
parent child
Show More
@@ -64,6 +64,9 class Figure:
64 HEIGHT = None
64 HEIGHT = None
65 PREFIX = 'fig'
65 PREFIX = 'fig'
66
66
67 xmin = None
68 xmax = None
69
67 def __init__(self):
70 def __init__(self):
68
71
69 raise ValueError, "This method is not implemented"
72 raise ValueError, "This method is not implemented"
@@ -95,39 +98,73 class Figure:
95
98
96 return widthscreen, heightscreen
99 return widthscreen, heightscreen
97
100
98 def getTimeLim(self, x, xmin, xmax):
101 def getTimeLim(self, x, xmin=None, xmax=None, timerange=None):
99
102
100 if self.timerange != None:
103 if self.xmin != None and self.xmax != None:
101 txmin = x[0] - x[0]%self.timerange
104 if timerange == None:
102 else:
105 timerange = self.xmax - self.xmin
103 txmin = numpy.min(x)
106 xmin = self.xmin + timerange
104
107 xmax = self.xmax + timerange
105 thisdatetime = datetime.datetime.utcfromtimestamp(txmin)
108
106 thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0))
109 return xmin, xmax
107
110
108 ####################################################
109 #If the x is out of xrange
110 if xmax != None:
111 if xmax < (thisdatetime - thisdate).seconds/(60*60.):
112 xmin = None
113 xmax = None
114
111
115 if xmin == None:
112 if timerange != None and self.xmin == None and self.xmax == None:
116 td = thisdatetime - thisdate
113 txmin = x[0] - x[0]%timerange
117 xmin = td.seconds/(60*60.)
114 thisdatetime = datetime.datetime.utcfromtimestamp(txmin)
115 thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0))
116 xmin = (thisdatetime - thisdate).seconds/(60*60.)
117 xmax = xmin + timerange/(60*60.)
118
118
119 if xmax == None:
119
120 xmax = xmin + self.timerange/(60*60.)
120 if timerange == None:
121 txmin = numpy.min(x)
122 thisdatetime = datetime.datetime.utcfromtimestamp(txmin)
123 thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0))
121
124
122 mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone)
125 mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone)
123 tmin = time.mktime(mindt.timetuple())
126 xmin_sec = time.mktime(mindt.timetuple())
124
127
125 maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone)
128 maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone)
126 tmax = time.mktime(maxdt.timetuple())
129 xmax_sec = time.mktime(maxdt.timetuple())
127
130
128 self.timerange = tmax - tmin
131 return xmin_sec, xmax_sec
129
132
130 return tmin, tmax
133
134
135
136
137 # if timerange != None:
138 # txmin = x[0] - x[0]%timerange
139 # else:
140 # txmin = numpy.min(x)
141 #
142 # thisdatetime = datetime.datetime.utcfromtimestamp(txmin)
143 # thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0))
144 #
145 # ####################################################
146 # #If the x is out of xrange
147 # if xmax != None:
148 # if xmax < (thisdatetime - thisdate).seconds/(60*60.):
149 # xmin = None
150 # xmax = None
151 #
152 # if xmin == None:
153 # td = thisdatetime - thisdate
154 # xmin = td.seconds/(60*60.)
155 #
156 # if xmax == None:
157 # xmax = xmin + self.timerange/(60*60.)
158 #
159 # mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone)
160 # tmin = time.mktime(mindt.timetuple())
161 #
162 # maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone)
163 # tmax = time.mktime(maxdt.timetuple())
164 #
165 # #self.timerange = tmax - tmin
166 #
167 # return tmin, tmax
131
168
132 def init(self, id, nplots, wintitle):
169 def init(self, id, nplots, wintitle):
133
170
@@ -278,8 +315,8 class Axes:
278 decimationx = None
315 decimationx = None
279 decimationy = None
316 decimationy = None
280
317
281 __MAXNUMX = 1000
318 __MAXNUMX = 300
282 __MAXNUMY = 500
319 __MAXNUMY = 150
283
320
284 def __init__(self, *args):
321 def __init__(self, *args):
285
322
@@ -459,6 +459,11 class RTIPlot(Figure):
459 self.EXP_CODE = None
459 self.EXP_CODE = None
460 self.SUB_EXP_CODE = None
460 self.SUB_EXP_CODE = None
461 self.PLOT_POS = None
461 self.PLOT_POS = None
462 self.tmin = None
463 self.tmax = None
464
465 self.xmin = None
466 self.xmax = None
462
467
463 def getSubplots(self):
468 def getSubplots(self):
464
469
@@ -536,8 +541,8 class RTIPlot(Figure):
536 if timerange != None:
541 if timerange != None:
537 self.timerange = timerange
542 self.timerange = timerange
538
543
539 tmin = None
544 #tmin = None
540 tmax = None
545 #tmax = None
541 factor = dataOut.normFactor
546 factor = dataOut.normFactor
542 x = dataOut.getTimeRange()
547 x = dataOut.getTimeRange()
543 y = dataOut.getHeiRange()
548 y = dataOut.getHeiRange()
@@ -565,7 +570,14 class RTIPlot(Figure):
565 showprofile=showprofile,
570 showprofile=showprofile,
566 show=show)
571 show=show)
567
572
568 tmin, tmax = self.getTimeLim(x, xmin, xmax)
573 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
574
575 # if timerange != None:
576 # self.timerange = timerange
577 # self.xmin, self.tmax = self.getTimeLim(x, xmin, xmax, timerange)
578
579
580
569 if ymin == None: ymin = numpy.nanmin(y)
581 if ymin == None: ymin = numpy.nanmin(y)
570 if ymax == None: ymax = numpy.nanmax(y)
582 if ymax == None: ymax = numpy.nanmax(y)
571 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
583 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
@@ -581,13 +593,16 class RTIPlot(Figure):
581
593
582
594
583 self.setWinTitle(title)
595 self.setWinTitle(title)
584
596
597 if ((self.xmax - x[1]) < (x[1]-x[0])):
598 x[1] = self.xmax
599
585 for i in range(self.nplots):
600 for i in range(self.nplots):
586 title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
601 title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
587 axes = self.axesList[i*self.__nsubplots]
602 axes = self.axesList[i*self.__nsubplots]
588 zdB = avgdB[i].reshape((1,-1))
603 zdB = avgdB[i].reshape((1,-1))
589 axes.pcolorbuffer(x, y, zdB,
604 axes.pcolorbuffer(x, y, zdB,
590 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
605 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
591 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
606 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
592 ticksize=9, cblabel='', cbsize="1%")
607 ticksize=9, cblabel='', cbsize="1%")
593
608
@@ -601,49 +616,54 class RTIPlot(Figure):
601
616
602 self.draw()
617 self.draw()
603
618
604 if lastone:
619 # if lastone:
605 if dataOut.blocknow >= dataOut.last_block:
620 # if dataOut.blocknow >= dataOut.last_block:
606 if figfile == None:
621 # if figfile == None:
607 figfile = self.getFilename(name = self.name)
622 # figfile = self.getFilename(name = self.name)
608 self.saveFigure(figpath, figfile)
623 # self.saveFigure(figpath, figfile)
609
624 #
610 if (save and not(lastone)):
625 # if (save and not(lastone)):
611
626 #
612 self.counter_imagwr += 1
627 # self.counter_imagwr += 1
613 if (self.counter_imagwr==wr_period):
628 # if (self.counter_imagwr==wr_period):
614 if figfile == None:
629 # if figfile == None:
615 figfile = self.getFilename(name = self.name)
630 # figfile = self.getFilename(name = self.name)
616 self.saveFigure(figpath, figfile)
631 # self.saveFigure(figpath, figfile)
617
632 #
618 if ftp:
633 # if ftp:
619 #provisionalmente envia archivos en el formato de la web en tiempo real
634 # #provisionalmente envia archivos en el formato de la web en tiempo real
620 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
635 # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
621 path = '%s%03d' %(self.PREFIX, self.id)
636 # path = '%s%03d' %(self.PREFIX, self.id)
622 ftp_file = os.path.join(path,'ftp','%s.png'%name)
637 # ftp_file = os.path.join(path,'ftp','%s.png'%name)
623 self.saveFigure(figpath, ftp_file)
638 # self.saveFigure(figpath, ftp_file)
624 ftp_filename = os.path.join(figpath,ftp_file)
639 # ftp_filename = os.path.join(figpath,ftp_file)
625 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
640 # self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
626 self.counter_imagwr = 0
641 # self.counter_imagwr = 0
642 #
643 # self.counter_imagwr = 0
627
644
628 self.counter_imagwr = 0
645 #if ((dataOut.utctime-time.timezone) >= self.axesList[0].xmax):
629
646 if x[1] >= self.axesList[0].xmax:
630 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
647 self.saveFigure(figpath, figfile)
631
632 self.__isConfig = False
648 self.__isConfig = False
633
649
634 if lastone:
650 # if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
635 if figfile == None:
651 #
636 figfile = self.getFilename(name = self.name)
652 # self.__isConfig = False
637 self.saveFigure(figpath, figfile)
653
638
654 # if lastone:
639 if ftp:
655 # if figfile == None:
640 #provisionalmente envia archivos en el formato de la web en tiempo real
656 # figfile = self.getFilename(name = self.name)
641 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
657 # self.saveFigure(figpath, figfile)
642 path = '%s%03d' %(self.PREFIX, self.id)
658 #
643 ftp_file = os.path.join(path,'ftp','%s.png'%name)
659 # if ftp:
644 self.saveFigure(figpath, ftp_file)
660 # #provisionalmente envia archivos en el formato de la web en tiempo real
645 ftp_filename = os.path.join(figpath,ftp_file)
661 # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
646 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
662 # path = '%s%03d' %(self.PREFIX, self.id)
663 # ftp_file = os.path.join(path,'ftp','%s.png'%name)
664 # self.saveFigure(figpath, ftp_file)
665 # ftp_filename = os.path.join(figpath,ftp_file)
666 # self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
647
667
648
668
649 class SpectraPlot(Figure):
669 class SpectraPlot(Figure):
@@ -1090,6 +1110,9 class CoherenceMap(Figure):
1090 self.SUB_EXP_CODE = None
1110 self.SUB_EXP_CODE = None
1091 self.PLOT_POS = None
1111 self.PLOT_POS = None
1092 self.counter_imagwr = 0
1112 self.counter_imagwr = 0
1113
1114 self.xmin = None
1115 self.xmax = None
1093
1116
1094 def getSubplots(self):
1117 def getSubplots(self):
1095 ncol = 1
1118 ncol = 1
@@ -1150,8 +1173,8 class CoherenceMap(Figure):
1150 if len(pairsIndexList) > 4:
1173 if len(pairsIndexList) > 4:
1151 pairsIndexList = pairsIndexList[0:4]
1174 pairsIndexList = pairsIndexList[0:4]
1152
1175
1153 tmin = None
1176 # tmin = None
1154 tmax = None
1177 # tmax = None
1155 x = dataOut.getTimeRange()
1178 x = dataOut.getTimeRange()
1156 y = dataOut.getHeiRange()
1179 y = dataOut.getHeiRange()
1157
1180
@@ -1169,7 +1192,10 class CoherenceMap(Figure):
1169 showprofile=showprofile,
1192 showprofile=showprofile,
1170 show=show)
1193 show=show)
1171
1194
1172 tmin, tmax = self.getTimeLim(x, xmin, xmax)
1195 #tmin, tmax = self.getTimeLim(x, xmin, xmax)
1196
1197 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1198
1173 if ymin == None: ymin = numpy.nanmin(y)
1199 if ymin == None: ymin = numpy.nanmin(y)
1174 if ymax == None: ymax = numpy.nanmax(y)
1200 if ymax == None: ymax = numpy.nanmax(y)
1175 if zmin == None: zmin = 0.
1201 if zmin == None: zmin = 0.
@@ -1186,6 +1212,9 class CoherenceMap(Figure):
1186
1212
1187 self.setWinTitle(title)
1213 self.setWinTitle(title)
1188
1214
1215 if ((self.xmax - x[1]) < (x[1]-x[0])):
1216 x[1] = self.xmax
1217
1189 for i in range(self.nplots):
1218 for i in range(self.nplots):
1190
1219
1191 pair = dataOut.pairsList[pairsIndexList[i]]
1220 pair = dataOut.pairsList[pairsIndexList[i]]
@@ -1211,7 +1240,7 class CoherenceMap(Figure):
1211 title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1240 title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1212 axes = self.axesList[i*self.__nsubplots*2]
1241 axes = self.axesList[i*self.__nsubplots*2]
1213 axes.pcolorbuffer(x, y, z,
1242 axes.pcolorbuffer(x, y, z,
1214 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1243 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1215 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1244 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1216 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
1245 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
1217
1246
@@ -1233,7 +1262,7 class CoherenceMap(Figure):
1233 title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1262 title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1234 axes = self.axesList[i*self.__nsubplots*2 + counter]
1263 axes = self.axesList[i*self.__nsubplots*2 + counter]
1235 axes.pcolorbuffer(x, y, z,
1264 axes.pcolorbuffer(x, y, z,
1236 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
1265 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
1237 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1266 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1238 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
1267 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
1239
1268
@@ -1248,29 +1277,33 class CoherenceMap(Figure):
1248
1277
1249 self.draw()
1278 self.draw()
1250
1279
1251 if save:
1280 if x[1] >= self.axesList[0].xmax:
1252
1281 self.saveFigure(figpath, figfile)
1253 self.counter_imagwr += 1
1254 if (self.counter_imagwr==wr_period):
1255 if figfile == None:
1256 figfile = self.getFilename(name = self.name)
1257 self.saveFigure(figpath, figfile)
1258
1259 if ftp:
1260 #provisionalmente envia archivos en el formato de la web en tiempo real
1261 name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
1262 path = '%s%03d' %(self.PREFIX, self.id)
1263 ftp_file = os.path.join(path,'ftp','%s.png'%name)
1264 self.saveFigure(figpath, ftp_file)
1265 ftp_filename = os.path.join(figpath,ftp_file)
1266 self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1267 self.counter_imagwr = 0
1268
1269 self.counter_imagwr = 0
1270
1271
1272 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1273 self.__isConfig = False
1282 self.__isConfig = False
1283
1284 # if save:
1285 #
1286 # self.counter_imagwr += 1
1287 # if (self.counter_imagwr==wr_period):
1288 # if figfile == None:
1289 # figfile = self.getFilename(name = self.name)
1290 # self.saveFigure(figpath, figfile)
1291 #
1292 # if ftp:
1293 # #provisionalmente envia archivos en el formato de la web en tiempo real
1294 # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS)
1295 # path = '%s%03d' %(self.PREFIX, self.id)
1296 # ftp_file = os.path.join(path,'ftp','%s.png'%name)
1297 # self.saveFigure(figpath, ftp_file)
1298 # ftp_filename = os.path.join(figpath,ftp_file)
1299 # self.sendByFTP_Thread(ftp_filename, server, folder, username, password)
1300 # self.counter_imagwr = 0
1301 #
1302 # self.counter_imagwr = 0
1303 #
1304 #
1305 # if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1306 # self.__isConfig = False
1274
1307
1275 class BeaconPhase(Figure):
1308 class BeaconPhase(Figure):
1276
1309
@@ -1428,11 +1461,11 class BeaconPhase(Figure):
1428 path = '%s%03d' %(self.PREFIX, self.id)
1461 path = '%s%03d' %(self.PREFIX, self.id)
1429 beacon_file = os.path.join(path,'%s.txt'%self.name)
1462 beacon_file = os.path.join(path,'%s.txt'%self.name)
1430 self.filename_phase = os.path.join(figpath,beacon_file)
1463 self.filename_phase = os.path.join(figpath,beacon_file)
1431 self.save_phase(self.filename_phase)
1464 #self.save_phase(self.filename_phase)
1432
1465
1433
1466
1434 #store data beacon phase
1467 #store data beacon phase
1435 self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1468 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1436
1469
1437 self.setWinTitle(title)
1470 self.setWinTitle(title)
1438
1471
@@ -919,8 +919,12 class SpectraProc(ProcessingUnit):
919
919
920 return 1
920 return 1
921
921
922 def getBeaconSignal(self, tauindex = 0, channelindex = 0):
922 def getBeaconSignal(self, tauindex = 0, channelindex = 0, hei_ref=None):
923 newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex])
923 newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex])
924
925 if hei_ref != None:
926 newheis = numpy.where(self.dataOut.heightList>hei_ref)
927
924 minIndex = min(newheis[0])
928 minIndex = min(newheis[0])
925 maxIndex = max(newheis[0])
929 maxIndex = max(newheis[0])
926 data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]
930 data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]
General Comments 0
You need to be logged in to leave comments. Login now