Ignore:
Timestamp:
09/26/14 09:30:50 (10 years ago)
Author:
dneise
Message:
more pythonic way of getting the number of events
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/new_pyfact/pyfact.py

    r17973 r17975  
    8282        self._setup_columns()
    8383
     84    def __len__(self):
     85        """ return the number of events, in case it's a FACT physics data file
     86        or simply the number of rows in case it's a slow data (so called aux) file.
     87        """
     88        return self.f.GetNumRows()
     89
    8490    def _make_header(self):
    8591        """
     
    136142        self._cols = {}
    137143        self.cols = {}
    138         N = self.header['NAXIS2']
     144       
     145        N = len(self)
    139146        for key,col in self.f.GetColumns():
    140147            self._cols[key] = np.zeros(col.num, col_type_to_np_type_map[col.type])
     
    151158                    step = 10
    152159                if i % step == 0:
    153                     print "reading line", i
     160                    print "reading line", i, 'of', self.header['NAXIS2']
    154161
    155162            for key in self._cols:
     
    226233    f = RawData(sys.argv[1], sys.argv[2])
    227234
    228     print "number of events:", f.header['NAXIS2']
     235    print "number of events:", len(f)
    229236    print "date of observation:", f.header['DATE']
    230237    print "The files has these cols:", f.cols.keys()
Note: See TracChangeset for help on using the changeset viewer.