##// END OF EJS Templates
-Bug fixed in HDF5 writing module...
Julio Valdez -
r724:fb11662812fb
parent child
Show More
@@ -258,8 +258,8 class HDF5Reader(ProcessingUnit):
258 try:
258 try:
259 fp = fp = h5py.File(filename,'r')
259 fp = fp = h5py.File(filename,'r')
260 except IOError:
260 except IOError:
261 print "File %s can't be opened" %(filename)
261 traceback.print_exc()
262 return None
262 raise IOError, "The file %s can't be opened" %(filename)
263
263
264 grp = fp['Data']
264 grp = fp['Data']
265 timeAux = grp['time']
265 timeAux = grp['time']
@@ -593,13 +593,14 class HDF5Writer(Operation):
593
593
594 nDimsForDs = None
594 nDimsForDs = None
595
595
596 currentDay = None
597
596 def __init__(self):
598 def __init__(self):
597
599
598 Operation.__init__(self)
600 Operation.__init__(self)
599 self.isConfig = False
601 self.isConfig = False
600 return
602 return
601
603
602
603 def setup(self, dataOut, **kwargs):
604 def setup(self, dataOut, **kwargs):
604
605
605 self.path = kwargs['path']
606 self.path = kwargs['path']
@@ -643,6 +644,10 class HDF5Writer(Operation):
643 if type(dataAux)==float or type(dataAux)==int:
644 if type(dataAux)==float or type(dataAux)==int:
644 arrayDim[i,0] = 1
645 arrayDim[i,0] = 1
645 else:
646 else:
647
648 if dataAux == None:
649 return 0
650
646 arrayDim0 = dataAux.shape
651 arrayDim0 = dataAux.shape
647 arrayDim[i,0] = len(arrayDim0)
652 arrayDim[i,0] = len(arrayDim0)
648 arrayDim[i,4] = mode[i]
653 arrayDim[i,4] = mode[i]
@@ -664,7 +669,9 class HDF5Writer(Operation):
664 self.tableDim = numpy.array(tableList, dtype = dtype0)
669 self.tableDim = numpy.array(tableList, dtype = dtype0)
665 self.blockIndex = 0
670 self.blockIndex = 0
666
671
667 return
672 timeTuple = time.localtime(dataOut.utctime)
673 self.currentDay = timeTuple.tm_yday
674 return 1
668
675
669 def putMetadata(self):
676 def putMetadata(self):
670
677
@@ -734,6 +741,17 class HDF5Writer(Operation):
734 grp.create_dataset(self.metadataList[i], data=getattr(self.dataOut, self.metadataList[i]))
741 grp.create_dataset(self.metadataList[i], data=getattr(self.dataOut, self.metadataList[i]))
735 return
742 return
736
743
744 def dateFlag(self):
745
746 timeTuple = time.localtime(self.dataOut.utctime)
747 dataDay = timeTuple.tm_yday
748
749 if dataDay == self.currentDay:
750 return False
751
752 self.currentDay = dataDay
753 return True
754
737 def setNextFile(self):
755 def setNextFile(self):
738
756
739 ext = self.ext
757 ext = self.ext
@@ -761,7 +779,10 class HDF5Writer(Operation):
761 setFile = -1
779 setFile = -1
762 else:
780 else:
763 setFile = -1 #inicializo mi contador de seteo
781 setFile = -1 #inicializo mi contador de seteo
764
782 else:
783 os.mkdir(fullpath)
784 setFile = -1 #inicializo mi contador de seteo
785
765 setFile += 1
786 setFile += 1
766
787
767 file = '%s%4.4d%3.3d%3.3d%s' % (self.optchar,
788 file = '%s%4.4d%3.3d%3.3d%s' % (self.optchar,
@@ -774,8 +795,12 class HDF5Writer(Operation):
774
795
775 #Setting HDF5 File
796 #Setting HDF5 File
776 fp = h5py.File(filename,'w')
797 fp = h5py.File(filename,'w')
798
799 #writemetadata
800 self.writeMetadata(fp)
801
777 grp = fp.create_group("Data")
802 grp = fp.create_group("Data")
778 grp.attrs['metadata'] = self.metaFile
803 # grp.attrs['metadata'] = self.metaFile
779
804
780 # grp.attrs['blocksPerFile'] = 0
805 # grp.attrs['blocksPerFile'] = 0
781
806
@@ -844,7 +869,7 class HDF5Writer(Operation):
844 if not self.firsttime:
869 if not self.firsttime:
845 self.readBlock()
870 self.readBlock()
846
871
847 if self.blockIndex == self.blocksPerFile:
872 if self.blockIndex == self.blocksPerFile or self.dateFlag():
848
873
849 self.setNextFile()
874 self.setNextFile()
850
875
@@ -898,7 +923,6 class HDF5Writer(Operation):
898
923
899 return
924 return
900
925
901
902 def setBlock(self):
926 def setBlock(self):
903 '''
927 '''
904 data Array configured
928 data Array configured
@@ -979,26 +1003,24 class HDF5Writer(Operation):
979 else:
1003 else:
980 self.ds[i].resize((self.ds[i].shape[0] + dataShape[0],self.ds[i].shape[1],self.ds[i].shape[2]))
1004 self.ds[i].resize((self.ds[i].shape[0] + dataShape[0],self.ds[i].shape[1],self.ds[i].shape[2]))
981 self.ds[i][dsShape[0]:,:,0] = self.data[i]
1005 self.ds[i][dsShape[0]:,:,0] = self.data[i]
982 # self.ds[i].append(self.data[i])
983 # self.fp.flush()
984 # if not self.firsttime:
985 # self.fp.root.Data._v_attrs.nRecords = self.blockIndex
986
987 # if self.firsttime:
988 # self.fp.close()
989 # self.readBlock2()
990
1006
991 self.blockIndex += 1
1007 self.blockIndex += 1
992 self.firsttime = False
1008 self.firsttime = False
993 return
1009 return
994
1010
995 def run(self, dataOut, **kwargs):
1011 def run(self, dataOut, **kwargs):
1012
996 if not(self.isConfig):
1013 if not(self.isConfig):
997 self.setup(dataOut, **kwargs)
1014 flagdata = self.setup(dataOut, **kwargs)
1015
1016 if not(flagdata):
1017 return
1018
998 self.isConfig = True
1019 self.isConfig = True
999 self.putMetadata()
1020 # self.putMetadata()
1000 self.setNextFile()
1021 self.setNextFile()
1001
1022
1002 self.putData()
1023 self.putData()
1003 return
1024 return
1004
1025
1026
General Comments 0
You need to be logged in to leave comments. Login now