@@ -577,22 +577,77 class SpectraHeis(JROData): | |||
|
577 | 577 | |
|
578 | 578 | class Fits: |
|
579 | 579 | |
|
580 | heightList = None | |
|
581 | ||
|
582 | channelList = None | |
|
583 | ||
|
584 | flagNoData = True | |
|
585 | ||
|
586 | flagTimeBlock = False | |
|
587 | ||
|
588 | useLocalTime = False | |
|
589 | ||
|
590 | utctime = None | |
|
591 | ||
|
592 | timeZone = None | |
|
593 | ||
|
594 | ippSeconds = None | |
|
595 | ||
|
596 | timeInterval = None | |
|
597 | ||
|
598 | nCohInt = None | |
|
599 | ||
|
600 | nIncohInt = None | |
|
601 | ||
|
602 | noise = None | |
|
603 | ||
|
604 | windowOfFilter = 1 | |
|
605 | ||
|
606 | #Speed of ligth | |
|
607 | C = 3e8 | |
|
608 | ||
|
609 | frequency = 49.92e6 | |
|
610 | ||
|
611 | realtime = False | |
|
612 | ||
|
613 | ||
|
580 | 614 | def __init__(self): |
|
581 | self.useLocalTime = False | |
|
615 | ||
|
616 | self.type = "Fits" | |
|
617 | ||
|
618 | self.nProfiles = None | |
|
619 | ||
|
620 | self.heightList = None | |
|
621 | ||
|
622 | self.channelList = None | |
|
623 | ||
|
624 | # self.channelIndexList = None | |
|
625 | ||
|
626 | self.flagNoData = True | |
|
627 | ||
|
582 | 628 | self.utctime = None |
|
583 | self.timeZone = None | |
|
584 |
self. |
|
|
585 | self.timeInterval = None | |
|
586 |
self. |
|
|
587 | self.data_header = None | |
|
588 |
self. |
|
|
589 | self.datatime = None | |
|
590 |
self. |
|
|
591 |
self. |
|
|
592 |
self. |
|
|
593 |
self. |
|
|
594 |
self. |
|
|
595 | self.comments = '' | |
|
629 | ||
|
630 | self.nCohInt = None | |
|
631 | ||
|
632 | self.nIncohInt = None | |
|
633 | ||
|
634 | self.useLocalTime = True | |
|
635 | ||
|
636 | # self.utctime = None | |
|
637 | # self.timeZone = None | |
|
638 | # self.ltctime = None | |
|
639 | # self.timeInterval = None | |
|
640 | # self.header = None | |
|
641 | # self.data_header = None | |
|
642 | # self.data = None | |
|
643 | # self.datatime = None | |
|
644 | # self.flagNoData = False | |
|
645 | # self.expName = '' | |
|
646 | # self.nChannels = None | |
|
647 | # self.nSamples = None | |
|
648 | # self.dataBlocksPerFile = None | |
|
649 | # self.comments = '' | |
|
650 | # | |
|
596 | 651 | |
|
597 | 652 | |
|
598 | 653 | def getltctime(self): |
@@ -618,9 +673,49 class Fits: | |||
|
618 | 673 | |
|
619 | 674 | return datatime |
|
620 | 675 | |
|
676 | def getHeiRange(self): | |
|
677 | ||
|
678 | heis = self.heightList | |
|
679 | ||
|
680 | return heis | |
|
681 | ||
|
621 | 682 | def isEmpty(self): |
|
622 | 683 | |
|
623 | 684 | return self.flagNoData |
|
624 | 685 | |
|
686 | def getNHeights(self): | |
|
687 | ||
|
688 | return len(self.heightList) | |
|
689 | ||
|
690 | def getNChannels(self): | |
|
691 | ||
|
692 | return len(self.channelList) | |
|
693 | ||
|
694 | def getChannelIndexList(self): | |
|
695 | ||
|
696 | return range(self.nChannels) | |
|
697 | ||
|
698 | def getNoise(self, type = 1): | |
|
699 | ||
|
700 | self.noise = numpy.zeros(self.nChannels) | |
|
701 | ||
|
702 | if type == 1: | |
|
703 | noise = self.getNoisebyHildebrand() | |
|
704 | ||
|
705 | if type == 2: | |
|
706 | noise = self.getNoisebySort() | |
|
707 | ||
|
708 | if type == 3: | |
|
709 | noise = self.getNoisebyWindow() | |
|
710 | ||
|
711 | return noise | |
|
712 | ||
|
625 | 713 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
714 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
|
715 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
|
716 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") | |
|
717 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
|
718 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
|
719 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
|
720 | ||
|
626 | 721 | ltctime = property(getltctime, "I'm the 'ltctime' property") No newline at end of file |
@@ -2883,23 +2883,36 class FitsWriter(Operation): | |||
|
2883 | 2883 | parm_name = parameter.name |
|
2884 | 2884 | parm_value = parameter.value |
|
2885 | 2885 | |
|
2886 | if parm_value == 'fromdatadatetime': | |
|
2887 | value = time.strftime("%b %d %Y %H:%M:%S", dataOut.datatime.timetuple()) | |
|
2888 | elif parm_value == 'fromdataheights': | |
|
2889 | value = dataOut.nHeights | |
|
2890 | elif parm_value == 'fromdatachannel': | |
|
2891 | value = dataOut.nChannels | |
|
2892 | elif parm_value == 'fromdatasamples': | |
|
2893 | value = dataOut.nFFTPoints | |
|
2894 | else: | |
|
2895 | value = parm_value | |
|
2886 | # if parm_value == 'fromdatadatetime': | |
|
2887 | # value = time.strftime("%b %d %Y %H:%M:%S", dataOut.datatime.timetuple()) | |
|
2888 | # elif parm_value == 'fromdataheights': | |
|
2889 | # value = dataOut.nHeights | |
|
2890 | # elif parm_value == 'fromdatachannel': | |
|
2891 | # value = dataOut.nChannels | |
|
2892 | # elif parm_value == 'fromdatasamples': | |
|
2893 | # value = dataOut.nFFTPoints | |
|
2894 | # else: | |
|
2895 | # value = parm_value | |
|
2896 | 2896 | |
|
2897 | header_data.header[parm_name] = value | |
|
2897 | header_data.header[parm_name] = parm_value | |
|
2898 | 2898 | |
|
2899 | ||
|
2900 | header_data.header['DATETIME'] = time.strftime("%b %d %Y %H:%M:%S", dataOut.datatime.timetuple()) | |
|
2901 | header_data.header['CHANNELLIST'] = str(dataOut.channelList) | |
|
2902 | header_data.header['NCHANNELS'] = dataOut.nChannels | |
|
2903 | #header_data.header['HEIGHTS'] = dataOut.heightList | |
|
2904 | header_data.header['NHEIGHTS'] = dataOut.nHeights | |
|
2905 | ||
|
2906 | header_data.header['IPPSECONDS'] = dataOut.ippSeconds | |
|
2907 | header_data.header['NCOHINT'] = dataOut.nCohInt | |
|
2908 | header_data.header['NINCOHINT'] = dataOut.nIncohInt | |
|
2909 | header_data.header['TIMEZONE'] = dataOut.timeZone | |
|
2899 | 2910 | header_data.header['NBLOCK'] = self.blockIndex |
|
2900 | 2911 | |
|
2901 | 2912 | header_data.writeto(self.filename) |
|
2902 | 2913 | |
|
2914 | self.addExtension(dataOut.heightList,'HEIGHTLIST') | |
|
2915 | ||
|
2903 | 2916 | |
|
2904 | 2917 | def setup(self, dataOut, path, dataBlocksPerFile, metadatafile): |
|
2905 | 2918 | |
@@ -2912,9 +2925,16 class FitsWriter(Operation): | |||
|
2912 | 2925 | self.fitsObj = pyfits.open(self.filename, mode='update') |
|
2913 | 2926 | |
|
2914 | 2927 | |
|
2928 | def addExtension(self, data, tagname): | |
|
2929 | self.open() | |
|
2930 | extension = pyfits.ImageHDU(data=data, name=tagname) | |
|
2931 | #extension.header['TAG'] = tagname | |
|
2932 | self.fitsObj.append(extension) | |
|
2933 | self.write() | |
|
2934 | ||
|
2915 | 2935 | def addData(self, data): |
|
2916 | 2936 | self.open() |
|
2917 | extension = pyfits.ImageHDU(data=data, name=self.fitsObj[0].header['DATA']) | |
|
2937 | extension = pyfits.ImageHDU(data=data, name=self.fitsObj[0].header['DATATYPE']) | |
|
2918 | 2938 | extension.header['UTCTIME'] = self.dataOut.utctime |
|
2919 | 2939 | self.fitsObj.append(extension) |
|
2920 | 2940 | self.blockIndex += 1 |
@@ -3013,7 +3033,7 class FitsWriter(Operation): | |||
|
3013 | 3033 | |
|
3014 | 3034 | class FitsReader(ProcessingUnit): |
|
3015 | 3035 | |
|
3016 | __TIMEZONE = time.timezone | |
|
3036 | # __TIMEZONE = time.timezone | |
|
3017 | 3037 | |
|
3018 | 3038 | expName = None |
|
3019 | 3039 | datetimestr = None |
@@ -3038,6 +3058,7 class FitsReader(ProcessingUnit): | |||
|
3038 | 3058 | self.filename = None |
|
3039 | 3059 | self.fileSize = None |
|
3040 | 3060 | self.fitsObj = None |
|
3061 | self.timeZone = None | |
|
3041 | 3062 | self.nReadBlocks = 0 |
|
3042 | 3063 | self.nTotalBlocks = 0 |
|
3043 | 3064 | self.dataOut = self.createObjByDefault() |
@@ -3098,7 +3119,7 class FitsReader(ProcessingUnit): | |||
|
3098 | 3119 | self.filename = filename |
|
3099 | 3120 | self.fileSize = fileSize |
|
3100 | 3121 | self.fitsObj = fitsObj |
|
3101 | ||
|
3122 | self.blockIndex = 0 | |
|
3102 | 3123 | print "Setting the file: %s"%self.filename |
|
3103 | 3124 | |
|
3104 | 3125 | return 1 |
@@ -3107,15 +3128,39 class FitsReader(ProcessingUnit): | |||
|
3107 | 3128 | headerObj = self.fitsObj[0] |
|
3108 | 3129 | |
|
3109 | 3130 | self.header_dict = headerObj.header |
|
3110 | self.expName = headerObj.header['EXPNAME'] | |
|
3131 | if 'EXPNAME' in headerObj.header.keys(): | |
|
3132 | self.expName = headerObj.header['EXPNAME'] | |
|
3133 | ||
|
3134 | if 'DATATYPE' in headerObj.header.keys(): | |
|
3135 | self.dataType = headerObj.header['DATATYPE'] | |
|
3136 | ||
|
3111 | 3137 | self.datetimestr = headerObj.header['DATETIME'] |
|
3112 | struct_time = time.strptime(headerObj.header['DATETIME'], "%b %d %Y %H:%M:%S") | |
|
3113 | # self.utc = time.mktime(struct_time) - self.__TIMEZONE | |
|
3114 |
self.n |
|
|
3115 |
self. |
|
|
3138 | self.channelList = headerObj.header['CHANNELLIST'] | |
|
3139 | self.nChannels = headerObj.header['NCHANNELS'] | |
|
3140 | self.nHeights = headerObj.header['NHEIGHTS'] | |
|
3141 | self.ippSeconds = headerObj.header['IPPSECONDS'] | |
|
3142 | self.nCohInt = headerObj.header['NCOHINT'] | |
|
3143 | self.nIncohInt = headerObj.header['NINCOHINT'] | |
|
3116 | 3144 | self.dataBlocksPerFile = headerObj.header['NBLOCK'] |
|
3117 |
self. |
|
|
3145 | self.timeZone = headerObj.header['TIMEZONE'] | |
|
3146 | ||
|
3147 | self.timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt | |
|
3148 | ||
|
3149 | if 'COMMENT' in headerObj.header.keys(): | |
|
3150 | self.comments = headerObj.header['COMMENT'] | |
|
3118 | 3151 | |
|
3152 | self.readHeightList() | |
|
3153 | ||
|
3154 | def readHeightList(self): | |
|
3155 | self.blockIndex = self.blockIndex + 1 | |
|
3156 | obj = self.fitsObj[self.blockIndex] | |
|
3157 | self.heightList = obj.data | |
|
3158 | self.blockIndex = self.blockIndex + 1 | |
|
3159 | ||
|
3160 | def readExtension(self): | |
|
3161 | obj = self.fitsObj[self.blockIndex] | |
|
3162 | self.heightList = obj.data | |
|
3163 | self.blockIndex = self.blockIndex + 1 | |
|
3119 | 3164 | |
|
3120 | 3165 | def setNextFile(self): |
|
3121 | 3166 | |
@@ -3130,7 +3175,7 class FitsReader(ProcessingUnit): | |||
|
3130 | 3175 | self.readHeader() |
|
3131 | 3176 | |
|
3132 | 3177 | self.nReadBlocks = 0 |
|
3133 | self.blockIndex = 1 | |
|
3178 | # self.blockIndex = 1 | |
|
3134 | 3179 | return 1 |
|
3135 | 3180 | |
|
3136 | 3181 | def __searchFilesOffLine(self, |
@@ -3298,7 +3343,7 class FitsReader(ProcessingUnit): | |||
|
3298 | 3343 | if not self.online: |
|
3299 | 3344 | return 0 |
|
3300 | 3345 | |
|
3301 |
if (self.nReadBlocks >= self. |
|
|
3346 | if (self.nReadBlocks >= self.dataBlocksPerFile): | |
|
3302 | 3347 | return 0 |
|
3303 | 3348 | |
|
3304 | 3349 | currentPointer = self.fp.tell() |
@@ -3388,10 +3433,12 class FitsReader(ProcessingUnit): | |||
|
3388 | 3433 | self.dataOut.header = self.header_dict |
|
3389 | 3434 | self.dataOut.expName = self.expName |
|
3390 | 3435 | self.dataOut.nChannels = self.nChannels |
|
3391 |
self.dataOut. |
|
|
3436 | self.dataOut.timeZone = self.timeZone | |
|
3392 | 3437 | self.dataOut.dataBlocksPerFile = self.dataBlocksPerFile |
|
3393 | 3438 | self.dataOut.comments = self.comments |
|
3394 | ||
|
3439 | self.dataOut.timeInterval = self.timeInterval | |
|
3440 | self.dataOut.channelList = self.channelList | |
|
3441 | self.dataOut.heightList = self.heightList | |
|
3395 | 3442 | self.dataOut.flagNoData = False |
|
3396 | 3443 | |
|
3397 | 3444 | return self.dataOut.data |
@@ -1487,9 +1487,9 class RTIfromSpectraHeis(Figure): | |||
|
1487 | 1487 | |
|
1488 | 1488 | |
|
1489 | 1489 | # title = "RTI %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1490 |
title = "RTI |
|
|
1490 | title = "RTI - %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
|
1491 | 1491 | |
|
1492 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] | |
|
1492 | legendlabels = ["channel %d"%idchannel for idchannel in channelIndexList] | |
|
1493 | 1493 | axes = self.axesList[0] |
|
1494 | 1494 | |
|
1495 | 1495 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
@@ -1430,6 +1430,19 class SpectraHeisProc(ProcessingUnit): | |||
|
1430 | 1430 | # self.dataOut.deltaHeight=self.dataIn.deltaHeight |
|
1431 | 1431 | |
|
1432 | 1432 | |
|
1433 | def __updateObjFromFits(self): | |
|
1434 | self.dataOut.utctime = self.dataIn.utctime | |
|
1435 | self.dataOut.channelIndexList = self.dataIn.channelIndexList | |
|
1436 | ||
|
1437 | self.dataOut.channelList = self.dataIn.channelList | |
|
1438 | self.dataOut.heightList = self.dataIn.heightList | |
|
1439 | self.dataOut.data_spc = self.dataIn.data | |
|
1440 | self.dataOut.timeInterval = self.dataIn.timeInterval | |
|
1441 | self.dataOut.timeZone = self.dataIn.timeZone | |
|
1442 | self.dataOut.useLocalTime = True | |
|
1443 | # self.dataOut. | |
|
1444 | # self.dataOut. | |
|
1445 | ||
|
1433 | 1446 | def __getFft(self): |
|
1434 | 1447 | |
|
1435 | 1448 | fft_volt = numpy.fft.fft(self.dataIn.data, axis=1) |
@@ -1441,6 +1454,11 class SpectraHeisProc(ProcessingUnit): | |||
|
1441 | 1454 | |
|
1442 | 1455 | self.dataOut.flagNoData = True |
|
1443 | 1456 | |
|
1457 | if self.dataIn.type == "Fits": | |
|
1458 | self.__updateObjFromFits() | |
|
1459 | self.dataOut.flagNoData = False | |
|
1460 | return | |
|
1461 | ||
|
1444 | 1462 | if self.dataIn.type == "SpectraHeis": |
|
1445 | 1463 | self.dataOut.copy(self.dataIn) |
|
1446 | 1464 | return |
General Comments 0
You need to be logged in to leave comments.
Login now