Ignore:
Timestamp:
04/05/12 17:32:54 (13 years ago)
Author:
lusterma
Message:
updated
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/pyscripts/doc/_build/latex/pyfact.tex

    r13151 r13324  
    1313
    1414\title{pyfact Documentation}
    15 \date{February 09, 2012}
     15\date{April 05, 2012}
    1616\release{0.1}
    1717\author{Werner Lustermann}
     
    135135\end{itemize}
    136136
     137If you are new to python you need to learn the basics. In any case it would be wise to study the following book:
     138
     139\emph{A Primer on Scientific Programming with Python - Hans Petter Langtangen}
     140
     141pyfact is supposed to follow closely the programming style thought in this book.
     142
     143\href{http://docs.python.org/}{python documentation pages}
     144
     145\href{http://www.astropython.org/resources}{astropython.org}
     146
     147
     148\section{Python version and modules used}
     149\label{introduction:python-version-and-modules-used}
     150As long as you work on the ISDC FACT cluster most things should be just fine.
     151{\color{red}\bfseries{}\textbar{}}python version: 2.6.6
     152{\color{red}\bfseries{}\textbar{}}--- add later: list of modules
     153
     154
     155\section{Style guide and coding conventions}
     156\label{introduction:style-guide-and-coding-conventions}
     157The code of pyfact follows the {\color{red}\bfseries{}{}`}Style Guide for python code \textless{}\href{http://www.python.org/dev/peps/pep-0008/}{http://www.python.org/dev/peps/pep-0008/}\textgreater{}.
     158
     159
     160\chapter{Getting Started}
     161\label{getting_started:getting-started}\label{getting_started::doc}\begin{enumerate}
     162\item {}
     163Get an account at the FACT data center at ISDC
     164
     165\item {}
     166Setup your environment variables
     167
     168\item {}
     169Checkout the pyfact software repository
     170
     171\item {}
     172Try a few examples
     173
     174\end{enumerate}
     175
     176
     177\section{1. Important links}
     178\label{getting_started:important-links}\begin{description}
     179\item[{\textbf{FACT data center at ISDC} \textless{}\href{http://www.isdc.unige.ch/fact/datacenter}{http://www.isdc.unige.ch/fact/datacenter}\textgreater{}**}] \leavevmode
     180here you find instructions how to get an account, how to set it up and how to use it
     181
     182\item[{\textbf{SVN repository} \textless{}\href{https://fact.isdc.unige.ch/svn/fact/}{https://fact.isdc.unige.ch/svn/fact/}\textgreater{}}] \leavevmode
     183hosts all FACT software (including pyfact)
     184
     185\item[{\textbf{FACT run database} \textless{}\href{https://www.fact-project.org/run\_db/db/fact\_runinfo.php}{https://www.fact-project.org/run\_db/db/fact\_runinfo.php}\textgreater{}}] \leavevmode
     186here you find information about all available runs
     187
     188\item[{\textbf{eLogbook} \textless{}\href{https://www.fact-project.org/logbook/}{https://www.fact-project.org/logbook/}\textgreater{}}] \leavevmode
     189telescope logbook used since Dec. 1, 2012; for logbook information before this date have a look here: \textless{}\href{http://fact.ethz.ch/FACTelog/index.jsp}{http://fact.ethz.ch/FACTelog/index.jsp}\textgreater{}
     190
     191\item[{\textbf{FACT La Palma pages} \textless{}\href{https://www.fact-project.org/}{https://www.fact-project.org/}\textgreater{}}] \leavevmode
     192plenty of information concerning the telescope in La Palma
     193
     194\end{description}
     195
     196
     197\section{2. Environment variables}
     198\label{getting_started:environment-variables}
     199set the following env variables depending on the SHELL you are using, for instance in .bashrc or .tcshrc
     200\begin{itemize}
     201\item {}
     202\textbf{ROOTSYS}: /swdev\_nfs/root\_v5.28.00
     203
     204\item {}
     205\textbf{PATH}: add \$ROOTSYS/bin
     206
     207\item {}
     208\textbf{PATH}: add /swdev\_nfs/FACT++
     209
     210\item {}
     211\textbf{LD\_LIBRARY\_PATH}: \$ROOTSYS/lib:/swdev\_nfs/FACT++/.libs
     212
     213\item {}
     214\textbf{PYTHONPATH}: \$ROOTSYS/lib
     215
     216\item {} \begin{description}
     217\item[{\textbf{PYTHONPATH}: add all directories where python should search for modules. At least:}] \leavevmode\begin{itemize}
     218\item {}
     219pyscripts/pyfact
     220
     221\item {}
     222pyscript/tools
     223
     224\item {}
     225pyscripts/ecamples
     226
     227\end{itemize}
     228
     229\end{description}
     230
     231\end{itemize}
     232
     233the absolute path depends on where you have checked (or will check) out the pyscripts repository
     234
     235
     236\section{3. Check out the repository}
     237\label{getting_started:check-out-the-repository}
     238svn co \href{https://fact.isdc.unige.ch/svn/fact/tools/pyscripts/}{https://fact.isdc.unige.ch/svn/fact/tools/pyscripts/}
     239
     240
     241\section{4. Create pyfits\_h.so library}
     242\label{getting_started:create-pyfits-h-so-library}
     243FACT data are stored in (gzipped) fits files, but the data files are too large to be read by the existing tools:
     244
     245\emph{pyfits \textless{}http://www.stsci.edu/institute/software\_hardware/pyfits\textgreater{}} which uses \href{http://heasarc.gsfc.nasa.gov/fitsio/}{cfitsio}.
     246
     247To mitigate this problem a C++ class defined in fits.h \footnote{
     248fits.h (here named pyfits.h) is part of MARS and was written by T.Bretz, it was added to this repository for convienience
     249} is used. A simple possibility to create an interface of this C++ class is to use ROOT and later to import it using the
     250\href{http://root.cern.ch/drupal/category/package-context/pyroot}{pyroot} module.
     251
     252got to the directory: pyscripts/pyfact
     253
     254simple:
     255
     256\begin{Verbatim}[commandchars=@\[\]]
     257@PYGZlb[]lusterma@PYGZat[]isdc-cn02 pyfact@PYGZrb[]@$ root
     258ROOT 5.28/00 (trunk@PYGZat[]37585, Dec 14 2010, 15:20:27 on linuxx8664gcc)
     259CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
     260Type ? for help. Commands must be C++ statements.
     261Enclose multiple statements between { }.
     262
     263root @PYGZlb[]0@PYGZrb[] .L fits.h++
     264Info in @textless[]TUnixSystem::ACLiC@textgreater[]: creating shared library /home@_nfs/isdc/lusterma/pyscripts/pyfact/./fits@_h.so
     265root @PYGZlb[]1@PYGZrb[]
     266\end{Verbatim}
     267
     268This might not work for whatenver reason then it should be done like this:
     269
     270\begin{Verbatim}[commandchars=@\[\]]
     271@$rootcint -f my@_dict.C -c fits.h izstream.h
     272@$g++ -fPIC -c -I@$ROOTSYS/include my@_dict.C -o my@_dict.o
     273@$g++ -o fits@_h.so -shared my@_dict.o
     274\end{Verbatim}
     275
     276Now you can check if the reading rawdata is working:
     277
     278\$ pyfact.py
     279
     280this should print some data from a few events
     281
     282
     283\section{5. Run examples}
     284\label{getting_started:run-examples}
     285
     286\chapter{Classes}
     287\label{getting_started:classes}
     288
     289\section{pyfact.py}
     290\label{getting_started:pyfact-py}
     291
     292\subsection{rawdata access}
     293\label{getting_started:rawdata-access}\index{RawData (class in pyfact)}
     294
     295\begin{fulllineitems}
     296\phantomsection\label{getting_started:pyfact.RawData}\pysiglinewithargsret{\strong{class }\code{pyfact.}\bfcode{RawData}}{\emph{data\_file\_name}, \emph{calib\_file\_name}, \emph{user\_action\_calib=\textless{}function \textless{}lambda\textgreater{} at 0xab028b4\textgreater{}}, \emph{baseline\_file\_name='`}, \emph{return\_dict=None}}{}
     297raw data access and calibration
     298\begin{itemize}
     299\item {}
     300open raw data file and drs calibration file
     301
     302\item {}
     303performs amplitude calibration
     304
     305\item {}
     306performs baseline substraction if wanted
     307
     308\item {}
     309provides all data in an array:
     310row = number of pixel
     311col = length of region of interest
     312
     313\end{itemize}
     314
     315initialize object
     316
     317open data file and calibration data file
     318get basic information about the data in data\_file\_name
     319allocate buffers for data access
     320
     321data\_file\_name   : fits or fits.gz file of the data including the path
     322calib\_file\_name : fits or fits.gz file containing DRS calibration data
     323baseline\_file\_name : npy file containing the baseline values
     324\index{baseline\_correct() (pyfact.RawData method)}
     325
     326\begin{fulllineitems}
     327\phantomsection\label{getting_started:pyfact.RawData.baseline_correct}\pysiglinewithargsret{\bfcode{baseline\_correct}}{}{}
     328subtract baseline from the data
     329
     330\end{fulllineitems}
     331
     332\index{baseline\_read\_values() (pyfact.RawData method)}
     333
     334\begin{fulllineitems}
     335\phantomsection\label{getting_started:pyfact.RawData.baseline_read_values}\pysiglinewithargsret{\bfcode{baseline\_read\_values}}{\emph{file}, \emph{bsl\_hist='bsl\_sum/hplt\_mean'}}{}
     336open ROOT file with baseline histogram and read baseline values
     337file       name of the root file
     338bsl\_hist   path to the histogram containing the basline values
     339
     340\end{fulllineitems}
     341
     342\index{board\_times (pyfact.RawData attribute)}
     343
     344\begin{fulllineitems}
     345\phantomsection\label{getting_started:pyfact.RawData.board_times}\pysigline{\bfcode{board\_times}}{}
     346time when the FAD was triggered, in some strange units...
     347
     348\end{fulllineitems}
     349
     350\index{calib\_file (pyfact.RawData attribute)}
     351
     352\begin{fulllineitems}
     353\phantomsection\label{getting_started:pyfact.RawData.calib_file}\pysigline{\bfcode{calib\_file}}{}
     354drs calibration file
     355
     356\end{fulllineitems}
     357
     358\index{calibrate\_drs\_amplitude() (pyfact.RawData method)}
     359
     360\begin{fulllineitems}
     361\phantomsection\label{getting_started:pyfact.RawData.calibrate_drs_amplitude}\pysiglinewithargsret{\bfcode{calibrate\_drs\_amplitude}}{}{}
     362perform the drs amplitude calibration of the event data
     363
     364\end{fulllineitems}
     365
     366\index{data (pyfact.RawData attribute)}
     367
     368\begin{fulllineitems}
     369\phantomsection\label{getting_started:pyfact.RawData.data}\pysigline{\bfcode{data}}{}
     3701D array with raw data
     371
     372\end{fulllineitems}
     373
     374\index{data\_file (pyfact.RawData attribute)}
     375
     376\begin{fulllineitems}
     377\phantomsection\label{getting_started:pyfact.RawData.data_file}\pysigline{\bfcode{data\_file}}{}
     378data file (fits object)
     379
     380\end{fulllineitems}
     381
     382\index{info() (pyfact.RawData method)}
     383
     384\begin{fulllineitems}
     385\phantomsection\label{getting_started:pyfact.RawData.info}\pysiglinewithargsret{\bfcode{info}}{}{}
     386print run information
     387
     388\end{fulllineitems}
     389
     390\index{nevents (pyfact.RawData attribute)}
     391
     392\begin{fulllineitems}
     393\phantomsection\label{getting_started:pyfact.RawData.nevents}\pysigline{\bfcode{nevents}}{}
     394number of events in the data run
     395
     396\end{fulllineitems}
     397
     398\index{next() (pyfact.RawData method)}
     399
     400\begin{fulllineitems}
     401\phantomsection\label{getting_started:pyfact.RawData.next}\pysiglinewithargsret{\bfcode{next}}{}{}
     402used by \_\_iter\_\_
     403
     404\end{fulllineitems}
     405
     406\index{next\_event() (pyfact.RawData method)}
     407
     408\begin{fulllineitems}
     409\phantomsection\label{getting_started:pyfact.RawData.next_event}\pysiglinewithargsret{\bfcode{next\_event}}{}{}
     410load the next event from disk and calibrate it
     411
     412\end{fulllineitems}
     413
     414\index{npix (pyfact.RawData attribute)}
     415
     416\begin{fulllineitems}
     417\phantomsection\label{getting_started:pyfact.RawData.npix}\pysigline{\bfcode{npix}}{}
     418number of pixels (should be 1440)
     419
     420\end{fulllineitems}
     421
     422\index{nroi (pyfact.RawData attribute)}
     423
     424\begin{fulllineitems}
     425\phantomsection\label{getting_started:pyfact.RawData.nroi}\pysigline{\bfcode{nroi}}{}
     426region of interest (number of DRS slices read)
     427
     428\end{fulllineitems}
     429
     430\index{start\_cells (pyfact.RawData attribute)}
     431
     432\begin{fulllineitems}
     433\phantomsection\label{getting_started:pyfact.RawData.start_cells}\pysigline{\bfcode{start\_cells}}{}
     434slice where drs readout started
     435
     436\end{fulllineitems}
     437
     438
     439\end{fulllineitems}
     440
     441
     442
     443\subsection{fnames of a data run}
     444\label{getting_started:fnames-of-a-data-run}\index{fnames (class in pyfact)}
     445
     446\begin{fulllineitems}
     447\phantomsection\label{getting_started:pyfact.fnames}\pysiglinewithargsret{\strong{class }\code{pyfact.}\bfcode{fnames}}{\emph{specifier={[}`012', `023', `2011', `11', `24'{]}, rpath='/scratch\_nfs/res/bsl/', zipped=True}}{}
     448organize file names of a FACT data run
     449\begin{description}
     450\item[{specifier}] \leavevmode{[}list of strings defined as:{]}
     451{[} `DRS calibration file', `Data file', `YYYY', `MM', `DD'{]}
     452
     453\end{description}
     454
     455rpath     : directory path for the results; YYYYMMDD will be appended to rpath
     456zipped    : use zipped (True) or unzipped (Data)
     457\index{info() (pyfact.fnames method)}
     458
     459\begin{fulllineitems}
     460\phantomsection\label{getting_started:pyfact.fnames.info}\pysiglinewithargsret{\bfcode{info}}{}{}
     461print complete filenames
     462
     463\end{fulllineitems}
     464
     465\index{make() (pyfact.fnames method)}
     466
     467\begin{fulllineitems}
     468\phantomsection\label{getting_started:pyfact.fnames.make}\pysiglinewithargsret{\bfcode{make}}{\emph{specifier}, \emph{rpath}, \emph{zipped}}{}
     469create (make) the filenames
     470
     471names   : dictionary of filenames, tags \{ `data', `drscal', `results' \}
     472data    : name of the data file
     473drscal  : name of the drs calibration file
     474results : radikal of file name(s) for results (to be completed  by suffixes)
     475
     476\end{fulllineitems}
     477
     478
     479\end{fulllineitems}
     480
     481
    137482
    138483\chapter{Classes}
     
    146491
    147492\subsection{fnames of a data run}
    148 \label{classes:fnames-of-a-data-run}
     493\label{classes:fnames-of-a-data-run}\index{fnames (class in pyfact)}
     494
     495\begin{fulllineitems}
     496\phantomsection\label{classes:pyfact.fnames}\pysiglinewithargsret{\strong{class }\code{pyfact.}\bfcode{fnames}}{\emph{specifier={[}`012', `023', `2011', `11', `24'{]}, rpath='/scratch\_nfs/res/bsl/', zipped=True}}{}
     497organize file names of a FACT data run
     498\begin{description}
     499\item[{specifier}] \leavevmode{[}list of strings defined as:{]}
     500{[} `DRS calibration file', `Data file', `YYYY', `MM', `DD'{]}
     501
     502\end{description}
     503
     504rpath     : directory path for the results; YYYYMMDD will be appended to rpath
     505zipped    : use zipped (True) or unzipped (Data)
     506\index{info() (pyfact.fnames method)}
     507
     508\begin{fulllineitems}
     509\phantomsection\label{classes:pyfact.fnames.info}\pysiglinewithargsret{\bfcode{info}}{}{}
     510print complete filenames
     511
     512\end{fulllineitems}
     513
     514\index{make() (pyfact.fnames method)}
     515
     516\begin{fulllineitems}
     517\phantomsection\label{classes:pyfact.fnames.make}\pysiglinewithargsret{\bfcode{make}}{\emph{specifier}, \emph{rpath}, \emph{zipped}}{}
     518create (make) the filenames
     519
     520names   : dictionary of filenames, tags \{ `data', `drscal', `results' \}
     521data    : name of the data file
     522drscal  : name of the drs calibration file
     523results : radikal of file name(s) for results (to be completed  by suffixes)
     524
     525\end{fulllineitems}
     526
     527
     528\end{fulllineitems}
     529
     530
     531
     532\section{FIR filter functions}
     533\label{classes:fir-filter-functions}
    149534
    150535\chapter{Examples}
Note: See TracChangeset for help on using the changeset viewer.