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 | Now you can check if the reading rawdata is working:
|
---|
105 |
|
---|
106 | $ ./pyfact.py
|
---|
107 |
|
---|
108 | this should print some data from a few events
|
---|
109 |
|
---|
110 | 5. Run examples
|
---|
111 | ===============
|
---|
112 |
|
---|
113 | *datafilepath* and *calibfilepath* should be adjusted in case you are not working
|
---|
114 | on the ISDC cluster.
|
---|
115 |
|
---|
116 | explore class RawData::
|
---|
117 |
|
---|
118 | import pyfact
|
---|
119 | datafilepath = '/data00/fact-construction/raw/2012/03/04/20120304_018.fits.gz'
|
---|
120 | calibfilepath = '/data00/fact-construction/raw/2012/03/04/20120304_012.drs.fits.gz'
|
---|
121 | run = pyfact.RawData( datafilepath, calibfilepath, return_dict = True)
|
---|
122 | event = run.next()
|
---|
123 |
|
---|
124 | type(event)
|
---|
125 |
|
---|
126 | print 70*'*'
|
---|
127 | for key in event:
|
---|
128 | print 'key :', key
|
---|
129 | print 'value:', event[key]
|
---|
130 | print 70*'*'
|
---|
131 |
|
---|
132 | loop over RawData::
|
---|
133 |
|
---|
134 | import pyfact
|
---|
135 | datafilepath = '/data00/fact-construction/raw/2012/03/04/20120304_018.fits.gz'
|
---|
136 | calibfilepath = '/data00/fact-construction/raw/2012/03/04/20120304_012.drs.fits.gz'
|
---|
137 | run = pyfact.RawData( datafilepath, calibfilepath, return_dict = True)
|
---|
138 |
|
---|
139 | for event in run:
|
---|
140 | print 'event_id:', event['event_id']
|
---|
141 | # the data can be found in event['acal_data']
|
---|
142 |
|
---|
143 | .. rubric:: Footnotes
|
---|
144 | .. [#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 |
---|