1 | ===============
|
---|
2 | Getting Started
|
---|
3 | ===============
|
---|
4 |
|
---|
5 | 1) Get an account at the FACT data center at ISDC
|
---|
6 | 2) Setup your environment variables
|
---|
7 | 3) Checkout the pyfact software repository
|
---|
8 | 4) Try a few examples
|
---|
9 |
|
---|
10 | 1. Important links
|
---|
11 | =================================
|
---|
12 |
|
---|
13 | **FACT data center at ISDC** <http://www.isdc.unige.ch/fact/datacenter>**
|
---|
14 | here you find instructions how to get an account, how to set it up and how to use it
|
---|
15 |
|
---|
16 | **SVN repository** <https://fact.isdc.unige.ch/svn/fact/>
|
---|
17 | hosts all FACT software (including pyfact)
|
---|
18 |
|
---|
19 | **FACT run database** <https://www.fact-project.org/run_db/db/fact_runinfo.php>
|
---|
20 | here you find information about all available runs
|
---|
21 |
|
---|
22 | **eLogbook** <https://www.fact-project.org/logbook/>
|
---|
23 | telescope logbook used since Dec. 1, 2012; for logbook information before this date have a look here: <http://fact.ethz.ch/FACTelog/index.jsp>
|
---|
24 |
|
---|
25 | **FACT La Palma pages** <https://www.fact-project.org/>
|
---|
26 | plenty of information concerning the telescope in La Palma
|
---|
27 |
|
---|
28 | 2. Environment variables
|
---|
29 | ========================
|
---|
30 | set the following env variables depending on the SHELL you are using, for instance in .bashrc or .tcshrc
|
---|
31 |
|
---|
32 |
|
---|
33 | * **ROOTSYS**: /swdev_nfs/root_v5.28.00
|
---|
34 | * **PATH**: add $ROOTSYS/bin
|
---|
35 | * **LD_LIBRARY_PATH**: add $ROOTSYS/lib
|
---|
36 | * **PYTHONPATH**: $ROOTSYS/lib
|
---|
37 | * **PYTHONPATH**: add all directories where python should search for modules. At least:
|
---|
38 | * pyscripts/pyfact
|
---|
39 | * **LD_LIBRARY_PATH**: add the path to pyfits_h.so
|
---|
40 | * pyscripts/pyfact in many cases
|
---|
41 |
|
---|
42 | the absolute path depends on where you have checked (or will check) out the pyscripts repository
|
---|
43 |
|
---|
44 | example .bashrc::
|
---|
45 |
|
---|
46 | # this is just a convenient shortcut
|
---|
47 | export MY_PYFACT=/home_nfs/isdc/neise/py/pyscripts/pyfact
|
---|
48 |
|
---|
49 | # this is needed for ROOT only
|
---|
50 | export ROOTSYS=/swdev_nfs/root_v5.28.00
|
---|
51 | export PATH=$ROOTSYS/bin:$PATH
|
---|
52 | export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH
|
---|
53 |
|
---|
54 | # this is needed for Python to find the pyfact classes and PyROOT
|
---|
55 | export PYTHONPATH=$MY_PYFACT
|
---|
56 | export PYTHONPATH=$ROOTSYS/lib:$PYTHONPATH
|
---|
57 |
|
---|
58 | #this is one of many possible ways, for ROOT to find pyfits_h.so
|
---|
59 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MY_PYFACT
|
---|
60 |
|
---|
61 |
|
---|
62 | 3. Check out the repository
|
---|
63 | ===========================
|
---|
64 | svn co https://fact.isdc.unige.ch/svn/fact/tools/pyscripts py
|
---|
65 |
|
---|
66 |
|
---|
67 | 4a. Create the needed *.so libs @ ISDC
|
---|
68 | ======================================
|
---|
69 |
|
---|
70 | FACT data are stored in (gzipped) fits files, but the data files are too large to be read by the existing tools:
|
---|
71 |
|
---|
72 | `pyfits <http://www.stsci.edu/institute/software_hardware/pyfits>` which uses `cfitsio <http://heasarc.gsfc.nasa.gov/fitsio/>`_.
|
---|
73 |
|
---|
74 | To mitigate this problem a C++ class defined in fits.h [#f1]_ is used. A simple possibility to create an interface of this C++ class is to use ROOT and later to import it using the
|
---|
75 | `pyroot <http://root.cern.ch/drupal/category/package-context/pyroot>`_ module.
|
---|
76 |
|
---|
77 | example::
|
---|
78 | neise@isdc-viewer00:~/py/pyfact$ root -l -q makelibs.C
|
---|
79 | root [0]
|
---|
80 | Processing makelibs.C...
|
---|
81 | Info in <TUnixSystem::ACLiC>: creating shared library /home_nfs/isdc/neise/test_py/pyfact/./izstream_h.so
|
---|
82 | Info in <TUnixSystem::ACLiC>: creating shared library /home_nfs/isdc/neise/test_py/pyfact/./factfits_h.so
|
---|
83 | [... quite some warnings ...]
|
---|
84 |
|
---|
85 | neise@isdc-viewer00:~/py/pyfact$ ls *.so
|
---|
86 | calfactfits_h.so factfits_h.so izstream_h.so
|
---|
87 |
|
---|
88 | 4b. Create pyfits_h.so library
|
---|
89 | =============================
|
---|
90 |
|
---|
91 | -----------This is a depricated section---------------
|
---|
92 |
|
---|
93 | FACT data are stored in (gzipped) fits files, but the data files are too large to be read by the existing tools:
|
---|
94 |
|
---|
95 | `pyfits <http://www.stsci.edu/institute/software_hardware/pyfits>` which uses `cfitsio <http://heasarc.gsfc.nasa.gov/fitsio/>`_.
|
---|
96 |
|
---|
97 | To mitigate this problem a C++ class defined in fits.h [#f1]_ is used. A simple possibility to create an interface of this C++ class is to use ROOT and later to import it using the
|
---|
98 | `pyroot <http://root.cern.ch/drupal/category/package-context/pyroot>`_ module.
|
---|
99 |
|
---|
100 | example::
|
---|
101 |
|
---|
102 | neise@isdc-viewer00:~/py/pyscripts/pyfact$ root
|
---|
103 | ROOT 5.28/00 (trunk@37585, Dec 14 2010, 15:20:27 on linuxx8664gcc)
|
---|
104 | CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
|
---|
105 | Type ? for help. Commands must be C++ statements.
|
---|
106 | Enclose multiple statements between { }.
|
---|
107 | root [0] .L pyfits.h++
|
---|
108 | Info in <TUnixSystem::ACLiC>: creating shared library /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits_h.so
|
---|
109 | In file included from /home_nfs/isdc/neise/py/pyscripts/pyfact/pyfits_h_ACLiC_dict.h:34,
|
---|
110 | from /home_nfs/isdc/neise/py/pyscripts/pyfact/pyfits_h_ACLiC_dict.cxx:17:
|
---|
111 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h: In member function »size_t std::fits::Table::GetN(const std::string&) const«:
|
---|
112 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h:442: Warnung: Deklaration von »it« überdeckt einen vorhergehenden lokalen Bezeichner
|
---|
113 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h:437: Warnung: Verdeckte Deklaration ist hier
|
---|
114 | root [1] .q
|
---|
115 |
|
---|
116 | check if it worked::
|
---|
117 |
|
---|
118 | neise@isdc-viewer00:~/py/pyscripts/pyfact$ ls pyfits*
|
---|
119 | pyfits.h pyfits_h.d pyfits_h.so
|
---|
120 |
|
---|
121 |
|
---|
122 | This might not work for whatenver reason then you can try this::
|
---|
123 |
|
---|
124 | $rootcint -f my_dict.C -c pyfits.h izstream.h
|
---|
125 | $g++ -fPIC -c -I$ROOTSYS/include my_dict.C -o my_dict.o
|
---|
126 | $g++ -o pyfits_h.so -shared my_dict.o
|
---|
127 |
|
---|
128 |
|
---|
129 | In case one uses root 5.32 instead of root 5.28, one should do::
|
---|
130 |
|
---|
131 | neise@isdc-viewer00:~/py/pyscripts/pyfact$ root -b
|
---|
132 | *******************************************
|
---|
133 | * *
|
---|
134 | * W E L C O M E to R O O T *
|
---|
135 | * *
|
---|
136 | * Version 5.32/00 2 December 2011 *
|
---|
137 | * *
|
---|
138 | * You are welcome to visit our Web site *
|
---|
139 | * http://root.cern.ch *
|
---|
140 | * *
|
---|
141 | *******************************************
|
---|
142 |
|
---|
143 | ROOT 5.32/00 (tags/v5-32-00@42375, Dec 02 2011, 12:42:25 on linuxx8664gcc)
|
---|
144 |
|
---|
145 | CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
|
---|
146 | Type ? for help. Commands must be C++ statements.
|
---|
147 | Enclose multiple statements between { }.
|
---|
148 | root [0] gSystem->Load("/usr/lib64/libz.so")
|
---|
149 | (int)0
|
---|
150 | root [1] .L pyfits.h++
|
---|
151 | Info in <TUnixSystem::ACLiC>: creating shared library /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits_h.so
|
---|
152 | In file included from /home_nfs/isdc/neise/py/pyscripts/pyfact/pyfits_h_ACLiC_dict.h:34,
|
---|
153 | from /home_nfs/isdc/neise/py/pyscripts/pyfact/pyfits_h_ACLiC_dict.cxx:17:
|
---|
154 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h: In member function »size_t std::fits::Table::GetN(const std::string&) const«:
|
---|
155 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h:442: Warnung: Deklaration von »it« überdeckt einen vorhergehenden lokalen Bezeichner
|
---|
156 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h:437: Warnung: Verdeckte Deklaration ist hier
|
---|
157 | root [2] .q
|
---|
158 | neise@isdc-viewer00:~/py/pyscripts/pyfact$ ls pyfits*
|
---|
159 | pyfits.h pyfits_h.d pyfits_h.so
|
---|
160 |
|
---|
161 | Now you can check if the reading rawdata is working::
|
---|
162 |
|
---|
163 | neise@isdc-viewer00:~/py/pyfact$ pyfact.py
|
---|
164 | showing test of iterator of RawData class
|
---|
165 | in order to test the SlowData classe please use: ./pyfact.py fits-file-name
|
---|
166 | ev 1 data[0,0] = -7.68806196438 start_cell[0] = 426 trigger type = 416
|
---|
167 | ev 2 data[0,0] = 0.792280672486 start_cell[0] = 437 trigger type = 416
|
---|
168 | ev 3 data[0,0] = 54.9490855517 start_cell[0] = 449 trigger type = 416
|
---|
169 | ev 4 data[0,0] = 3.9482592671 start_cell[0] = 461 trigger type = 416
|
---|
170 | ev 5 data[0,0] = -66.4329317281 start_cell[0] = 474 trigger type = 416
|
---|
171 | ev 6 data[0,0] = 8.2917625181 start_cell[0] = 485 trigger type = 416
|
---|
172 | ev 7 data[0,0] = -41.6565116079 start_cell[0] = 498 trigger type = 416
|
---|
173 | ev 8 data[0,0] = 33.4668984163 start_cell[0] = 509 trigger type = 416
|
---|
174 | ev 9 data[0,0] = -28.520090549 start_cell[0] = 522 trigger type = 416
|
---|
175 | ev 10 data[0,0] = -20.4925692795 start_cell[0] = 533 trigger type = 416
|
---|
176 |
|
---|
177 |
|
---|
178 | 5. Run examples
|
---|
179 | ===============
|
---|
180 |
|
---|
181 | *datafilepath* and *calibfilepath* should be adjusted in case you are not working
|
---|
182 | on the ISDC cluster.
|
---|
183 |
|
---|
184 | explore class RawData::
|
---|
185 |
|
---|
186 | import pyfact
|
---|
187 | datafilepath = '/data00/fact-construction/raw/2012/03/04/20120304_018.fits.gz'
|
---|
188 | calibfilepath = '/data00/fact-construction/raw/2012/03/04/20120304_012.drs.fits.gz'
|
---|
189 | run = pyfact.RawData( datafilepath, calibfilepath, return_dict = True)
|
---|
190 | event = run.next()
|
---|
191 |
|
---|
192 | type(event)
|
---|
193 |
|
---|
194 | print 70*'*'
|
---|
195 | for key in event:
|
---|
196 | print 'key :', key
|
---|
197 | print 'value:', event[key]
|
---|
198 | print 70*'*'
|
---|
199 |
|
---|
200 | loop over RawData::
|
---|
201 |
|
---|
202 | import pyfact
|
---|
203 | datafilepath = '/data00/fact-construction/raw/2012/03/04/20120304_018.fits.gz'
|
---|
204 | calibfilepath = '/data00/fact-construction/raw/2012/03/04/20120304_012.drs.fits.gz'
|
---|
205 | run = pyfact.RawData( datafilepath, calibfilepath, return_dict = True)
|
---|
206 |
|
---|
207 | for event in run:
|
---|
208 | print 'event_id:', event['event_id']
|
---|
209 | # the data can be found in event['acal_data']
|
---|
210 |
|
---|
211 | .. rubric:: Footnotes
|
---|
212 | .. [#f1] fits.h (here named pyfits.h) is part of MARS and was written by T.Bretz, it was added to this repository for convienience |
---|