@@ -258,8 +258,8 class HDF5Reader(ProcessingUnit): | |||
|
258 | 258 | try: |
|
259 | 259 | fp = fp = h5py.File(filename,'r') |
|
260 | 260 | except IOError: |
|
261 | print "File %s can't be opened" %(filename) | |
|
262 | return None | |
|
261 | traceback.print_exc() | |
|
262 | raise IOError, "The file %s can't be opened" %(filename) | |
|
263 | 263 | |
|
264 | 264 | grp = fp['Data'] |
|
265 | 265 | timeAux = grp['time'] |
@@ -593,13 +593,14 class HDF5Writer(Operation): | |||
|
593 | 593 | |
|
594 | 594 | nDimsForDs = None |
|
595 | 595 | |
|
596 | currentDay = None | |
|
597 | ||
|
596 | 598 | def __init__(self): |
|
597 | 599 | |
|
598 | 600 | Operation.__init__(self) |
|
599 | 601 | self.isConfig = False |
|
600 | 602 | return |
|
601 | 603 | |
|
602 | ||
|
603 | 604 | def setup(self, dataOut, **kwargs): |
|
604 | 605 | |
|
605 | 606 | self.path = kwargs['path'] |
@@ -643,6 +644,10 class HDF5Writer(Operation): | |||
|
643 | 644 | if type(dataAux)==float or type(dataAux)==int: |
|
644 | 645 | arrayDim[i,0] = 1 |
|
645 | 646 | else: |
|
647 | ||
|
648 | if dataAux == None: | |
|
649 | return 0 | |
|
650 | ||
|
646 | 651 | arrayDim0 = dataAux.shape |
|
647 | 652 | arrayDim[i,0] = len(arrayDim0) |
|
648 | 653 | arrayDim[i,4] = mode[i] |
@@ -664,7 +669,9 class HDF5Writer(Operation): | |||
|
664 | 669 | self.tableDim = numpy.array(tableList, dtype = dtype0) |
|
665 | 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 | 676 | def putMetadata(self): |
|
670 | 677 | |
@@ -734,6 +741,17 class HDF5Writer(Operation): | |||
|
734 | 741 | grp.create_dataset(self.metadataList[i], data=getattr(self.dataOut, self.metadataList[i])) |
|
735 | 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 | 755 | def setNextFile(self): |
|
738 | 756 | |
|
739 | 757 | ext = self.ext |
@@ -761,7 +779,10 class HDF5Writer(Operation): | |||
|
761 | 779 | setFile = -1 |
|
762 | 780 | else: |
|
763 | 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 | 786 | setFile += 1 |
|
766 | 787 | |
|
767 | 788 | file = '%s%4.4d%3.3d%3.3d%s' % (self.optchar, |
@@ -774,8 +795,12 class HDF5Writer(Operation): | |||
|
774 | 795 | |
|
775 | 796 | #Setting HDF5 File |
|
776 | 797 | fp = h5py.File(filename,'w') |
|
798 | ||
|
799 | #writemetadata | |
|
800 | self.writeMetadata(fp) | |
|
801 | ||
|
777 | 802 | grp = fp.create_group("Data") |
|
778 | grp.attrs['metadata'] = self.metaFile | |
|
803 | # grp.attrs['metadata'] = self.metaFile | |
|
779 | 804 | |
|
780 | 805 | # grp.attrs['blocksPerFile'] = 0 |
|
781 | 806 | |
@@ -844,7 +869,7 class HDF5Writer(Operation): | |||
|
844 | 869 | if not self.firsttime: |
|
845 | 870 | self.readBlock() |
|
846 | 871 | |
|
847 | if self.blockIndex == self.blocksPerFile: | |
|
872 | if self.blockIndex == self.blocksPerFile or self.dateFlag(): | |
|
848 | 873 | |
|
849 | 874 | self.setNextFile() |
|
850 | 875 | |
@@ -898,7 +923,6 class HDF5Writer(Operation): | |||
|
898 | 923 | |
|
899 | 924 | return |
|
900 | 925 | |
|
901 | ||
|
902 | 926 | def setBlock(self): |
|
903 | 927 | ''' |
|
904 | 928 | data Array configured |
@@ -979,26 +1003,24 class HDF5Writer(Operation): | |||
|
979 | 1003 | else: |
|
980 | 1004 | self.ds[i].resize((self.ds[i].shape[0] + dataShape[0],self.ds[i].shape[1],self.ds[i].shape[2])) |
|
981 | 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 | 1007 | self.blockIndex += 1 |
|
992 | 1008 | self.firsttime = False |
|
993 | 1009 | return |
|
994 | 1010 | |
|
995 | 1011 | def run(self, dataOut, **kwargs): |
|
1012 | ||
|
996 | 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 | 1019 | self.isConfig = True |
|
999 | self.putMetadata() | |
|
1020 | # self.putMetadata() | |
|
1000 | 1021 | self.setNextFile() |
|
1001 | 1022 | |
|
1002 | 1023 | self.putData() |
|
1003 | 1024 | return |
|
1004 | 1025 | |
|
1026 |
General Comments 0
You need to be logged in to leave comments.
Login now