Ejemplo n.º 1
0
 def date(self):
     '''Returns the date in the first FIN file.'''
     if self._date is None:
         # User hasn't called 'element' yet; we need to parse it =(
         ff = fin.FIN(self._files()[0])
         self._date = ff.date()
     assert (self._date is not None)
     return self._date
Ejemplo n.º 2
0
 def run_filename(self):
     '''The "run filename" is the 3rd line of the FIN files.  For a single run
 (i.e. all the associated files in a FINDir), all the run filenames should
 be the same.'''
     if self._runfilename is None:
         ff = fin.FIN(self._files()[0])
         self._runfilename = ff.run_filename()
     return self._runfilename
Ejemplo n.º 3
0
    def element(self, element_name):
        '''Gets the full data for the given element, by parsing every FIN file in
      the directory.  This will take some time!'''
        data = []
        last_time = 0.0
        for f in self._files():
            ff = fin.FIN(f)
            ff.set_time_offset(last_time)

            # Cache some metadata clients sometimes want to query.
            if self._elements is None: self._elements = ff.elements()
            if self._runfilename is None: self._runfilename = ff.run_filename()
            if self._scan_time is None: self._scan_time = ff.time()

            # All the run filenames should be the same... else the user is mixing
            # data from different data sets.
            if validate() and self._runfilename != ff.run_filename():
                raise UserWarning(
                    "I saw a 'run filename' (3rd line of a FIN file) "
                    "of " + self._runfilename + ", but I'm looking at " + f +
                    " right now, and it has a run filename of " +
                    ff.run_filename() + ".  This probably means you "
                    "are mixing FIN files from logically separate "
                    "data sets.\n"
                    "You can set the environment variable "
                    "'BUB_NO_VALIDATE' to get around this, but you're "
                    "probably processing unassociated data together, "
                    "which does not make sense.")
            if validate() and not equalf(self._scan_time, ff.time()):
                raise UserWarning("Scan times are changing.")

            elem = ff.element(element_name)
            if element_name is "Time": last_time = max(elem)
            if self._points_per_file is None: self._points_per_file = len(elem)
            if validate() and self._points_per_file != len(elem):
                raise UserWarning("Points per file changing.")
            data.extend(elem)

        return data
Ejemplo n.º 4
0
 def _data_points_per_line(self):
     if self._points_per_file is None:
         ff = fin.FIN(self._files()[0])
         # we know "Time" will always exist.
         self._points_per_file = len(ff.element("Time"))
     return self._points_per_file
Ejemplo n.º 5
0
 def scanning_time_per_line(self):
     if self._scan_time is None:
         ff = fin.FIN(self._files()[0])
         self._scan_time = ff.time()
     return self._scan_time
Ejemplo n.º 6
0
 def elements(self):
     '''Returns the list of elements in this data set.'''
     if self._elements is None:
         ff = fin.FIN(self._files()[0])
         self._elements = ff.elements()
     return self._elements