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

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

Chapitre V complete sur data formats,I/O + maj piahelp.tex genere par la derniere version de piapp (V=4.1) - Reza 10/12/2007

File size: 55.7 KB
RevLine 
[3041]1\documentclass[twoside,10pt]{article}
[2384]2% \usepackage[latin1]{inputenc}
3% \usepackage[T1]{fontenc}
[2171]4\usepackage[francais]{babel}
5\usepackage{graphicx}
6
[2384]7\usepackage{amsmath}
8\usepackage{amssymb}
9\usepackage{latexsym}
10
[2171]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
[3429]24\setlength{\textwidth}{15cm}
25\setlength{\textheight}{20.5cm}
26\setlength{\topmargin}{0.cm}
[2171]27\setlength{\oddsidemargin}{0.cm}
28\setlength{\evensidemargin}{0.cm}
29\setlength{\unitlength}{1mm}
30
[2384]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
[3041]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
[2171]44\newcommand{\piacommand}[1]{
[2384]45$\blacksquare$ \hspace{3mm} {\bf \Large #1 } \index{#1} % (Command)
[2171]46}
47\newcommand{\piahelpitem}[1]{
[2384]48$\square$ \hspace{3mm} {\bf \Large #1 } \index{#1} (Help item)
[2171]49}
50
[3041]51\newcommand{\menubar}[1]{\hspace{1mm} \framebox{\it MenuBar::#1} \hspace{1mm}}
52
[2171]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}
[3429]74{\bf \Large piapp Version: 4.1 (V\_Nov2007) }
[2171]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
[3041]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%%%
[3429]113\begin{figure}[ht!]
114\begin{center}
115\includegraphics[width=15cm]{piapp_mainwin.eps}
116\caption{piapp main window}
117\label{figmainwin}
118\end{center}
119\end{figure}
120\subsection{starting piapp}
[3041]121 {\bf piapp} can simply be started on the command line in a terminal window
122once the SOPHYA/piapp environment has been initialised.
123The environment variables {\tt SOPHYABASE} should contain the directory
124where SOPHYA/piapp has been installed. the shared library path
125{\tt LD\_LIBRARY\_PATH} must contain {\tt \$SOPHYABASE /slb} and the
126current directory {\tt .} and the executable search path {\tt PATH} must
127contain {\tt \$SOPHYABASE /exe}. Refer to the SOPHYA overview manual
128for more information on SOPHYA directory structure. \\
129It might also be necessary to define the environment variable
130{\bf PIXKBMOMASK}, used by the libPI.a to map correctly
131the {\tt <Alt>} key with some X servers (in particular with
132X11 on MacOS X). \\
133{\tt csh> setenv PIXKBMODMASK 2 }
134\par
135{\tt (s)piapp -h} provides a brief help of the command line
[2171]136arguments. Xtoolkit options can also be specified as command line
[3041]137arguments. {\bf spiapp} is the name of SOPHYA/piapp executable,
138in order to distinguish it from PEIDA/piapp.
[2171]139\begin{verbatim}
140csh> spiapp -h
[3041]141 SophyaInitiator::SophyaInitiator() BaseTools Init
142 PIOPersist::Initialize() Starting Sophya Persistence management service
[3429]143SOPHYA Version 2.1 Revision 0 (V_Nov2007) -- Nov 24 2007 13:08:58 gcc 3.3
14420030304 (Apple Computer, Inc. build 1495)
[3041]145 piapp: Interactive data analysis and visualisation program
[3429]146 Usage: piapp [-nored] [-doublered] [-termread] [-term]
147 [-hidezswin] [-small] [-nosig] [-nosigfpe] [-nosigsegv]
[3041]148 [-tmpdir TmpDirectory] [-help2tex] [-exec file [args]]
149 -nored : Don't redirect stdout/stderr to piapp console
[3429]150 -doublered : Redirect stdout/stderr to piapp console AND the terminal
[3041]151 -termread : Read commands on terminal (stdin)
152 -term : equivalent to -nored -termread -small
153 -hidezswin : Hide Zoom/Stat/ColMap window
154 -small : Create small size main piapp window
155 -nosig : Don't catch SigFPE, SigSEGV
156 -nosigfpe -nosigsegv: Don t catch SigFPE / SigSEGV
157 -tmpdir TmpDirectory: defines TMDIR for temporary files
[2171]158 -help2tex: Create a LaTeX help file (piahelp.tex)
[3041]159 -exec file [args] : Execute command file (last option)
[2171]160\end{verbatim}
[3041]161Once {\bf piapp} is started, the main piapp window appears.
162It contains the menu bar, an upper part with the zoom and colormap
163widgets for image displays, memory and CPU usage and a terminal like
164widget (piapp console, see {\bf PIConsole} \myppageref{PIConsole})
165in the lower part. The figure \ref{figmainwin}
[2171]166shows an image of the piapp main window.
[3041]167{\tt stdout/cout, stderr/cerr} are redirected to the piapp console and
168commands can be entered in this widget. It is also possible to keep
169the terminal where piapp was started for {\tt stdout/stderr} (flag {\tt -nored}).
170It is also possible to have a command reader on the terminal
171({\tt stdin}), using the flag {\tt -term}. \\[1mm]
172%
173{\bf Warning:} The output redirection uses unix pipes. On Linux, with commands
174producing long outputs, the application may block because of incorrect management
[3429]175of pipes. If this happens, use piapp with {\tt -nored} flag. This problem has been
176in principle solved with SOPHYA V=2.1 / piapp V=4.1
[2171]177
[3041]178\par
179In section 2, we present a quick tour of {\bf piapp}.
180a brief overview of piapp graphics, supported data formats, interactive
181analysis possibilities, the command interpreter and c++ execution
182are presented in the following sections.
183Section \ref{piappcmdref} contains a brief description of all piapp commands
184and help items. Various interactive control windows are described in appendix.
[2171]185
186
187\newpage
188\section{A Tour of piapp}
[3041]189\subsection{Interacting with piapp, getting help}
190Users interact with piapp through commands entered in the piapp-console
191(or the unix terminal), and through the different menus.
192Some of the possibilities of the piapp-console are described
193in {\bf PIConsole} help item, in the command reference section \myppageref{PIConsole}.
194The description
195of the commands in available online using the help command.
196An online help window can be displayed by \menubar{File / Help}.
197Commands and help items are grouped in categories which can be
198selected using the OptionMenu in the Help window.
199\begin{verbatim}
200Cmd> help func
201Displays a function y=f(x) (Fills a vector with function values)
202 Usage: func f(x) xmin xmax [npt graphic_attributes]
203 Related commands: funcff func2d func2dff
204Cmd> func sin(x)/x 0.1 10 100 'red line=solid,2'
205---> Graphic display of the function
206\end{verbatim}
207The directory {\tt DemoPIApp} contains a number of example
208command script and sample data files.
209
[2171]210\subsection{the Object Manager (NamedObjMgr)}
211The {\bf piapp} application is built around an object manager
212(class {\tt NamedObjMgr}) and a graphic application
213(class {\tt PIStdImgApp}). Objects inheriting from
214the class {\tt AnyDataObj} can be managed through adapter
215classes (classes inheriting from {\tt NObjMgrAdapter}) by
216the object manager.
217\par
218User sees the objects (such as Sophya objects Histo, NTuple,
219Arrays, Images, SkyMaps, \ldots) kept in memory, organized
220in a single level tree structure. Four memory directories
221are automatically created and can not be removed: \\
222\centerline{\bf /home \hspace{10mm} /old \hspace{10mm} /tmp \hspace{10mm} /autoc}
223The default working directory (in memory) is {\bf /home}.
224Other directories can be created by the user.
225\begin{center}
226{\bf Warning:} These are only the directory
227structure managed by the piapp application and do not
228correspond to the file system directories
229\end{center}
230The window {\bf ObjMgr} shown in figure \ref{figobjmgrw}
231can be used to navigate in the memory directories and
[3041]232execute simple operations on objects. \\
233This window can be displayed using the menu command
234\menubar{Objects / ObjectManager}.
[2171]235The button \framebox{\small \bf SetCurObj} can be used to set the value
236of the interpreter's variable {\tt cobj} to the selected
237object name.
238Refer to the commands in group {\bf Object Management}
239for more information.
240
241\vspace*{5mm}
242\begin{figure}[ht!]
243\begin{center}
244\includegraphics[width=10cm]{piapp_objmgr.eps}
245\caption{The interactive object management window}
246\label{figobjmgrw}
247\end{center}
248\end{figure}
249
250\subsection{command language}
[3041]251A basic command interpreter ({\bf PIACmd/Commander}) is included in {\bf piapp} and
[2171]252other command interpreters can be inserted in the application
253framework.
[3041]254This interpreter ({\bf Commander} \myppageref{Commander})
[2171]255synthax is close to the c-shell
256(csh) shell script. It is possible to define and use variables
257({\tt set} command, {\tt \$varname}), and execute loops
258({\tt foreach,for}), as well as simple tests
259({\tt if test then ... else ... endif}).
260Commands from a file (default extension .pic) can be executed
261using the {\tt exec} command.
262Long commands can be put on several lines, by ending a line
263by the backslash \\ caracter, to signal that the command
264continues on the next line.
265
266The command macro below shows a sample piapp session, where
267data from the file {\tt demo.ppf} are displayed.
268\begin{verbatim}
269# Trace mode -> On
270traceon
271# Deleting all objects in the current directory
272delobjs *
273# Opening the PPF file demo.ppf
274openppf demo.ppf
275# Various displays in a graphic window, divided into 2x2 zones
276zone 2 2
277# 1D histogram display
278disp h1d blue
279# 2D histogram display
280disp h2d
281# Function display
282func sin(x)/x 0.1 10. 200 gold
283# Surface representation of a matrix
284surf mtx1 colbr32
[2253]285# Contour representation of a matrix
286contour mtx1 'colrj32 normalline ncont=7'
[2171]287# 3D representation of points using a PAW like command
288n/plot nt31.z%y%x ! ! win
289# 3D points superimposed on the previous display
290nt3d nt32 x y z ex ey ez - - 'same fcirclemarker7 red'
291\end{verbatim}
292
293\subsection{NTuple vue / PAW like commands}
294It is possible to plot various expressions of objects, seen as
295a 2D table, with named columns. This possibility exist not only
296for NTuples, but also for most objects (from SOPHYA) handled
297by piapp. See command groups {\bf Expr.Plotting} and
298{\bf pawCmd}
299
300\subsection{C++ execution inside piapp}
301For more complex processings, where the full power of C++
302and the class libraries are necessary, {\bf piapp} provide
303the possibility of executing C++ code, without the burden
304of having to write a complete program. The objects
305present in the current directory are automatically
306declared. The communication with the piapp application
307is done by the {\bf NamedObjMgr} class.
308Two macros {\tt KeepObj()} and {\tt DisplayObj()}
309simplify the task of keeping newly created objects.
310In the example below, we first create a noisy signal
311in a vector, and we keep it in the application
312(Notice the use of multiline command) :
313
314\begin{verbatim}
315Cmd> c++exec c++exec Vector in(1024); \
[3041]316...? in = RandomSequence(RandomSequence::Gaussian, 0., 1.); \
317...? for(int kk=0; kk<in.Size(); kk++) \
318...? in(kk) += 2*sin(kk*0.05); \
319...? KeepObj(in);
[2171]320\end{verbatim}
321We can of course display the resulting vector:
322\begin{verbatim}
323Cmd> disp in
324\end{verbatim}
325
326And, at a subsequent stage, make a low pass filter
327on the vector in:
328\begin{verbatim}
329Cmd> c++exec Vector out(1024); \
[3041]330...? int w = 2; \
331...? for(int k=w; k<in.Size()-w; k++) \
332...? out(k) = in(Range(k-w, k+w)).Sum()/(2.*w+1.); \
333...? KeepObj(out);
[2171]334\end{verbatim}
335
336We can display the new vector {\tt out} overlayed
337on the previously displayed vector:
338\begin{verbatim}
339Cmd> disp out 'red same'
340\end{verbatim}
341
342See command group {\bf CxxExecutorCmd} for more information,
343and the option window activated by the menu:
344{\bf Special/CxxExecOption}.
345
346\subsection{Extending the application}
347The {\bf piapp} application can easily be extended by the user.
348This is done through shared libraries which can be opened
349and used by the application.
350Two main methods can be used (see command group
351{\bf ExternalModules}) :
352\begin{itemize}
353\item Creation of user functions. A shared library containing
354at least one user function with the following prototype
355should be created:
356\begin{verbatim}
357extern "C" {
358 void myfonction(vector<string>& args);
359}
360\end{verbatim}
361The class {\bf NameObjMgr} should be used to communicate with the
362application. The {\tt link} \myppageref{link} and {\tt call} \myppageref{call}
363should be used to load and execute user functions. An example of
364user function can be found in DemoPIApp/user.cc exlink.pic.
365
366\item Creation of loadable modules: Loadable modules can be
367used to extend the application possibilities in a way totally
368transparent to the user. It is possible to define new commands,
369handling of new object types, additional graphic functionalities
370in a loadable module.
371
372The class {\bf CmdExecutor} is the base class for extending piapp.
373A shared library should be built, containing two functions,for
374the activation and deactivation of the module, with the following
375prototype (where {\tt mymodule} is the module's name.
376\begin{verbatim}
377extern "C" {
378 void mymodule_init();
379 void mymodule_end();
380}
381\end{verbatim}
382
383\end{itemize}
384
[3041]385%%%%%%%%%% Section 3: Graphiques
[2171]386\newpage
[3043]387\section{Interactive graphics}
388%%%
389\subsection{Display commands}
390Many objects managed by piapp have a default graphic representation. The
391{\bf disp} command \myppageref{disp} can be used to display the object, while
392other commands like {\bf surf} \myppageref{surf} , {\bf imag}
[3429]393or {\bf contour} \myppageref{contour} will try to force a given graphic representation.
394
[3043]395Data from table like objects can be plotted using commands like {\bf nt2d}
396\myppageref{nt2d} or {\bf nt3d} \myppageref{nt3d}. Most objects in piapp
397can also be manipulated like table for plotting purposes, using commands
398like {\bf plot2d} \myppageref{plot2d} , {\bf plot3d} \myppageref{plot3d}
399or {\bf n/plot} \myppageref{nZplot}. These commands are described in section
[3429]400\ref{tableplot}.
401
402Commands producing a graphic output have usually an optional argument called \\
403{\tt graphic\_attributes} or {\tt gr\_att}. \\
404This argument provide a flexible and easy
405way to change and customise the output graphic, as discussed in the paragraphs below.
406
[3043]407The piapp graphics can be exported in postscript (.ps) or encapsulated postscript
408(.eps) format. The commands {\bf w2ps} \myppageref{w2ps} and
409 {\bf w2eps} \myppageref{w2eps} as well the menu \menubar{PostScript} can
[3429]410 be used to export graphics. \\[2mm]
411The examples in the followwing pages illustrates the usage of some piapp graphic commands.
412\newpage
[3043]413\begin{enumerate}
414\item Image display
415\begin{verbatim}
416# Open a PPF file containing topographic data for france
417# as a TMatrix<short> 1332x1548
418openppf francetopo.ppf
419# Display the matrix, whit a zoom factor, lut and color map
420disp francetopo 'zoom/3 lut=lin,-700,800 colbr128 win'
421w2eps francetopo.eps
422\end{verbatim}
423\begin{center}
424\includegraphics[width=13cm]{francetopo.eps}
425\end{center}
[2171]426
[3043]427\item Simple 2D graphics with vector displays
428\begin{verbatim}
429# Create and initialize two vectors - prevent display : nodisp
430Cmd> newvec vva 100 sin(x/10.+0.7)+cos(x/7.+1.4)*1.26 nodisp
431Cmd> newvec vvb 100 sin(x/10.)+cos(x/7.)*1.34 nodisp
432# Set axe drawing options
433Cmd> setaxesatt 'font=times,bold,16 minorticks tickslen=0.02,0.012'
434# Display the two vectors, with different graphic attributes
435Cmd> disp vva 'red line=solid,2 notitle'
436# Define a title for the graphic
437Cmd> settitle 'Example-1: 2 vectors' ' ' 'font=times,bolditalic,18'
438Cmd> disp vvb 'blue marker=box,7 same'
439# Save the graphic into an eps file
440Cmd> w2eps gr2vec.eps
441\end{verbatim}
442% \begin{figure}[ht!]
443\begin{center}
444\includegraphics[width=12cm]{gr2vec.eps}
445% \label{g22vec}
446\end{center}
447%%%
448\item Creating a comparison chart using {\bf bargraph}
449\begin{verbatim}
450# Representation du PNB (en $, 2003) pour quelques pays
451set pays ( Allemagne Espagne France Italie Pays-Bas Suisse UK USA )
452set pnbh ( 22670 14430 22010 18960 23960 37930 25250 35060 )
453setaxesatt 'font=times,bold,16'
454bargraph pnbh pays - 'blue horizontalbars nofill packfrac=0.65 font=helvetica,bold,14'
455setaxelabels 'PNB / Hab , $ 2003' ' ' 'font=times,bold,16'
456w2eps pnbargraph.eps
457\end{verbatim}
458\begin{center}
459\includegraphics[width=12cm]{pnbbargraph.eps}
460\end{center}
461%%%
462\item Displaying a matrix as a surface
463\begin{verbatim}
464openppf demo.ppf mtx1
465setaxesatt 'font=time,bold,16'
466surf mtx1 'colbr128 line=solid,1 grey'
467w2eps surfcol.eps
468\end{verbatim}
469\begin{center}
470\includegraphics[width=13cm]{surfcol.eps}
471\end{center}
472
473\end{enumerate}
474
475%%%%%%%%%%
476\subsection{Graphic objects in piapp}
477The piapp graphics is handled by the {\bf PI} \footnote {http://www.sophya.org/PI} library,
478which provide a large variety of 2D representations,
479few 3D graphics and powerful image display. \\
480Currently, all graphic representations, except for image displays, are handled
481through {\bf PIDrawers} which are managed by a viewer. A viewer can
482manage several {\bf PIDrawers} objects which correspond then to a multilayer
483graphic display. The viewers are also responsible for managing user
484interactions. \\
485Image displays are handled through a specific viewer
486{\bf PIImage} which is also capable of managing PIDrawer objects
487for multi-layer 2D overlay vector graphics. \\[2mm]
488%%
[3429]489Main piapp/PI graphic viewers, windows and drawer objects are described if
490the following sections.
491
492\subsubsection{PIScDrawWdg (2D display)}
493The {\bf PIScDrawWdg} handles a set of of 2-D drawers, managing
[3043]494the 2D coordinate system and interactive zoom. The axes drawing is
495handled by a specialised drawer, number 0, which also manages various added
496graphic elements (text \ldots). The list of various mouse and
497keyboard actions is described in the reference section, under {\bf PIScDrawWdg} \myppageref{PIScDrawWdg} title. In particular, mouse-button-2 can be used
498to zoom on a particular part, {\tt $<$Alt$>$A} activates the coordinates
499and axes manipulation window ({\bf PIAxesTools}) and {\tt $<$Alt$>$G}
500activates the PIDrawer graphic attributes control window ({\bf PIDrawerTools}).
501%%%
[3429]502\subsubsection{PIDraw3DWdg (3D display)}
503The {\bf PIDraw3DWdg} handles a set of of 3-D drawers, managing
[3043]504interactive camera/object rotation (mouse-button-2) and zoom (mouse-button-2).
505{\tt $<$Alt$>$G} to display/activate the PIDrawer graphic attributes
506control window ({\bf PIDrawerTools}).
507See {\bf PIDraw3DWdg} \myppageref{PIDraw3DWdg} for a complete list of mouse
508and keyboard actions.
509Drawer 0 handles axes drawing and graphic elements.
510%%%
[3429]511\subsubsection{PIImage (Image Display)}
512The display of 2-D arrays $A(i,j)$ as an image is managed by
[3043]513the {\bf PIImage} viewer/widget. The PI library interface {\bf P2DArrayAdapter} is used
514to represent a generic 2-D array. The array values are converted into an index, converted
515itself into a color by the use of a color-map or color-table {\bf PIColorMap}.
516$$ \mathrm{LUT:} A(i,j) \longrightarrow idx(i,j) \hspace{5mm} \mathrm{ColorMap:}
517 idx(i,j) \longrightarrow col(i,j) $$
518Currently index range is 0...255 with color-map having 32 or 128 distinct colors.
519PIImage viewers controls a zoom widget, as well as a global image view widget, and
520a color map view widget. A specific image control window can be activated using
521 {\tt $<$Alt$>$O}. See {\bf PIImage} \myppageref{PIImage} for
522a complete list of mouse and keyboard actions. A base drawer (number 0) can handle
523axes drawing and added graphic elements.
524%%%
[3429]525\subsubsection{Windows}
[3043]526The viewers described above are displayed in differnt kind of windows.
527The graphic option {\tt next,win,same,stack} can be used to control the way the
528type of windows used. Graphic windows can be divided into several zones
[3429]529(Command {\bf zone} \myppageref{zone}).
530
531When an object is diplayed in piapp, a widget (PIWdg) is created which manages
532the drawer or the 2d-array. The default name for this widget is the displayed
533object name. However, it is possible to specify a name using the graphic attribute: \\
534\hspace*{5mm} {\tt wname=WidgetName} \\
535It is possible to display multiple objects on a single widget, corresponding
536to the superposition of the different drawers. Displaying an object superimposed
537on the previously displayed object can be done using the graphic option
538{\tt same}. It is also possible to specify a target widget by its name, through
539the graphic option \\
540\hspace*{5mm} {\tt samew=WidgetName} \\
541It is also possible to specify the display of the drawer in a specified region
542of the last displayed widget \\
543\hspace*{5mm} {\tt same=fx1,fx2,fy1,fy2} \\
544where {\tt fx1,fx2,fy1,fy2} express X and Y limits, as fraction of widget size.
545
[2172]546Refer to the command reference section on windows ({\bf Windows}
547\myppageref{Windows})
[2171]548for information on the different type of windows used by piapp
[3429]549and their properties. \\
550
[3043]551%%%
[3429]552\subsubsection{Drawers}
553Graphical representation of most objects in piapp is
554handled through objects inheriting from the {\bf PIDrawer class}. A base drawer
[3043]555(PIElDrawer, number 0) associated to all three above viewers manages the axes drawing
556as well as the added graphic elements (text, arrow, \ldots). A drawer management menu
557can be activated using {\tt $<$Alt$>$D}. This menu can be used to move and resize
558drawers, or to display a window for changing drawers graphic attributes.
[3429]559%%%
[2172]560\par
[2171]561In addition, a number of control windows can be used to examine and
562change view properties of differents viewers and drawers.
563\begin{itemize}
[3043]564\item[] {\bf PIDrawerTools} activated using {\tt $<$Alt$>$G} or
565\menubar{Tools/Show DrawerTools} on any viewer (see page \myppageref{secdrwtools})
566\item[] {\bf PIAxesTools} activated using {\tt $<$Alt$>$A} or
567\menubar{Tools/Show AxeTools} on PIScDrawWdg (see page \myppageref{secaxestools})
568\item[] {\bf PIImageTools} activated using {\tt $<$Alt$>$O} or
569\menubar{Tools/Show ImageTools} on PIImage
570(see page \myppageref{secimagetools})
571\item[] {\bf PIHisto2DTools} activated using {\tt $<$Alt$>$O} or through the PIDrawerTools
572for an active PIHisto2D drawer. (see page \myppageref{sech2dtools})
573\item[] {\bf PIContourTools} activated using {\tt $<$Alt$>$O} or through the PIDrawerTools
574for an active PIContourDrawer drawer. (see page \myppageref{secconttools})
[2171]575\end{itemize}
[3043]576These control tools are briefly described in appendix.
[2171]577
[3043]578%%%%%%%%%%
579\subsection{Graphic attributes}
580Graphic attributes are specified as a set of space separated strings. Use
581quotes to group them into a single argument parsed by the command
582interpreter. The options are decoded by the different objects handling the
583graphic (viewer widget, drawer, axe drawer). \\
584The complex decoding scheme
585is usually transparent for piapp users. However, there is an ambiguity when
586specifying some of the axes attributes, such as color or the font used for
587drawing the axes. The command {\bf setaxesatt} (\myppageref{setaxesatt})
588should thus be used to specify generic graphic attributes (color, font, line type). \\
589for axes.
590\begin{itemize}
591\item[\bul] The {\bf PIScDrawWdg} viewer options: \\
592\begin{verbatim}
593>> To define the 2D axes limits (in user coordinates)
594 xylimits=xmin,xmax,ymin,ymax
595>> To define the default drawing rectangle, in fraction of widget size
596 defdrrect=x1,x2,y1,y2 (default: x1=y1=0.1 x2=y2=0.9)
597>> Axes flags :
598 linx logx liny logy
599>> To change the background color (default=white)
600 wbgcol=colname
601
602\end{verbatim}
603%%%
604\item[\bul] The {\bf PIDraw3DWdg} viewer options: \\
605\begin{verbatim}
606>> To define the 3D box limits :
607 xyzlimits=xmin,xmax,ymin,ymax,zmin,zmax
608 limit3dbox=xmin,xmax,ymin,ymax,zmin,zmax
609>> Autoscaling flags (rescaling of X/Y or X/Y/Z axes)
610 autoscale3dbox / noautoscale3dbox
611 autoscalexy3dbox / noautoscalexy3dbox
612 autoscalez3dbox / noautoscalez3dbox
613>> To change the background color (default=white)
614 wbgcol=colname
615
616\end{verbatim}
617%%%
618\item[\bul] The {\bf PIImage} viewer options: \\
619\begin{verbatim}
620>> Define display zoomfactor
621 zoomxFact (zoomx2 zoomx3 ... zoomx9 ...)
622 zoom/Fact (zoom/2 zoom/3 ... )
623>> LUT (look-up table) definition (pixel value to index conversion)
624 lut=type,min,max (type=lin/log/sqrt/square)
[3294]625>> AutoLut selector : define the method for automatic determination
626 of LUT limits (min/max)
627 autolut=alt[,ns[,minp,maxp]] (minp<=pixels<=maxp)
628 - autolut=minmax[,Frac] 0<=Frac<=1
629 - autolut=meansig[,ns] --> mean +/- ns*sigma
630 - autolut=hispeak[,ns] --> around the peak of pixel values histogram
631 - autolut=histail[,ns] --> the tail of pixel values histogram
[3043]632>> Define color table and reversing color indexing flag
633 ColTableName revcmap
634 ==> Standard tables with 32 distinct colors:
635 grey32 invgrey32 colrj32 colbr32 colrv32
636 ==> Standard tables with 128 distinct colors:
637 grey128 invgrey128 colrj128 colbr128
638 ==> Shades of red/green/blue ...
639 red32cm green32cm blue32cm yellow32cm
640 orange32cm cyan32cm violet32cm
641 ==> Some of MIDAS color tables :
642 midas_pastel midas_heat midas_rainbow3
643 midas_bluered midas_bluewhite midas_stairs8
644 midas_stairs9 midas_staircase midas_color
645 midas_manycol midas_idl14 midas_idl15
646 ==> Other tables
647 multicol16 multicol64
648>> Viewed center position (image/array coordinates)
649 imagecenter=xc,yc
650>> Array axes to window axes mapping flags
651 invx invy exchxy
652>> To change the background color (default=black)
653 wbgcol=colname
654
655\end{verbatim}
656%%%
657\item[\bul] The {\bf PIGraphicAtt} Generic graphic attributes (color/font/line \ldots)
658decoded by all drawers: \\
659\begin{verbatim}
660>>> color=ColorName - fgcolor=ColorName - bgcolor=ColorName
661 ColorName: black white grey red blue green yellow
662 magenta cyan turquoise navyblue orange
663 siennared purple limegreen gold violet
664 violetred blueviolet darkviolet skyblue
665 royalblue forestgreen orangered brown
666>>> line=DashType,LineWidth
667 DashType: solid, dash, dotted, dashdotted Width: 1,2,...
668>>> font=FontName,FontAtt,FontSize
669 FontName: courier, helvetica, times, symbol
670 FontAtt: roman, bold, italic, bolditalic
671 FontSize: 6,8,10,12... (pts) - integer
672>>> marker=MarkerType,MarkerSize (MarkerSize: integer 3,5,7...
673 MarkerType: dot, plus, cross, circle, fcircle, box, fbox
674 triangle, ftriangle, star, fstar
675>>> arrow=ArrowType,ArrowSize (ArrowSize: integer 3,5,7...
676 ArrowType: basic, triangle, ftriangle,
677 arrowshaped, farrowshaped
678>>> ColorTables: defcmap grey32 invgrey32 colrj32 colbr32
679 grey128 invgrey128 colrj128 colbr128
680 red32cm green32cm blue32cm yellow32cm
681 orange32cm cyan32cm violet32cm
682 midas_pastel midas_heat midas_rainbow3 midas_bluered
683 midas_bluewhite midas_redwhite
684 multicol16 multicol64
685> revcmap : This flag reverses ColorMap indexing
686------- Old style graphic att ----------
687>> Lines: defline normalline thinline thickline dashedline thindashedline
688 thickdashedline dottedline thindottedline thickdottedline
689>> Font Att: deffontatt normalfont boldfont italicfont bolditalicfont
690 smallfont smallboldfont smallitalicfont smallbolditalicfont
691 bigfont bigboldfont bigitalicfont bigbolditalicfont
692 hugefont hugeboldfont hugeitalicfont hugebolditalicfont
693>> Font Names: deffont courierfont helveticafont timesfont symbolfont
694>> Marker: dotmarker<S> plusmarker<S> crossmarker<S> circlemarker <S>
695 fcirclemarker<S> boxmarker<S> fboxmarker<S> trianglemarker<S>
696 ftrianglemarker<S> starmarker<S> fstarmarker<S>
697 with <S> = 1 3 5 7 9 , Example fboxmarker5 , plusmarker9 ...
698
699\end{verbatim}
700%%%%
701\item[\bul] The {\bf PIElDrawer} decodes axe drawing attributes: \\
702\begin{verbatim}
703 >> Axe and grid configuration flags:
704 axesnone stdaxes defaxes
705 boxaxes boxaxesgrid fineaxes fineaxesgrid
706 centeredaxes finecenteredaxes centeredaxesgrid
707 finecenteredaxesgrid grid/nogrid
708 >> Centered axes position: axescenter=xc,yc
709 >> Axe ticks/labels (h=horizontal/x, v=vertical/y):
710 labels/nolabels hlabels/nohlabels vlabels/novlabels
711 ticks/noticks minorticks/nominorticks
712 extticks/intticks/extintticks nbticks=X_NbTicks,Y_NbTicks
713 tickslen=MajorTickLenFrac,MinorTickLenFraC
714 >> Axe label font size:
715 autofontsize=FontSizeFrac fixedfontsize
716 >> Up/Down title: title tit notitle notit
717 ... Color/Font/line attributes :
718
719\end{verbatim}
720\item[\bul] The {\bf PINTuple} handles most 2D plotting : \\
721\begin{verbatim}
722 sta,stat,stats: activate statistic display
723 nsta,nstat,nostat,nostats: deactivate statistic display
724 statposoff=OffsetX,OffsetY : Position offset for Stats drawing
725 as a fraction of total size
726 connectpoints: The points are connected by a line
727 noconnectpoints (this is the default)
728 colorscale/nocolorscale (Use color scale for weight)
729 sizescale/sizescale=nbins/nosizescale (Use marker size for weight)
730 (and usual color/line/marker/... attribute decoding)
731
732\end{verbatim}
733%%%
734\item[\bul] {\bf PIHisto} and {\bf PIHisto2D} handle1D and 2D histograms display. \\
735The following options are recognised by PIHisto: \\
736\begin{verbatim}
[3138]737 ---- PIHisto options help info :
[3043]738 sta,stat,stats: activate statistic display
739 nsta,nstat,nostat,nostats: deactivate statistic display
740 err / noerr,nerr : draw, do not draw error bars
741 autoerr : draw error bars if Marker drawing requested OR Profile histo
742 fill / nofill,nfill : fill, do not fill bars with selected color
743 statposoff=OffsetX,OffsetY : Position offset for Stats drawing
744 as a fraction of total size
[3151]745 ---- HistoWrapper options :
746 hbincont: select bin content as Y value for display (default)
747 hbinerr: select bin error as Y value for display
748 hbinent: select bin entries as Y value for display
749 hscale=value : multiplicative factor for Y value
750 hoffset=value : additive coefficient for Y value
751 hs1: set hscale=1 hoffset=0 (default)
752 hscale=value : multiplicative factor (in Y)
[3138]753
[3043]754\end{verbatim}
755The following options are recognised by PIHisto2D: \\
756\begin{verbatim}
757- sta,stat,stats: activate statistic display
758 nsta,nstat,nostat,nostats: deactivate statistic display
759- h2disp=typ[,fracpts]: choose display type
760 typ=var: variable size boxes
761 typ=hbk: "a la hbook2"
762 typ=img: image like (use "h2col" for color map)
763 typ=pts: point clouds (fracpts=max possible fraction
764 of used pixels per bin [0,1])
765- h2scale=lin/log[,logscale]: choose linear or logarithmic scale
766- h2dyn=[hmin][,hmax]: choose histogramme range for display
767- use general key to define color table (ex: grey32,midas_heat,...)
768 (see general graphicatt description)
769- use key "revcmap" to reverse color table
770- h2frac=[fmin][,fmax]: choose sub-range display [0,1]
[3151]771 ---- HistoWrapper options : (see HistoWrapper above)
[3043]772
773\end{verbatim}
774%%%%
775\item[\bul] The {\bf PINTuple3D} and {\bf PISurfaceDrawer}
776handles basic 3D plotting and can decode the common 3D box options: \\
777\begin{verbatim}
778 X/Y,Z axis rescaling option (-> cubic 3D box)
779 rescale=autoscale/ norescale=noautoscale : X/Y and Z axis
780 rescalexy=autoscalexy / norescalexy=noautoscalexy : X/Y axis
781 rescalexy=autoscalexy / norescalexy=noautoscalexy : Z axis
782\end{verbatim}
783The PINTuple3D decodes in addition the following options:
784\begin{verbatim}
785 connectpoints: The points are connected by a line
786 noconnectpoints (this is the default)
787 colorscale/nocolorscale (Use color scale for weight)
788 sizescale/sizescale=nbins/nosizescale (Use marker size for weight)
789
790\end{verbatim}
[3429]791\item[\bul] The {\bf (PIContourDrawer)} decodes the following options : \\
792\begin{verbatim}
793 autolevels : automatic selection of levels and number of contours
794 ncont=nLevel (or nc=NLevel) : sets the number of contour
795 lev=v1,v2,v3... (or niv=v1,v2,v3...) set the number and levels of contours
796 lstep=nLev,start,step : define incremental levels
797 labon/laboff : display of contour level values on/off
798 linear/bspline/cubicspl=3spl : select contour kind
799
800\end{verbatim}
801
[3043]802\item[\bul] {\bf PIBarGraph} options : \\
803\begin{verbatim}
804 ---- PIBarGraph options help info :
805 fill/nofill: set bar fill option
806 horizontalbars/verticalbars: set bar orientation
807 packfrac=value : set bar packing fraction (0..1)
808 barvaluelabel/nobarvaluelabel: Use/Don't use bar value as labels
809 --- + Usual colr/line/font attribute decoding ...
810 \end{verbatim}
811\end{itemize}
812
813
[3041]814%%%%%%%%%%%%%%% Section 4 : I/O
815\newpage
[3302]816\section{Data formats and input-output (I/O)}
817The data file formats recognized by piapp are the ones supported by the
818SOPHYA library or its extension.
[3041]819\begin{itemize}
[3302]820\item[\bul] ASCII files - Data can be imported from ascii (text) files as
821datatables or arrays. These objects can also be exported as text files.
822\item[\bul] FITS files - FITS is a popular format used in particular in astronomy.
823\href{http://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html}
824Data is usually read from FITS files as vectors, images, cubes or tables.
825A subset of SOPHYA objects can be exported in FITS format.
826\item[\bul] PPF (Portable Persistence file Format) is the native SOPHYA
827data format.
828\item[\bul] PostScript - All graphic output produced by piapp can be exported
829as postscript (.ps) or encapsulated postscript (.eps) files.
830\end{itemize}
831
[3429]832\subsection{Text files}
833Text (or ascii) files can be read into array or datatable objects by spiapp.
834
835{\bf Arrays :} \\
836Arrays can be written to to files in text/ascii format using the {\tt arrtoascii}
837 \myppageref{arrtoascii} command. Double precision matrices and vectors
838 can be read from text files using the commands
839 {\tt mtxfrascii} \myppageref{mtxfrascii} and
840 {\tt vecfrascii} \myppageref{vecfrascii} . \\
841The menu-bar command \menubar{File/Open-ASCII} reads in a text
842file as a matrix.
843\begin{verbatim}
844# Create and initialize a matrix
845newmtx arr 250 150 x+3*y
846# Save the file in the text file arr.txt
847arrtoascii arr arr.txt
848# Read the previously created file and fill a matrix
849mtxfrascii mxa arr.txt
850# Print and display the matrix
851print mxa
852disp mxa zoomx2
853\end{verbatim}
854It is possible to specify the field separator in the input file, as well as the marker for the comment
855lines.
856
857{\bf DataTable :} \\
858Text files can also be read as a 2-D table (NTuple or DataTable). The table should be
859created using the {\tt newnt} \myppageref{newnt} or
860{\tt newdt} \myppageref{newdt} command.
861The command {\tt ntfrascii} \myppageref{ntfrascii} can then be used to append
862data from the file to the datatable.
863
864\subsection{PPF}
865%%%
866PPF (Portable Persistence file Format) is the the native persistence
867format of SOPHYA and thus is fully handled by spiapp. PPF files can
868be opened through the menu-bar \menubar{File/Open-PPF}, or through
869the {\tt openppf} \myppageref{openppf}.
870
871If the PPF file contains NameTags, only the objects marked with nametags are read and given
872the corresponding names. Otherwise, all objects are red sequentially, with their names
873formed by the filename followed by a sequence number. It is also possible to force the sequential
874reading specifying the {\tt -s} flag for openppf.
875
876The objects managed in spiapp by the {\bf NamedObjMgr} can be saved to PPF files, with their
877names as NameTags. The commands {\tt saveppf} \myppageref{saveppf} or
878 {\tt saveall} \myppageref{saveall} can be used to this end.
879
880\begin{verbatim}
881# Create two vectors and two matrices
882newvec va1 150 sin(sqrt(x))
883newvec vb2 150 sin(sqrt(x))*sqrt(x*0.1)
884newmtx mxa 250 150 x+2.*y
885newmtx mxb 250 150 sin(sqrt(x))*cos(sqrt(y))
886# List of the objects in memory
887listobjs
888# Save the two vectors in the file vecab.ppf
889saveppf v* vecab.ppf
890# Save the two matrices in the file mxab.ppf
891saveppf m* mxab.ppf
892\end{verbatim}
893
894\subsection{FITS}
895FITS files may contain three types of data structures
896\begin{enumerate}
897\item Image or array data structure : {\tt IMAGE\_HDU}
898\item Binary table : {\tt BINARY\_TBL}
899\item ascii table : {\tt ASCII\_TBL}
900\end{enumerate}
901The {\bf FitsIOServer} module contain FitsHandler classes which
902can map many SOPHYA classes on FITS data structures.
903Generic {\tt IMAGE\_HDU} correspond to the SOPHYA \tcls{TArray}
904class, while {\tt BINARY\_TBL} or {\tt ASCII\_TBL} is mapped
905to NTuple or DataTable.
906
907FITS format files can be read through the menu command \menubar{File/Open-Fits},
908or using {\tt readfits/openfits} \myppageref{readfits} command.
909Objects can be exported to FITS using the {\tt writefits/savefits}
910\myppageref{writefits} command.
911
912\begin{verbatim}
913# Open the PPF file created by the commands above
914openppf vecab.ppf
915# Export the two vector objects to file vecab.fits
916# Note that the '!' forces c-fitsio to overwrite the file, if it exists
917writefits v?? !vecab.fits
918\end{verbatim}
919
[3302]920\subsection{Graphic export in postscript}
[3429]921%%
922Postscript a page description language widely used for printing and
923graphic output, developed by Adobe systems. Refer to
924\href{http://www.adobe.com/products/postscript/}{Adobe/PostScript3}
925for more detail.
[2171]926
[3429]927Piapp graphic output can be exported in postscript (level 2) or
928encapsulated postscript format.
929Postscript (.ps) files my contain several pages, each vue or window
930corresponding to one page and are suitable for direct printing.
931An Encapsulated Postscript (.eps) file contains a single page,
932corresponding to a window and is suitable for inclusion in
933other document.
934
935Postscript file can easily be converted to other formats,
936PDF or image formats (jpeg \ldots) using converters like
937{\bf ps2pdf} or {imagemagick}.
938
939The menu items under \menubar{PostScript} can be used to export
940graphics in postscript. The default file name is {\tt pia.ps}
941or {\tt pia1.eps} {\tt pia2.eps} \ldots
942The following commands can also be used to create postscriot file
943from the display in the current graphic window:
944\begin{itemize}
945\item {\tt w2ps} \myppageref{w2ps} to add the current graphic
946output as a new page to the output postscript file.
947The current output postscript file (default = w2ps.ps)
948should be closed before being used. Exiting piapp closes automatically
949all postscript files.
950\item {\tt psclosefile} \myppageref{psclosefile} to close the current
951output postscript file.
952\item {\tt pssetfilename} \myppageref{pssetfilename} To define
953the output postscript file name for the subsequent {\tt w2ps} commands.
954\item {\tt w2eps} \myppageref{w2eps} to export the current
955graphic display, in Encapsulated Postscript format to the specified file.
956\begin{verbatim}
957# Open the PPF file created by the commands above
958openppf vecab.ppf
959# Display one of the vectors
960setaxesatt 'font=helvetica,bold,18 fixedfontsize'
961disp va1 'blue marker=box,5'
962# Export the graphic to file va1.eps
963w2eps va1.eps
964# The created file can be viewed using gv
965\end{verbatim}
966\end{itemize}
967
[3041]968%%%%%%%%%%%%%%% Section 5 : analyse a la paw
[2171]969\newpage
[3041]970\section{Tables and interactive analysis}
[3043]971\label{tableplot}
[3041]972
973%%%%%%%%%%%%%%% Section 6 : command interpreter
974\newpage
975\section{Command interpreter}
976piapp uses the class {\bf PIACmd} which extends slightly the
977SOPHYA class {\bf Commander} as the command interpreter.
978{\bf Commander} is a c-shell inspired, string oriented command
979interpreter. Although it has many limitations compared to
980c-shell, or Tcl , it provides some interesting possibilities:
981\begin{itemize}
982\item Extended arithmetic operations (c-like and RPN)
983\item Simple and vector variables
984\item Script definition
985\item Command execution in separate threads
986\item Dynamic Load
987\end{itemize}
988
989We describe below the {\bf Commander} possibilities,
990as well as the few {\bf PIACmd} extensions.
991
992\subsection{Variables}
993The SOPHYA::Commander interpreter manages non typed set of variables.
994Environment variables are also accessible through
995the usual {\tt \$varenvname}, unless shadowed by a Commander
996variable. All Commander variables are vector of strings, and are
997extended as necessary. {\tt \$varname} is the string formed by all
998the vector elements. Except when performing arithmetic operations,
999variables are treated as strings.
1000\par
1001An application level set of variables is also managed
1002by Commander, through redefinition of \\
[3043]1003{\tt Commander::GetVarApp() / GetVarApp() \ldots } methods. \\
[3041]1004The {\bf PIACmd} in piapp redefines the {\tt GetVarApp() }
1005in order to provide an easy access to some of objects attributes or methods,
[3043]1006managed by {\bf NamedObjMgr} (See below).
[3041]1007
1008\begin{itemize}
1009\item[\rond] {\bf Definition and initialisation of variables }
1010\begin{verbatim}
1011# Notice that the set command has no = sign
1012Cmd> set sv StringValue
1013# Clearing/removing of a variable : unset or clearvar
1014Cmd> unset sv
1015
1016# Definition of a multi element variable (vector type)
1017# Notice that spaces before / after '(' and ')' are mandatory
1018Cmd> set vecv ( mot1 mot2 mot3 mot4 mot5 )
[3429]1019# Arithmetic expression : C language syntax - spaces
1020# before/after '=' are mandatory
[3046]1021Cmd> a = 2+3*sqrt(4)
[3041]1022# The '=' operator can also be used to initialize a variable with a string
1023Cmd> a = 'Bonjour Madame'
1024# A vector element can be specified in the left hand side
1025Cmd> vecv[2] = 'coucou'
1026# Or using an interpreter variable as index :
1027Cmd> i = 3
1028Cmd> vecv[i] = 'Ooohhh'
1029\end{verbatim}
1030
1031On the right hand side, the value of a variable should be accessed using
1032the \$ character. \\
1033A string can be parsed into words using {\tt var2words}
1034\begin{verbatim}
1035Cmd> var2words varname wordvarname [separateur]
1036\end{verbatim}
1037
1038\item[\rond] {\bf Accessing variable contents } \\
1039The \$ character is used to access the content of a variable {\tt \$varname} .
1040Substitution rules :
1041The {\tt \$xxx} is replaced by the value of variable xxx.
1042No substitution is performed for strings enclosed in simple quotes {\tt ' ... \$xxx '},
1043but substitution is done in strings enclosed in double quotes.
1044Parenthesis or brackets can be used to specify the variable name, inside a string
1045without white space: {\tt \${vname} } ou {\tt \$(vname)}.
1046\begin{verbatim}
1047Cmd> x = 'Hello'
1048Cmd> echo $x
1049# Size of a vector variable : $#vname
1050Cmd> set vx ( 111 2222 3333 444444 )
1051Cmd> echo $#vx
1052# Accessing vector elements
1053Cmd> echo $vx[0] $vx[1]
1054# or using an interpreter variable as index :
1055Cmd> i = 2
1056Cmd> echo $vx[i]
1057# Special syntax: $[vname] is replaced by the content
1058# of a variable whose name is $vname
1059Cmd> zzz = 'Commander'
1060Cmd> xxx = 'zzz'
1061Cmd> echo '---> $[xxx]= ' $[xxx]
1062---> $[xxx]= Commander
1063\end{verbatim}
1064
1065\par
1066
1067\item[\rond] {\bf Special variables }
1068\begin{itemize}
1069\item {\tt \$retval} ou {\tt \$retstr} : the string specified in the last {\bf return} statement
1070\item {\tt \$status} : Return code from the last executed command.
1071Arguments of scripts (see below) or file executed through {\bf exec} command.
1072\item {\tt \$\# } : number of arguments, except \$0
1073\item {\tt \$0} : Script or file name
1074\item {\tt \$1 \$2 \$3} .... : Arguments (for scripts and .pic files (exec))
1075\end{itemize}
[3043]1076
1077\item[\rond] {\bf Objects/Application level variables} \\
1078For some classes managed by NamedObjMgr,
1079PIACmd provide acces to some of the attributes of the object by
1080{\tt \${objname.attname} }. This mechanism has been implemented in particular for
1081TArrays, TMatrix/TVector, Histograms, NTuples and DataTables.
1082In addition, when brackets are used ($\${vname}$), the priority level between interpreter variables
1083and application level variable is changed. If {\tt vname} exist at the application level,
1084{\tt \${vname} } is replaced by its value, even if an interpreter variable with the
1085same name has been defined.
1086\begin{verbatim}
1087# -------- Example with a Vector
1088piapp[1] newvec va 12
1089piapp[2] echo $va
1090TVector<d>(12) (nr=12, nc=1)
1091# ------- An undefined attribute, such as ? might be
1092# used to get list of valid attributes
1093piapp[3] echo ${va.?}
1094TMatrix.Att: rank size/nelts nrow/nrows ncol/ncols sum
[3429]1095# Compound names, in the form name.att must be inclosed in
1096# braces {name.att}
[3043]1097piapp[4] echo ${va.size}
109812
1099# -------- Example with an histogram
1100piapp[8] newh1d his 0. 20. 40
1101piapp[10] echo ${his.?}
1102Histo1D: nbin binw mean sigma over under nentries ndata
1103 xmin xmax vmin vmax imin imax
1104piapp[11] echo ${his.nbin}
110540
1106\end{verbatim}
1107
1108\item[\rond] {\bf Environment variables} can simply be accessed by {\tt \$varenvname}.
1109However, the environment variables have the lowest priority during substitution.
1110Interpreter's variables have the highest priority, followed
1111by the application level variables.
1112
[3041]1113\end{itemize}
1114
[3043]1115
[3041]1116\subsection{Control structures}
1117
1118\begin{itemize}
1119\item[\rond] Enumerated loop:
1120\begin{verbatim}
1121foreach f ( w1 w2 w3 ... )
1122 ...
1123 echo $f
1124end
1125\end{verbatim}
1126
1127Note that spaces before/after '(' et and ')' are mandatory.
1128An alternative form uses a vector variable name :
1129\begin{verbatim}
1130foreach v vecname
1131 ...
1132 echo $v
1133end
1134\end{verbatim}
1135
1136\item[\rond] Integer type loop:
1137\begin{verbatim}
1138for i startInt:endInt[:stepInt]
1139 ....
1140 echo $i
1141end
1142\end{verbatim}
1143
1144\item[\rond] Integer type loop:
1145\begin{verbatim}
1146for f startFloat:endFloat[:stepFloat]
1147 ....
1148 echo $f
1149end
1150\end{verbatim}
1151
1152\item[\rond] Loop over lines of a file
1153\begin{verbatim}
1154forinfile line FileName
1155 ...
1156 echo $line
1157end
1158\end{verbatim}
1159
1160\item[\rond] The {\tt break} instruction can be used to exit from a loop
1161
1162\item[\rond] {\bf if then else} Conditional execution:
1163\begin{verbatim}
1164if ( test ) then
1165endif
1166
1167if ( test ) then
1168 ....
1169else
1170 ....
1171endif
1172\end{verbatim}
1173Note that spaces before/after '(' et and ')' are mandatory.
1174
1175test is in the form {\tt a == b} OR {\tt a != b} OR {\tt a < b} OR {\tt a > b}
1176OR {\tt a <= b} OR {\tt a >= b}. Comparison operators should be delimited
1177by spaces.
1178{\tt ==} et {\tt !=} make a string comparison, while
1179{\tt < , > , <= , >=} compare the values obtained after string to double conversion.
1180\end{itemize}
1181
1182\subsection{Script definition}
1183A script is a sequence of commands. It is very similar to the execution of commands
1184from a file ({\bf exec filename}). Once a script has been defined, it can be called specifying
1185specifying the script name followed by its arguments.
1186\begin{verbatim}
1187# Script definition :
1188defscript scriptname [description ]
1189 ....
1190endscript
1191
1192# Executing the script
1193Cmd> scriptname arg1 arg2 arg3 ....
1194\end{verbatim}
1195
1196The {\tt return} instruction stops the execution and returns from a script, or from a command
1197file called through {\bf exec}. \\
1198The commands {\bf listscript } and {\bf clearscript scriptname} can be used
1199to obtain the list of already defined script, or to clear a script definition.
1200
1201\subsection{Other built-in commands}
1202\begin{itemize}
1203\item[\rond] Instruction {\bf echo } to write the line to cout/stdout
1204\item[\rond] Instruction {\bf echo2file} to write (append) the line to file ({\tt echo2file filename ....})
1205\item[\rond] Instruction {\bf sleep nsec} wait for {\tt nsec} seconds
1206\item[\rond] Instructions {\bf timingon , timingoff , traceon , traceoff } \\
1207%
1208\item[\rond] {\bf exec filename [arg1 arg2 ... ] } to execute command from
1209the file named {\tt filename}. {\tt .pic} is the default extension for the interpreter
1210command files.
1211\item[\rond] {\bf help} and {help keyword/commandname }
1212\item[\rond] {\bf listvars , listcommands } to print the list of defined variables and known
1213commands
1214\item[\rond] An alias for a command by {\bf alias aliasname 'string ' }. Alias substitution
1215occurs for the first word in a command line. {\bf listalias} prints the list of all
1216defined aliases.
1217\item[\rond] Execution control (piapp/PIACmd extension):
1218It is possible to stop the interpreter execution in a loop, a script or
1219a command file by the {\bf stop} command, or using
1220 {\tt <Cntrl C>} in the piapp console (PIConsole) \\
1221\end{itemize}
1222
1223\subsection {Command execution in separate threads}
1224It is possible to create new threads to execute commands
1225( for non built-in interpreter commands). The syntax is similar
1226to unix shell background tasks: an {\&} should be added at the end
1227of the command line. A new thread is then created for the
1228execution of the command, if declared as thread safe \\
1229(see {\tt CmdExecutor::IsThreadable() }.
1230\par
1231Thread management commands:
1232\begin{itemize}
1233\item[\rond] {\bf thrlist }Print current list of threads, with the associated command
1234the thread identifier (integer ThrId) and its status.
1235\item[\rond] {\bf cleanthrlist } Removes all finished threads from the list.
1236An automatic cleanup is performed periodically.
1237\item[\rond] {\bf cancelthr ThId } / {\bf killthr ThId } Stops/kills the thread with
1238the identifier ThId. Avoid using theses commands as the cleanup does
1239not release some resources associated with
1240the thread (memory, mutex \ldots).
1241\end{itemize}
1242
1243%%%%%%%%%%%%%%% Section 7 : c++ execution
1244\newpage
1245\section{On the fly C++ execution}
1246
1247%%%%%%%%%%%%%%% Section 8 : command reference
1248\newpage
[2171]1249\section{piapp command reference}
[2253]1250\label{piappcmdref}
[2171]1251This section contains the description of piapp commands. This information
1252is available on-line, through the help command, or through a graphic
[3041]1253window, accessible by \menubar{File / Help}.
[2171]1254The help items and command are divided into different sections,
1255where related commands are grouped. \\[10mm]
1256
1257% \include{piahelp}
1258\input{piahelp.tex}
1259
1260% La partie des appendix
1261\appendix
1262\newpage
[3041]1263\section{Interactive control windows}
1264\subsection{DrawerTools} \index{DrawerTools}
[2171]1265\label{secdrwtools}
1266The {\bf PIDrawerTools}, shown in the figure \ref{figdrwtools} can be
1267used to change the graphic attributes (color, font, marker, \ldots)
1268of the Drawers displayed in 2D displays
1269({\bf PIScDrawWdg} \myppageref{PIScDrawWdg}) or 3D displays
1270({\bf PIDraw3DWdg} \myppageref{PIDraw3DWdg}), as well in image displays
1271{\bf PIImage} (\myppageref{PIImage}). The PIDrawerTools can be activated
1272either using {\tt Alt<G>} on a PIScDrawWdg,PIDraw3DWdg,PIImage,
[3043]1273or through the \menubar{Tools/Show DrawerTools}.
1274A given drawer can be selected through the DrawerId selector (+ / - buttons)
[2171]1275
[3041]1276\vspace*{5mm}
[2171]1277\begin{figure}[ht!]
1278\begin{center}
[3043]1279\includegraphics[width=8cm]{piapp_drwtools.eps}
[2171]1280\caption{PIDrawerTools}
1281\label{figdrwtools}
1282\end{center}
1283\end{figure}
[3041]1284%%%%
1285\subsection{AxesTools} \index{AxesTools}
[2171]1286\label{secaxestools}
1287The {\bf PIAxesTools}, shown in the figure \ref{figaxestools} can be used to
1288control and change the setting of axes on 2D displays
1289({\bf PIScDrawWdg} \myppageref{PIScDrawWdg}).
1290The PIAxesTools can be activated
1291either using {\tt Alt<A>} on a PIScDrawWdg or through
[3043]1292the \menubar{Tools/Show AxesTools}.
[2171]1293
[3041]1294\vspace*{5mm}
[2171]1295\begin{figure}[ht!]
1296\begin{center}
1297\includegraphics[width=8cm]{piapp_axestools.eps}
1298\caption{PIAxesTools}
1299\label{figaxestools}
1300\end{center}
1301\end{figure}
[3041]1302%%%%%
[3043]1303\subsection{ImageTools} \index{ImageTools}
[2171]1304\label{secimagetools}
1305The {\bf PIImageTools}, shown in the figure \ref{figimgtools} can be used to
1306manipulate a display of type image. Image display are handled by the
1307{\bf PIImage} (\myppageref{PIImage}). The PIImageTools can be activated
[3043]1308either using {\tt Alt<O>} on a PIImage, or through the
1309\menubar{Tools/Show ImageTools}.
[2171]1310
[3041]1311\vspace*{5mm}
[2171]1312\begin{figure}[ht!]
1313\begin{center}
1314\includegraphics[width=8cm]{piapp_imgtools.eps}
1315\caption{PIImageTools}
1316\label{figimgtools}
1317\end{center}
1318\end{figure}
1319
[3041]1320\subsection{Histo2DTools} \index{Histo2DTools}
[2171]1321\label{sech2dtools}
1322The {\bf PIHisto2DTools}, shown in the figure \ref{figh2dtools} can be
1323used to control and change the display caracteristics of 2D histograms.
[2253]1324PIHisto2DTools can be activated
[2171]1325either using {\tt Alt<O>} on a PIScDrawWdg, when the active
1326drawer is a PIHisto2DDrawer, or through the generic drawer tool
1327PIDrawerTools.
1328
[3041]1329\vspace*{5mm}
[2171]1330\begin{figure}[ht!]
1331\begin{center}
1332\includegraphics[width=8cm]{piapp_h2dtools.eps}
1333\caption{PIHisto2DTools}
1334\label{figh2dtools}
1335\end{center}
1336\end{figure}
1337
[3041]1338\subsection{ContourTools} \index{ContourTools}
[2171]1339\label{secconttools}
1340The {\bf PIContourTools}, shown in the figure \ref{figconttools} can be
1341used to control and change the caracteristics of contour displays.
[2253]1342PIContourTools can be activated
[2171]1343either using {\tt Alt<O>} on a PIScDrawWdg, when the active
1344drawer is a PIContDrawer, or through the generic drawer tool
1345PIDrawerTools.
1346
1347\vspace*{10mm}
1348\begin{figure}[ht!]
1349\begin{center}
1350\includegraphics[width=11cm]{piapp_conttools.eps}
1351\caption{PIContourTools}
1352\label{figconttools}
1353\end{center}
1354\end{figure}
1355
1356
[2253]1357
1358Both drawing options (e.g. color, line type, fonts...) and contour
1359determination parameters (e.g. contour number and levels) are controlled
1360by {\bf PIContourTools}.
1361
[3041]1362\subsubsection{Drawing options}
[2253]1363The top choices in {\bf PIContourTools}
1364concern the color map (left choice) or color (right choice) of the contours.
1365If a color map has been chosen, it is used to give each contour a color
1366(according to its level). If no color map has been chosen, contours may be
1367given a color using the left choice box.
1368
1369Contour are by default traced by lines.
1370Alternatively (or in addition) the user may ask to trace them by markers
1371or to put numeric labels (with the contour's level) aside the contour.
1372These options are enabled/disabled by the {\tt LineON}, {\tt MarkerON} and {\tt LabelON}
1373buttons from {\bf PIContourTools}.
1374
1375Options may be recovered ({\tt GetAtt}) or set ({\tt SetAtt})
1376from/to a drawer. Setting an option which adds to the screen will be immediately visible
1377whereas unsetting it requires a {\tt Refresh} to be visible.
1378
1379
[3041]1380\subsubsection{Contour options}
[2253]1381The contouring routines in {\tt spiapp} are based on a hack of the {\tt GNUPlot}
1382routines. Contours are determined from a grid of values
1383using an interpolation scheme. Three schemes may be used
1384(selected by the left menu) :
1385\begin{enumerate}
1386\item Linear interpolation (default), selected by the {\tt Int. Lin.} option
1387\item A cubic spline algorithm, selected by the {\tt CubicSpl} option
1388\item A 2d BSpline algorihm, selected by the {\tt B-Spline} option
1389\end{enumerate}
1390
1391Contour levels and number are automatically
1392determined by the program. They may be specified differently,
1393 through command-line options
1394(see section \ref{piappcmdref} for the help of the contour/ntcont commands)
1395or the lower part of the {\bf PIContourTools} window.
1396
1397The user may specify one of the following alternatives :
1398\begin{enumerate}
1399\item the number of contour (their level beeing automatically set).
1400To do this, select {\tt LevelNum} in the right menu and enter the contour number
1401in the left box below.
1402\item the levels of the contours, through an array of numerical values
1403(e.g. 1,4,6,9,27,4.5 will result in 6 contour lines being drawn, if possible and necessary).
1404To do this, select {\tt LevelDisc} and enter the contour number (left box)
1405and the values (right box) separated by ``{\tt ,}''.
1406\item the levels of the contours through an initial (lower) value and an increment.
1407For this, select {\tt LevelInc} and enter the contour number (left box)
1408and the initial value and increment in the right box, as above.
1409\item come back to the default situation, by choosing {\tt LevelAuto}
1410\end{enumerate}
1411
1412Once these options are set, it is necessary the the program recomputes
1413the contour lines. This is commanded by the {\tt SetParm} button.
1414
1415
[2171]1416\newpage
1417\addcontentsline{toc}{section}{Index}
1418\printindex
1419
1420\end{document}
Note: See TracBrowser for help on using the repository browser.