Changeset 14102 for fact/tools/pyscripts


Ignore:
Timestamp:
06/07/12 11:03:02 (12 years ago)
Author:
neise
Message:
some more examples
File:
1 edited

Legend:

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

    r14100 r14102  
    6565
    6666
    67 4a. Create the needed *.so libs @ ISDC
     674. Create the needed *.so libs @ ISDC
    6868======================================
    6969
     
    8787  calfactfits_h.so  factfits_h.so  izstream_h.so
    8888
    89 4b. Create pyfits_h.so library
    90 =============================
     895. Test if everything is running
     90=================================
     91
     92Now you can check if the reading rawdata is working::
     93
     94  neise@isdc-viewer00:~/py/pyfact$ pyfact.py
     95  showing test of iterator of RawData class
     96  in order to test the SlowData classe please use: ./pyfact.py fits-file-name
     97  ev  1 data[0,0] =  -7.68806196438 start_cell[0] =  426 trigger type =  416
     98  ev  2 data[0,0] =  0.792280672486 start_cell[0] =  437 trigger type =  416
     99  ev  3 data[0,0] =  54.9490855517 start_cell[0] =  449 trigger type =  416
     100  ev  4 data[0,0] =  3.9482592671 start_cell[0] =  461 trigger type =  416
     101  ev  5 data[0,0] =  -66.4329317281 start_cell[0] =  474 trigger type =  416
     102  ev  6 data[0,0] =  8.2917625181 start_cell[0] =  485 trigger type =  416
     103  ev  7 data[0,0] =  -41.6565116079 start_cell[0] =  498 trigger type =  416
     104  ev  8 data[0,0] =  33.4668984163 start_cell[0] =  509 trigger type =  416
     105  ev  9 data[0,0] =  -28.520090549 start_cell[0] =  522 trigger type =  416
     106  ev  10 data[0,0] =  -20.4925692795 start_cell[0] =  533 trigger type =  416
     107
     108This should work at ISDC only, but if it does not work, please ask somebody for help.
     109
     1106. Tiny examples
     111===============
     112
     113one may interactively play with the two most important classes *RawData* and
     114*SlowData* from module pyfact...
     115
     116*datafilepath* and *calibfilepath* should be adjusted in case you are not working
     117on the ISDC cluster.
     118
     119explore class RawData::
     120
     121  from pyfact import RawData
     122  # or from pyfact import *
     123 
     124  datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'
     125  calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'
     126  run = RawData(datafilepath, calibfilepath)
     127  event = run.next()
     128 
     129  type(event)
     130 
     131  print 70*'*'
     132  for key in event:
     133    print 'key  :', key
     134    print 'value:', event[key]
     135    print 70*'*'
     136
     137for historical reasons, an event contains *data* and *acal_data*, where *acal_data*
     138would be the DRS amplitude calibrated data, and *data* would be uncalibrated.
     139But since the calibration was moved into a C++ class, for better performance,
     140these keys now contains the same data.
     141
     142loop over RawData::
     143
     144  from pyfact import RawData
     145  # or from pyfact import *
     146 
     147  datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'
     148  calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'
     149  run = RawData(datafilepath, calibfilepath)
     150
     151  for event in run:
     152    print 'event_id:', event['event_id']
     153    # the data can be found in event['data']
     154
     155have a look at some SlowData::
     156
     157  :~$ cd /fact/aux/2012/05/30
     158  :/fact/aux/2012/05/30$ python
     159 
     160  from pyfact import SlowData
     161  file = SlowData('20120530.FTM_CONTROL_TRIGGER_RATES.fits')
     162  file.show()
     163 
     164
     165have a look at the *columns*, that are available::
     166
     167  'columns': {'BoardRate': (40L, 4L, 'E', 'Hz'),
     168             'ElapsedTime': (1L, 4L, 'E', 'sec'),
     169             'FTMtimeStamp': (1L, 8L, 'K', 'us'),
     170             'OnTime': (1L, 4L, 'E', 'sec'),
     171             'OnTimeCounter': (1L, 8L, 'K', 'us'),
     172             'PatchRate': (160L, 4L, 'E', 'Hz'),
     173             'QoS': (1L, 4L, 'J', ''),
     174             'Time': (1L, 8L, 'D', 'MJD'),
     175             'TriggerCounter': (1L, 4L, 'J', 'int'),
     176             'TriggerRate': (1L, 4L, 'E', 'Hz')},
     177
     178choose the *columns* you would like to retrieve from the file::
     179
     180  file.register('TriggerRate')
     181  file.register('Time')
     182  # or in case you are unsure
     183  file.register('all')
     184
     185check, what happened. file has got some new members::
     186
     187  file.show()
     188
     189but they are all zero. Now one should call *next()* in order to get
     190the file contents row by row::
     191
     192  file.next()
     193  file.show()
     194
     195or loop over the file::
     196
     197  counter = 0
     198  for row in file::
     199    if counter > 10:
     200      break
     201   
     202    print row.Time, row. OnTime
     203    counter += 1
     204
     2057. Old way of creating the so files
     206===================================
    91207
    92208-----------This is a depricated section---------------
     
    160276    pyfits.h  pyfits_h.d  pyfits_h.so
    161277
    162 Now you can check if the reading rawdata is working::
    163 
    164   neise@isdc-viewer00:~/py/pyfact$ pyfact.py
    165   showing test of iterator of RawData class
    166   in order to test the SlowData classe please use: ./pyfact.py fits-file-name
    167   ev  1 data[0,0] =  -7.68806196438 start_cell[0] =  426 trigger type =  416
    168   ev  2 data[0,0] =  0.792280672486 start_cell[0] =  437 trigger type =  416
    169   ev  3 data[0,0] =  54.9490855517 start_cell[0] =  449 trigger type =  416
    170   ev  4 data[0,0] =  3.9482592671 start_cell[0] =  461 trigger type =  416
    171   ev  5 data[0,0] =  -66.4329317281 start_cell[0] =  474 trigger type =  416
    172   ev  6 data[0,0] =  8.2917625181 start_cell[0] =  485 trigger type =  416
    173   ev  7 data[0,0] =  -41.6565116079 start_cell[0] =  498 trigger type =  416
    174   ev  8 data[0,0] =  33.4668984163 start_cell[0] =  509 trigger type =  416
    175   ev  9 data[0,0] =  -28.520090549 start_cell[0] =  522 trigger type =  416
    176   ev  10 data[0,0] =  -20.4925692795 start_cell[0] =  533 trigger type =  416
    177 
    178 
    179 5. Run examples
    180 ===============
    181 
    182 one may interactively play with the two most important classes *RawData* and
    183 *SlowData* from module pyfact...
    184 
    185 *datafilepath* and *calibfilepath* should be adjusted in case you are not working
    186 on the ISDC cluster.
    187 
    188 explore class RawData::
    189 
    190   from pyfact import RawData
    191   # or from pyfact import *
    192  
    193   datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'
    194   calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'
    195   run = RawData(datafilepath, calibfilepath)
    196   event = run.next()
    197  
    198   type(event)
    199  
    200   print 70*'*'
    201   for key in event:
    202     print 'key  :', key
    203     print 'value:', event[key]
    204     print 70*'*'
    205 
    206 for historical reasons, an event contains *data* and *acal_data*, where *acal_data*
    207 would be the DRS amplitude calibrated data, and *data* would be uncalibrated.
    208 But since the calibration was moved into a C++ class, for better performance,
    209 these keys now contains the same data.
    210 
    211 loop over RawData::
    212 
    213   from pyfact import RawData
    214   # or from pyfact import *
    215  
    216   datafilepath = '/fact/raw/2012/03/04/20120304_018.fits.gz'
    217   calibfilepath = '/fact/raw/2012/03/04/20120304_012.drs.fits.gz'
    218   run = RawData(datafilepath, calibfilepath)
    219 
    220   for event in run:
    221     print 'event_id:', event['event_id']
    222     # the data can be found in event['data']
    223 
    224 have a look at some SlowData::
    225 
    226   :~$ cd /fact/aux/2012/05/30
    227   :/fact/aux/2012/05/30$ python
    228  
    229   from pyfact import SlowData
    230   file = SlowData('20120530.FTM_CONTROL_TRIGGER_RATES.fits')
    231   file.show()
    232  
    233 
    234 have a look at the *columns*, that are available::
    235 
    236   'columns': {'BoardRate': (40L, 4L, 'E', 'Hz'),
    237              'ElapsedTime': (1L, 4L, 'E', 'sec'),
    238              'FTMtimeStamp': (1L, 8L, 'K', 'us'),
    239              'OnTime': (1L, 4L, 'E', 'sec'),
    240              'OnTimeCounter': (1L, 8L, 'K', 'us'),
    241              'PatchRate': (160L, 4L, 'E', 'Hz'),
    242              'QoS': (1L, 4L, 'J', ''),
    243              'Time': (1L, 8L, 'D', 'MJD'),
    244              'TriggerCounter': (1L, 4L, 'J', 'int'),
    245              'TriggerRate': (1L, 4L, 'E', 'Hz')},
    246 
    247 choose the *columns* you would like to retrieve from the file::
    248 
    249   file.register('TriggerRate')
    250   file.register('Time')
    251   # or in case you are unsure
    252   file.register('all')
    253 
    254 check, what happened. file has got some new members::
    255 
    256   file.show()
    257 
    258 but they are all zero. Now one should call *next()* in order to get
    259 the file contents row by row::
    260 
    261   file.next()
    262   file.show()
    263 
    264 or loop over the file::
    265 
    266   counter = 0
    267   for row in file::
    268     if counter > 10:
    269       break
    270    
    271     print row.Time, row. OnTime
    272     counter += 1
    273 
    274278
    275279.. rubric:: Footnotes
Note: See TracChangeset for help on using the changeset viewer.