| 1 | \documentclass[twoside,10pt]{article} | 
|---|
| 2 | % \usepackage[latin1]{inputenc} | 
|---|
| 3 | % \usepackage[T1]{fontenc} | 
|---|
| 4 | \usepackage[francais]{babel} | 
|---|
| 5 | \usepackage{graphicx} | 
|---|
| 6 |  | 
|---|
| 7 | \usepackage{amsmath} | 
|---|
| 8 | \usepackage{amssymb} | 
|---|
| 9 | \usepackage{latexsym} | 
|---|
| 10 |  | 
|---|
| 11 | \usepackage{palatino} | 
|---|
| 12 |  | 
|---|
| 13 | %  Definition pour Docs Sophya | 
|---|
| 14 | \usepackage{defsophya} | 
|---|
| 15 |  | 
|---|
| 16 | \usepackage{makeidx} | 
|---|
| 17 |  | 
|---|
| 18 | \usepackage[ps2pdf,bookmarks,bookmarksnumbered,% | 
|---|
| 19 | urlcolor=blue,citecolor=blue,linkcolor=blue,% | 
|---|
| 20 | pagecolor=blue,%hyperindex,% | 
|---|
| 21 | colorlinks=true,hyperfigures=true,hyperindex=true | 
|---|
| 22 | ]{hyperref} | 
|---|
| 23 |  | 
|---|
| 24 | \setlength{\textwidth}{15cm} | 
|---|
| 25 | \setlength{\textheight}{20.5cm} | 
|---|
| 26 | \setlength{\topmargin}{0.cm} | 
|---|
| 27 | \setlength{\oddsidemargin}{0.cm} | 
|---|
| 28 | \setlength{\evensidemargin}{0.cm} | 
|---|
| 29 | \setlength{\unitlength}{1mm} | 
|---|
| 30 |  | 
|---|
| 31 | % \newcommand{\piacommand}[1]{ | 
|---|
| 32 | %  \framebox{\bf \Large #1 } \index{#1} % (Command) | 
|---|
| 33 | %} | 
|---|
| 34 | % \newcommand{\piahelpitem}[1]{ | 
|---|
| 35 | %  \framebox{\bf \Large #1 } \index{#1} (Help item) | 
|---|
| 36 | %} | 
|---|
| 37 |  | 
|---|
| 38 | \newcommand{\rond}{$\bullet \ $} | 
|---|
| 39 | \newcommand{\etoile}{$\star \ $} | 
|---|
| 40 | \newcommand{\cercle}{$\circ \ $} | 
|---|
| 41 | \newcommand{\carre}{$\Box \ $} | 
|---|
| 42 |  | 
|---|
| 43 | %%%% Definition des commandes pour l'aide en ligne | 
|---|
| 44 | \newcommand{\piacommand}[1]{ | 
|---|
| 45 | $\blacksquare$ \hspace{3mm} {\bf \Large #1 } \index{#1} % (Command) | 
|---|
| 46 | } | 
|---|
| 47 | \newcommand{\piahelpitem}[1]{ | 
|---|
| 48 | $\square$ \hspace{3mm} {\bf \Large #1 } \index{#1} (Help item) | 
|---|
| 49 | } | 
|---|
| 50 |  | 
|---|
| 51 | \newcommand{\menubar}[1]{\hspace{1mm} \framebox{\it MenuBar::#1} \hspace{1mm}} | 
|---|
| 52 |  | 
|---|
| 53 | \newcommand{\myppageref}[1]{ (p. \pageref{#1} ) } | 
|---|
| 54 |  | 
|---|
| 55 | \makeindex     %  Constitution d'index | 
|---|
| 56 |  | 
|---|
| 57 | \begin{document} | 
|---|
| 58 | \begin{titlepage} | 
|---|
| 59 | %  The title page - top of the page with the title of the paper | 
|---|
| 60 | \titrehp{piapp \\ An interactive data analysis tool} | 
|---|
| 61 | %  Authors list | 
|---|
| 62 | \auteurs{ | 
|---|
| 63 | R. Ansari            &  ansari@lal.in2p3.fr       \\ | 
|---|
| 64 | E. Aubourg           &  aubourg@hep.saclay.cea.fr \\ | 
|---|
| 65 | C. Magneville        &  cmv@hep.saclay.cea.fr     \\ | 
|---|
| 66 | O. Perdereau         &  perderos@lal.in2p3.fr     \\ | 
|---|
| 67 | } | 
|---|
| 68 | % \author{R. Ansari {\tt ansari@lal.in2p3.fr} \\ | 
|---|
| 69 | % E. Aubourg {\tt aubourg@hep.saclay.cea.fr} \\ | 
|---|
| 70 | % C. Magneville {\tt cmv@hep.saclay.cea.fr} | 
|---|
| 71 | % } | 
|---|
| 72 | \vspace{1cm} | 
|---|
| 73 | \begin{center} | 
|---|
| 74 | {\bf \Large piapp Version: 4.3 (V\_Sep2007) } \\ | 
|---|
| 75 | {\bf SOPHYA version=4.2 , PI version= 4.2 } | 
|---|
| 76 | \end{center} | 
|---|
| 77 | \titrebp{5} | 
|---|
| 78 |  | 
|---|
| 79 | \end{titlepage} | 
|---|
| 80 |  | 
|---|
| 81 | \newpage | 
|---|
| 82 | \tableofcontents | 
|---|
| 83 | \newpage | 
|---|
| 84 |  | 
|---|
| 85 | \section{Introduction} | 
|---|
| 86 | \index{piapp} | 
|---|
| 87 | {\bf piapp} (or {\bf spiapp}) is an interactive data analysis | 
|---|
| 88 | and visualization  program. It is based on the {\bf PI} GUI library | 
|---|
| 89 | and the {\bf SOPHYA} \footnote{see http://www.sophya.org} | 
|---|
| 90 | (or {\bf PEIDA++} \footnote{PEIDA++ has been used in EROS software. | 
|---|
| 91 | (http://eros.in2p3.fr). It is not maintained anymore.}) | 
|---|
| 92 | C++ data analysis class library. | 
|---|
| 93 | \par | 
|---|
| 94 | {\bf piapp} is a powerful command oriented tool for visualising and analysing data. | 
|---|
| 95 | Its main features are summarised below: | 
|---|
| 96 | \begin{itemize} | 
|---|
| 97 | \item[\rond] Image, multiple 2D and few 3D representations | 
|---|
| 98 | \item[\rond] Highly interactive graphics, with postscript as export format | 
|---|
| 99 | \item[\rond] Capability to handle large data sets. Data can be imported and | 
|---|
| 100 | exported in different formats: ASCII, PPF and FITS. | 
|---|
| 101 | \item[\rond] Interactive analysis: 2D/3D distributions, histograms, FFT \ldots | 
|---|
| 102 | \item[\rond] Flexible c-shell inspired command interpreter. | 
|---|
| 103 | \item[\rond] Possibility to perform more complex operations in C++, on objects | 
|---|
| 104 | managed by the application through the on-the-fly compilation and execution | 
|---|
| 105 | of c++ code fragments in piapp. | 
|---|
| 106 | \item[\rond] piapp is a multi-threaded program with separate threads for graphics | 
|---|
| 107 | and command execution, ensuring interactive response, even while heavy | 
|---|
| 108 | computation is being performed. In addition, thread safe commands can be executed | 
|---|
| 109 | in separate threads, for taking advantage of multi CPU (or CPU-cores) workstations. | 
|---|
| 110 | \item[\rond] The application can be easily extended through modules which can be | 
|---|
| 111 | loaded at run time. | 
|---|
| 112 | \end{itemize} | 
|---|
| 113 |  | 
|---|
| 114 | \subsection{Acknowlegments} | 
|---|
| 115 | Many people have contributed to the development SOPHYA and/or the PI library | 
|---|
| 116 | and (s)piapp interactive analysis tool. | 
|---|
| 117 | we are grateful to the following people: | 
|---|
| 118 |  | 
|---|
| 119 | \begin{tabular}{lcl} | 
|---|
| 120 | Reza Ansari & \hspace{5mm} & (LAL-Univ.Paris Sud, Orsay) \\ | 
|---|
| 121 | Eric Aubourg & & (DAPNIA-CEA/APC, Saclay) \\ | 
|---|
| 122 | Sophie Henrot-Versille & & (LAL-IN2P3/CNRS, Orsay) \\ | 
|---|
| 123 | Alex Kim & & (LBL, Berkeley) \\ | 
|---|
| 124 | Guy Le Meur & & (LAL-IN2P3/CNRS, Orsay) \\ | 
|---|
| 125 | Eric Lesquoy & & (DAPNIA-CEA, Saclay) \\ | 
|---|
| 126 | Christophe Magneville & & (DAPNIA-CEA, Saclay) \\ | 
|---|
| 127 | Bruno Mansoux & & (LAL-IN2P3/CNRS, Orsay) \\ | 
|---|
| 128 | Olivier Perdereau & & (LAL-IN2P3/CNRS, Orsay) \\ | 
|---|
| 129 | Nicolas Regnault & & (LPNHE-IN2P3/CNRS, Paris) \\ | 
|---|
| 130 | Benoit Revenu & & (APC/Univ.Paris 7, Paris) \\ | 
|---|
| 131 | Francois Touze & & (LAL-IN2P3/CNRS, Orsay) \\ | 
|---|
| 132 | \end{tabular} | 
|---|
| 133 |  | 
|---|
| 134 | We thank also the persons who have helped us by useful suggestions, among others : \\ | 
|---|
| 135 | S. Bargot, S. Plasczczynski, C. Renault and D. Yvon. | 
|---|
| 136 |  | 
|---|
| 137 | %%% | 
|---|
| 138 | \begin{figure}[ht!] | 
|---|
| 139 | \begin{center} | 
|---|
| 140 | \includegraphics[width=15cm]{piapp_mainwin.eps} | 
|---|
| 141 | \caption{piapp main window} | 
|---|
| 142 | \label{figmainwin} | 
|---|
| 143 | \end{center} | 
|---|
| 144 | \end{figure} | 
|---|
| 145 | \subsection{starting piapp} | 
|---|
| 146 | {\bf piapp} can simply be started on the command line in a terminal window | 
|---|
| 147 | once the SOPHYA/piapp  environment has been initialised. | 
|---|
| 148 | The environment variables {\tt SOPHYABASE} should contain the directory | 
|---|
| 149 | where SOPHYA/piapp has been installed. the shared library path | 
|---|
| 150 | {\tt LD\_LIBRARY\_PATH} must contain {\tt \$SOPHYABASE /slb} and the | 
|---|
| 151 | current directory {\tt .} and the executable search path {\tt PATH} must | 
|---|
| 152 | contain {\tt \$SOPHYABASE /exe}. Refer to the SOPHYA overview manual | 
|---|
| 153 | for more information on SOPHYA directory structure. \\ | 
|---|
| 154 | \par | 
|---|
| 155 | {\tt (s)piapp -h} provides a brief help of the command line | 
|---|
| 156 | arguments. Xtoolkit options can also be specified as command line | 
|---|
| 157 | arguments. {\bf spiapp} is the name of SOPHYA/piapp executable, | 
|---|
| 158 | in order to distinguish it from PEIDA/piapp. | 
|---|
| 159 | \begin{verbatim} | 
|---|
| 160 | csh> spiapp -h | 
|---|
| 161 | SophyaInitiator::SophyaInitiator() BaseTools Init | 
|---|
| 162 | PIOPersist::Initialize() Starting Sophya Persistence management service | 
|---|
| 163 | SOPHYA Version  2.1 Revision 0 (V_Nov2007) -- Nov 24 2007 13:08:58 gcc 3.3 | 
|---|
| 164 | 20030304 (Apple Computer, Inc. build 1495) | 
|---|
| 165 | piapp: Interactive data analysis and visualisation program | 
|---|
| 166 | Usage: piapp [-nored] [-doublered] [-termread] [-term] | 
|---|
| 167 | [-hidezswin] [-small] [-nosig] [-nosigfpe] [-nosigsegv] | 
|---|
| 168 | [-tmpdir TmpDirectory] [-help2tex] [-exec file [args]] | 
|---|
| 169 | -nored : Don't redirect stdout/stderr to piapp console | 
|---|
| 170 | -doublered : Redirect stdout/stderr to piapp console AND the terminal | 
|---|
| 171 | -termread : Read commands on terminal (stdin) | 
|---|
| 172 | -term : equivalent to -nored -termread -small | 
|---|
| 173 | -hidezswin : Hide Zoom/Stat/ColMap window | 
|---|
| 174 | -small : Create small size main piapp window | 
|---|
| 175 | -nosig : Don't catch SigFPE, SigSEGV | 
|---|
| 176 | -nosigfpe -nosigsegv: Don t catch SigFPE / SigSEGV | 
|---|
| 177 | -tmpdir TmpDirectory: defines TMDIR for temporary files | 
|---|
| 178 | -help2tex: Create a LaTeX help file (piahelp.tex) | 
|---|
| 179 | -exec file [args] : Execute command file (last option) | 
|---|
| 180 | \end{verbatim} | 
|---|
| 181 | Once {\bf piapp} is started, the main piapp window appears. | 
|---|
| 182 | It contains the menu bar, an upper part with the zoom and colormap | 
|---|
| 183 | widgets for  image displays, memory and CPU usage and a terminal like | 
|---|
| 184 | widget (piapp console, see {\bf PIConsole} \myppageref{PIConsole}) | 
|---|
| 185 | in the lower part. The figure \ref{figmainwin} | 
|---|
| 186 | shows an image of the piapp main window. | 
|---|
| 187 | {\tt stdout/cout, stderr/cerr} are redirected to the piapp console and | 
|---|
| 188 | commands can be entered in this widget. It is also possible to keep | 
|---|
| 189 | the terminal where piapp was started  for {\tt stdout/stderr} (flag {\tt -nored}). | 
|---|
| 190 | The flag {\tt -term} activate a command reader on the terminal | 
|---|
| 191 | It is also possible to have a command reader on  the terminal ({\tt stdin}).  \\[1mm] | 
|---|
| 192 | The environment variable {\tt PIDEFAFSZFRAC} controls the automatic selection | 
|---|
| 193 | of font size for drawing axes, as a function of the window size (typical value 0.03 \ldots 0.1). | 
|---|
| 194 | Check the command {\tt setdefafsz } \myppageref{setdefafsz} and {\tt setaxesatt} | 
|---|
| 195 | \myppageref{setaxesatt} for more information. \\[1mm] | 
|---|
| 196 |  | 
|---|
| 197 | \par | 
|---|
| 198 | In section 2, we present  a quick tour of {\bf piapp}. | 
|---|
| 199 | a brief overview of piapp graphics, supported data formats, interactive | 
|---|
| 200 | analysis possibilities, the command interpreter and c++ execution | 
|---|
| 201 | are presented in the following sections. | 
|---|
| 202 | Section \ref{piappcmdref} contains a brief description of all piapp commands | 
|---|
| 203 | and help items. Various interactive control windows are described in appendix. | 
|---|
| 204 |  | 
|---|
| 205 | \subsection{DemoPIApp and DemoData} | 
|---|
| 206 | The directory {\bf DemoPIApp} contains a number of example scripts, such as the | 
|---|
| 207 | {\tt demo.pic} and the associated data file {\tt demo.ppf}. It contains | 
|---|
| 208 | also examples of loadable modules for piapp. The  DemoPIApp/CONTENT | 
|---|
| 209 | file contains a brief description of the different files. \\ | 
|---|
| 210 | The {\bf DemoData} contains a number of data files, in PPF and FITS format, which are | 
|---|
| 211 | used for the examples in this document. | 
|---|
| 212 |  | 
|---|
| 213 | \subsection{Warnings/Known problems} | 
|---|
| 214 | \begin{enumerate} | 
|---|
| 215 | \item It might  be necessary to define the environment variable | 
|---|
| 216 | {\bf PIXKBMODMASK}, used by the libPI.a to map correctly | 
|---|
| 217 | the {\tt <Alt>} key with some X servers (in particular with | 
|---|
| 218 | X11 on MacOS X). \\ | 
|---|
| 219 | {\tt csh> setenv PIXKBMODMASK 2 } | 
|---|
| 220 | However, the default value has been changed in PI/piapp V=4.1 and it should not be | 
|---|
| 221 | necessary anymore to define PIXKBMODMASK. | 
|---|
| 222 | %% | 
|---|
| 223 | \item The output redirection uses unix pipes. On Linux, with commands | 
|---|
| 224 | producing long outputs, the application may block because of incorrect management | 
|---|
| 225 | of pipes. If this happens, use piapp with  {\tt -nored} flag. This problem has been | 
|---|
| 226 | in principle solved with SOPHYA V=2.1 / piapp V=4.1 | 
|---|
| 227 | \end{enumerate} | 
|---|
| 228 |  | 
|---|
| 229 | \newpage | 
|---|
| 230 | \section{A Tour of piapp} | 
|---|
| 231 | \subsection{Interacting with piapp, getting help} | 
|---|
| 232 | Users interact with piapp through commands entered in the piapp-console | 
|---|
| 233 | (or the unix terminal), and through the different menus. | 
|---|
| 234 | Some of the possibilities of the piapp-console are described | 
|---|
| 235 | in {\bf PIConsole} help item, in the command reference section \myppageref{PIConsole}. | 
|---|
| 236 | The description | 
|---|
| 237 | of the commands in available online using the help command. | 
|---|
| 238 | An online help window can be displayed by \menubar{File / Help}. | 
|---|
| 239 | Commands and help items are grouped in categories which can be | 
|---|
| 240 | selected using the OptionMenu in the Help window. | 
|---|
| 241 | \begin{verbatim} | 
|---|
| 242 | Cmd> help func | 
|---|
| 243 | Displays a function y=f(x) (Fills a vector with function values) | 
|---|
| 244 | Usage: func f(x) xmin xmax [npt graphic_attributes] | 
|---|
| 245 | Related commands: funcff func2d func2dff | 
|---|
| 246 | Cmd> func sin(x)/x 0.1 10 100 'red line=solid,2' | 
|---|
| 247 | ---> Graphic display of the function | 
|---|
| 248 | \end{verbatim} | 
|---|
| 249 | The directory {\tt DemoPIApp} contains a number of example | 
|---|
| 250 | command script and sample data files. | 
|---|
| 251 |  | 
|---|
| 252 | \subsection{The Object Manager (NamedObjMgr)} | 
|---|
| 253 | The {\bf piapp} application is built around an object manager | 
|---|
| 254 | (class {\tt NamedObjMgr}) and a graphic application | 
|---|
| 255 | (class {\tt PIStdImgApp}). Objects inheriting from | 
|---|
| 256 | the class {\tt AnyDataObj} can be managed through adapter | 
|---|
| 257 | classes (classes inheriting from {\tt NObjMgrAdapter}) by | 
|---|
| 258 | the object manager. | 
|---|
| 259 | \par | 
|---|
| 260 | User sees the objects (such as Sophya objects Histo, NTuple, | 
|---|
| 261 | Arrays, Images, SkyMaps, \ldots) kept in memory, organized | 
|---|
| 262 | in a single level tree structure. Four memory directories | 
|---|
| 263 | are automatically created and can not be removed: \\ | 
|---|
| 264 | \centerline{\bf /home \hspace{10mm} /old \hspace{10mm} /tmp \hspace{10mm} /autoc} | 
|---|
| 265 | The default working directory (in memory) is {\bf /home}. | 
|---|
| 266 | Other directories can be created by the user. | 
|---|
| 267 | \begin{center} | 
|---|
| 268 | {\bf Warning:} These are only the directory | 
|---|
| 269 | structure managed by the piapp application and do not | 
|---|
| 270 | correspond to the file system directories | 
|---|
| 271 | \end{center} | 
|---|
| 272 | The window {\bf ObjMgr} shown in figure \ref{figobjmgrw} | 
|---|
| 273 | can be used to navigate in the memory directories and | 
|---|
| 274 | execute simple operations on objects. \\ | 
|---|
| 275 | This window can be displayed using the menu command | 
|---|
| 276 | \menubar{Objects / ObjectManager}. | 
|---|
| 277 | The button \framebox{\small \bf SetCurObj} can be used to set the value | 
|---|
| 278 | of the interpreter's variable {\tt cobj} to the selected | 
|---|
| 279 | object name. | 
|---|
| 280 | Refer to the commands in group {\bf Object Management} | 
|---|
| 281 | for more information. | 
|---|
| 282 |  | 
|---|
| 283 | \vspace*{5mm} | 
|---|
| 284 | \begin{figure}[ht!] | 
|---|
| 285 | \begin{center} | 
|---|
| 286 | \includegraphics[width=10cm]{piapp_objmgr.eps} | 
|---|
| 287 | \caption{The interactive object management window} | 
|---|
| 288 | \label{figobjmgrw} | 
|---|
| 289 | \end{center} | 
|---|
| 290 | \end{figure} | 
|---|
| 291 |  | 
|---|
| 292 | \subsection{command language} | 
|---|
| 293 | A basic command interpreter ({\bf PIACmd/Commander}) is included in {\bf piapp} and | 
|---|
| 294 | other command interpreters can be inserted in the application | 
|---|
| 295 | framework. | 
|---|
| 296 | This interpreter ({\bf Commander} \myppageref{Commander}) | 
|---|
| 297 | synthax is close to the c-shell | 
|---|
| 298 | (csh) shell script. It is possible to define and use variables | 
|---|
| 299 | ({\tt set} command, {\tt \$varname}), and execute loops | 
|---|
| 300 | ({\tt foreach,for}), as well as simple tests | 
|---|
| 301 | ({\tt if test then ... else ... endif}). | 
|---|
| 302 | Commands from a file (default extension .pic) can be executed | 
|---|
| 303 | using the {\tt exec} command. | 
|---|
| 304 | Long commands can be put on several lines, by ending a line | 
|---|
| 305 | by the backslash \\ caracter, to signal that the command | 
|---|
| 306 | continues on the next line. | 
|---|
| 307 |  | 
|---|
| 308 | The command macro below shows a sample piapp session, where | 
|---|
| 309 | data from the file {\tt demo.ppf} are displayed. | 
|---|
| 310 | \begin{verbatim} | 
|---|
| 311 | #  Trace mode -> On | 
|---|
| 312 | traceon | 
|---|
| 313 | #  Deleting all objects in the current directory | 
|---|
| 314 | delobjs * | 
|---|
| 315 | #  Opening the PPF file demo.ppf | 
|---|
| 316 | openppf demo.ppf | 
|---|
| 317 | # Various displays in a graphic window, divided into 2x2 zones | 
|---|
| 318 | zone 2 2 | 
|---|
| 319 | #  1D histogram display | 
|---|
| 320 | disp h1d blue | 
|---|
| 321 | #  2D histogram display | 
|---|
| 322 | disp h2d | 
|---|
| 323 | #  Function display | 
|---|
| 324 | func sin(x)/x 0.1 10. 200 gold | 
|---|
| 325 | #  Surface representation of a matrix | 
|---|
| 326 | surf mtx1 colbr32 | 
|---|
| 327 | # Contour representation of a matrix | 
|---|
| 328 | contour mtx1 'colrj32 normalline ncont=7' | 
|---|
| 329 | #  3D representation of points using a PAW like command | 
|---|
| 330 | n/plot nt31.z%y%x ! ! win | 
|---|
| 331 | #  3D points superimposed on the previous display | 
|---|
| 332 | nt3d nt32 x y  z ex ey ez - - 'same fcirclemarker7 red' | 
|---|
| 333 | \end{verbatim} | 
|---|
| 334 |  | 
|---|
| 335 | \subsection{NTuple vue / PAW like commands} | 
|---|
| 336 | It is possible to plot various expressions of objects, seen as | 
|---|
| 337 | a 2D table, with named columns. This possibility exist not only | 
|---|
| 338 | for NTuples/DataTables, but also for most objects (from SOPHYA) handled | 
|---|
| 339 | by piapp. The related commands are grouped under {\bf Expr.Plotting} and | 
|---|
| 340 | {\bf pawCmd} and are described in section \ref{tableplot}. | 
|---|
| 341 |  | 
|---|
| 342 | \subsection{C++ execution inside piapp} | 
|---|
| 343 | For more complex processings, where the full power of C++ | 
|---|
| 344 | and the class libraries are necessary, {\bf piapp} provide | 
|---|
| 345 | the possibility of executing C++ code, without the burden | 
|---|
| 346 | of having to write a complete program. The objects | 
|---|
| 347 | present in the current directory are automatically | 
|---|
| 348 | declared. The communication with the piapp application | 
|---|
| 349 | is done by the {\bf NamedObjMgr} class. | 
|---|
| 350 | Two macros {\tt KeepObj()} and {\tt DispObj()} | 
|---|
| 351 | simplify the task of keeping newly created objects. | 
|---|
| 352 | In the example below, we first create a noisy signal | 
|---|
| 353 | in a vector, and we keep it in the application | 
|---|
| 354 | (Notice the use of multiline command) : | 
|---|
| 355 |  | 
|---|
| 356 | \begin{verbatim} | 
|---|
| 357 | Cmd> c++exec c++exec Vector in(1024); \ | 
|---|
| 358 | ...? in = RandomSequence(RandomSequence::Gaussian, 0., 1.); \ | 
|---|
| 359 | ...? for(int kk=0; kk<in.Size(); kk++) \ | 
|---|
| 360 | ...? in(kk) += 2*sin(kk*0.05); \ | 
|---|
| 361 | ...? KeepObj(in); | 
|---|
| 362 | \end{verbatim} | 
|---|
| 363 | We can of course display the resulting vector: | 
|---|
| 364 | \begin{verbatim} | 
|---|
| 365 | Cmd> disp in | 
|---|
| 366 | \end{verbatim} | 
|---|
| 367 |  | 
|---|
| 368 | And, at a subsequent stage, make a low pass filter | 
|---|
| 369 | on the vector in: | 
|---|
| 370 | \begin{verbatim} | 
|---|
| 371 | Cmd> c++exec Vector out(1024); \ | 
|---|
| 372 | ...? int w = 2; \ | 
|---|
| 373 | ...? for(int k=w; k<in.Size()-w; k++) \ | 
|---|
| 374 | ...?   out(k) = in(Range(k-w, k+w)).Sum()/(2.*w+1.); \ | 
|---|
| 375 | ...? KeepObj(out); | 
|---|
| 376 | \end{verbatim} | 
|---|
| 377 |  | 
|---|
| 378 | We can display the new vector {\tt out} overlayed | 
|---|
| 379 | on the previously displayed vector: | 
|---|
| 380 | \begin{verbatim} | 
|---|
| 381 | Cmd> disp out 'red same' | 
|---|
| 382 | \end{verbatim} | 
|---|
| 383 |  | 
|---|
| 384 | See section \ref{flycplusplus} and command group {\bf CxxExecutorCmd} | 
|---|
| 385 | for more information. | 
|---|
| 386 |  | 
|---|
| 387 | \subsection{Extending the application} | 
|---|
| 388 | The {\bf piapp} application can easily be extended by the user. | 
|---|
| 389 | This is done through shared libraries which can be opened | 
|---|
| 390 | and used by the application. | 
|---|
| 391 | Two main methods can be used (see  command group | 
|---|
| 392 | {\bf ExternalModules}) : | 
|---|
| 393 | \begin{itemize} | 
|---|
| 394 | \item Creation of user functions. A shared library containing | 
|---|
| 395 | at least one user function with the following prototype | 
|---|
| 396 | should be created: | 
|---|
| 397 | \begin{verbatim} | 
|---|
| 398 | extern "C" { | 
|---|
| 399 | void myfonction(vector<string>& args); | 
|---|
| 400 | } | 
|---|
| 401 | \end{verbatim} | 
|---|
| 402 | The class {\bf NameObjMgr} should be used to communicate with the | 
|---|
| 403 | application. The {\tt link} \myppageref{link} and {\tt call} \myppageref{call} | 
|---|
| 404 | should be used to load and execute user functions. An example of | 
|---|
| 405 | user function can be found in DemoPIApp/user.cc exlink.pic. | 
|---|
| 406 |  | 
|---|
| 407 | \item Creation of loadable modules: Loadable modules can be | 
|---|
| 408 | used to extend the application possibilities in a way totally | 
|---|
| 409 | transparent to the user. It is possible to define new commands, | 
|---|
| 410 | handling of new object types, additional graphic functionalities | 
|---|
| 411 | in a loadable module. | 
|---|
| 412 |  | 
|---|
| 413 | The class {\bf CmdExecutor} is the base class for extending piapp. | 
|---|
| 414 | A shared library should be built, containing two functions,for | 
|---|
| 415 | the activation and deactivation of the module, with the following | 
|---|
| 416 | prototype (where {\tt mymodule} is the module's name. | 
|---|
| 417 | \begin{verbatim} | 
|---|
| 418 | extern "C" { | 
|---|
| 419 | void mymodule_init(); | 
|---|
| 420 | void mymodule_end(); | 
|---|
| 421 | } | 
|---|
| 422 | \end{verbatim} | 
|---|
| 423 |  | 
|---|
| 424 | \end{itemize} | 
|---|
| 425 |  | 
|---|
| 426 | %%%%%%%%%% Section 3: Graphiques | 
|---|
| 427 | \newpage | 
|---|
| 428 | \section{Interactive graphics} | 
|---|
| 429 | \label{intgraphics} | 
|---|
| 430 | %%% | 
|---|
| 431 | \subsection{Display commands} | 
|---|
| 432 | Many objects managed by piapp have a default graphic representation. The | 
|---|
| 433 | {\bf disp} command  \myppageref{disp} can be used to display the object, while | 
|---|
| 434 | other commands like {\bf surf} \myppageref{surf} , {\bf imag} | 
|---|
| 435 | or {\bf contour} \myppageref{contour} will try to force a given graphic representation. | 
|---|
| 436 |  | 
|---|
| 437 | Data from table like objects can be plotted using commands like {\bf nt2d} | 
|---|
| 438 | \myppageref{nt2d} or {\bf nt3d} \myppageref{nt3d}. Most objects in piapp | 
|---|
| 439 | can also be manipulated like table for plotting purposes, using commands | 
|---|
| 440 | like  {\bf plot2d} \myppageref{plot2d} , {\bf plot3d} \myppageref{plot3d} | 
|---|
| 441 | or {\bf n/plot}  \myppageref{nZplot}. These commands are described in section | 
|---|
| 442 | \ref{tableplot}. | 
|---|
| 443 |  | 
|---|
| 444 | Commands producing a graphic output have usually an optional argument called \\ | 
|---|
| 445 | {\tt graphic\_attributes} or {\tt gr\_att}. \\ | 
|---|
| 446 | This argument provide a flexible and easy | 
|---|
| 447 | way to change and customise the output graphic, as discussed in the paragraphs below. | 
|---|
| 448 |  | 
|---|
| 449 | The piapp graphics can be exported in postscript (.ps) or encapsulated postscript | 
|---|
| 450 | (.eps) format. The commands {\bf w2ps} \myppageref{w2ps} and | 
|---|
| 451 | {\bf w2eps} \myppageref{w2eps} as well the menu  \menubar{PostScript} can | 
|---|
| 452 | be used to export graphics. \\[2mm] | 
|---|
| 453 | The examples in the following pages illustrates the usage of some piapp graphic commands. | 
|---|
| 454 | % \newpage | 
|---|
| 455 | \begin{enumerate} | 
|---|
| 456 | \label{francetopo} | 
|---|
| 457 | \item Image display. The following example uses the data file francetopo.ppf | 
|---|
| 458 | which can be found in the {\bf DemoData} directory. This PPF file contains | 
|---|
| 459 | a TMatrix$<$int\_2$>$ (short integers) representing  30 arcmin gridded | 
|---|
| 460 | ($\sim$ 1 km N-S $\times$ 0.7 km E-W) elevation (or altitude) | 
|---|
| 461 | for the area centered on France. It has been made using topographic | 
|---|
| 462 | data (DEM: Digital Elevation Model) available from the {\bf N}ational | 
|---|
| 463 | {\bf G}eophysical {\bf D}ata {\bf C}enter | 
|---|
| 464 | \href{http://www.ngdc.noaa.gov/mgg/topo/}{({\bf NGDC/GLOBE})} | 
|---|
| 465 | \footnote{NGDC web site: \hspace{5mm} | 
|---|
| 466 | http://www.ngdc.noaa.gov/ }. | 
|---|
| 467 | In section \ref{tableplot}, an example shows how to use this data set to | 
|---|
| 468 | create altitude distribution histogram for selected regions. | 
|---|
| 469 | \begin{verbatim} | 
|---|
| 470 | #  Open a PPF file containing topographic data for france | 
|---|
| 471 | #  as a TMatrix<short> 1332x1548 | 
|---|
| 472 | #  The file is in the directory DemoData/ | 
|---|
| 473 | openppf francetopo.ppf | 
|---|
| 474 | #  Display the matrix, whit a zoom factor, lut and color map | 
|---|
| 475 | disp francetopo 'zoom/3 lut=lin,-700,800 colbr128 win' | 
|---|
| 476 | w2eps francetopo.eps | 
|---|
| 477 | \end{verbatim} | 
|---|
| 478 | \begin{center} | 
|---|
| 479 | \includegraphics[width=13cm]{francetopo.eps} | 
|---|
| 480 | \end{center} | 
|---|
| 481 |  | 
|---|
| 482 | \item Simple 2D graphics with vector displays | 
|---|
| 483 | \begin{verbatim} | 
|---|
| 484 | #  Create and initialize two vectors - prevent display : nodisp | 
|---|
| 485 | Cmd> newvec vva 100 sin(x/10.+0.7)+cos(x/7.+1.4)*1.26 nodisp | 
|---|
| 486 | Cmd> newvec vvb 100 sin(x/10.)+cos(x/7.)*1.34 nodisp | 
|---|
| 487 | #  Set axe drawing options | 
|---|
| 488 | Cmd> setaxesatt 'font=times,bold,16 minorticks tickslen=0.02,0.012' | 
|---|
| 489 | #  Display the two vectors, with different graphic attributes | 
|---|
| 490 | Cmd> disp vva 'red line=solid,2 notitle' | 
|---|
| 491 | #  Define a title for the graphic | 
|---|
| 492 | Cmd> settitle 'Example-1: 2 vectors'  ' ' 'font=times,bolditalic,18' | 
|---|
| 493 | Cmd> disp vvb 'blue marker=box,7 same' | 
|---|
| 494 | #  Save the graphic into an eps file | 
|---|
| 495 | Cmd> w2eps gr2vec.eps | 
|---|
| 496 | \end{verbatim} | 
|---|
| 497 | % \begin{figure}[ht!] | 
|---|
| 498 | \begin{center} | 
|---|
| 499 | \includegraphics[width=12cm]{gr2vec.eps} | 
|---|
| 500 | % \label{g22vec} | 
|---|
| 501 | \end{center} | 
|---|
| 502 | %%% | 
|---|
| 503 | \item Creating a comparison chart using {\bf bargraph} | 
|---|
| 504 | \begin{verbatim} | 
|---|
| 505 | #  Representation du PNB (en $, 2003) pour quelques pays | 
|---|
| 506 | set pays ( Allemagne Espagne France Italie Pays-Bas Suisse UK USA ) | 
|---|
| 507 | set pnbh ( 22670 14430 22010 18960 23960 37930 25250 35060 ) | 
|---|
| 508 | setaxesatt 'font=times,bold,16' | 
|---|
| 509 | bargraph pnbh pays - 'blue horizontalbars nofill packfrac=0.65 font=helvetica,bold,14' | 
|---|
| 510 | setaxelabels 'PNB / Hab , $ 2003' ' ' 'font=times,bold,16' | 
|---|
| 511 | w2eps pnbargraph.eps | 
|---|
| 512 | \end{verbatim} | 
|---|
| 513 | \begin{center} | 
|---|
| 514 | \includegraphics[width=12cm]{pnbbargraph.eps} | 
|---|
| 515 | \end{center} | 
|---|
| 516 | %%% | 
|---|
| 517 | \item Displaying a matrix as a surface | 
|---|
| 518 | \begin{verbatim} | 
|---|
| 519 | openppf demo.ppf mtx1 | 
|---|
| 520 | setaxesatt 'font=time,bold,16' | 
|---|
| 521 | surf mtx1 'colbr128 line=solid,1 grey' | 
|---|
| 522 | w2eps surfcol.eps | 
|---|
| 523 | \end{verbatim} | 
|---|
| 524 | \begin{center} | 
|---|
| 525 | \includegraphics[width=13cm]{surfcol.eps} | 
|---|
| 526 | \end{center} | 
|---|
| 527 |  | 
|---|
| 528 | \end{enumerate} | 
|---|
| 529 |  | 
|---|
| 530 | %%%%%%%%%% | 
|---|
| 531 | \subsection{Graphic objects in piapp} | 
|---|
| 532 | The piapp graphics is handled by the {\bf PI} \footnote {http://www.sophya.org/PI} library, | 
|---|
| 533 | which provide a large variety of 2D representations, | 
|---|
| 534 | few 3D graphics and powerful image display. \\ | 
|---|
| 535 | Currently, all graphic representations, except for image displays, are handled | 
|---|
| 536 | through {\bf PIDrawers} which are managed by a viewer. A viewer can | 
|---|
| 537 | manage several {\bf PIDrawers} objects which correspond then to a multilayer | 
|---|
| 538 | graphic display. The viewers are also responsible for managing user | 
|---|
| 539 | interactions. \\ | 
|---|
| 540 | Image displays are handled through a specific viewer | 
|---|
| 541 | {\bf  PIImage} which is also capable of managing PIDrawer objects | 
|---|
| 542 | for multi-layer 2D overlay vector graphics. \\[2mm] | 
|---|
| 543 | %% | 
|---|
| 544 | Main piapp/PI graphic viewers, windows and drawer objects are described if | 
|---|
| 545 | the following sections. | 
|---|
| 546 |  | 
|---|
| 547 | \subsubsection{PIScDrawWdg (2D display)} | 
|---|
| 548 | The {\bf PIScDrawWdg} handles a set of  of 2-D drawers, managing | 
|---|
| 549 | the 2D coordinate  system and interactive zoom. The axes drawing is | 
|---|
| 550 | handled by a specialised drawer, number 0, which also manages various added | 
|---|
| 551 | graphic elements (text \ldots). The list of various mouse and | 
|---|
| 552 | keyboard actions is described in the reference section, under {\bf PIScDrawWdg} \myppageref{PIScDrawWdg} title. In particular, mouse-button-2 can be used | 
|---|
| 553 | to zoom on a particular part, {\tt $<$Alt$>$A} activates the coordinates | 
|---|
| 554 | and axes manipulation window ({\bf PIAxesTools}) and   {\tt $<$Alt$>$G} | 
|---|
| 555 | activates the PIDrawer graphic attributes control window ({\bf PIDrawerTools}). | 
|---|
| 556 | %%% | 
|---|
| 557 | \subsubsection{PIDraw3DWdg (3D display)} | 
|---|
| 558 | The {\bf PIDraw3DWdg}  handles a set of of 3-D drawers, managing | 
|---|
| 559 | interactive camera/object rotation (mouse-button-2) and zoom (mouse-button-2). | 
|---|
| 560 | {\tt $<$Alt$>$G} to display/activate  the PIDrawer graphic attributes | 
|---|
| 561 | control window ({\bf PIDrawerTools}). | 
|---|
| 562 | See {\bf PIDraw3DWdg} \myppageref{PIDraw3DWdg} for a complete list of mouse | 
|---|
| 563 | and keyboard actions. | 
|---|
| 564 | Drawer 0 handles axes drawing and graphic elements. | 
|---|
| 565 | %%% | 
|---|
| 566 | \subsubsection{PIImage (Image Display)} | 
|---|
| 567 | The display of 2-D arrays $A(i,j)$ as an image is managed by | 
|---|
| 568 | the {\bf PIImage} viewer/widget. The PI library interface  {\bf P2DArrayAdapter} is used | 
|---|
| 569 | to represent a generic 2-D array. The array values are converted into an index, converted | 
|---|
| 570 | itself into a color by the use of a color-map or color-table {\bf PIColorMap}. | 
|---|
| 571 | $$ \mathrm{LUT:} A(i,j) \longrightarrow idx(i,j) \hspace{5mm} \mathrm{ColorMap:} | 
|---|
| 572 | idx(i,j) \longrightarrow col(i,j) $$ | 
|---|
| 573 | Currently index range is 0...255 with color-map having 32 or 128 distinct colors. | 
|---|
| 574 | PIImage viewers  controls a zoom widget, as well as a global image view widget, and | 
|---|
| 575 | a color map view widget. A specific image control window can be activated using | 
|---|
| 576 | {\tt $<$Alt$>$O}.  See {\bf PIImage} \myppageref{PIImage} for | 
|---|
| 577 | a complete list of mouse and keyboard actions. A base drawer (number 0) handles | 
|---|
| 578 | axes drawing and added graphic elements. The colormap with the LUT information | 
|---|
| 579 | can also be displayed through a second drawer (PICMapDrawer). The colormap | 
|---|
| 580 | display in the main image window is controlled by the {\tt showcmap} graphic option. | 
|---|
| 581 | %%% | 
|---|
| 582 | \subsubsection{Windows} | 
|---|
| 583 | The viewers described above are displayed in differnt kind of windows. | 
|---|
| 584 | The graphic option {\tt next,win,same,stack,inset} can be used to control the way the | 
|---|
| 585 | type of windows used, or the way the object is displayed in the window. | 
|---|
| 586 | Graphic windows can be divided into several zones | 
|---|
| 587 | (Command {\bf zone} \myppageref{zone}). | 
|---|
| 588 |  | 
|---|
| 589 | When an object is diplayed in piapp, a widget (PIWdg) is created which manages | 
|---|
| 590 | the drawer or the 2d-array.  The default name for this widget is the displayed | 
|---|
| 591 | object name. However, it is possible to specify a name using the graphic attribute: \\ | 
|---|
| 592 | \hspace*{5mm} {\tt wname=WidgetName} \\ | 
|---|
| 593 | It is possible to display multiple objects on a single widget, corresponding | 
|---|
| 594 | to the superposition of the different drawers. Displaying an object superimposed | 
|---|
| 595 | on the previously displayed object can be done using the graphic option | 
|---|
| 596 | {\tt same}. It is also possible to specify a target widget by its name, through | 
|---|
| 597 | the graphic option \\ | 
|---|
| 598 | \hspace*{5mm} {\tt samew=WidgetName} \\ | 
|---|
| 599 | It is also possible to specify the display of the drawer in a specific region | 
|---|
| 600 | of the last displayed widget using the {\tt inset} option, or | 
|---|
| 601 | \hspace*{3mm} {\tt inset=fx1,fx2,fy1,fy2} \\ | 
|---|
| 602 | where {\tt fx1,fx2,fy1,fy2} express X and Y limits, as fractions of the widget size. | 
|---|
| 603 |  | 
|---|
| 604 | Refer to the command reference section on windows ({\bf Windows} | 
|---|
| 605 | \myppageref{Windows}) | 
|---|
| 606 | for information on the different type of windows used by piapp | 
|---|
| 607 | and their properties. \\ | 
|---|
| 608 |  | 
|---|
| 609 | %%% | 
|---|
| 610 | \subsubsection{Drawers} | 
|---|
| 611 | Graphical representation of most objects in piapp is | 
|---|
| 612 | handled through objects inheriting from the {\bf PIDrawer class}. A base drawer | 
|---|
| 613 | ({\bf PIElDrawer}, number 0) is associated to the three viewers presented above, | 
|---|
| 614 | and manages the axes drawing as well as the added graphic elements | 
|---|
| 615 | (text, arrow, \ldots). A drawer management menu | 
|---|
| 616 | can be activated using {\tt $<$Alt$>$D}. This menu can be used to move and resize | 
|---|
| 617 | drawers, or to display a window for changing drawers graphic attributes. | 
|---|
| 618 | %%% | 
|---|
| 619 | \par | 
|---|
| 620 | In addition, a number of control windows can be used to examine and | 
|---|
| 621 | change view properties of differents viewers and drawers. | 
|---|
| 622 | \begin{itemize} | 
|---|
| 623 | \item[] {\bf PIDrawerTools} activated using {\tt $<$Alt$>$G} or | 
|---|
| 624 | \menubar{Tools/Show DrawerTools} on any viewer (see page \myppageref{secdrwtools}) | 
|---|
| 625 | \item[] {\bf PIAxesTools} activated using {\tt $<$Alt$>$A} or | 
|---|
| 626 | \menubar{Tools/Show AxeTools} on PIScDrawWdg (see page \myppageref{secaxestools}) | 
|---|
| 627 | \item[] {\bf PIImageTools} activated using {\tt $<$Alt$>$O} or | 
|---|
| 628 | \menubar{Tools/Show ImageTools} on PIImage | 
|---|
| 629 | (see page \myppageref{secimagetools}) | 
|---|
| 630 | \item[] {\bf PIHisto2DTools} activated using {\tt $<$Alt$>$O} or through the PIDrawerTools | 
|---|
| 631 | for an active PIHisto2D drawer. (see page \myppageref{sech2dtools}) | 
|---|
| 632 | \item[] {\bf PIContourTools}  activated using {\tt $<$Alt$>$O} or through the PIDrawerTools | 
|---|
| 633 | for an active PIContourDrawer  drawer.  (see page \myppageref{secconttools}) | 
|---|
| 634 | \end{itemize} | 
|---|
| 635 | These control tools are briefly described in appendix. | 
|---|
| 636 |  | 
|---|
| 637 | %%%%%%%%%% | 
|---|
| 638 | \subsection{Graphic attributes} | 
|---|
| 639 | Graphic attributes are specified as a set of space separated strings. Use | 
|---|
| 640 | quotes to group them into a single argument parsed by the command | 
|---|
| 641 | interpreter. The options are decoded by the different objects handling the | 
|---|
| 642 | graphic (viewer widget, drawer, axe drawer). \\ | 
|---|
| 643 | The complex decoding scheme is usually transparent for piapp users. | 
|---|
| 644 | However, there is an ambiguity when | 
|---|
| 645 | specifying some of the axes attributes, such as color or the font used for | 
|---|
| 646 | drawing the axes. The command {\bf setaxesatt}  (\myppageref{setaxesatt}) | 
|---|
| 647 | should thus be used to specify generic graphic attributes (color, font, line type) for axes. | 
|---|
| 648 |  | 
|---|
| 649 | \subsection{Complex 2D array display} | 
|---|
| 650 | A specific graphic attribute can be specified when displaying 2D arrays | 
|---|
| 651 | with complex numbers as their content. By default, the complex arrays are rendered | 
|---|
| 652 | using the modulus of the complex | 
|---|
| 653 | numbers ($\sqrt{\mathrm{real}(z)^2+\mathrm{imag}(z)^2}$), in particular for | 
|---|
| 654 | image and surface display {\tt (disp, imag, surf)}. It is however possible to change | 
|---|
| 655 | this behaviour by specifying the following graphic attributes: | 
|---|
| 656 | \begin{verbatim} | 
|---|
| 657 | cdreal : graphic rendering using the real(z) | 
|---|
| 658 | cdimag : graphic rendering using the imaginary part, imag(z) | 
|---|
| 659 | cdphase : graphic rendering using the phase, atan2(real,imag) | 
|---|
| 660 | cdmod : graphic rendering using the module. this is the defaut. | 
|---|
| 661 | cdmod2 : graphic rendering using the module squared (re^2+im^2) | 
|---|
| 662 |  | 
|---|
| 663 | ## Consider a complex matrix cmx | 
|---|
| 664 | piapp> disp cmx | 
|---|
| 665 | # will represent the module(cmx) in grey/color scale | 
|---|
| 666 | piapp> disp cmx 'cdphase' | 
|---|
| 667 | # will represent the phase(cmx) in grey/color scale | 
|---|
| 668 | \end{verbatim} | 
|---|
| 669 |  | 
|---|
| 670 |  | 
|---|
| 671 | \subsubsection{PIScDrawWdg} | 
|---|
| 672 | The {\bf PIScDrawWdg} which handles 2d graphics recognizes the following options: | 
|---|
| 673 | \begin{verbatim} | 
|---|
| 674 | >> To define the 2D axes limits (in user coordinates) | 
|---|
| 675 | xylimits=xmin,xmax,ymin,ymax | 
|---|
| 676 | >>  To define the default drawing rectangle, in fraction of widget size | 
|---|
| 677 | defdrrect=x1,x2,y1,y2  (default: x1=y1=0.1  x2=y2=0.9) | 
|---|
| 678 | >> Axes flags : | 
|---|
| 679 | linx  logx  : Linear or logarithmic scale for X Axis | 
|---|
| 680 | liny logy : Linear or logarithmic scale for Y Axis | 
|---|
| 681 | axerl : Set X axis direction  Right to Left (or revax) | 
|---|
| 682 | axeud : Set Y axis direction  Up to Down (or revay) | 
|---|
| 683 | axelr : AxeDirLtoR   axedu : AxeDirDownUp | 
|---|
| 684 | >> To change the background color (default=white) | 
|---|
| 685 | wbgcol=colname | 
|---|
| 686 |  | 
|---|
| 687 | \end{verbatim} | 
|---|
| 688 | %%% | 
|---|
| 689 | \subsubsection{PIDraw3DWdg} | 
|---|
| 690 | The {\bf PIDraw3DWdg} which handles 3d graphics recognizes the following options: | 
|---|
| 691 | \begin{verbatim} | 
|---|
| 692 | >> To define the 3D box limits : | 
|---|
| 693 | xyzlimits=xmin,xmax,ymin,ymax,zmin,zmax | 
|---|
| 694 | limit3dbox=xmin,xmax,ymin,ymax,zmin,zmax | 
|---|
| 695 | >> Autoscaling flags (rescaling of X/Y or X/Y/Z axes) | 
|---|
| 696 | autoscale3dbox  / noautoscale3dbox | 
|---|
| 697 | autoscalexy3dbox / noautoscalexy3dbox | 
|---|
| 698 | autoscalez3dbox / noautoscalez3dbox | 
|---|
| 699 | >> To change the background color (default=white) | 
|---|
| 700 | wbgcol=colname | 
|---|
| 701 |  | 
|---|
| 702 | \end{verbatim} | 
|---|
| 703 | %%% | 
|---|
| 704 | \subsubsection{PIImage} | 
|---|
| 705 | The {\bf PIImage} which handles image display recognizes the following options: | 
|---|
| 706 | \begin{verbatim} | 
|---|
| 707 | >> Define display zoomfactor | 
|---|
| 708 | zoomxFact     (zoomx2 zoomx3 ... zoomx9 ...) | 
|---|
| 709 | zoom/Fact  (zoom/2 zoom/3 ... ) | 
|---|
| 710 | >> LUT (look-up table) definition (pixel value to index conversion) | 
|---|
| 711 | lut=type,min,max   (type=lin/log/exp/sqrt/square) | 
|---|
| 712 | lut_type=rgb is reserved for true color image display | 
|---|
| 713 | >> AutoLut selector : define the method for automatic determination | 
|---|
| 714 | of LUT limits (min/max) | 
|---|
| 715 | autolut=alt[,ns[,minp,maxp]] (minp<=pixels<=maxp) | 
|---|
| 716 | - autolut=minmax[,Frac] 0<=Frac<=1 | 
|---|
| 717 | - autolut=meansig[,ns] --> mean +/- ns*sigma | 
|---|
| 718 | - autolut=hispeak[,ns] --> around the peak of pixel values histogram | 
|---|
| 719 | - autolut=histail[,ns] --> the tail of pixel values histogram | 
|---|
| 720 | - autolut=hisrng[,Frac[,minp,maxp]] 0<=Frac<=1 --> the central pixel values | 
|---|
| 721 | >> To display the color map with the LUT scale in the main image widget | 
|---|
| 722 | showcmap , showcmap=showcmap=no ,  showcmap=top | 
|---|
| 723 | showcmap=no/top/right/bottom/left/horiz/vert | 
|---|
| 724 | >> Define color table and reversing color indexing flag | 
|---|
| 725 | ColTableName     revcmap | 
|---|
| 726 | ==> Standard tables with 32 distinct colors: | 
|---|
| 727 | grey32  invgrey32 colrj32  colbr32  colrv32 | 
|---|
| 728 | ==> Standard tables with 128 distinct colors: | 
|---|
| 729 | grey128  invgrey128  colrj128  colbr128 | 
|---|
| 730 | ==> Shades of red/green/blue ... | 
|---|
| 731 | red32cm  green32cm  blue32cm  yellow32cm | 
|---|
| 732 | orange32cm cyan32cm violet32cm | 
|---|
| 733 | ==> Some of MIDAS color tables : | 
|---|
| 734 | midas_pastel  midas_heat  midas_rainbow3 | 
|---|
| 735 | midas_bluered  midas_bluewhite  midas_stairs8 | 
|---|
| 736 | midas_stairs9 midas_staircase midas_color | 
|---|
| 737 | midas_manycol  midas_idl14  midas_idl15 | 
|---|
| 738 | ==> Other tables | 
|---|
| 739 | multicol16 multicol64 | 
|---|
| 740 | ==> Other tables RGB component color map (lut_type=RGB) | 
|---|
| 741 | rgb216cm rgb512cm rgb4096cm rgb32768cm | 
|---|
| 742 | >> Viewed center position (image/array coordinates) | 
|---|
| 743 | imagecenter=xc,yc | 
|---|
| 744 | >> Array axes to window axes mapping flags | 
|---|
| 745 | invx  invy  exchxy | 
|---|
| 746 | >> To change the background color (default=black) | 
|---|
| 747 | wbgcol=colname | 
|---|
| 748 |  | 
|---|
| 749 | \end{verbatim} | 
|---|
| 750 | %%% | 
|---|
| 751 | \subsubsection{PIGraphicAtt} | 
|---|
| 752 | The {\bf PIGraphicAtt} Generic graphic attributes (color/font/line \ldots) | 
|---|
| 753 | decoded by all drawers: | 
|---|
| 754 | \begin{verbatim} | 
|---|
| 755 | >>> color=ColorName - fgcolor=ColorName - bgcolor=ColorName | 
|---|
| 756 | ColorName: black white grey red blue green yellow | 
|---|
| 757 | magenta cyan turquoise navyblue orange | 
|---|
| 758 | siennared purple  limegreen gold violet | 
|---|
| 759 | violetred blueviolet darkviolet skyblue | 
|---|
| 760 | royalblue forestgreen orangered brown | 
|---|
| 761 | >>> line=DashType,LineWidth | 
|---|
| 762 | DashType: solid, dash, dotted, dashdotted   Width: 1,2,... | 
|---|
| 763 | >>> font=FontName,FontAtt,FontSize | 
|---|
| 764 | FontName: courier, helvetica, times, symbol | 
|---|
| 765 | FontAtt: roman, bold, italic, bolditalic | 
|---|
| 766 | FontSize: 6,8,10,12... (pts) - integer | 
|---|
| 767 | >>> marker=MarkerType,MarkerSize (MarkerSize: integer 3,5,7... | 
|---|
| 768 | MarkerType: dot, plus, cross, circle, fcircle, box, fbox | 
|---|
| 769 | triangle, ftriangle, star, fstar | 
|---|
| 770 | >>> arrow=ArrowType,ArrowSize (ArrowSize: integer 3,5,7... | 
|---|
| 771 | ArrowType: basic, triangle, ftriangle, | 
|---|
| 772 | arrowshaped, farrowshaped | 
|---|
| 773 | >>> ColorTables: defcmap  grey32  invgrey32  colrj32  colbr32 | 
|---|
| 774 | grey128  invgrey128  colrj128  colbr128 | 
|---|
| 775 | red32cm  green32cm  blue32cm  yellow32cm | 
|---|
| 776 | orange32cm cyan32cm violet32cm | 
|---|
| 777 | midas_pastel midas_heat midas_rainbow3 midas_bluered | 
|---|
| 778 | midas_bluewhite midas_redwhite | 
|---|
| 779 | multicol16 multicol64 | 
|---|
| 780 | rgb216cm rgb512cm rgb4096cm rgb32768cm | 
|---|
| 781 | >   revcmap : This flag reverses ColorMap indexing | 
|---|
| 782 | ------- Old style graphic att ---------- | 
|---|
| 783 | >> Lines:  defline normalline thinline thickline dashedline thindashedline | 
|---|
| 784 | thickdashedline dottedline thindottedline thickdottedline | 
|---|
| 785 | >> Font Att: deffontatt normalfont boldfont italicfont bolditalicfont | 
|---|
| 786 | smallfont smallboldfont smallitalicfont smallbolditalicfont | 
|---|
| 787 | bigfont bigboldfont bigitalicfont bigbolditalicfont | 
|---|
| 788 | hugefont  hugeboldfont hugeitalicfont hugebolditalicfont | 
|---|
| 789 | >> Font Names: deffont courierfont helveticafont timesfont symbolfont | 
|---|
| 790 | >> Marker: dotmarker<S>  plusmarker<S>  crossmarker<S> circlemarker <S> | 
|---|
| 791 | fcirclemarker<S> boxmarker<S> fboxmarker<S> trianglemarker<S> | 
|---|
| 792 | ftrianglemarker<S>  starmarker<S>  fstarmarker<S> | 
|---|
| 793 | with <S> = 1 3 5 7 9 , Example fboxmarker5 , plusmarker9 ... | 
|---|
| 794 |  | 
|---|
| 795 | \end{verbatim} | 
|---|
| 796 | %%%% | 
|---|
| 797 | \subsubsection{PIElDrawer} | 
|---|
| 798 | The {\bf PIElDrawer} decodes axe drawing attributes: | 
|---|
| 799 | \begin{verbatim} | 
|---|
| 800 | >> Axe and grid configuration flags: | 
|---|
| 801 | axesnone  stdaxes defaxes | 
|---|
| 802 | boxaxes boxaxesgrid fineaxes fineaxesgrid | 
|---|
| 803 | centeredaxes finecenteredaxes centeredaxesgrid | 
|---|
| 804 | finecenteredaxesgrid  grid/nogrid | 
|---|
| 805 | >> Centered axes position: axescenter=xc,yc | 
|---|
| 806 | >> Axe ticks/labels (h=horizontal/x, v=vertical/y): | 
|---|
| 807 | labels/nolabels  hlabels/nohlabels vlabels/novlabels | 
|---|
| 808 | ticks/noticks minorticks/nominorticks | 
|---|
| 809 | extticks/intticks/extintticks nbticks=X_NbTicks,Y_NbTicks | 
|---|
| 810 | tickslen=MajorTickLenFrac,MinorTickLenFraC | 
|---|
| 811 | >> Axe label font size: | 
|---|
| 812 | autofontsize=FontSizeFrac fixedfontsize | 
|---|
| 813 | >> Up/Down title: title tit notitle notit | 
|---|
| 814 | ... Color/Font/line attributes : | 
|---|
| 815 |  | 
|---|
| 816 | \end{verbatim} | 
|---|
| 817 | The {\bf PINTuple} handles most 2D plotting : \\ | 
|---|
| 818 | \begin{verbatim} | 
|---|
| 819 | sta,stat,stats:            activate   statistic display | 
|---|
| 820 | nsta,nstat,nostat,nostats: deactivate statistic display | 
|---|
| 821 | statposoff=OffsetX,OffsetY : Position offset for Stats drawing | 
|---|
| 822 | as a fraction of total size | 
|---|
| 823 | connectpoints: The points are connected by a line | 
|---|
| 824 | noconnectpoints (this is the default) | 
|---|
| 825 | colorscale/nocolorscale (Use color scale for weight) | 
|---|
| 826 | sizescale/sizescale=nbins/nosizescale (Use marker size for weight) | 
|---|
| 827 | (and usual color/line/marker/... attribute decoding) | 
|---|
| 828 |  | 
|---|
| 829 | \end{verbatim} | 
|---|
| 830 | %%% | 
|---|
| 831 | \subsubsection{PIHisto, PIHisto2D} | 
|---|
| 832 | {\bf PIHisto} and {\bf PIHisto2D} handle1D and 2D histograms display. \\ | 
|---|
| 833 | The following options are recognised by {\bf PIHisto}: \\ | 
|---|
| 834 | \begin{verbatim} | 
|---|
| 835 | ---- PIHisto options help info : | 
|---|
| 836 | sta,stat,stats:            activate   statistic display | 
|---|
| 837 | nsta,nstat,nostat,nostats: deactivate statistic display | 
|---|
| 838 | err / noerr,nerr : draw, do not draw error bars | 
|---|
| 839 | autoerr : draw error bars if Marker drawing requested OR Profile histo | 
|---|
| 840 | fill / nofill,nfill : fill, do not fill bars with selected color | 
|---|
| 841 | statposoff=OffsetX,OffsetY : Position offset for Stats drawing | 
|---|
| 842 | as a fraction of total size | 
|---|
| 843 | ---- HistoWrapper options : | 
|---|
| 844 | hbincont: select bin content as Y value for display (default) | 
|---|
| 845 | hbinerr: select bin error as Y value for display | 
|---|
| 846 | hbinent: select bin entries as Y value for display | 
|---|
| 847 | hscale=value : multiplicative factor for Y value | 
|---|
| 848 | hoffset=value : additive coefficient for Y value | 
|---|
| 849 | hs1: set hscale=1 hoffset=0  (default) | 
|---|
| 850 | hscale=value  : multiplicative factor (in Y) | 
|---|
| 851 |  | 
|---|
| 852 | \end{verbatim} | 
|---|
| 853 | The following options are recognised by {\bf PIHisto2D}: \\ | 
|---|
| 854 | \begin{verbatim} | 
|---|
| 855 | - sta,stat,stats:            activate   statistic display | 
|---|
| 856 | nsta,nstat,nostat,nostats: deactivate statistic display | 
|---|
| 857 | - h2disp=typ[,fracpts]: choose display type | 
|---|
| 858 | typ=var: variable size boxes | 
|---|
| 859 | typ=hbk: "a la hbook2" | 
|---|
| 860 | typ=img: image like (use "h2col" for color map) | 
|---|
| 861 | typ=pts: point clouds (fracpts=max possible fraction | 
|---|
| 862 | of used pixels per bin [0,1]) | 
|---|
| 863 | - h2scale=lin/log[,logscale]: choose linear or logarithmic scale | 
|---|
| 864 | - h2dyn=[hmin][,hmax]: choose histogramme range for display | 
|---|
| 865 | - use general key to define color table (ex: grey32,midas_heat,...) | 
|---|
| 866 | (see general graphicatt description) | 
|---|
| 867 | - use key "revcmap" to reverse color table | 
|---|
| 868 | - h2frac=[fmin][,fmax]: choose sub-range display [0,1] | 
|---|
| 869 | ---- HistoWrapper options : (see HistoWrapper above) | 
|---|
| 870 |  | 
|---|
| 871 | \end{verbatim} | 
|---|
| 872 | %%%% | 
|---|
| 873 | \subsubsection{PINTuple3D , PISurfaceDrawer} | 
|---|
| 874 | The {\bf PINTuple3D} and {\bf PISurfaceDrawer} | 
|---|
| 875 | handles basic 3D plotting and can decode the common 3D box options: | 
|---|
| 876 | \begin{verbatim} | 
|---|
| 877 | X/Y,Z axis rescaling option (-> cubic 3D box) | 
|---|
| 878 | rescale=autoscale/ norescale=noautoscale : X/Y and Z axis | 
|---|
| 879 | rescalexy=autoscalexy / norescalexy=noautoscalexy : X/Y  axis | 
|---|
| 880 | rescalexy=autoscalexy / norescalexy=noautoscalexy : Z axis | 
|---|
| 881 | \end{verbatim} | 
|---|
| 882 | The {\bf PINTuple3D} decodes in addition the following options: | 
|---|
| 883 | \begin{verbatim} | 
|---|
| 884 | connectpoints: The points are connected by a line | 
|---|
| 885 | noconnectpoints (this is the default) | 
|---|
| 886 | colorscale/nocolorscale (Use color scale for weight) | 
|---|
| 887 | sizescale/sizescale=nbins/nosizescale (Use marker size for weight) | 
|---|
| 888 |  | 
|---|
| 889 | \end{verbatim} | 
|---|
| 890 |  | 
|---|
| 891 | \subsubsection{PIContourDrawer} | 
|---|
| 892 | The {\bf PIContourDrawer} decodes the following options :  \\ | 
|---|
| 893 | \begin{verbatim} | 
|---|
| 894 | autolevels : automatic selection of levels and number of contours | 
|---|
| 895 | ncont=nLevel (or nc=NLevel) : sets the number of contour | 
|---|
| 896 | lev=v1,v2,v3... (or niv=v1,v2,v3...) set the number and levels of contours | 
|---|
| 897 | lstep=nLev,start,step : define incremental levels | 
|---|
| 898 | labon/laboff : display of contour level values on/off | 
|---|
| 899 | linear/bspline/cubicspl=3spl : select contour kind | 
|---|
| 900 |  | 
|---|
| 901 | \end{verbatim} | 
|---|
| 902 |  | 
|---|
| 903 | \subsubsection{PIBarGraph , PITextDrawer} | 
|---|
| 904 | {\bf PIBarGraph} is used by the {\tt bargraph} \myppageref{bargraph} | 
|---|
| 905 | command and has the following graphic options: | 
|---|
| 906 | \begin{verbatim} | 
|---|
| 907 | ---- PIBarGraph options help info : | 
|---|
| 908 | fill/nofill: set bar fill option | 
|---|
| 909 | horizontalbars/verticalbars: set bar orientation | 
|---|
| 910 | packfrac=value : set bar packing fraction (0..1) | 
|---|
| 911 | barvaluelabel/nobarvaluelabel: Use/Don't use bar value as labels | 
|---|
| 912 | --- + Usual colr/line/font  attribute decoding ... | 
|---|
| 913 | \end{verbatim} | 
|---|
| 914 | The command {\tt textdrawer} \myppageref{textdrawer} uses the | 
|---|
| 915 | {\bf PITextDrawer} which has the following options : \\ | 
|---|
| 916 | \hspace*{10mm} {\tt frame,noframe: enable/disable frame drawing} | 
|---|
| 917 |  | 
|---|
| 918 |  | 
|---|
| 919 | %%%%%%%%%%%%%%% Section 4 :   I/O | 
|---|
| 920 | \newpage | 
|---|
| 921 | \section{Data formats and input-output (I/O)} | 
|---|
| 922 | The data file formats recognized by piapp are the ones supported by the | 
|---|
| 923 | SOPHYA library or its extension. | 
|---|
| 924 | \begin{itemize} | 
|---|
| 925 | \item[\bul] ASCII files - Data can be imported from ascii (text) files as | 
|---|
| 926 | datatables or arrays. These objects can also be exported as text files. | 
|---|
| 927 | \item[\bul] FITS files - FITS is a popular format used in particular in astronomy. | 
|---|
| 928 | \href{http://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html} | 
|---|
| 929 | Data is usually read from FITS files as vectors, images, cubes or tables. | 
|---|
| 930 | A subset of SOPHYA objects can be imported or exported in FITS format. | 
|---|
| 931 | \item[\bul] PPF (Portable Persistence file Format) is the native SOPHYA | 
|---|
| 932 | data format. | 
|---|
| 933 | \item[\bul] PostScript - All graphic output produced by piapp can be exported | 
|---|
| 934 | as postscript (.ps) or encapsulated postscript (.eps) files. | 
|---|
| 935 | \end{itemize} | 
|---|
| 936 |  | 
|---|
| 937 | \subsection{Text files} | 
|---|
| 938 | Text (or ascii) files can be read into array or datatable objects by spiapp. | 
|---|
| 939 |  | 
|---|
| 940 | {\bf Arrays :} \\ | 
|---|
| 941 | Arrays can be written to to files in text/ascii format using the {\tt arrtoascii} | 
|---|
| 942 | \myppageref{arrtoascii} command. Double precision matrices and vectors | 
|---|
| 943 | can be read from text files using the commands | 
|---|
| 944 | {\tt mtxfrascii}  \myppageref{mtxfrascii} and | 
|---|
| 945 | {\tt vecfrascii}  \myppageref{vecfrascii} . \\ | 
|---|
| 946 | The menu-bar command  \menubar{File/Open-ASCII} reads in a text | 
|---|
| 947 | file as a matrix. | 
|---|
| 948 | \begin{verbatim} | 
|---|
| 949 | #  Create and initialize a matrix | 
|---|
| 950 | newmtx arr 250 150 x+3*y | 
|---|
| 951 | #  Save the file in the text file arr.txt | 
|---|
| 952 | arrtoascii arr arr.txt | 
|---|
| 953 | #  Read the previously created file and fill a matrix | 
|---|
| 954 | mtxfrascii mxa arr.txt | 
|---|
| 955 | #  Print and display the matrix | 
|---|
| 956 | print mxa | 
|---|
| 957 | disp mxa zoomx2 | 
|---|
| 958 | \end{verbatim} | 
|---|
| 959 | It is possible to specify the field separator in the input file, as well as the marker for the comment | 
|---|
| 960 | lines. | 
|---|
| 961 |  | 
|---|
| 962 | {\bf DataTable :} \\ | 
|---|
| 963 | Text files can also be read as a 2-D table (NTuple or DataTable). The table should be | 
|---|
| 964 | created using the  {\tt newnt} \myppageref{newnt}  or | 
|---|
| 965 | {\tt newdt} \myppageref{newdt} command. | 
|---|
| 966 | The command {\tt ntfrascii} \myppageref{ntfrascii} can then be used to append | 
|---|
| 967 | data from the file to the datatable. | 
|---|
| 968 |  | 
|---|
| 969 | \subsection{PPF} | 
|---|
| 970 | %%% | 
|---|
| 971 | PPF (Portable Persistence file Format) is the the native persistence | 
|---|
| 972 | format of SOPHYA and thus is fully handled by spiapp.   PPF files can | 
|---|
| 973 | be opened through the menu-bar  \menubar{File/Open-PPF}, or through | 
|---|
| 974 | the {\tt openppf} \myppageref{openppf}. | 
|---|
| 975 |  | 
|---|
| 976 | If the PPF file contains NameTags, only the objects marked with nametags are read and given | 
|---|
| 977 | the corresponding names. Otherwise, all objects are red sequentially, with their names | 
|---|
| 978 | formed by the filename followed by a sequence number. It is also possible to force the sequential | 
|---|
| 979 | reading specifying the {\tt -s} flag for openppf. | 
|---|
| 980 |  | 
|---|
| 981 | The objects managed in spiapp by the {\bf NamedObjMgr} can be saved to PPF files, with their | 
|---|
| 982 | names as NameTags. The commands {\tt saveppf} \myppageref{saveppf} or | 
|---|
| 983 | {\tt saveall} \myppageref{saveall} can be used to this end. | 
|---|
| 984 |  | 
|---|
| 985 | \begin{verbatim} | 
|---|
| 986 | # Create two vectors and two matrices | 
|---|
| 987 | newvec va1 150 sin(sqrt(x)) | 
|---|
| 988 | newvec vb2 150 sin(sqrt(x))*sqrt(x*0.1) | 
|---|
| 989 | newmtx mxa 250 150 x+2.*y | 
|---|
| 990 | newmtx mxb 250 150 sin(sqrt(x))*cos(sqrt(y)) | 
|---|
| 991 | # List of the objects in memory | 
|---|
| 992 | listobjs | 
|---|
| 993 | #  Save the two vectors in the file vecab.ppf | 
|---|
| 994 | saveppf v* vecab.ppf | 
|---|
| 995 | #  Save the two matrices in the file mxab.ppf | 
|---|
| 996 | saveppf m* mxab.ppf | 
|---|
| 997 | \end{verbatim} | 
|---|
| 998 |  | 
|---|
| 999 | \subsection{FITS} | 
|---|
| 1000 | FITS files may contain three types of data structures | 
|---|
| 1001 | \begin{enumerate} | 
|---|
| 1002 | \item Image or array data structure : {\tt IMAGE\_HDU} | 
|---|
| 1003 | \item Binary table : {\tt BINARY\_TBL} | 
|---|
| 1004 | \item ascii table : {\tt ASCII\_TBL} | 
|---|
| 1005 | \end{enumerate} | 
|---|
| 1006 | The {\bf FitsIOServer} module contain FitsHandler classes which | 
|---|
| 1007 | can map many SOPHYA classes on FITS data structures. | 
|---|
| 1008 | Generic {\tt IMAGE\_HDU} correspond to the SOPHYA \tcls{TArray} | 
|---|
| 1009 | class, while {\tt BINARY\_TBL} or {\tt ASCII\_TBL} is mapped | 
|---|
| 1010 | to NTuple or DataTable. | 
|---|
| 1011 |  | 
|---|
| 1012 | FITS format files can be read through the menu command \menubar{File/Open-Fits}, | 
|---|
| 1013 | or using {\tt readfits/openfits} \myppageref{readfits} command. The command | 
|---|
| 1014 | {\tt rdfitsarr} \myppageref{rdfitsarr} offer additional possibilities for reading | 
|---|
| 1015 | arrays from FITS IMAGE\_HDU, for example array type conversion. | 
|---|
| 1016 | Objects can be exported to FITS using the {\tt writefits/savefits} | 
|---|
| 1017 | \myppageref{writefits} command. | 
|---|
| 1018 |  | 
|---|
| 1019 | \begin{verbatim} | 
|---|
| 1020 | # Open the PPF file created by the commands above | 
|---|
| 1021 | openppf vecab.ppf | 
|---|
| 1022 | # Export the two vector objects to file vecab.fits | 
|---|
| 1023 | # Note that the '!' forces c-fitsio to overwrite the file, if it exists | 
|---|
| 1024 | writefits v?? !vecab.fits | 
|---|
| 1025 | \end{verbatim} | 
|---|
| 1026 |  | 
|---|
| 1027 | There are two commands useful | 
|---|
| 1028 | when analyzing large catalogs (BINARY\_TBL) in FITS format, which avoid reading the whole | 
|---|
| 1029 | table in memory. {\tt swfitstable}\myppageref{swfitstable} reads a specified HDU | 
|---|
| 1030 | as a {\bf SwFitsDataTable} object which uses the FITS file as swap space. | 
|---|
| 1031 | The {\tt fitsadapt}\myppageref{fitsadapt} can also be used for similar purposes. | 
|---|
| 1032 |  | 
|---|
| 1033 | The following commands shows how to open a FITS file containing a synchrotron map | 
|---|
| 1034 | of our galaxy. This file contains sky emission at 408 MHz, | 
|---|
| 1035 | as brightness temperature, represented as a SOPHYA spherical map | 
|---|
| 1036 | (SphereHEALPix$<$r\_4$>$) in \href{http://healpix.jpl.nasa.gov/}{\bf HEALPix} | 
|---|
| 1037 | format \footnote{HEALPix home page: \hspace{5mm} http://healpix.jpl.nasa.gov/}. | 
|---|
| 1038 | It has been made, by rebinning, from the Haslam 408 MHz | 
|---|
| 1039 | all sky survey map, available from the NASA CMB data repository | 
|---|
| 1040 | \href{http://lambda.gsfc.nasa.gov/}{\bf LAMBDA} | 
|---|
| 1041 | \footnote{LAMBDA web site: \hspace{5mm} http://lambda.gsfc.nasa.gov/}. | 
|---|
| 1042 | \label{syncmap} | 
|---|
| 1043 | \begin{verbatim} | 
|---|
| 1044 | #  Open the fits file : the map is in HEALPix format | 
|---|
| 1045 | readfits syncmap.fits | 
|---|
| 1046 | #  Create a window with the appropriate size | 
|---|
| 1047 | newwin 1 1 800 400 | 
|---|
| 1048 | # Display the map, specifying the colormap | 
|---|
| 1049 | disp syncmap 'lut=lin,2,50 midas_bluered' | 
|---|
| 1050 | \end{verbatim} | 
|---|
| 1051 | \begin{figure}[h] | 
|---|
| 1052 | \begin{center} | 
|---|
| 1053 | \includegraphics[width=15cm]{syncmap.eps} | 
|---|
| 1054 | \caption{Synchron map of our Galaxy, displayed in Molleweide projection. | 
|---|
| 1055 | The underlying SOPHYA object is a \tcls{SphereHEALPix} } | 
|---|
| 1056 | \end{center} | 
|---|
| 1057 | \end{figure} | 
|---|
| 1058 |  | 
|---|
| 1059 | \subsection{Graphic export in postscript} | 
|---|
| 1060 | %% | 
|---|
| 1061 | Postscript a page description language widely used for printing and | 
|---|
| 1062 | graphic output, developed by Adobe systems. Refer to | 
|---|
| 1063 | \href{http://www.adobe.com/products/postscript/}{Adobe/PostScript3} | 
|---|
| 1064 | for more detail. | 
|---|
| 1065 |  | 
|---|
| 1066 | Piapp graphic output can be exported in postscript (level 2) or | 
|---|
| 1067 | encapsulated postscript format, preserving the full precision | 
|---|
| 1068 | of vector graphics. | 
|---|
| 1069 | Postscript (.ps) files my contain several pages, each vue or window | 
|---|
| 1070 | corresponding to one page and are suitable for direct printing. | 
|---|
| 1071 | An Encapsulated Postscript (.eps) file contains a single page, | 
|---|
| 1072 | corresponding to a window and is suitable for inclusion in | 
|---|
| 1073 | other document. | 
|---|
| 1074 |  | 
|---|
| 1075 | Postscript file can easily be converted to other formats, | 
|---|
| 1076 | PDF or image formats (jpeg \ldots) using converters like | 
|---|
| 1077 | {\bf ps2pdf} or {\bf imagemagick}. | 
|---|
| 1078 |  | 
|---|
| 1079 | The menu items under \menubar{PostScript} can be used to export | 
|---|
| 1080 | graphics in postscript. The default file name is {\tt pia.ps} | 
|---|
| 1081 | or {\tt pia1.eps} {\tt pia2.eps} \ldots | 
|---|
| 1082 | The following commands can also be used to create postscriot file | 
|---|
| 1083 | from the display in the current graphic window: | 
|---|
| 1084 | \begin{itemize} | 
|---|
| 1085 | \item {\tt w2ps} \myppageref{w2ps} to add the current graphic | 
|---|
| 1086 | output as a new page to the output postscript file. | 
|---|
| 1087 | The current output postscript file (default = w2ps.ps) | 
|---|
| 1088 | should be closed before being used. Exiting piapp closes automatically | 
|---|
| 1089 | all postscript files. | 
|---|
| 1090 | \item {\tt psclosefile} \myppageref{psclosefile} to close the current | 
|---|
| 1091 | output postscript file. | 
|---|
| 1092 | \item {\tt pssetfilename} \myppageref{pssetfilename} To define | 
|---|
| 1093 | the output postscript file name for the subsequent {\tt w2ps} commands. | 
|---|
| 1094 | \item {\tt w2eps} \myppageref{w2eps} to export the current | 
|---|
| 1095 | graphic display, in Encapsulated Postscript format to the specified file. | 
|---|
| 1096 | \begin{verbatim} | 
|---|
| 1097 | # Open the PPF file created by the commands above | 
|---|
| 1098 | openppf vecab.ppf | 
|---|
| 1099 | # Display one of the vectors | 
|---|
| 1100 | setaxesatt 'font=helvetica,bold,18 fixedfontsize' | 
|---|
| 1101 | disp va1 'blue marker=box,5' | 
|---|
| 1102 | #  Export the graphic to file va1.eps | 
|---|
| 1103 | w2eps va1.eps | 
|---|
| 1104 | #  The created file can be viewed using gv | 
|---|
| 1105 | \end{verbatim} | 
|---|
| 1106 | \end{itemize} | 
|---|
| 1107 |  | 
|---|
| 1108 | \subsection{RGB pixel files} | 
|---|
| 1109 | Graphics displayed in piapp windows and widgets (in PIImage, PIScDrawWdg, PIDraw3DWdg) | 
|---|
| 1110 | can be exported in a PI-specific image format coding the RGB (Red/Green/Blue) intensities | 
|---|
| 1111 | of each pixel. The commands {\tt wdg2rgb} \myppageref{ wdg2rgb } and | 
|---|
| 1112 | {\tt wdg2rgb} \myppageref{ win2rgb } can be used to export graphics to PI-RGB | 
|---|
| 1113 | files. The content of PI-RGB  files can be read back and displayed using the | 
|---|
| 1114 | command {\tt pirgbdisp} \myppageref{pirgbdisp}. | 
|---|
| 1115 | It is also possible to compute  RGB images and save in this format, for example | 
|---|
| 1116 | for creating a false color composite image, from a set of intensity coded images | 
|---|
| 1117 | in three wavebands. Check the class {\bf PIPixRGBArray} in the file (PI/pipixutils.h) for | 
|---|
| 1118 | more information on PI-RGB format. | 
|---|
| 1119 |  | 
|---|
| 1120 | The {\bf PIPhoto} add-on package  can be used to convert PI-RGB images to/from | 
|---|
| 1121 | standard image formats (gif, jpeg \ldots). The {\bf PIPhoto} module uses the | 
|---|
| 1122 | ImageMagick libraries. It contains also a piapp loadable module which extends | 
|---|
| 1123 | the piapp possibilities through a set of commands for reading, writing and | 
|---|
| 1124 | manipulating standard image formats in piapp. | 
|---|
| 1125 |  | 
|---|
| 1126 |  | 
|---|
| 1127 |  | 
|---|
| 1128 |  | 
|---|
| 1129 | %%%%%%%%%%%%%%% Section 5 :   analyse a la paw | 
|---|
| 1130 | \newpage | 
|---|
| 1131 | \section{Tables and Expression Plotting} | 
|---|
| 1132 | \label{tableplot} | 
|---|
| 1133 | A powerful data analysis technic available in piapp is | 
|---|
| 1134 | 2D, 3D plot, and histogramming applied to arbitrary analytical | 
|---|
| 1135 | expression of table columns. | 
|---|
| 1136 | This analysis technic has been introduced by the popular | 
|---|
| 1137 | CERN \href{http://paw.web.cern.ch/paw/}{\bf PAW} | 
|---|
| 1138 | ({\bf P}hysics {\bf A}nalysis {\bf Workstation}) | 
|---|
| 1139 | \footnote{PAW home page : http://paw.web.cern.ch/paw/ } program | 
|---|
| 1140 | and the underlying HBOOK fortran library. | 
|---|
| 1141 | Compared to PAW, piapp extends in many respects this capability, | 
|---|
| 1142 | piapp offers in particular the possibility to manipulate many | 
|---|
| 1143 | objects as if they where a DataTable, or NTuple. | 
|---|
| 1144 | There are also additional 2D and 3D representations e.g. | 
|---|
| 1145 | {\tt plot2de} \myppageref{plot2de}, | 
|---|
| 1146 | {\tt plot2dw} \myppageref{plot2dw}, | 
|---|
| 1147 | {\tt plot2dc} \myppageref{plot2dc} and | 
|---|
| 1148 | {\tt plot3dw} \myppageref{plot3dw}. | 
|---|
| 1149 |  | 
|---|
| 1150 | \subsection{How does it work ?} | 
|---|
| 1151 |  | 
|---|
| 1152 | The Expression.Plotting commands in piapp operate on objects through the | 
|---|
| 1153 | {\bf NTupleInterface} class methods. Some classes like NTuple or BaseDataTable | 
|---|
| 1154 | inherit from NTupleInterface, while for the other classes, the corresponding | 
|---|
| 1155 | NObjMgrAdapter class exposes an object conforming to NTupleInterface through the | 
|---|
| 1156 | method : \\ | 
|---|
| 1157 | \hspace*{5mm} {\tt  NTupleInterface* NObjMgrAdapter::GetNTupleInterface()} \\ | 
|---|
| 1158 | A C file (PIATmp\_xxx/expf\_pia\_dl.c) is created by piapp containing the | 
|---|
| 1159 | specified expressions, which should conform to the C-language syntax. | 
|---|
| 1160 | In addition to the functions in {\tt math.h} (sin, cos, log \ldots), | 
|---|
| 1161 | the following functions are defined by piapp and can be used: | 
|---|
| 1162 | \begin{itemize} | 
|---|
| 1163 | \item Flat random number generators: {\tt drand01() , drandpm1() } | 
|---|
| 1164 | \item Gaussian random number generator: {\tt GauRand() } | 
|---|
| 1165 | \item Angle conversion: {\tt deg2rad(double d), rad2deg(double r) } | 
|---|
| 1166 | \item $(\theta,\varphi)$ to Molleweide X,Y projection: \\ | 
|---|
| 1167 | \hspace*{5mm}{\tt double tetphi2mollX(double theta, double phi)} \\ | 
|---|
| 1168 | \hspace*{5mm}{\tt double tetphi2mollY(double theta)} | 
|---|
| 1169 | \item Longitude(0..360) deg., Latitude(-90..90) deg. conversion to Molleweide X,Y: \\ | 
|---|
| 1170 | \hspace*{5mm}{\tt double longlat2mollX(double longit, double lat) } \\ | 
|---|
| 1171 | \hspace*{5mm}{\tt double longlat2mollY(double lat) } | 
|---|
| 1172 | \end{itemize} | 
|---|
| 1173 |  | 
|---|
| 1174 | The processing steps for an Expression.Plotting in piapp : | 
|---|
| 1175 | \begin{enumerate} | 
|---|
| 1176 | \item Creation of the C-file. | 
|---|
| 1177 | \item On the fly compilation of the generated file. | 
|---|
| 1178 | \item The resulting shared-object is loaded and linked with the application | 
|---|
| 1179 | \item Loop over the NTupleInterface object rows. The created function is called | 
|---|
| 1180 | with the data from each row | 
|---|
| 1181 | \item The return values are used to fill an histogram, or a matrix/vector or | 
|---|
| 1182 | another NTuple or to produce a 2D or 3D graphic display. | 
|---|
| 1183 | \end{enumerate} | 
|---|
| 1184 |  | 
|---|
| 1185 | Although rather complex, the efficiency gain during processing data easily compensates | 
|---|
| 1186 | for the overhead of the compilation step. | 
|---|
| 1187 |  | 
|---|
| 1188 | \subsection{Column/variable names} | 
|---|
| 1189 |  | 
|---|
| 1190 | When working with real 2-D tables (NTuple, DataTable \ldots), the column names | 
|---|
| 1191 | are the name of the variables which can be used in the C-expressions. | 
|---|
| 1192 | There is an additional variable, called {\tt \_nl}, automatically | 
|---|
| 1193 | provided by piapp, corresponding the table row number, starting from 0. | 
|---|
| 1194 |  | 
|---|
| 1195 | For the other objects in piapp, the variable names are listed below: | 
|---|
| 1196 | \begin{itemize} | 
|---|
| 1197 | \item[\rond] For 2D table objects {\bf (NTuple,DataTable,\ldots)}:  ColumnNames,\_nl | 
|---|
| 1198 | \item[\rond] For FITS files opened through {\tt fitsadapt} command: FITSColumnNames,\_nl | 
|---|
| 1199 | \item[\rond] For {\bf Histo1D/HProf} objects : i,x,val,err,nb,\_nl | 
|---|
| 1200 | \item[\rond] For {\bf Histo2D} objects : i,j,x,y,val,err,\_nl | 
|---|
| 1201 | \item[\rond] For {\bf HistoErr} objects : i,x,val,err2,nb,\_nl | 
|---|
| 1202 | \item[\rond] For {\bf Histo2DErr} objects : i,j,x,y,val,err2,nb,\_nl | 
|---|
| 1203 | \item[\rond] For {\bf \tcls{TVector}, \tcls{TMatrix} , \tcls{Image} } objects : \\ | 
|---|
| 1204 | \hspace*{10mm}  n,r,c,val,real,imag,mod,phas,\_nl | 
|---|
| 1205 | \item[\rond] For {\bf \tcls{TArray}} objects : n,x,y,z,t,u,val,real,imag,mod,phas,\_nl | 
|---|
| 1206 | \item[\rond] For {\bf GeneralFitData} objects : x0,ex0 x1,ex1 ...  xn,exn  y,ey ,ok,\_nl | 
|---|
| 1207 | \item[\rond] For {\bf \tcls{SphereHEALPix} , \tcls{SphereThetaPhi} , \tcls{SphereECP} | 
|---|
| 1208 | \tcls{LocalMap} } objects : \hspace{10mm} i,k,val,real,imag,mod,phas,teta,phi,\_nl | 
|---|
| 1209 | \end{itemize} | 
|---|
| 1210 |  | 
|---|
| 1211 | %%%%% | 
|---|
| 1212 | \subsection{Examples} | 
|---|
| 1213 | The following examples illustrates the use of some Expression Plotting commands | 
|---|
| 1214 | (see the command groups {\bf Expr. Plotting} \myppageref{ExprZZPlotting} and | 
|---|
| 1215 | {\bf pawCmd} \myppageref{pawCmd}). | 
|---|
| 1216 | The {\bf pawCmd} defines a number of operations with command name and syntax | 
|---|
| 1217 | similar to the CERN PAW program. | 
|---|
| 1218 | The graphic output from the examples below are shown in the figures | 
|---|
| 1219 | \ref{exhis2dpl} and \ref{uzcpos}. | 
|---|
| 1220 | \begin{enumerate} | 
|---|
| 1221 | \item 2D plot with error bars \\[1mm] | 
|---|
| 1222 | \begin{verbatim} | 
|---|
| 1223 | # Set the axes attibute (the font used for axes ...) | 
|---|
| 1224 | setaxesatt 'font=helvetica,bold,16 minorticks fixedfontsize' | 
|---|
| 1225 | #  Open the file demo.ppf (in DemoPIApp) | 
|---|
| 1226 | openppf demo.ppf | 
|---|
| 1227 | print nt21 | 
|---|
| 1228 | print nt22 | 
|---|
| 1229 | # 2D plot directly from the NTuple columns (nt2d) | 
|---|
| 1230 | # nt2d DO NOT use a compiled c file | 
|---|
| 1231 | nt2d nt21 x y - - - - 'font=helvetica,bold,16' | 
|---|
| 1232 | # Overlay a plot with scaled error bars from nt22 | 
|---|
| 1233 | plot2de nt22 x y ex*0.3 ey*0.5 1 \ | 
|---|
| 1234 | 'same marker=box,7 red font=helvetica,bold,16 ' | 
|---|
| 1235 | \end{verbatim} | 
|---|
| 1236 | \vspace*{4mm} | 
|---|
| 1237 | \item Compute the histogram of pixel values for a \tcls{SphreHEALPix}. | 
|---|
| 1238 | The data come from the synchrotron map (syncmap.fits), described page \pageref{syncmap}. | 
|---|
| 1239 | \begin{verbatim} | 
|---|
| 1240 | # Open the synchrotron map file (HEALPix format spherical map) | 
|---|
| 1241 | # The file can be found in directory DemoData/ | 
|---|
| 1242 | readfits syncmap.fits | 
|---|
| 1243 | newwin 1 1 800 400 | 
|---|
| 1244 | disp syncmap 'lut=lin,2,50 midas_bluered' | 
|---|
| 1245 | newwin 1 2 | 
|---|
| 1246 | # Compute and display the pixel value histogram (brightness temperature) | 
|---|
| 1247 | n/plot syncmap.val val<200 ! ! 'font=helvetica,bold,16 notit' | 
|---|
| 1248 | settitle 'Sky brightness @ 408 MHz' ' ' 'font=helvetica,bold,16' | 
|---|
| 1249 | # display the pixel value histogram in the galactic plane | 
|---|
| 1250 | n/plot syncmap.val val<200&&(fabs(teta-M_PI/2)<0.025) ! ! 'red notit' | 
|---|
| 1251 | settitle '408 MHz - Galactic plane' ' ' 'font=helvetica,bold,16 red' | 
|---|
| 1252 | \end{verbatim} | 
|---|
| 1253 | \vspace*{4mm} | 
|---|
| 1254 | \item Sources (galaxies) distribution over the sky. The data used below (uzc.ppf) | 
|---|
| 1255 | has been extracted from the {\bf U}pdated {\bf Z}wicky {\bf C}atalog of Galaxies, | 
|---|
| 1256 | available from the Harvard-Smithsonian Center For Astrophysics | 
|---|
| 1257 | \href{http://tdc-www.harvard.edu/uzc/}{CfA/UZC web site}. | 
|---|
| 1258 | \footnote{CfA web site: \hspace{5mm} http://tdc-www.harvard.edu/uzc/} \\[1mm] | 
|---|
| 1259 | %%% | 
|---|
| 1260 | \begin{verbatim} | 
|---|
| 1261 | #  Keep the synchrotron map | 
|---|
| 1262 | #  Open the Updated Zwicky Catalog of galaxies (in DemoData) | 
|---|
| 1263 | openppf uzc.ppf | 
|---|
| 1264 | zone 1 2 | 
|---|
| 1265 | # Draw a longitude-latitude grid in Molleweide projection | 
|---|
| 1266 | mollgrid 5 7 'axesnone black font=helvetica,roman,12 notit' | 
|---|
| 1267 | # Overlay the sources distribution from UZC, for bright objects (mag<14) | 
|---|
| 1268 | plot2d uzc longlat2mollX(ra*15,dec) longlat2mollY(dec) mag<14 \ | 
|---|
| 1269 | 'same red marker=circle,5' | 
|---|
| 1270 | # Change the plot title | 
|---|
| 1271 | settitle 'RA-Dec in degrees UZC (Updated Zwicky Catalog)' ' ' \ | 
|---|
| 1272 | 'font=helvetica,bold,16 red' | 
|---|
| 1273 | # Display the synchrotron map | 
|---|
| 1274 | disp syncmap 'lut=lin,2,40 grey128' | 
|---|
| 1275 | # Add the source distribution in Galactic coordinates | 
|---|
| 1276 | plot2d uzc longlat2mollX(glong,glat) longlat2mollY(glat) mag<14  \ | 
|---|
| 1277 | 'same nsta red marker=circle,5' | 
|---|
| 1278 | \end{verbatim} | 
|---|
| 1279 | %%%%%%%%%%%%%%%% | 
|---|
| 1280 | %%%%%%%%%%%%%%%% | 
|---|
| 1281 | \item Analysis of elevation (altitude) data for france. We use the francetopo.ppf | 
|---|
| 1282 | data set described page \pageref{francetopo}. | 
|---|
| 1283 | \begin{verbatim} | 
|---|
| 1284 | # open and display the topographic data for france | 
|---|
| 1285 | openppf francetopo.ppf (in DemoData/ directory) | 
|---|
| 1286 | print francetoto | 
|---|
| 1287 | #--- TMatrix<s>(NRows=1332, NCols=1548) ND=2 SizeX*Y*...= 1548x1332 --- | 
|---|
| 1288 | disp francetopo 'zoom/2 imagecenter=750,700 lut=lin,-700,800 colbr128' | 
|---|
| 1289 | #  Compute the altitude distribution | 
|---|
| 1290 | newh1d altf 0. 4000 100 | 
|---|
| 1291 | projh1d altf francetopo val val>0.1 | 
|---|
| 1292 | # Display the histogram overlayed on the topographic map | 
|---|
| 1293 | disp altf 'white line=solid,2 font=helvetica,bold,14 inset=0.1,0.6,0.45,0.9' | 
|---|
| 1294 | # Compute altitude distribution for the massif central (Auvergne) | 
|---|
| 1295 | newh1d altmc 0. 2000 100 | 
|---|
| 1296 | # We select the region as a circle of radius 200, centered on x=c=970,y=r=920 | 
|---|
| 1297 | set regcut (sqrt((c-970)*(c-970)+(r-920)*(r-920))<200) | 
|---|
| 1298 | projh1d altmc francetopo val (val>0.1)&&$regcut | 
|---|
| 1299 | # Create a new window and display the two histograms | 
|---|
| 1300 | newwin 1 2 | 
|---|
| 1301 | setaxesatt 'font=helvetica,bold,16 fixedfontsize' | 
|---|
| 1302 | disp altf 'notit' | 
|---|
| 1303 | settitle 'Elevation (altitude) distribution over France' ' ' \ | 
|---|
| 1304 | 'font=helvetica,bold,16' | 
|---|
| 1305 | disp altmc 'notit' | 
|---|
| 1306 | settitle 'Elevation (altitude) distribution over MassifCentral' ' ' \ | 
|---|
| 1307 | 'font=helvetica,bold,16' | 
|---|
| 1308 | \end{verbatim} | 
|---|
| 1309 | \end{enumerate} | 
|---|
| 1310 |  | 
|---|
| 1311 | \begin{figure}[hp] | 
|---|
| 1312 | \includegraphics[width=15cm]{exhis2dpl.eps} | 
|---|
| 1313 | \caption{ | 
|---|
| 1314 | top: 2d plot example with error bars \hspace{5mm} | 
|---|
| 1315 | bottom: Histogram of pixel values from the synchrotron map | 
|---|
| 1316 | of our galaxy} | 
|---|
| 1317 | \label{exhis2dpl} | 
|---|
| 1318 | \end{figure} | 
|---|
| 1319 |  | 
|---|
| 1320 | \begin{figure}[p] | 
|---|
| 1321 | \includegraphics[width=15cm]{uzcpos.eps} | 
|---|
| 1322 | \caption{UZC: Updated Zwicky Catalog. \hspace{5mm} | 
|---|
| 1323 | top: The galaxy position distribution in equatorial | 
|---|
| 1324 | $(\alpha, \delta)$ coordinates. \hspace{5mm} | 
|---|
| 1325 | bottom: Position distribution in Galactic coordinates, superimposed on | 
|---|
| 1326 | the synchrotron map.} | 
|---|
| 1327 | \label{uzcpos} | 
|---|
| 1328 | \end{figure} | 
|---|
| 1329 |  | 
|---|
| 1330 | %%%%%%%%%%%%%%% Section 6 :  command interpreter | 
|---|
| 1331 | \newpage | 
|---|
| 1332 | \section{Command interpreter} | 
|---|
| 1333 | piapp uses the class {\bf PIACmd} which extends slightly the | 
|---|
| 1334 | SOPHYA class {\bf Commander} as the command interpreter. | 
|---|
| 1335 | {\bf Commander} is a  c-shell inspired, string oriented command | 
|---|
| 1336 | interpreter.  Although it has many limitations compared to | 
|---|
| 1337 | c-shell, or Tcl , it provides some interesting possibilities: | 
|---|
| 1338 | \begin{itemize} | 
|---|
| 1339 | \item Extended arithmetic operations (c-like and RPN) | 
|---|
| 1340 | \item Simple and vector variables | 
|---|
| 1341 | \item Script definition | 
|---|
| 1342 | \item Command execution in separate threads | 
|---|
| 1343 | \item Dynamic Load | 
|---|
| 1344 | \end{itemize} | 
|---|
| 1345 |  | 
|---|
| 1346 | We describe below  the {\bf Commander} possibilities, | 
|---|
| 1347 | as well as the few {\bf PIACmd} extensions. | 
|---|
| 1348 |  | 
|---|
| 1349 | \subsection{Variables} | 
|---|
| 1350 | The SOPHYA::Commander interpreter manages non typed set of variables. | 
|---|
| 1351 | Environment variables are also accessible through | 
|---|
| 1352 | the usual {\tt \$varenvname}, unless shadowed by a Commander | 
|---|
| 1353 | variable. All Commander variables are vector of strings, and are | 
|---|
| 1354 | extended as necessary.  {\tt \$varname} is the string formed by all | 
|---|
| 1355 | the vector elements. Except when performing arithmetic operations, | 
|---|
| 1356 | variables are treated  as strings. | 
|---|
| 1357 | \par | 
|---|
| 1358 | An application level set of variables is also managed | 
|---|
| 1359 | by Commander, through redefinition of \\ | 
|---|
| 1360 | {\tt Commander::GetVarApp() / GetVarApp() \ldots } methods.  \\ | 
|---|
| 1361 | The {\bf PIACmd} in piapp redefines the {\tt GetVarApp() } | 
|---|
| 1362 | in order to provide an easy access to some of objects attributes or methods, | 
|---|
| 1363 | managed by {\bf NamedObjMgr} (See below). | 
|---|
| 1364 |  | 
|---|
| 1365 | \subsubsection{Interpreter/Commander variables} | 
|---|
| 1366 | \begin{itemize} | 
|---|
| 1367 | \item[\rond] {\bf Definition and initialisation of variables } | 
|---|
| 1368 | \begin{verbatim} | 
|---|
| 1369 | # Notice that the set command has no = sign | 
|---|
| 1370 | Cmd> set sv StringValue | 
|---|
| 1371 | # Clearing/removing  of a variable : unset or clearvar | 
|---|
| 1372 | Cmd> unset sv | 
|---|
| 1373 |  | 
|---|
| 1374 | # Definition of a multi element variable (vector type) | 
|---|
| 1375 | # Notice that spaces before / after '(' and ')' are mandatory | 
|---|
| 1376 | Cmd> set vecv ( mot1 mot2 mot3 mot4 mot5 ) | 
|---|
| 1377 | # Arithmetic  expression : C language syntax - spaces | 
|---|
| 1378 | # before/after '=' are mandatory | 
|---|
| 1379 | Cmd> a = 2+3*sqrt(4) | 
|---|
| 1380 | # The '=' operator can also be used to initialize a variable with a string | 
|---|
| 1381 | Cmd> a = 'Bonjour Madame' | 
|---|
| 1382 | # A vector element can be specified in the left hand side | 
|---|
| 1383 | Cmd> vecv[2] = 'coucou' | 
|---|
| 1384 | # Or using an interpreter variable as index : | 
|---|
| 1385 | Cmd> i = 3 | 
|---|
| 1386 | Cmd> vecv[i] = 'Ooohhh' | 
|---|
| 1387 | \end{verbatim} | 
|---|
| 1388 |  | 
|---|
| 1389 | On the right hand side, the value of a variable should be accessed using | 
|---|
| 1390 | the \$ character.  \\ | 
|---|
| 1391 | A string can be parsed  into words using {\tt  var2words} | 
|---|
| 1392 | \begin{verbatim} | 
|---|
| 1393 | Cmd> var2words varname wordvarname [separateur] | 
|---|
| 1394 | \end{verbatim} | 
|---|
| 1395 |  | 
|---|
| 1396 | \item[\rond] {\bf Accessing variable contents } \\ | 
|---|
| 1397 | The \$ character is used to access the content of a variable {\tt \$varname} . | 
|---|
| 1398 | Substitution rules : | 
|---|
| 1399 | The {\tt \$xxx} is replaced by the value of  variable xxx. | 
|---|
| 1400 | No substitution is performed for strings enclosed in simple quotes {\tt ' ... \$xxx '}, | 
|---|
| 1401 | but substitution is done in strings enclosed in double quotes. | 
|---|
| 1402 | Parenthesis or brackets can be used to specify the variable name, inside a string | 
|---|
| 1403 | without white space: {\tt \${vname} } ou {\tt \$(vname)}. | 
|---|
| 1404 | \begin{verbatim} | 
|---|
| 1405 | Cmd> x = 'Hello' | 
|---|
| 1406 | Cmd> echo $x | 
|---|
| 1407 | # Size of a vector variable : $#vname | 
|---|
| 1408 | Cmd> set vx ( 111 2222 3333 444444 ) | 
|---|
| 1409 | Cmd> echo $#vx | 
|---|
| 1410 | # Accessing vector elements | 
|---|
| 1411 | Cmd> echo $vx[0] $vx[1] | 
|---|
| 1412 | #  or using an interpreter variable as index : | 
|---|
| 1413 | Cmd> i = 2 | 
|---|
| 1414 | Cmd> echo $vx[i] | 
|---|
| 1415 | # Special syntax:  $[vname] is replaced by the content | 
|---|
| 1416 | # of a  variable whose name is $vname | 
|---|
| 1417 | Cmd> zzz = 'Commander' | 
|---|
| 1418 | Cmd> xxx = 'zzz' | 
|---|
| 1419 | Cmd> echo '---> $[xxx]= '  $[xxx] | 
|---|
| 1420 | ---> $[xxx]= Commander | 
|---|
| 1421 | \end{verbatim} | 
|---|
| 1422 |  | 
|---|
| 1423 | \par | 
|---|
| 1424 | \end{itemize} | 
|---|
| 1425 |  | 
|---|
| 1426 | \subsubsection{Special variables} | 
|---|
| 1427 | \begin{itemize} | 
|---|
| 1428 | \item {\tt \$retval} ou {\tt \$retstr}  :  the string specified in the last {\bf return} statement | 
|---|
| 1429 | \item {\tt \$status} : Return code from the last executed command. | 
|---|
| 1430 | Arguments of scripts (see below) or file executed through {\bf exec} command. | 
|---|
| 1431 | \item {\tt \$\# } : number of arguments, except \$0 | 
|---|
| 1432 | \item {\tt \$0}  : Script or file name | 
|---|
| 1433 | \item {\tt \$1 \$2 \$3} ....  : Arguments  (for scripts and .pic files (exec)) | 
|---|
| 1434 | \end{itemize} | 
|---|
| 1435 |  | 
|---|
| 1436 | \subsubsection{Environment variables} | 
|---|
| 1437 | Environment variables can simply be accessed by {\tt \$varenvname}. | 
|---|
| 1438 | However,  the environment variables have the lowest priority during substitution. | 
|---|
| 1439 | Interpreter's variables have the highest priority, followed | 
|---|
| 1440 | by the application level variables. | 
|---|
| 1441 |  | 
|---|
| 1442 | \subsubsection{Objects/Application level variables} | 
|---|
| 1443 | For some classes managed by NamedObjMgr, | 
|---|
| 1444 | PIACmd provide acces to some of the attributes of the object by | 
|---|
| 1445 | {\tt \${objname.attname} }. This mechanism has been implemented in particular for | 
|---|
| 1446 | TArrays, TMatrix/TVector, Histograms, NTuples and DataTables. | 
|---|
| 1447 | In addition, when brackets  are used ($\${vname}$), the priority level between interpreter variables | 
|---|
| 1448 | and application level variable is changed. If {\tt vname} exist at the application level, | 
|---|
| 1449 | {\tt \${vname} }  is replaced by its value, even if an interpreter variable with the | 
|---|
| 1450 | same name has been defined. | 
|---|
| 1451 | \begin{itemize} | 
|---|
| 1452 | \item[\rond] Accessing object attributes | 
|---|
| 1453 | \begin{verbatim} | 
|---|
| 1454 | # -------- Example with a Vector | 
|---|
| 1455 | piapp[1] newvec va 12 | 
|---|
| 1456 | piapp[2] echo $va | 
|---|
| 1457 | TVector<d>(12) (nr=12, nc=1) | 
|---|
| 1458 | # ------- An undefined attribute, such as ? might be | 
|---|
| 1459 | #           used to get list of valid attributes | 
|---|
| 1460 | piapp[3] echo ${va.?} | 
|---|
| 1461 | TMatrix.Att: rank size/nelts nrow/nrows ncol/ncols sum sumsq norm min ... | 
|---|
| 1462 | #  Compound names, in the form  name.att must be inclosed in | 
|---|
| 1463 | #    braces {name.att} | 
|---|
| 1464 | piapp[4] echo ${va.size} | 
|---|
| 1465 | 12 | 
|---|
| 1466 | # -------- Example with an histogram | 
|---|
| 1467 | piapp[8] newh1d his 0. 20. 40 | 
|---|
| 1468 | piapp[10] echo ${his.?} | 
|---|
| 1469 | Histo1D: nbin binw mean sigma over under nentries ndata | 
|---|
| 1470 | xmin xmax vmin vmax imin imax | 
|---|
| 1471 | piapp[11] echo ${his.nbin} | 
|---|
| 1472 | 40 | 
|---|
| 1473 | \end{verbatim} | 
|---|
| 1474 |  | 
|---|
| 1475 | \item[\rond] Accessing object.Info() \\ | 
|---|
| 1476 | For objects having an DVList Info() object (TArray/TVector/TMatrix , NTuple, DataTable, SwPPFDataTable, it is possible to access DVList members by the corresponding names : \\ | 
|---|
| 1477 | \hspace*{10mm} {\tt \$\{objName.info.varName\} } | 
|---|
| 1478 | \item[\rond] Getting DataTable rows \\ | 
|---|
| 1479 | For NTuple and BaseDataTable objects (DataTable, SwPPFDataTable, SwFitsDataTable), it is | 
|---|
| 1480 | possible to get a string representation of a given row, by specifying | 
|---|
| 1481 | \$\{tableName.row\} followed by the row number (starting from 0) : \\ | 
|---|
| 1482 | \hspace*{10mm} {\tt \$\{tableName.row.num\} } | 
|---|
| 1483 | \end{itemize} | 
|---|
| 1484 |  | 
|---|
| 1485 |  | 
|---|
| 1486 |  | 
|---|
| 1487 | \subsection{Control structures} | 
|---|
| 1488 |  | 
|---|
| 1489 | \begin{itemize} | 
|---|
| 1490 | \item[\rond] Enumerated loop: | 
|---|
| 1491 | \begin{verbatim} | 
|---|
| 1492 | foreach f ( w1 w2 w3 ... ) | 
|---|
| 1493 | ... | 
|---|
| 1494 | echo $f | 
|---|
| 1495 | end | 
|---|
| 1496 | \end{verbatim} | 
|---|
| 1497 |  | 
|---|
| 1498 | Note that spaces before/after  '(' et and  ')' are mandatory. | 
|---|
| 1499 | An alternative form uses a vector variable name : | 
|---|
| 1500 | \begin{verbatim} | 
|---|
| 1501 | foreach v vecname | 
|---|
| 1502 | ... | 
|---|
| 1503 | echo $v | 
|---|
| 1504 | end | 
|---|
| 1505 | \end{verbatim} | 
|---|
| 1506 |  | 
|---|
| 1507 | \item[\rond] Integer type loop: | 
|---|
| 1508 | \begin{verbatim} | 
|---|
| 1509 | for i  startInt:endInt[:stepInt] | 
|---|
| 1510 | .... | 
|---|
| 1511 | echo $i | 
|---|
| 1512 | end | 
|---|
| 1513 | \end{verbatim} | 
|---|
| 1514 |  | 
|---|
| 1515 | \item[\rond] Integer type loop: | 
|---|
| 1516 | \begin{verbatim} | 
|---|
| 1517 | for f  startFloat:endFloat[:stepFloat] | 
|---|
| 1518 | .... | 
|---|
| 1519 | echo $f | 
|---|
| 1520 | end | 
|---|
| 1521 | \end{verbatim} | 
|---|
| 1522 |  | 
|---|
| 1523 | \item[\rond] Loop over lines of a file | 
|---|
| 1524 | \begin{verbatim} | 
|---|
| 1525 | forinfile line FileName | 
|---|
| 1526 | ... | 
|---|
| 1527 | echo $line | 
|---|
| 1528 | end | 
|---|
| 1529 | \end{verbatim} | 
|---|
| 1530 |  | 
|---|
| 1531 | \item[\rond] The {\tt break} instruction can be used to exit from a loop | 
|---|
| 1532 |  | 
|---|
| 1533 | \item[\rond] {\bf if then else} Conditional execution: | 
|---|
| 1534 | \begin{verbatim} | 
|---|
| 1535 | if ( test ) then | 
|---|
| 1536 | endif | 
|---|
| 1537 |  | 
|---|
| 1538 | if ( test ) then | 
|---|
| 1539 | .... | 
|---|
| 1540 | else | 
|---|
| 1541 | .... | 
|---|
| 1542 | endif | 
|---|
| 1543 | \end{verbatim} | 
|---|
| 1544 | Note that spaces before/after  '(' et and  ')' are mandatory. | 
|---|
| 1545 |  | 
|---|
| 1546 | test is in the form {\tt a == b} OR {\tt a != b} OR {\tt a < b}  OR {\tt a > b} | 
|---|
| 1547 | OR {\tt a <= b} OR {\tt a >= b}. Comparison operators should be delimited | 
|---|
| 1548 | by spaces. | 
|---|
| 1549 | {\tt ==} et {\tt !=}  make a string comparison, while | 
|---|
| 1550 | {\tt < , > , <= , >=} compare the values obtained after string to double conversion. | 
|---|
| 1551 | \end{itemize} | 
|---|
| 1552 |  | 
|---|
| 1553 | \subsection{Script definition} | 
|---|
| 1554 | A script is a sequence of commands. It is very similar to the execution of commands | 
|---|
| 1555 | from a file ({\bf exec filename}). Once a script has been defined, it can be called specifying | 
|---|
| 1556 | specifying the script name followed by its arguments. | 
|---|
| 1557 | \begin{verbatim} | 
|---|
| 1558 | #  Script definition : | 
|---|
| 1559 | defscript scriptname  [description ] | 
|---|
| 1560 | .... | 
|---|
| 1561 | endscript | 
|---|
| 1562 |  | 
|---|
| 1563 | #  Executing the script | 
|---|
| 1564 | Cmd> scriptname arg1 arg2 arg3 .... | 
|---|
| 1565 | \end{verbatim} | 
|---|
| 1566 |  | 
|---|
| 1567 | The {\tt return} instruction stops the execution and returns from a script, or from a command | 
|---|
| 1568 | file called through {\bf exec}. \\ | 
|---|
| 1569 | The commands  {\bf listscript } and  {\bf clearscript scriptname} can be used | 
|---|
| 1570 | to obtain the list of already defined script, or to clear a script definition. | 
|---|
| 1571 |  | 
|---|
| 1572 | \subsection{Other built-in commands} | 
|---|
| 1573 | \begin{itemize} | 
|---|
| 1574 | \item[\rond] Instruction {\bf echo } to write the line to cout/stdout | 
|---|
| 1575 | \item[\rond] Instruction {\bf echo2file} to write (append) the line to file ({\tt echo2file filename ....}) | 
|---|
| 1576 | \item[\rond] Instruction {\bf sleep nsec} wait for {\tt nsec}  seconds | 
|---|
| 1577 | \item[\rond] Instructions {\bf timingon , timingoff , traceon , traceoff } \\ | 
|---|
| 1578 | % | 
|---|
| 1579 | \item[\rond] {\bf exec filename [arg1 arg2 ... ] } to execute command from | 
|---|
| 1580 | the file named {\tt filename}. {\tt .pic} is the default extension for the interpreter | 
|---|
| 1581 | command files. | 
|---|
| 1582 | \item[\rond]  {\bf help} and {help keyword/commandname } | 
|---|
| 1583 | \item[\rond]  {\bf listvars , listcommands } to print the list of defined variables and known | 
|---|
| 1584 | commands | 
|---|
| 1585 | \item[\rond]  An alias for a command by {\bf alias aliasname 'string ' }. Alias substitution | 
|---|
| 1586 | occurs for the first word in a command line. {\bf  listalias} prints the list of all | 
|---|
| 1587 | defined aliases. | 
|---|
| 1588 | \item[\rond] Execution control (piapp/PIACmd extension): | 
|---|
| 1589 | It is possible to stop the interpreter execution in a loop, a script or | 
|---|
| 1590 | a command file by the {\bf stop} command, or using | 
|---|
| 1591 | {\tt <Cntrl C>} in the piapp console (PIConsole) \\ | 
|---|
| 1592 | \end{itemize} | 
|---|
| 1593 |  | 
|---|
| 1594 | \subsection {Command execution in separate threads} | 
|---|
| 1595 | It is possible to create new threads to execute commands | 
|---|
| 1596 | ( for non built-in interpreter commands). The syntax is similar | 
|---|
| 1597 | to unix shell background tasks: an {\&} should be added at the end | 
|---|
| 1598 | of the command line.  A new thread is then created for the | 
|---|
| 1599 | execution of the command, if declared as thread safe \\ | 
|---|
| 1600 | (see {\tt CmdExecutor::IsThreadable() }. | 
|---|
| 1601 | \par | 
|---|
| 1602 | Thread management commands: | 
|---|
| 1603 | \begin{itemize} | 
|---|
| 1604 | \item[\rond] {\bf thrlist }Print current list of threads, with the associated command | 
|---|
| 1605 | the thread identifier (integer ThrId) and its status. | 
|---|
| 1606 | \item[\rond] {\bf cleanthrlist } Removes all finished threads from the list. | 
|---|
| 1607 | An automatic cleanup is performed periodically. | 
|---|
| 1608 | \item[\rond] {\bf cancelthr ThId } / {\bf killthr ThId } Stops/kills the thread with | 
|---|
| 1609 | the identifier ThId. Avoid using theses commands as the cleanup does | 
|---|
| 1610 | not release some resources associated with | 
|---|
| 1611 | the thread (memory, mutex \ldots). | 
|---|
| 1612 | \end{itemize} | 
|---|
| 1613 |  | 
|---|
| 1614 | Executing commands in a separate thread is useful for CPU or data intensive | 
|---|
| 1615 | commands. Most {\bf Expr.Plotting} | 
|---|
| 1616 | (plot2d, plot2dw, plot2de, plot3d, ntloop, fillvec, fillmtx \ldots) | 
|---|
| 1617 | and some of the {\bf pawCmd} (n/plot n/proj) are thread safe. However, due to the | 
|---|
| 1618 | current mutex lock management for these Expr.Plotting/pawCmd commands, only one | 
|---|
| 1619 | such command can run concurrently with other piapp threads. | 
|---|
| 1620 | Some of the commands in the {\bf CxxExecutorCmd} ( | 
|---|
| 1621 | c++exec, c++execfrf, c++create, c++createfrf, c++compile, c++link) are also thread safe. | 
|---|
| 1622 | The same remark concerning lock management applies to these commands, while | 
|---|
| 1623 | CxxExecutorCmd commands can run in parallel with Expr.Plotting commands. | 
|---|
| 1624 |  | 
|---|
| 1625 |  | 
|---|
| 1626 | %%%%%%%%%%%%%%% Section 7 :  c++ execution | 
|---|
| 1627 | \newpage | 
|---|
| 1628 | \section{On the fly C++ execution} | 
|---|
| 1629 | \label{flycplusplus} | 
|---|
| 1630 | Piapp operates on the underlying SOPHYA class library objects. | 
|---|
| 1631 | Obviously, only a small fraction of functionalities in the libraries | 
|---|
| 1632 | are directly available through the commands. On the fly C++ compilation | 
|---|
| 1633 | and execution in piapp provides an easy access to the whole class library. | 
|---|
| 1634 |  | 
|---|
| 1635 | The {\bf NamedObjMgr} class handles most of the communication between different | 
|---|
| 1636 | component of the application, including user c++ code. | 
|---|
| 1637 | The NamedObjMgr class implements a singleton scheme, where all instances of the | 
|---|
| 1638 | class operate on the same data. | 
|---|
| 1639 | Most operations, in particular directory and object management are thread-safe. | 
|---|
| 1640 | The most usefull NamedObjMgr methods in user code are: | 
|---|
| 1641 | \begin{itemize} | 
|---|
| 1642 | \item Adding an object using its pointer. The object should be created using new. \\ | 
|---|
| 1643 | {\tt \small bool NamedObjMgr::AddObj(AnyDataObj* obj, string \& nom, bool crd=false) } | 
|---|
| 1644 | \item Adding an object using its reference. The Object Adapter is used to Clone | 
|---|
| 1645 | the object. For classes like TArray or Spherical maps, implementing reference sharing, | 
|---|
| 1646 | the cloned object shares its data with the original object. | 
|---|
| 1647 | The Cloned object is then added to the list. \\ | 
|---|
| 1648 | {\tt \small bool NamedObjMgr::AddObj(AnyDataObj\& obj, string \& nom, bool crd=false)} | 
|---|
| 1649 | \item Object display methods : \\ | 
|---|
| 1650 | {\tt \small NamedObjMgr::DisplayObj(string \& nom, string dopt="")  \\ | 
|---|
| 1651 | NamedObjMgr::DisplayImage(string \& nom, \ldots ) \\ | 
|---|
| 1652 | NamedObjMgr::DisplayNT(string \& nom, \ldots )} \\ | 
|---|
| 1653 | \ldots | 
|---|
| 1654 | \item Access to other parts of the piapp application : \\ | 
|---|
| 1655 | {\tt \small PIStdImgApp* NamedObjMgr::GetImgApp() \\ | 
|---|
| 1656 | PIACmd* PIStdImgApp::CmdInterpreter() } | 
|---|
| 1657 | \end{itemize} | 
|---|
| 1658 |  | 
|---|
| 1659 | \subsection{How does it work ?} | 
|---|
| 1660 | When one the {\bf CxxExecutorCmd} \myppageref{CxxExecutorCmd} commands | 
|---|
| 1661 | ({\tt c++exec} or {\tt c++execfrf}) is invoked, piapp performs the | 
|---|
| 1662 | following operations: | 
|---|
| 1663 | \begin{itemize} | 
|---|
| 1664 | \item Create a c++ file, and includes the usual libstc++ and SOPHYA header files | 
|---|
| 1665 | (file named PIATmp\_xxx/cxx\_spiapp.cc) | 
|---|
| 1666 | \item The user code is put in a c++ function: \\ | 
|---|
| 1667 | {\small \tt  int usercxx( vector<string> \& args ) } | 
|---|
| 1668 | \item References to all objects present in the current working NamedObjMgr directory | 
|---|
| 1669 | (default=/home) are declared and initialized. Objects in the current directory can | 
|---|
| 1670 | thus be easily accessed through variables bearing the corresponding object name | 
|---|
| 1671 | in piapp. | 
|---|
| 1672 | \item The c++ source file is compiled and linked with SOPHYA libraries, | 
|---|
| 1673 | and any additional library, specified through {\tt c++mylibs} \myppageref{cZZmylibs}). | 
|---|
| 1674 | The compilation and link steps are carried by the SOPHYA class {\b CxxCompilerLinker}. | 
|---|
| 1675 | \item The resulting shared object is loaded by piapp and the function | 
|---|
| 1676 | {\tt usercxx()} is called. | 
|---|
| 1677 | \end{itemize} | 
|---|
| 1678 |  | 
|---|
| 1679 | To facilitate communication with piapp/NamedObjMgr, two CPP macros are defined: | 
|---|
| 1680 | \begin{itemize} | 
|---|
| 1681 | \item[\rond] {\bf KeepObj(VarName) } where VarName is a user declared | 
|---|
| 1682 | c++ variable, corresponding to an object inheriting from AnyDataObj. | 
|---|
| 1683 | When this macro is called, the corresponding object is cloned by the object | 
|---|
| 1684 | Adapter and added to the list managed by NamedObjMgr, | 
|---|
| 1685 | with VarName as the object name. | 
|---|
| 1686 | \item[\rond] {\bf DispObj(VarName, graphic\_att) } adds the object and | 
|---|
| 1687 | request its display. | 
|---|
| 1688 | \end{itemize} | 
|---|
| 1689 |  | 
|---|
| 1690 | \subsection{Examples} | 
|---|
| 1691 |  | 
|---|
| 1692 | \begin{enumerate} | 
|---|
| 1693 | \item Computation using TimeStamp object. \\[1mm] | 
|---|
| 1694 | %% | 
|---|
| 1695 | $\longrightarrow$ File compdate.cc : | 
|---|
| 1696 | \begin{verbatim} | 
|---|
| 1697 | TimeStamp now;     // Current date | 
|---|
| 1698 | TimeStamp y2000(2000,1,1,12,0,0.);  // 1 jan 2000, 12:00 | 
|---|
| 1699 | cout << " Y2000=" << y2000 << " --> Now: " << now << endl; | 
|---|
| 1700 | cout << " From Y2000 to Now= " << now.ToDays() - y2000.ToDays() << " days" << endl; | 
|---|
| 1701 | \end{verbatim} | 
|---|
| 1702 | $\longrightarrow$ piapp commands : \\ | 
|---|
| 1703 | {\tt piapp> c++execfrf compdate.cc} \\ | 
|---|
| 1704 | $\longrightarrow$ The result : \\ | 
|---|
| 1705 | \begin{verbatim} | 
|---|
| 1706 | PIABaseExecutor: Call usercxx( ... ) | 
|---|
| 1707 | Y2000= 01/01/2000 12:00:0.0 UT  --> Now:  13/12/2007 14:20:50.0 UT | 
|---|
| 1708 | From Y2000 to Now= 2903.1 days | 
|---|
| 1709 | \end{verbatim} | 
|---|
| 1710 | %%%% | 
|---|
| 1711 | \item Working with objects in piapp: \\[1mm] | 
|---|
| 1712 | \begin{verbatim} | 
|---|
| 1713 | #  We create three vectors | 
|---|
| 1714 | newvec va 256 sin(x/5.) | 
|---|
| 1715 | newvec vb 256 cos(x/18.)*exp(-x/150.) | 
|---|
| 1716 | newvec vc 256 | 
|---|
| 1717 | #  We call c++exec to make an operation on these vectors | 
|---|
| 1718 | c++exec vc=va+3.*vb; | 
|---|
| 1719 | #  Display the resulting vector | 
|---|
| 1720 | disp vc | 
|---|
| 1721 | \end{verbatim} | 
|---|
| 1722 | %%% | 
|---|
| 1723 | \item Creating and adding new objects \\[1mm] | 
|---|
| 1724 | $\longrightarrow$ File myf\_fft.h : | 
|---|
| 1725 | \begin{verbatim} | 
|---|
| 1726 | inline double myf(double x) | 
|---|
| 1727 | { | 
|---|
| 1728 | return(3*sin(0.2*x)+4*cos(x)+5*sin(4*x+0.25) | 
|---|
| 1729 | +3.5*cos(9*x+0.45) + 0.05*x); | 
|---|
| 1730 | } | 
|---|
| 1731 | \end{verbatim} | 
|---|
| 1732 | $\longrightarrow$ File myf\_fft.h : | 
|---|
| 1733 | \begin{verbatim} | 
|---|
| 1734 | TVector<r_8> in(4048); | 
|---|
| 1735 | TVector<r_8> noise(4048); | 
|---|
| 1736 | TVector< complex<r_8> > out; | 
|---|
| 1737 | in = RegularSequence(0., 0.05); | 
|---|
| 1738 | noise = RandomSequence(RandomSequence::Gaussian, 0., 4.); | 
|---|
| 1739 | MathArray<r_8> ma; | 
|---|
| 1740 | ma.ApplyFunctionInPlace(in, myf); | 
|---|
| 1741 | in += noise; | 
|---|
| 1742 | FFTPackServer FFTServ; | 
|---|
| 1743 | cout << " Calling FFT " << endl; | 
|---|
| 1744 | FFTServ.FFTForward(in, out); | 
|---|
| 1745 | DispObj(in, ""); | 
|---|
| 1746 | DispObj(out, "red"); | 
|---|
| 1747 | \end{verbatim} | 
|---|
| 1748 | $\longrightarrow$ piapp commands : | 
|---|
| 1749 | \begin{verbatim} | 
|---|
| 1750 | # Remove existing in/out objects | 
|---|
| 1751 | rm in out | 
|---|
| 1752 | # Divide then graphic window in two regions | 
|---|
| 1753 | zone 1 2 | 
|---|
| 1754 | #  Compile and execute the c++ code | 
|---|
| 1755 | c++execfrf fft.icc myf_fft.h | 
|---|
| 1756 | listobjs | 
|---|
| 1757 | \end{verbatim} | 
|---|
| 1758 | \end{enumerate} | 
|---|
| 1759 |  | 
|---|
| 1760 | \subsection{Include files, libraries \ldots} | 
|---|
| 1761 | \begin{itemize} | 
|---|
| 1762 | \item[\rond] The different steps of c++exec or c++execfrf | 
|---|
| 1763 | can be performed by the following commands: {\tt c++create , c++createfrf, | 
|---|
| 1764 | c++compile, c++link, call}. This is useful when the same code | 
|---|
| 1765 | has to be executed multiple times. | 
|---|
| 1766 | \item[\rond] An interactive editing / c++ execution window can be | 
|---|
| 1767 | displayed through the menu-bar, \menubar{Tools/CxxExecutorWindow} | 
|---|
| 1768 | \item[\rond] The {\tt c++import} \myppageref{cZZimport} | 
|---|
| 1769 | activate inclusion of header files for additional SOPHYA modules, | 
|---|
| 1770 | such as Samba SkyMap SkyT FitsIOServe \ldots. | 
|---|
| 1771 | \item[\rond] The inclusion of additional header files and libraries | 
|---|
| 1772 | can be specified using the {\tt c++include} \myppageref{cZZinclude} | 
|---|
| 1773 | and  {\tt c++mylibs} \myppageref{cZZmylibs}. | 
|---|
| 1774 | \item[\rond] A dialog window for changing various c++ compile and link | 
|---|
| 1775 | options can be displayed by through the menu-bar | 
|---|
| 1776 | \menubar{Special/CxxExecOption} | 
|---|
| 1777 | \end{itemize} | 
|---|
| 1778 |  | 
|---|
| 1779 |  | 
|---|
| 1780 | %%%%%%%%%%%%%%% Section 8 :  command reference | 
|---|
| 1781 | \newpage | 
|---|
| 1782 | \section{piapp command reference} | 
|---|
| 1783 | \label{piappcmdref} | 
|---|
| 1784 | This section contains the description of piapp commands. This information | 
|---|
| 1785 | is available on-line, through the help command, or through a graphic | 
|---|
| 1786 | window, accessible  by \menubar{File / Help}. | 
|---|
| 1787 | The help items and command are divided into different sections, | 
|---|
| 1788 | where related commands are grouped. \\[10mm] | 
|---|
| 1789 |  | 
|---|
| 1790 | % \include{piahelp} | 
|---|
| 1791 | \input{piahelp.tex} | 
|---|
| 1792 |  | 
|---|
| 1793 | %  La partie des appendix | 
|---|
| 1794 | \appendix | 
|---|
| 1795 | \newpage | 
|---|
| 1796 | \section{Interactive control windows} | 
|---|
| 1797 | \subsection{DrawerTools} \index{DrawerTools} | 
|---|
| 1798 | \label{secdrwtools} | 
|---|
| 1799 | The {\bf PIDrawerTools}, shown in the figure \ref{figdrwtools} can be | 
|---|
| 1800 | used to change the graphic attributes (color, font, marker, \ldots) | 
|---|
| 1801 | of the Drawers displayed in 2D displays | 
|---|
| 1802 | ({\bf PIScDrawWdg} \myppageref{PIScDrawWdg}) or 3D displays | 
|---|
| 1803 | ({\bf PIDraw3DWdg} \myppageref{PIDraw3DWdg}), as well in image displays | 
|---|
| 1804 | {\bf PIImage} (\myppageref{PIImage}). The PIDrawerTools can be activated | 
|---|
| 1805 | either using {\tt Alt<G>} on a PIScDrawWdg,PIDraw3DWdg,PIImage, | 
|---|
| 1806 | or through the \menubar{Tools/Show DrawerTools}. | 
|---|
| 1807 | A given drawer can be selected through the DrawerId selector (+ / - buttons) | 
|---|
| 1808 |  | 
|---|
| 1809 | \vspace*{5mm} | 
|---|
| 1810 | \begin{figure}[ht!] | 
|---|
| 1811 | \begin{center} | 
|---|
| 1812 | \includegraphics[width=8cm]{piapp_drwtools.eps} | 
|---|
| 1813 | \caption{PIDrawerTools} | 
|---|
| 1814 | \label{figdrwtools} | 
|---|
| 1815 | \end{center} | 
|---|
| 1816 | \end{figure} | 
|---|
| 1817 | %%%% | 
|---|
| 1818 | \subsection{AxesTools} \index{AxesTools} | 
|---|
| 1819 | \label{secaxestools} | 
|---|
| 1820 | The {\bf PIAxesTools}, shown in the figure \ref{figaxestools} can be used to | 
|---|
| 1821 | control and change the setting of axes on 2D displays | 
|---|
| 1822 | ({\bf PIScDrawWdg} \myppageref{PIScDrawWdg}). | 
|---|
| 1823 | The PIAxesTools can be activated | 
|---|
| 1824 | either using {\tt Alt<A>} on a PIScDrawWdg or through | 
|---|
| 1825 | the \menubar{Tools/Show AxesTools}. | 
|---|
| 1826 |  | 
|---|
| 1827 | \vspace*{5mm} | 
|---|
| 1828 | \begin{figure}[ht!] | 
|---|
| 1829 | \begin{center} | 
|---|
| 1830 | \includegraphics[width=8cm]{piapp_axestools.eps} | 
|---|
| 1831 | \caption{PIAxesTools} | 
|---|
| 1832 | \label{figaxestools} | 
|---|
| 1833 | \end{center} | 
|---|
| 1834 | \end{figure} | 
|---|
| 1835 | %%%%% | 
|---|
| 1836 | \subsection{ImageTools} \index{ImageTools} | 
|---|
| 1837 | \label{secimagetools} | 
|---|
| 1838 | The {\bf PIImageTools}, shown in the figure \ref{figimgtools} can be used to | 
|---|
| 1839 | manipulate a display of type image. Image display are handled by the | 
|---|
| 1840 | {\bf PIImage} (\myppageref{PIImage}). The PIImageTools can be activated | 
|---|
| 1841 | either using {\tt Alt<O>} on a PIImage, or through the | 
|---|
| 1842 | \menubar{Tools/Show ImageTools}. | 
|---|
| 1843 |  | 
|---|
| 1844 | \vspace*{5mm} | 
|---|
| 1845 | \begin{figure}[ht!] | 
|---|
| 1846 | \begin{center} | 
|---|
| 1847 | \includegraphics[width=8cm]{piapp_imgtools.eps} | 
|---|
| 1848 | \caption{PIImageTools} | 
|---|
| 1849 | \label{figimgtools} | 
|---|
| 1850 | \end{center} | 
|---|
| 1851 | \end{figure} | 
|---|
| 1852 |  | 
|---|
| 1853 | \subsection{Histo2DTools} \index{Histo2DTools} | 
|---|
| 1854 | \label{sech2dtools} | 
|---|
| 1855 | The {\bf PIHisto2DTools}, shown in the figure \ref{figh2dtools} can be | 
|---|
| 1856 | used to control and change the display caracteristics of 2D histograms. | 
|---|
| 1857 | PIHisto2DTools can be activated | 
|---|
| 1858 | either using {\tt Alt<O>} on a PIScDrawWdg, when the active | 
|---|
| 1859 | drawer is a PIHisto2DDrawer, or through the generic drawer tool | 
|---|
| 1860 | PIDrawerTools. | 
|---|
| 1861 |  | 
|---|
| 1862 | \vspace*{5mm} | 
|---|
| 1863 | \begin{figure}[ht!] | 
|---|
| 1864 | \begin{center} | 
|---|
| 1865 | \includegraphics[width=8cm]{piapp_h2dtools.eps} | 
|---|
| 1866 | \caption{PIHisto2DTools} | 
|---|
| 1867 | \label{figh2dtools} | 
|---|
| 1868 | \end{center} | 
|---|
| 1869 | \end{figure} | 
|---|
| 1870 |  | 
|---|
| 1871 | \subsection{ContourTools} \index{ContourTools} | 
|---|
| 1872 | \label{secconttools} | 
|---|
| 1873 | The {\bf PIContourTools}, shown in the figure \ref{figconttools} can be | 
|---|
| 1874 | used to control and change the caracteristics of contour displays. | 
|---|
| 1875 | PIContourTools can be activated | 
|---|
| 1876 | either using {\tt Alt<O>} on a PIScDrawWdg, when the active | 
|---|
| 1877 | drawer is a PIContDrawer, or through the generic drawer tool | 
|---|
| 1878 | PIDrawerTools. | 
|---|
| 1879 |  | 
|---|
| 1880 | \vspace*{10mm} | 
|---|
| 1881 | \begin{figure}[ht!] | 
|---|
| 1882 | \begin{center} | 
|---|
| 1883 | \includegraphics[width=11cm]{piapp_conttools.eps} | 
|---|
| 1884 | \caption{PIContourTools} | 
|---|
| 1885 | \label{figconttools} | 
|---|
| 1886 | \end{center} | 
|---|
| 1887 | \end{figure} | 
|---|
| 1888 |  | 
|---|
| 1889 |  | 
|---|
| 1890 |  | 
|---|
| 1891 | Both drawing options  (e.g. color, line type, fonts...) and contour | 
|---|
| 1892 | determination parameters (e.g. contour number and levels) are controlled | 
|---|
| 1893 | by {\bf PIContourTools}. | 
|---|
| 1894 |  | 
|---|
| 1895 | \subsubsection{Drawing options} | 
|---|
| 1896 | The top choices in {\bf PIContourTools} | 
|---|
| 1897 | concern the color map (left choice) or color (right choice) of the contours. | 
|---|
| 1898 | If a color map has been chosen, it is used to give each contour a color | 
|---|
| 1899 | (according to its level). If no color map has been chosen, contours may be | 
|---|
| 1900 | given a color using the left choice box. | 
|---|
| 1901 |  | 
|---|
| 1902 | Contour are by default traced by lines. | 
|---|
| 1903 | Alternatively (or in addition) the user may ask to trace them by markers | 
|---|
| 1904 | or to put numeric labels (with the contour's level) aside the contour. | 
|---|
| 1905 | These options are enabled/disabled by the {\tt LineON}, {\tt MarkerON} and {\tt LabelON} | 
|---|
| 1906 | buttons from {\bf PIContourTools}. | 
|---|
| 1907 |  | 
|---|
| 1908 | Options may be recovered ({\tt GetAtt}) or set ({\tt SetAtt}) | 
|---|
| 1909 | from/to a drawer. Setting an option which adds to the screen will be immediately visible | 
|---|
| 1910 | whereas unsetting it requires a {\tt Refresh} to be visible. | 
|---|
| 1911 |  | 
|---|
| 1912 |  | 
|---|
| 1913 | \subsubsection{Contour options} | 
|---|
| 1914 | The contouring routines in {\tt spiapp} are based on a hack of the {\tt GNUPlot} | 
|---|
| 1915 | routines. Contours are determined from a grid of values | 
|---|
| 1916 | using an interpolation scheme. Three schemes may be used | 
|---|
| 1917 | (selected by the left menu) : | 
|---|
| 1918 | \begin{enumerate} | 
|---|
| 1919 | \item Linear interpolation (default), selected by the  {\tt Int. Lin.} option | 
|---|
| 1920 | \item A cubic spline algorithm, selected by the  {\tt CubicSpl} option | 
|---|
| 1921 | \item A 2d BSpline algorihm, selected by the  {\tt B-Spline} option | 
|---|
| 1922 | \end{enumerate} | 
|---|
| 1923 |  | 
|---|
| 1924 | Contour levels and number are automatically | 
|---|
| 1925 | determined by the program.  They may be specified differently, | 
|---|
| 1926 | through command-line options | 
|---|
| 1927 | (see section \ref{piappcmdref} for the help of the contour/ntcont commands) | 
|---|
| 1928 | or the lower part of the {\bf PIContourTools} window. | 
|---|
| 1929 |  | 
|---|
| 1930 | The user may specify one  of the following alternatives : | 
|---|
| 1931 | \begin{enumerate} | 
|---|
| 1932 | \item the number of contour (their level beeing automatically set). | 
|---|
| 1933 | To do this, select {\tt LevelNum} in the right menu and enter the contour number | 
|---|
| 1934 | in the left box below. | 
|---|
| 1935 | \item the levels of the contours, through an array of numerical values | 
|---|
| 1936 | (e.g. 1,4,6,9,27,4.5 will result in 6 contour lines being drawn, if possible and necessary). | 
|---|
| 1937 | To do this, select {\tt LevelDisc} and enter the contour number (left box) | 
|---|
| 1938 | and the values (right box) separated by ``{\tt ,}''. | 
|---|
| 1939 | \item the levels of the contours through an initial (lower) value and an increment. | 
|---|
| 1940 | For this, select {\tt LevelInc} and enter the contour number (left box) | 
|---|
| 1941 | and the initial value and increment in the right box, as above. | 
|---|
| 1942 | \item come back to the default situation, by choosing {\tt LevelAuto} | 
|---|
| 1943 | \end{enumerate} | 
|---|
| 1944 |  | 
|---|
| 1945 | Once these options are set, it is necessary the the program recomputes | 
|---|
| 1946 | the contour lines. This is commanded by the {\tt SetParm} button. | 
|---|
| 1947 |  | 
|---|
| 1948 |  | 
|---|
| 1949 | \newpage | 
|---|
| 1950 | \addcontentsline{toc}{section}{Index} | 
|---|
| 1951 | \printindex | 
|---|
| 1952 |  | 
|---|
| 1953 | \end{document} | 
|---|