From 9aee9f7a8e3e89d2448bcdf6afa84e9093e632ae 2015-11-24 15:10:29 From: Miguel Valdez Date: 2015-11-24 15:10:29 Subject: [PATCH] Version 2.1.3: -Bug fixed reading Fits data -Metadata file for Fits is optional. --- diff --git a/schainpy/VERSION b/schainpy/VERSION index 34e1960..269abe4 100644 --- a/schainpy/VERSION +++ b/schainpy/VERSION @@ -5,4 +5,11 @@ VERSIONS: Server thread opens and closes remote server each time file list is sent -jroplot_spectra.py: Noise path was not being created saving noise data. -jroIO_base.py: startTime can be greater than endTime --jroplot_heispectra.py: SpectraHeisScope was not showing the right channel + +2.1.3: +-jroplot_heispectra.py: SpectraHeisScope was not showing the right channels +-jroproc_voltage.py: Bug fixed selecting profiles (self.nProfiles took a wrong value), + Bug fixed selecting heights by block (selecting profiles instead heights) +-jroproc_voltage.py: New feature added: decoding data by block using FFT. +-jroIO_heispectra.py: Bug fixed in FitsReader. Using local Fits object instead schainpy.mode.data.jrodata.Fits object. +-jroIO_heispectra.py: Channel index list does not exist. \ No newline at end of file diff --git a/schainpy/__init__.py b/schainpy/__init__.py index 5d95b94..a4fd748 100644 --- a/schainpy/__init__.py +++ b/schainpy/__init__.py @@ -4,4 +4,4 @@ Created on Feb 7, 2012 @author $Author$ @version $Id$ ''' -__version__ = "2.1.2" \ No newline at end of file +__version__ = "2.1.3" \ No newline at end of file diff --git a/schainpy/controller.py b/schainpy/controller.py index 93942f4..a57e837 100644 --- a/schainpy/controller.py +++ b/schainpy/controller.py @@ -2,8 +2,7 @@ Created on September , 2012 @author: ''' -from xml.etree.ElementTree import Element, SubElement -from xml.etree import ElementTree as ET +from xml.etree.ElementTree import ElementTree, Element, SubElement, tostring from xml.dom import minidom from model import * @@ -18,7 +17,7 @@ import ast def prettify(elem): """Return a pretty-printed XML string for the Element. """ - rough_string = ET.tostring(elem, 'utf-8') + rough_string = tostring(elem, 'utf-8') reparsed = minidom.parseString(rough_string) return reparsed.toprettyxml(indent=" ") diff --git a/schainpy/gui/viewcontroller/basicwindow.py b/schainpy/gui/viewcontroller/basicwindow.py index b26f434..5adffb4 100644 --- a/schainpy/gui/viewcontroller/basicwindow.py +++ b/schainpy/gui/viewcontroller/basicwindow.py @@ -2245,7 +2245,7 @@ class BasicWindow(QMainWindow, Ui_BasicWindow): return 0 # if something happened - parms_ok, output_path, blocksperfile, metada = self.checkInputsPUSave(datatype='SpectraHeis') + parms_ok, output_path, blocksperfile, metadata_file = self.checkInputsPUSave(datatype='SpectraHeis') if parms_ok: name_operation = 'FitsWriter' optype = 'other' @@ -2254,13 +2254,18 @@ class BasicWindow(QMainWindow, Ui_BasicWindow): name_parameter3 = 'metadatafile' value1 = output_path value2 = blocksperfile - value3 = metada + value3 = metadata_file format2 = "int" format3 = "str" opObj = puObj.addOperation(name=name_operation, optype=optype) + opObj.addParameter(name=name_parameter1, value=value1) - opObj.addParameter(name=name_parameter2, value=value2, format=format2) - opObj.addParameter(name=name_parameter3, value=value3, format=format3) + + if blocksperfile: + opObj.addParameter(name=name_parameter2, value=value2, format=format2) + + if metadata_file: + opObj.addParameter(name=name_parameter3, value=value3, format=format3) self.console.clear() try: @@ -3882,8 +3887,8 @@ class BasicWindow(QMainWindow, Ui_BasicWindow): self.specHeisOutputMetada.clear() else: value = opObj.getParameterValue(parameterName='metadatafile') - metada = str(value) - self.specHeisOutputMetada.setText(metada) + metadata_file = str(value) + self.specHeisOutputMetada.setText(metadata_file) return @@ -5178,21 +5183,17 @@ class BasicWindow(QMainWindow, Ui_BasicWindow): if datatype == "SpectraHeis": output_path = str(self.specHeisOutputPath.text()) blocksperfile = str(self.specHeisOutputblocksperfile.text()) - metada = str(self.specHeisOutputMetada.text()) + metadata_file = str(self.specHeisOutputMetada.text()) if output_path == '': outputstr = 'Outputpath is empty' self.console.append(outputstr) parms_ok = False - data_path = None - - if output_path != None: - if not os.path.exists(output_path): - outputstr = 'OutputPath:%s does not exists' % output_path - self.console.append(outputstr) - parms_ok = False - output_path = None + if not os.path.isdir(output_path): + outputstr = 'OutputPath:%s does not exists' % output_path + self.console.append(outputstr) + parms_ok = False try: profilesperblock = int(profilesperblock) @@ -5218,16 +5219,11 @@ class BasicWindow(QMainWindow, Ui_BasicWindow): blocksperfile = None if datatype == "SpectraHeis": - if metada == '': - outputstr = 'Choose metada file' - self.console.append(outputstr) - parms_ok = False - if metada != None: - if not os.path.isfile(metada): - outputstr = 'Metadata:%s does not exists' % metada + if metadata_file != '': + if not os.path.isfile(metadata_file): + outputstr = 'Metadata file %s does not exist' % metadata_file self.console.append(outputstr) parms_ok = False - output_path = None if datatype == "Voltage": return parms_ok, output_path, blocksperfile, profilesperblock @@ -5238,7 +5234,7 @@ class BasicWindow(QMainWindow, Ui_BasicWindow): if datatype == "SpectraHeis": - return parms_ok, output_path, blocksperfile, metada + return parms_ok, output_path, blocksperfile, metadata_file def findDatafiles(self, data_path, ext, walk, expLabel=''): diff --git a/schainpy/gui/viewer/windows/ui_spectra_heis.py b/schainpy/gui/viewer/windows/ui_spectra_heis.py index 4b72bfe..e82de7d 100644 --- a/schainpy/gui/viewer/windows/ui_spectra_heis.py +++ b/schainpy/gui/viewer/windows/ui_spectra_heis.py @@ -228,13 +228,13 @@ class Ui_SpectraHeisTab(object): self.tabWidgetSpectraHeis.setTabText(self.tabWidgetSpectraHeis.indexOf(self.tabgraphSpectraHeis), _translate("MainWindow", "Graphics", None)) self.label_67.setText(_translate("MainWindow", "Path:", None)) - self.label_68.setText(_translate("MainWindow", "Blocks per File:", None)) + self.label_68.setText(_translate("MainWindow", "Blocks per file:", None)) self.label_66.setText(_translate("MainWindow", "Type:", None)) self.tabWidgetSpectraHeis.setTabText(self.tabWidgetSpectraHeis.indexOf(self.taboutputSpectraHeis), _translate("MainWindow", "Output", None)) self.specHeisOutputToolPath.setText(_translate("MainWindow", "...", None)) self.specHeisOutputComdata.setItemText(0, _translate("MainWindow", ".fits", None)) - self.label_69.setText(_translate("MainWindow", "Metada", None)) + self.label_69.setText(_translate("MainWindow", "Metadata file:", None)) self.specHeisOutputMetadaToolPath.setText(_translate("MainWindow", "...", None)) self.tabWidgetProject.setTabText(self.tabWidgetProject.indexOf(self.tabSpectraHeis), _translate("MainWindow", "SpectraHeis", None)) diff --git a/schainpy/model/data/jrodata.py b/schainpy/model/data/jrodata.py index 214d63e..84fbbb9 100644 --- a/schainpy/model/data/jrodata.py +++ b/schainpy/model/data/jrodata.py @@ -833,10 +833,6 @@ class Fits(JROData): return heis - def isEmpty(self): - - return self.flagNoData - def getNHeights(self): return len(self.heightList) diff --git a/schainpy/model/io/__init__.py b/schainpy/model/io/__init__.py index 022a2f0..0787d39 100644 --- a/schainpy/model/io/__init__.py +++ b/schainpy/model/io/__init__.py @@ -8,11 +8,6 @@ from jroIO_voltage import * from jroIO_spectra import * from jroIO_heispectra import * from jroIO_usrp import * - -# try: -# from jroIO_usrp_api import * -# except: -# print "jroIO_usrp_api could not be imported" from jroIO_amisr import * from jroIO_HDF5 import * diff --git a/schainpy/model/io/jroIO_heispectra.py b/schainpy/model/io/jroIO_heispectra.py index 2a46c0c..c84d359 100644 --- a/schainpy/model/io/jroIO_heispectra.py +++ b/schainpy/model/io/jroIO_heispectra.py @@ -9,24 +9,20 @@ import time, datetime import numpy import fnmatch import glob - -try: - from gevent import sleep -except: - from time import sleep +from time import sleep try: import pyfits -except: - """ - """ +except ImportError, e: + print "Fits data cannot be used. Install pyfits module" from xml.etree.ElementTree import ElementTree from jroIO_base import isRadarFolder, isNumber +from schainpy.model.data.jrodata import Fits from schainpy.model.proc.jroproc_base import Operation, ProcessingUnit -class Fits: +class PyFits(object): name=None format=None array =None @@ -103,7 +99,7 @@ class ParameterConf: def getElementName(self): return self.ELEMENTNAME -class Metadata: +class Metadata(object): def __init__(self, filename): self.parmConfObjList = [] @@ -134,28 +130,23 @@ class FitsWriter(Operation): self.ext = '.fits' self.setFile = 0 - def setFitsHeader(self, dataOut, metadatafile): + def setFitsHeader(self, dataOut, metadatafile=None): header_data = pyfits.PrimaryHDU() - metadata4fits = Metadata(metadatafile) - for parameter in metadata4fits.parmConfObjList: - parm_name = parameter.name - parm_value = parameter.value + header_data.header['EXPNAME'] = "RADAR DATA" + header_data.header['DATATYPE'] = "SPECTRA" + header_data.header['COMMENT'] = "" + + if metadatafile: -# if parm_value == 'fromdatadatetime': -# value = time.strftime("%b %d %Y %H:%M:%S", dataOut.datatime.timetuple()) -# elif parm_value == 'fromdataheights': -# value = dataOut.nHeights -# elif parm_value == 'fromdatachannel': -# value = dataOut.nChannels -# elif parm_value == 'fromdatasamples': -# value = dataOut.nFFTPoints -# else: -# value = parm_value - - header_data.header[parm_name] = parm_value + metadata4fits = Metadata(metadatafile) + for parameter in metadata4fits.parmConfObjList: + parm_name = parameter.name + parm_value = parameter.value + + header_data.header[parm_name] = parm_value header_data.header['DATETIME'] = time.strftime("%b %d %Y %H:%M:%S", dataOut.datatime.timetuple()) header_data.header['CHANNELLIST'] = str(dataOut.channelList) @@ -174,7 +165,7 @@ class FitsWriter(Operation): self.addExtension(dataOut.heightList,'HEIGHTLIST') - def setup(self, dataOut, path, dataBlocksPerFile, metadatafile): + def setup(self, dataOut, path, dataBlocksPerFile=100, metadatafile=None): self.path = path self.dataOut = dataOut @@ -388,7 +379,7 @@ class FitsReader(ProcessingUnit): self.dataOut.header = self.header_dict self.dataOut.expName = self.expName - self.dataOut.nChannels = self.nChannels + self.dataOut.timeZone = self.timeZone self.dataOut.dataBlocksPerFile = self.dataBlocksPerFile self.dataOut.comments = self.comments @@ -399,6 +390,8 @@ class FitsReader(ProcessingUnit): self.dataOut.nCohInt = self.nCohInt self.dataOut.nIncohInt = self.nIncohInt + self.dataOut.ippSeconds = self.ippSeconds + def readHeader(self): headerObj = self.fitsObj[0] @@ -688,6 +681,9 @@ class FitsReader(ProcessingUnit): return 1 + def printInfo(self): + + pass def getData(self): @@ -702,7 +698,7 @@ class FitsReader(ProcessingUnit): if not(self.readNextBlock()): return 0 - if self.data == None: + if self.data is None: self.dataOut.flagNoData = True return 0 @@ -739,7 +735,7 @@ class SpectraHeisWriter(Operation): subfolder = None def __init__(self): - self.wrObj = Fits() + self.wrObj = PyFits() # self.dataOut = dataOut self.nTotalBlocks=0 # self.set = None diff --git a/schainpy/model/proc/jroproc_heispectra.py b/schainpy/model/proc/jroproc_heispectra.py index a00b59c..9411b7c 100644 --- a/schainpy/model/proc/jroproc_heispectra.py +++ b/schainpy/model/proc/jroproc_heispectra.py @@ -56,7 +56,7 @@ class SpectraHeisProc(ProcessingUnit): def __updateObjFromFits(self): self.dataOut.utctime = self.dataIn.utctime - self.dataOut.channelIndexList = self.dataIn.channelIndexList +# self.dataOut.channelIndexList = self.dataIn.channelIndexList self.dataOut.channelList = self.dataIn.channelList self.dataOut.heightList = self.dataIn.heightList