@@ -820,4 +820,148 class CoherencePlot(Figure): | |||||
820 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
820 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
821 | self.__isConfig = False |
|
821 | self.__isConfig = False | |
822 |
|
822 | |||
|
823 | class RTIfromNoise(Figure): | |||
|
824 | ||||
|
825 | __isConfig = None | |||
|
826 | __nsubplots = None | |||
|
827 | ||||
|
828 | WIDTHPROF = None | |||
|
829 | HEIGHTPROF = None | |||
|
830 | PREFIX = 'rti' | |||
|
831 | ||||
|
832 | def __init__(self): | |||
|
833 | ||||
|
834 | self.__timerange = 24*60*60 | |||
|
835 | self.__isConfig = False | |||
|
836 | self.__nsubplots = 1 | |||
|
837 | ||||
|
838 | self.WIDTH = 800 | |||
|
839 | self.HEIGHT = 200 | |||
|
840 | ||||
|
841 | def getSubplots(self): | |||
|
842 | ||||
|
843 | ncol = 1 | |||
|
844 | nrow = self.nplots | |||
|
845 | ||||
|
846 | return nrow, ncol | |||
|
847 | ||||
|
848 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |||
|
849 | ||||
|
850 | self.__showprofile = showprofile | |||
|
851 | self.nplots = nplots | |||
|
852 | ||||
|
853 | ncolspan = 1 | |||
|
854 | colspan = 1 | |||
|
855 | ||||
|
856 | self.createFigure(idfigure = idfigure, | |||
|
857 | wintitle = wintitle, | |||
|
858 | widthplot = self.WIDTH + self.WIDTHPROF, | |||
|
859 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |||
|
860 | ||||
|
861 | nrow, ncol = self.getSubplots() | |||
|
862 | ||||
|
863 | self.addAxes(nrow, ncol, 0, 0, 1, 1) | |||
|
864 | ||||
|
865 | ||||
|
866 | ||||
|
867 | def __getTimeLim(self, x, xmin, xmax): | |||
|
868 | ||||
|
869 | thisdatetime = datetime.datetime.fromtimestamp(numpy.min(x)) | |||
|
870 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) | |||
|
871 | ||||
|
872 | #################################################### | |||
|
873 | #If the x is out of xrange | |||
|
874 | if xmax < (thisdatetime - thisdate).seconds/(60*60.): | |||
|
875 | xmin = None | |||
|
876 | xmax = None | |||
|
877 | ||||
|
878 | if xmin == None: | |||
|
879 | td = thisdatetime - thisdate | |||
|
880 | xmin = td.seconds/(60*60.) | |||
|
881 | ||||
|
882 | if xmax == None: | |||
|
883 | xmax = xmin + self.__timerange/(60*60.) | |||
|
884 | ||||
|
885 | mindt = thisdate + datetime.timedelta(0,0,0,0,0, xmin) | |||
|
886 | tmin = time.mktime(mindt.timetuple()) | |||
|
887 | ||||
|
888 | maxdt = thisdate + datetime.timedelta(0,0,0,0,0, xmax) | |||
|
889 | tmax = time.mktime(maxdt.timetuple()) | |||
|
890 | ||||
|
891 | self.__timerange = tmax - tmin | |||
|
892 | ||||
|
893 | return tmin, tmax | |||
|
894 | ||||
|
895 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |||
|
896 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |||
|
897 | timerange=None, | |||
|
898 | save=False, figpath='./', figfile=None): | |||
|
899 | ||||
|
900 | if channelList == None: | |||
|
901 | channelIndexList = dataOut.channelIndexList | |||
|
902 | else: | |||
|
903 | channelIndexList = [] | |||
|
904 | for channel in channelList: | |||
|
905 | if channel not in dataOut.channelList: | |||
|
906 | raise ValueError, "Channel %d is not in dataOut.channelList" | |||
|
907 | channelIndexList.append(dataOut.channelList.index(channel)) | |||
|
908 | ||||
|
909 | if timerange != None: | |||
|
910 | self.__timerange = timerange | |||
|
911 | ||||
|
912 | tmin = None | |||
|
913 | tmax = None | |||
|
914 | x = dataOut.getTimeRange() | |||
|
915 | y = dataOut.getHeiRange() | |||
|
916 | x1 = dataOut.datatime | |||
|
917 | # z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:]) | |||
|
918 | # avg = numpy.average(z, axis=1) | |||
|
919 | ||||
|
920 | noise = dataOut.getNoise() | |||
|
921 | ||||
|
922 | if not self.__isConfig: | |||
|
923 | ||||
|
924 | nplots = len(channelIndexList) | |||
|
925 | ||||
|
926 | self.setup(idfigure=idfigure, | |||
|
927 | nplots=nplots, | |||
|
928 | wintitle=wintitle, | |||
|
929 | showprofile=showprofile) | |||
|
930 | ||||
|
931 | tmin, tmax = self.__getTimeLim(x, xmin, xmax) | |||
|
932 | if ymin == None: ymin = numpy.nanmin(y) | |||
|
933 | if ymax == None: ymax = numpy.nanmax(y) | |||
|
934 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 | |||
|
935 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 | |||
|
936 | ||||
|
937 | self.__isConfig = True | |||
|
938 | ||||
|
939 | thisDatetime = dataOut.datatime | |||
|
940 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |||
|
941 | xlabel = "Velocity (m/s)" | |||
|
942 | ylabel = "Range (Km)" | |||
|
943 | ||||
|
944 | self.setWinTitle(title) | |||
|
945 | ||||
|
946 | for i in range(self.nplots): | |||
|
947 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |||
|
948 | axes = self.axesList[i*self.__nsubplots] | |||
|
949 | z = avg[i].reshape((1,-1)) | |||
|
950 | axes.pcolor(x, y, z, | |||
|
951 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |||
|
952 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |||
|
953 | ticksize=9, cblabel='', cbsize="1%") | |||
|
954 | ||||
|
955 | ||||
|
956 | self.draw() | |||
|
957 | ||||
|
958 | if save: | |||
|
959 | date = thisDatetime.strftime("%Y%m%d") | |||
|
960 | if figfile == None: | |||
|
961 | figfile = self.getFilename(name = date) | |||
|
962 | ||||
|
963 | self.saveFigure(figpath, figfile) | |||
|
964 | ||||
|
965 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |||
|
966 | self.__isConfig = False | |||
823 | No newline at end of file |
|
967 |
@@ -348,6 +348,22 class VoltageProc(ProcessingUnit): | |||||
348 | return 1 |
|
348 | return 1 | |
349 |
|
349 | |||
350 |
|
350 | |||
|
351 | def filterByHeights(self, window): | |||
|
352 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] | |||
|
353 | ||||
|
354 | if window == None: | |||
|
355 | window = self.dataOut.radarControllerHeaderObj.txA / deltaHeight | |||
|
356 | ||||
|
357 | newdelta = deltaHeight * window | |||
|
358 | r = self.dataOut.data.shape[1] % window | |||
|
359 | buffer = self.dataOut.data[:,0:self.dataOut.data.shape[1]-r] | |||
|
360 | buffer = buffer.reshape(self.dataOut.data.shape[0],self.dataOut.data.shape[1]/window,window) | |||
|
361 | buffer = numpy.average(buffer,2) | |||
|
362 | self.dataOut.data = buffer | |||
|
363 | self.dataOut.heightList = numpy.arange(self.dataOut.heightList[0],newdelta*self.dataOut.nHeights/window,newdelta) | |||
|
364 | ||||
|
365 | ||||
|
366 | ||||
351 | class CohInt(Operation): |
|
367 | class CohInt(Operation): | |
352 |
|
368 | |||
353 | __isConfig = False |
|
369 | __isConfig = False | |
@@ -544,6 +560,7 class CohInt(Operation): | |||||
544 | dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt |
|
560 | dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt | |
545 | dataOut.flagNoData = False |
|
561 | dataOut.flagNoData = False | |
546 |
|
562 | |||
|
563 | ||||
547 | class Decoder(Operation): |
|
564 | class Decoder(Operation): | |
548 |
|
565 | |||
549 | __isConfig = False |
|
566 | __isConfig = False | |
@@ -639,7 +656,6 class Decoder(Operation): | |||||
639 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip |
|
656 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip | |
640 |
|
657 | |||
641 |
|
658 | |||
642 |
|
||||
643 | class SpectraProc(ProcessingUnit): |
|
659 | class SpectraProc(ProcessingUnit): | |
644 |
|
660 | |||
645 | def __init__(self): |
|
661 | def __init__(self): | |
@@ -1072,3 +1088,63 class IncohInt(Operation): | |||||
1072 | dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt * dataOut.nIncohInt * dataOut.nFFTPoints |
|
1088 | dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt * dataOut.nIncohInt * dataOut.nFFTPoints | |
1073 | dataOut.flagNoData = False |
|
1089 | dataOut.flagNoData = False | |
1074 |
|
1090 | |||
|
1091 | class ProfileSelector(Operation): | |||
|
1092 | ||||
|
1093 | profileIndex = None | |||
|
1094 | # Tamanho total de los perfiles | |||
|
1095 | nProfiles = None | |||
|
1096 | ||||
|
1097 | def __init__(self): | |||
|
1098 | ||||
|
1099 | self.profileIndex = 0 | |||
|
1100 | ||||
|
1101 | def incIndex(self): | |||
|
1102 | self.profileIndex += 1 | |||
|
1103 | ||||
|
1104 | if self.profileIndex >= self.nProfiles: | |||
|
1105 | self.profileIndex = 0 | |||
|
1106 | ||||
|
1107 | def isProfileInRange(self, minIndex, maxIndex): | |||
|
1108 | ||||
|
1109 | if self.profileIndex < minIndex: | |||
|
1110 | return False | |||
|
1111 | ||||
|
1112 | if self.profileIndex > maxIndex: | |||
|
1113 | return False | |||
|
1114 | ||||
|
1115 | return True | |||
|
1116 | ||||
|
1117 | def isProfileInList(self, profileList): | |||
|
1118 | ||||
|
1119 | if self.profileIndex not in profileList: | |||
|
1120 | return False | |||
|
1121 | ||||
|
1122 | return True | |||
|
1123 | ||||
|
1124 | def run(self, dataOut, profileList=None, profileRangeList=None): | |||
|
1125 | ||||
|
1126 | self.nProfiles = dataOut.nProfiles | |||
|
1127 | ||||
|
1128 | if profileList != None: | |||
|
1129 | if not(self.isProfileInList(profileList)): | |||
|
1130 | dataOut.flagNoData = True | |||
|
1131 | else: | |||
|
1132 | dataOut.flagNoData = False | |||
|
1133 | self.incIndex() | |||
|
1134 | return 1 | |||
|
1135 | ||||
|
1136 | ||||
|
1137 | elif profileRangeList != None: | |||
|
1138 | minIndex = profileRangeList[0] | |||
|
1139 | maxIndex = profileRangeList[1] | |||
|
1140 | if not(self.isProfileInRange(minIndex, maxIndex)): | |||
|
1141 | dataOut.flagNoData = True | |||
|
1142 | else: | |||
|
1143 | dataOut.flagNoData = False | |||
|
1144 | self.incIndex() | |||
|
1145 | return 1 | |||
|
1146 | else: | |||
|
1147 | raise ValueError, "ProfileSelector needs profileList or profileRangeList" | |||
|
1148 | ||||
|
1149 | return 0 | |||
|
1150 |
General Comments 0
You need to be logged in to leave comments.
Login now