source: Sophya/trunk/SophyaLib/Manual/piapp.tex@ 3441

Last change on this file since 3441 was 3441, checked in by ansari, 18 years ago

fin(?) des modifications de la documentation pour V=2.1, Reza 13/12/2007

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