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/getting_started.rst

    r14106 r14119  
    112112This should work at ISDC only, but if it does not work, please ask somebody for help.
    113113
    114 6. Tiny examples
    115 ===============
    116114
    117 one may interactively play with the two most important classes *RawData* and
    118 *SlowData* from module pyfact...
    119 
    120 *datafilepath* and *calibfilepath* should be adjusted in case you are not working
    121 on the ISDC cluster.
    122 
    123 explore class RawData::
    124 
    125   from pyfact import RawData
    126   # or from pyfact import *
    127  
    128   datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'
    129   calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'
    130   run = RawData(datafilepath, calibfilepath)
    131   event = run.next()
    132  
    133   type(event)
    134  
    135   print 70*'*'
    136   for key in event:
    137     print 'key  :', key
    138     print 'value:', event[key]
    139     print 70*'*'
    140 
    141 for historical reasons, an event contains *data* and *acal_data*, where *acal_data*
    142 would be the DRS amplitude calibrated data, and *data* would be uncalibrated.
    143 But since the calibration was moved into a C++ class, for better performance,
    144 these keys now contains the same data.
    145 
    146 loop over RawData::
    147 
    148   from pyfact import RawData
    149   # or from pyfact import *
    150  
    151   datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'
    152   calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'
    153   run = RawData(datafilepath, calibfilepath)
    154 
    155   for event in run:
    156     print 'event_id:', event['event_id']
    157     # the data can be found in event['data']
    158 
    159 have a look at some SlowData::
    160 
    161   :~$ cd /fact/aux/2012/05/30
    162   :/fact/aux/2012/05/30$ python
    163  
    164   from pyfact import SlowData
    165   file = SlowData('20120530.FTM_CONTROL_TRIGGER_RATES.fits')
    166   file.show()
    167  
    168 
    169 have a look at the *columns*, that are available::
    170 
    171   'columns': {'BoardRate': (40L, 4L, 'E', 'Hz'),
    172              'ElapsedTime': (1L, 4L, 'E', 'sec'),
    173              'FTMtimeStamp': (1L, 8L, 'K', 'us'),
    174              'OnTime': (1L, 4L, 'E', 'sec'),
    175              'OnTimeCounter': (1L, 8L, 'K', 'us'),
    176              'PatchRate': (160L, 4L, 'E', 'Hz'),
    177              'QoS': (1L, 4L, 'J', ''),
    178              'Time': (1L, 8L, 'D', 'MJD'),
    179              'TriggerCounter': (1L, 4L, 'J', 'int'),
    180              'TriggerRate': (1L, 4L, 'E', 'Hz')},
    181 
    182 choose the *columns* you would like to retrieve from the file::
    183 
    184   file.register('TriggerRate')
    185   file.register('Time')
    186   # or in case you are unsure
    187   file.register('all')
    188 
    189 check, what happened. file has got some new members::
    190 
    191   file.show()
    192 
    193 but they are all zero. Now one should call *next()* in order to get
    194 the file contents row by row::
    195 
    196   file.next()
    197   file.show()
    198 
    199 or loop over the file::
    200 
    201   for row in file:
    202     print row.Time, row. OnTime
    203 
    204 *row* is just be a copy of *file*, but inside the for loop, I think it is
    205 convenient to access members of *row* rather than members of *file*.
    206 I is just easier to understand for the reader, I think.
    207 
    208 7. Old way of creating the so files
     1156. Old way of creating the so files
    209116===================================
    210117
Note: See TracChangeset for help on using the changeset viewer.