Ignore:
Timestamp:
06/08/12 15:31:39 (12 years ago)
Author:
neise
Message:
... working on the docu
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/doc/examples.rst

    r13151 r14119  
    22Examples
    33========
     4
     5
     6RawData
     7========
     8
     9one may interactively play with the two most important classes *RawData* and
     10*SlowData* from module pyfact...
     11
     12*datafilepath* and *calibfilepath* should be adjusted in case you are not working
     13on the ISDC cluster.
     14
     15explore class RawData::
     16
     17  from pyfact import RawData
     18  # or from pyfact import *
     19 
     20  datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'
     21  calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'
     22  run = RawData(datafilepath, calibfilepath)
     23  event = run.next()
     24 
     25  type(event)
     26 
     27  print 70*'*'
     28  for key in event:
     29    print 'key  :', key
     30    print 'value:', event[key]
     31    print 70*'*'
     32
     33for historical reasons, an event contains *data* and *acal_data*, where *acal_data*
     34would be the DRS amplitude calibrated data, and *data* would be uncalibrated.
     35But since the calibration was moved into a C++ class, for better performance,
     36these keys now contains the same data.
     37
     38loop over RawData::
     39
     40  from pyfact import RawData
     41  # or from pyfact import *
     42 
     43  datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'
     44  calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'
     45  run = RawData(datafilepath, calibfilepath)
     46
     47  for event in run:
     48    print 'event_id:', event['event_id']
     49    # the data can be found in event['data']
     50
     51SlowData
     52=========
     53
     54have a look at some SlowData::
     55
     56  :~$ cd /fact/aux/2012/05/30
     57  :/fact/aux/2012/05/30$ python
     58 
     59  from pyfact import SlowData
     60  file = SlowData('20120530.FTM_CONTROL_TRIGGER_RATES.fits')
     61  file.show()
     62 
     63
     64have a look at the *columns*, that are available::
     65
     66  'columns': {'BoardRate': (40L, 4L, 'E', 'Hz'),
     67             'ElapsedTime': (1L, 4L, 'E', 'sec'),
     68             'FTMtimeStamp': (1L, 8L, 'K', 'us'),
     69             'OnTime': (1L, 4L, 'E', 'sec'),
     70             'OnTimeCounter': (1L, 8L, 'K', 'us'),
     71             'PatchRate': (160L, 4L, 'E', 'Hz'),
     72             'QoS': (1L, 4L, 'J', ''),
     73             'Time': (1L, 8L, 'D', 'MJD'),
     74             'TriggerCounter': (1L, 4L, 'J', 'int'),
     75             'TriggerRate': (1L, 4L, 'E', 'Hz')},
     76
     77choose the *columns* you would like to retrieve from the file::
     78
     79  file.register('TriggerRate')
     80  file.register('Time')
     81  # or in case you are unsure
     82  file.register('all')
     83
     84check, what happened. file has got some new members::
     85
     86  file.show()
     87
     88but they are all zero. Now one should call *next()* in order to get
     89the file contents row by row::
     90
     91  file.next()
     92  file.show()
     93
     94or loop over the file::
     95
     96  for row in file:
     97    print row.Time, row. OnTime
     98
     99*row* is just be a copy of *file*, but inside the for loop, I think it is
     100convenient to access members of *row* rather than members of *file*.
     101I is just easier to understand for the reader, I think.
    4102
    5103calling a system command
     
    17115
    18116       
    19 
Note: See TracChangeset for help on using the changeset viewer.