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=$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/
|
---|
65 |
|
---|
66 | 4. Create pyfits_h.so library
|
---|
67 | =============================
|
---|
68 |
|
---|
69 | FACT data are stored in (gzipped) fits files, but the data files are too large to be read by the existing tools:
|
---|
70 |
|
---|
71 | `pyfits <http://www.stsci.edu/institute/software_hardware/pyfits>` which uses `cfitsio <http://heasarc.gsfc.nasa.gov/fitsio/>`_.
|
---|
72 |
|
---|
73 | 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
|
---|
74 | `pyroot <http://root.cern.ch/drupal/category/package-context/pyroot>`_ module.
|
---|
75 |
|
---|
76 | example::
|
---|
77 |
|
---|
78 | neise@isdc-viewer00:~/py/pyscripts/pyfact$ root
|
---|
79 | ROOT 5.28/00 (trunk@37585, Dec 14 2010, 15:20:27 on linuxx8664gcc)
|
---|
80 | CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
|
---|
81 | Type ? for help. Commands must be C++ statements.
|
---|
82 | Enclose multiple statements between { }.
|
---|
83 | root [0] .L pyfits.h++
|
---|
84 | Info in <TUnixSystem::ACLiC>: creating shared library /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits_h.so
|
---|
85 | In file included from /home_nfs/isdc/neise/py/pyscripts/pyfact/pyfits_h_ACLiC_dict.h:34,
|
---|
86 | from /home_nfs/isdc/neise/py/pyscripts/pyfact/pyfits_h_ACLiC_dict.cxx:17:
|
---|
87 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h: In member function »size_t std::fits::Table::GetN(const std::string&) const«:
|
---|
88 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h:442: Warnung: Deklaration von »it« überdeckt einen vorhergehenden lokalen Bezeichner
|
---|
89 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h:437: Warnung: Verdeckte Deklaration ist hier
|
---|
90 | root [1] .q
|
---|
91 |
|
---|
92 | check if it worked::
|
---|
93 |
|
---|
94 | neise@isdc-viewer00:~/py/pyscripts/pyfact$ ls pyfits*
|
---|
95 | pyfits.h pyfits_h.d pyfits_h.so
|
---|
96 |
|
---|
97 |
|
---|
98 | This might not work for whatenver reason then you can try this::
|
---|
99 |
|
---|
100 | $rootcint -f my_dict.C -c pyfits.h izstream.h
|
---|
101 | $g++ -fPIC -c -I$ROOTSYS/include my_dict.C -o my_dict.o
|
---|
102 | $g++ -o pyfits_h.so -shared my_dict.o
|
---|
103 |
|
---|
104 |
|
---|
105 | In case one uses root 5.32 instead of root 5.28, one should do::
|
---|
106 |
|
---|
107 | neise@isdc-viewer00:~/py/pyscripts/pyfact$ root -b
|
---|
108 | *******************************************
|
---|
109 | * *
|
---|
110 | * W E L C O M E to R O O T *
|
---|
111 | * *
|
---|
112 | * Version 5.32/00 2 December 2011 *
|
---|
113 | * *
|
---|
114 | * You are welcome to visit our Web site *
|
---|
115 | * http://root.cern.ch *
|
---|
116 | * *
|
---|
117 | *******************************************
|
---|
118 |
|
---|
119 | ROOT 5.32/00 (tags/v5-32-00@42375, Dec 02 2011, 12:42:25 on linuxx8664gcc)
|
---|
120 |
|
---|
121 | CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
|
---|
122 | Type ? for help. Commands must be C++ statements.
|
---|
123 | Enclose multiple statements between { }.
|
---|
124 | root [0] gSystem->Load("/usr/lib64/libz.so")
|
---|
125 | (int)0
|
---|
126 | root [1] .L pyfits.h++
|
---|
127 | Info in <TUnixSystem::ACLiC>: creating shared library /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits_h.so
|
---|
128 | In file included from /home_nfs/isdc/neise/py/pyscripts/pyfact/pyfits_h_ACLiC_dict.h:34,
|
---|
129 | from /home_nfs/isdc/neise/py/pyscripts/pyfact/pyfits_h_ACLiC_dict.cxx:17:
|
---|
130 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h: In member function »size_t std::fits::Table::GetN(const std::string&) const«:
|
---|
131 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h:442: Warnung: Deklaration von »it« überdeckt einen vorhergehenden lokalen Bezeichner
|
---|
132 | /home_nfs/isdc/neise/py/pyscripts/pyfact/./pyfits.h:437: Warnung: Verdeckte Deklaration ist hier
|
---|
133 | root [2] .q
|
---|
134 | neise@isdc-viewer00:~/py/pyscripts/pyfact$ ls pyfits*
|
---|
135 | pyfits.h pyfits_h.d pyfits_h.so
|
---|
136 |
|
---|
137 |
|
---|
138 |
|
---|
139 | Now you can check if the reading rawdata is working:
|
---|
140 |
|
---|
141 | $ ./pyfact.py
|
---|
142 |
|
---|
143 | this should print some data from a few events
|
---|
144 |
|
---|
145 | 5. Run examples
|
---|
146 | ===============
|
---|
147 |
|
---|
148 | *datafilepath* and *calibfilepath* should be adjusted in case you are not working
|
---|
149 | on the ISDC cluster.
|
---|
150 |
|
---|
151 | explore class RawData::
|
---|
152 |
|
---|
153 | import pyfact
|
---|
154 | datafilepath = '/data00/fact-construction/raw/2012/03/04/20120304_018.fits.gz'
|
---|
155 | calibfilepath = '/data00/fact-construction/raw/2012/03/04/20120304_012.drs.fits.gz'
|
---|
156 | run = pyfact.RawData( datafilepath, calibfilepath, return_dict = True)
|
---|
157 | event = run.next()
|
---|
158 |
|
---|
159 | type(event)
|
---|
160 |
|
---|
161 | print 70*'*'
|
---|
162 | for key in event:
|
---|
163 | print 'key :', key
|
---|
164 | print 'value:', event[key]
|
---|
165 | print 70*'*'
|
---|
166 |
|
---|
167 | loop over RawData::
|
---|
168 |
|
---|
169 | import pyfact
|
---|
170 | datafilepath = '/data00/fact-construction/raw/2012/03/04/20120304_018.fits.gz'
|
---|
171 | calibfilepath = '/data00/fact-construction/raw/2012/03/04/20120304_012.drs.fits.gz'
|
---|
172 | run = pyfact.RawData( datafilepath, calibfilepath, return_dict = True)
|
---|
173 |
|
---|
174 | for event in run:
|
---|
175 | print 'event_id:', event['event_id']
|
---|
176 | # the data can be found in event['acal_data']
|
---|
177 |
|
---|
178 | .. rubric:: Footnotes
|
---|
179 | .. [#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 |
---|