##// END OF EJS Templates
Calculo y ploteo de la fase del Beacon
Daniel Valdez -
r453:5535f3978be4
parent child
Show More
@@ -122,6 +122,8 class JROData:
122 frequency = 49.92e6
122 frequency = 49.92e6
123
123
124 realtime = False
124 realtime = False
125
126 beacon_heiIndexList = None
125
127
126 def __init__(self):
128 def __init__(self):
127
129
@@ -369,6 +371,9 class Spectra(JROData):
369 self.ippFactor = 1
371 self.ippFactor = 1
370
372
371 self.noise = None
373 self.noise = None
374
375 self.beacon_heiIndexList = []
376
372
377
373 def getNoisebyHildebrand(self):
378 def getNoisebyHildebrand(self):
374 """
379 """
@@ -1030,6 +1030,166 class CoherenceMap(Figure):
1030 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1030 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
1031 self.__isConfig = False
1031 self.__isConfig = False
1032
1032
1033 class BeaconPhase(Figure):
1034
1035 __isConfig = None
1036 __nsubplots = None
1037
1038 PREFIX = 'beacon_phase'
1039
1040 def __init__(self):
1041
1042 self.timerange = 24*60*60
1043 self.__isConfig = False
1044 self.__nsubplots = 1
1045 self.counter_imagwr = 0
1046 self.WIDTH = 600
1047 self.HEIGHT = 300
1048 self.WIDTHPROF = 120
1049 self.HEIGHTPROF = 0
1050 self.xdata = None
1051 self.ydata = None
1052
1053 self.PLOT_CODE = 999999
1054 self.FTP_WEI = None
1055 self.EXP_CODE = None
1056 self.SUB_EXP_CODE = None
1057 self.PLOT_POS = None
1058
1059 def getSubplots(self):
1060
1061 ncol = 1
1062 nrow = 1
1063
1064 return nrow, ncol
1065
1066 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1067
1068 self.__showprofile = showprofile
1069 self.nplots = nplots
1070
1071 ncolspan = 7
1072 colspan = 6
1073 self.__nsubplots = 2
1074
1075 self.createFigure(id = id,
1076 wintitle = wintitle,
1077 widthplot = self.WIDTH+self.WIDTHPROF,
1078 heightplot = self.HEIGHT+self.HEIGHTPROF,
1079 show=show)
1080
1081 nrow, ncol = self.getSubplots()
1082
1083 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1084
1085
1086 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1087 xmin=None, xmax=None, ymin=None, ymax=None,
1088 timerange=None,
1089 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1090 server=None, folder=None, username=None, password=None,
1091 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1092
1093 if pairsList == None:
1094 pairsIndexList = dataOut.pairsIndexList
1095 else:
1096 pairsIndexList = []
1097 for pair in pairsList:
1098 if pair not in dataOut.pairsList:
1099 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
1100 pairsIndexList.append(dataOut.pairsList.index(pair))
1101
1102 if pairsIndexList == []:
1103 return
1104
1105 if len(pairsIndexList) > 4:
1106 pairsIndexList = pairsIndexList[0:4]
1107
1108 if timerange != None:
1109 self.timerange = timerange
1110
1111 tmin = None
1112 tmax = None
1113 x = dataOut.getTimeRange()
1114 y = dataOut.getHeiRange()
1115
1116
1117 #thisDatetime = dataOut.datatime
1118 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1])
1119 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1120 xlabel = "Local Time"
1121 ylabel = "Phase"
1122
1123 nplots = len(pairsIndexList)
1124 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1125 phase_beacon = numpy.zeros(len(pairsIndexList))
1126 for i in range(nplots):
1127 pair = dataOut.pairsList[pairsIndexList[i]]
1128 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
1129 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
1130 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
1131 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
1132 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1133
1134 #print "Phase %d%d" %(pair[0], pair[1])
1135 #print phase[dataOut.beacon_heiIndexList]
1136
1137 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1138
1139 if not self.__isConfig:
1140
1141 nplots = len(pairsIndexList)
1142
1143 self.setup(id=id,
1144 nplots=nplots,
1145 wintitle=wintitle,
1146 showprofile=showprofile,
1147 show=show)
1148
1149 tmin, tmax = self.getTimeLim(x, xmin, xmax)
1150 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1151 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1152
1153 self.FTP_WEI = ftp_wei
1154 self.EXP_CODE = exp_code
1155 self.SUB_EXP_CODE = sub_exp_code
1156 self.PLOT_POS = plot_pos
1157
1158 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1159
1160
1161 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1162 self.__isConfig = True
1163
1164 self.xdata = numpy.array([])
1165 self.ydata = numpy.array([])
1166
1167 self.setWinTitle(title)
1168
1169
1170 title = "Beacon Signal %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1171
1172 legendlabels = ["pairs %d%d"%(pair[0], pair[1]) for pair in dataOut.pairsList]
1173
1174 axes = self.axesList[0]
1175
1176 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1177
1178 if len(self.ydata)==0:
1179 self.ydata = phase_beacon.reshape(-1,1)
1180 else:
1181 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1182
1183
1184 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1185 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax,
1186 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1187 XAxisAsTime=True, grid='both'
1188 )
1189
1190 self.draw()
1191
1192
1033 class Noise(Figure):
1193 class Noise(Figure):
1034
1194
1035 __isConfig = None
1195 __isConfig = None
@@ -918,6 +918,41 class SpectraProc(ProcessingUnit):
918
918
919 return 1
919 return 1
920
920
921 def getBeaconSignal(self, tauindex = 0, channelindex = 0):
922 newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex])
923 minIndex = min(newheis[0])
924 maxIndex = max(newheis[0])
925 data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]
926 heightList = self.dataOut.heightList[minIndex:maxIndex+1]
927
928 # determina indices
929 nheis = int(self.dataOut.radarControllerHeaderObj.txB/(self.dataOut.heightList[1]-self.dataOut.heightList[0]))
930 avg_dB = 10*numpy.log10(numpy.sum(data_spc[channelindex,:,:],axis=0))
931 beacon_dB = numpy.sort(avg_dB)[-nheis:]
932 beacon_heiIndexList = []
933 for val in avg_dB.tolist():
934 if val >= beacon_dB[0]:
935 beacon_heiIndexList.append(avg_dB.tolist().index(val))
936
937 #data_spc = data_spc[:,:,beacon_heiIndexList]
938 data_cspc = None
939 if self.dataOut.data_cspc != None:
940 data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1]
941 #data_cspc = data_cspc[:,:,beacon_heiIndexList]
942
943 data_dc = None
944 if self.dataOut.data_dc != None:
945 data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1]
946 #data_dc = data_dc[:,beacon_heiIndexList]
947
948 self.dataOut.data_spc = data_spc
949 self.dataOut.data_cspc = data_cspc
950 self.dataOut.data_dc = data_dc
951 self.dataOut.heightList = heightList
952 self.dataOut.beacon_heiIndexList = beacon_heiIndexList
953
954 return 1
955
921
956
922 def selectHeightsByIndex(self, minIndex, maxIndex):
957 def selectHeightsByIndex(self, minIndex, maxIndex):
923 """
958 """
General Comments 0
You need to be logged in to leave comments. Login now