Changeset 1648 in Sophya


Ignore:
Timestamp:
Sep 11, 2001, 4:05:28 PM (24 years ago)
Author:
ansari
Message:

modifications - MAJ de sophya.tex (overview) pour la version 1.2 , Reza 11/9/2001

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/Manual/sophya.tex

    r1436 r1648  
    3636\vspace{1cm}
    3737\begin{center}
    38 {\bf \Large Sophya Version: 1.1 (V\_Fev2001) \\
    39 Document revision 1.0 }
     38{\bf \Large Sophya Version: 1.2 (V\_Jul2001) }
     39% Document revision 1.0 }
    4040\end{center}
    4141\titrebp{1}
     
    5555numerical analysis libraries, encapsulating them whenever
    5656possible. Although some the modules in SOPHYA have been
    57 designed with the specific goal of providing the general framework for
     57designed with the specific goal of providing some of the tools for
    5858the Planck-HFI data processing software, most of the
    5959packages presented here have a more general scope than the
     
    8484services.
    8585\item[] {\bf TArray/} template numerical arrays, vectors and matrices \\
    86 ({\tt PixelMap<T> SphericalMap<T>} \ldots)
     86({\tt TArray<T> TMatrix<T> TVector<T> } \ldots)
    8787\item[] {\bf NTools/} Some standard numerical analysis tools
    8888(linear, and non linear parameter fitting, FFT, \ldots)
    89 \item[] {\bf HiStats/}  Histogram-ming and data set handling classes \\
     89\item[] {\bf HiStats/}  Histogram-ming and data set handling classes (tuples) \\
    9090({\tt Histo Histo2D NTuple XNTuple} \ldots)
     91\item[] {\bf SkyMap/} Local and full sky maps, and few geometry
     92handling utility classes. \\
     93({\tt PixelMap<T>, LocalMap<T>, SphericalMap<T>, \ldots})
    9194\end{itemize}
    9295
     
    9497CMB (Cosmic Microwave Background) data analysis problem:
    9598\begin{itemize}
    96 \item[] {\bf SkyMap/} Local and full sky maps, and few geometry
    97 handling utility classes. \\
    98 ({\tt PixelMap<T>, LocalMap<T>, SphericalMap<T>, \ldots})
    9999\item[] {\bf SkyT/}
    100100classes for spectral emission and detector frequency response modelling \\
     
    110110\item[] {\bf LinAlg/} Interface with Lapack linear algebra package
    111111\item[] {\bf IFFTW/} Interface with FFTW package (libfftw.a)
     112\item[] {\bf XAstroPack/} Interface to some common astronomical
     113computation libraries. Presently, this module uses an external library
     114extracted from the {\bf Xephem } source code. The corresponding source
     115code is also available from SOPHYA cvs repository, module {\bf XephemAstroLib}.
    112116\end{itemize}
    113117
     
    307311and object hierarchy. \\
    308312{\bf PPF} {\bf P}ortable {\bf P}ersistence file {\bf F}ormat.
     313\index{PPF}
    309314\item[] Handling of read/write for multiply referenced objects.
    310315\item[] All write operations are carried using sequential access only. This
     
    614619range can be specified, using the {\tt start} and {\tt end} index
    615620and an optional step (or stride). It is also possible to specify
    616 the {\tt start} index and the number of elements.
    617 In the following example, a simple low-pas filter, on a one
     621the {\tt start} index and the number of elements:
     622\begin{center}
     623
     624\begin{tabular}{ll}
     625\multicolumn{2}{c}{ {\bf Range} {\tt (start=0, end=0, size=1, step=1) } } \\[2mm]
     626\hline \\
     627{\bf Range} {\tt r(3,6); } &  index range 3,4,5,6 \\
     628{\bf Range} {\tt r(7,0,3); } &  index range 7,8,9 \\
     629{\bf Range} {\tt r(10,0,3,5); } &  index range 10,12,14,16,18 \\
     630\end{tabular}
     631\end{center}
     632
     633In the following example, a simple low-pass filter, on a one
    618634dimensional stream (Vector) has been written using sub-arrays: 
    619635
     
    630646    out(k) = in(Range(k-w, k+w).Sum()/(2.*w+1.);
    631647\end{verbatim}
     648
     649\subsection{Input, Output}
     650Arrays can easily be saved to, or restored from files in different formats.
     651SOPHYA library can handle array I/O to ASCII formatted files, to PPF streams,
     652as well as to files in FITS format.
     653FITS format input/output is provided through the classes in
     654{\bf FitsIOServer} module. Onnly arrays with data types
     655supported by the FITS standard can be handled during
     656I/O operations to and from FITS streams (See the FitsIOServer section
     657for additional details).
     658
     659\subsubsection{PPF streams}
     660
     661SOPHYA persistence (PPF streams) handles reference sharing, and multiply
     662referenced objects are only written once. A hierarchy of arrays and sub-arrays
     663written to a PPF stream is thus completely recovered, when the stream is read.
     664The following example illustrates this point:
     665\begin{verbatim}
     666{
     667// Saving an array with a sub-array into a POutPersist file
     668Matrix A(3,4);
     669A = RegularSequence(10,5);
     670// Create a sub-array of A
     671Matrix AS = A(Range(1,2), Range(2,3));
     672// Save the two arrays to a PPF stream
     673POutPersist pos("aas.ppf");
     674pos << A << AS;
     675}
     676{
     677// Reading arrays from the previously created PPF file aas.ppf
     678PInPersist pis("aas.ppf");
     679Matrix B,BS;
     680pis >> B >> BS;
     681// BS is a sub-array of B, modifying BS changes also B
     682BS(1,1) = 98765.;
     683cout << " B , BS after BS(1,1) = 98765. "
     684     << B << BS << endl;
     685}
     686\end{verbatim}
     687The execution of this sample code creates the file {\tt aas.ppf} and
     688its output is reproduced here. Notice that the array hierarch is
     689recovered. BS is a sub-array of B, and modifying BS changes also
     690the corresponding element in B.
     691\begin{verbatim}
     692 B , BS after BS(1,1) = 98765.
     693
     694--- TMatrix<double>(NRows=3, NCols=4) ND=2 SizeX*Y*...= 4x3 ---
     69510 15 20 25
     69630 35 40 45
     69750 55 60 98765
     698
     699--- TMatrix<double>(NRows=2, NCols=2) ND=2 SizeX*Y*...= 2x2 ---
     70040 45
     70160 98765
     702\end{verbatim}
     703
     704\centerline{\bf Warning: }
     705
     706There is a drawback in this behaviour: only a single
     707copy of an array is written to a file, even if the array is modified,
     708without being resized and written to a PPF stream.
     709\begin{verbatim}
     710{
     711POutPersist pos("mca.ppf");
     712TArray<int_4> ia(5,3);
     713ia = 8;
     714pos << ia;
     715ia = 16;
     716pos << ia;
     717ia = 32;
     718pos << ia;
     719}
     720\end{verbatim}
     721
     722Only a single copy of the data is effectively written to the output
     723PPF file, corresponding to the value 8 for array elements. When we
     724read the three array from the file mca.ppf, the same array elements
     725are obtained three times (all elements equal to 8):
     726\begin{verbatim}
     727{
     728PInPersist pis("mca.ppf");
     729TArray<int_4> ib;
     730pis >> ib;
     731cout << " First array read from mca.ppf : " << ib;
     732pis >> ib;
     733cout << " Second array read from mca.ppf : " << ib;
     734pis >> ib;
     735cout << " Third array read from mca.ppf : " << ib;
     736}
     737\end{verbatim}
     738
     739\subsubsection{ASCII streams}
     740
     741The {\bf WriteASCII} method can be used to dump an array to an ASCII
     742formatted file, while the {\bf ReadASCII} method can be used to decode
     743ASCII formatted files. Space or tabs are the possible separators.
     744Complex numbers should be specified as a pair of comma separated
     745real and imaginary parts, enclosed in parenthesis.
     746
     747\begin{verbatim}
     748{
     749// Creating array A and writing it to an ASCII file (aaa.txt)
     750Array A(4,6);
     751A = RegularSequence(0.5, 0.2);
     752ofstream ofs("aaa.txt");
     753A.WriteASCII(ofs);
     754}
     755{
     756// Decoding the ASCII file aaa.txt
     757ifstream ifs("aaa.txt");
     758Array B;
     759sa_size_t nr, nc;
     760B.ReadASCII(ifs,nr,nc);
     761cout << " Array B; B.ReadASCII() from file " << endl;
     762cout << B ;
     763}
     764\end{verbatim}
     765
     766
     767\subsection{Complex arrays}
     768The {\bf TArray} module provides few functions for manipulating
     769arrays of complex numbers (single and double precision).
     770These functions are declared in {\tt matharr.h}.
     771\begin{itemize}
     772\item[\bul] Creating a complex array through the specification of the
     773real and imaginary parts.
     774\item[\bul] Functions returning arrays corresponding to real and imaginary
     775parts of a complex array: {\tt real(za) , imag(za) }
     776({\bf Warning:} Note that the present implementation does not provide
     777shared memory access to real and imaginary parts.)
     778\item[\bul] Functions returning arrays corresponding to the module,
     779phase, and module squared of a complex array:
     780 {\tt phase(za) , module(za) , module2(za) }
     781\end{itemize}
     782
     783\begin{verbatim}
     784  TVector<r_4> p_real(10, BaseArray::RowVector);
     785  TVector<r_4> p_imag(10, BaseArray::RowVector);
     786  p_real = RegularSequence(0., 0.5);
     787  p_imag = RegularSequence(0., 0.25);
     788  TVector< complex<r_4> > zvec = ComplexArray(p_real, p_imag);
     789  cout << " :: zvec= " << zvec;
     790  cout << " :: real(zvec) = " << real(zvec) ;
     791  cout << " :::: imag(zvec) = " << imag(zvec) ;
     792  cout << " :::: module2(zvec) = " << module2(zvec) ;
     793  cout << " :::: module(zvec) = " << module(zvec) ;
     794  cout << " :::: phase(zvec) = " << phase(zvec) ;
     795\end{verbatim}
     796
     797The decoding of complex numbers from an ASCII formatted stream
     798is illustrated by the next example. As mentionned already,
     799complex numbers should be specified as a pair of comma separated
     800real and imaginary parts, enclosed in parenthesis.
     801
     802\begin{verbatim}
     803csh> cat zzz.txt
     804(1.,-1) (2., 2.5) -3. 12.
     805-24. (-6.,7.) 14.2 (8.,64.)
     806
     807//  Decoding of complex numbers from an ASCII file
     808//  Notice that the << operator can be used instead of ReadASCII
     809TArray< complex<r_4> > Z;
     810ifstream ifs("zzz.txt");
     811ifs >> Z;
     812cout << " TArray< complex<r_4> > Z from file zzz.txt " << Z ;
     813\end{verbatim}
     814
    632815
    633816\subsection{Memory organisation}
     
    12051388\end{verbatim}
    12061389
     1390The class {\bf FITS\_AutoReader} provides a limited FITS files reading
     1391and decoding capabilities. A partial class diagram of FITS persistence
     1392handling classes is shown below:
     1393\begin{figure}[hbt]
     1394\dclsbb{FitsIOhandler}{FITS\_TArray}
     1395\dclsb{FITS\_NTuple}
     1396% \dclsb{FITS\_XNTuple}
     1397\dclsb{FITS\_SphereHEALPix}
     1398% \dclsb{FITS\_LocalMap}
     1399\end{figure}
    12071400
    12081401\newpage
Note: See TracChangeset for help on using the changeset viewer.