Changeset 1648 in Sophya for trunk/SophyaLib/Manual
- Timestamp:
- Sep 11, 2001, 4:05:28 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Manual/sophya.tex
r1436 r1648 36 36 \vspace{1cm} 37 37 \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 } 40 40 \end{center} 41 41 \titrebp{1} … … 55 55 numerical analysis libraries, encapsulating them whenever 56 56 possible. Although some the modules in SOPHYA have been 57 designed with the specific goal of providing the general frameworkfor57 designed with the specific goal of providing some of the tools for 58 58 the Planck-HFI data processing software, most of the 59 59 packages presented here have a more general scope than the … … 84 84 services. 85 85 \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) 87 87 \item[] {\bf NTools/} Some standard numerical analysis tools 88 88 (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) \\ 90 90 ({\tt Histo Histo2D NTuple XNTuple} \ldots) 91 \item[] {\bf SkyMap/} Local and full sky maps, and few geometry 92 handling utility classes. \\ 93 ({\tt PixelMap<T>, LocalMap<T>, SphericalMap<T>, \ldots}) 91 94 \end{itemize} 92 95 … … 94 97 CMB (Cosmic Microwave Background) data analysis problem: 95 98 \begin{itemize} 96 \item[] {\bf SkyMap/} Local and full sky maps, and few geometry97 handling utility classes. \\98 ({\tt PixelMap<T>, LocalMap<T>, SphericalMap<T>, \ldots})99 99 \item[] {\bf SkyT/} 100 100 classes for spectral emission and detector frequency response modelling \\ … … 110 110 \item[] {\bf LinAlg/} Interface with Lapack linear algebra package 111 111 \item[] {\bf IFFTW/} Interface with FFTW package (libfftw.a) 112 \item[] {\bf XAstroPack/} Interface to some common astronomical 113 computation libraries. Presently, this module uses an external library 114 extracted from the {\bf Xephem } source code. The corresponding source 115 code is also available from SOPHYA cvs repository, module {\bf XephemAstroLib}. 112 116 \end{itemize} 113 117 … … 307 311 and object hierarchy. \\ 308 312 {\bf PPF} {\bf P}ortable {\bf P}ersistence file {\bf F}ormat. 313 \index{PPF} 309 314 \item[] Handling of read/write for multiply referenced objects. 310 315 \item[] All write operations are carried using sequential access only. This … … 614 619 range can be specified, using the {\tt start} and {\tt end} index 615 620 and 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 621 the {\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 633 In the following example, a simple low-pass filter, on a one 618 634 dimensional stream (Vector) has been written using sub-arrays: 619 635 … … 630 646 out(k) = in(Range(k-w, k+w).Sum()/(2.*w+1.); 631 647 \end{verbatim} 648 649 \subsection{Input, Output} 650 Arrays can easily be saved to, or restored from files in different formats. 651 SOPHYA library can handle array I/O to ASCII formatted files, to PPF streams, 652 as well as to files in FITS format. 653 FITS format input/output is provided through the classes in 654 {\bf FitsIOServer} module. Onnly arrays with data types 655 supported by the FITS standard can be handled during 656 I/O operations to and from FITS streams (See the FitsIOServer section 657 for additional details). 658 659 \subsubsection{PPF streams} 660 661 SOPHYA persistence (PPF streams) handles reference sharing, and multiply 662 referenced objects are only written once. A hierarchy of arrays and sub-arrays 663 written to a PPF stream is thus completely recovered, when the stream is read. 664 The following example illustrates this point: 665 \begin{verbatim} 666 { 667 // Saving an array with a sub-array into a POutPersist file 668 Matrix A(3,4); 669 A = RegularSequence(10,5); 670 // Create a sub-array of A 671 Matrix AS = A(Range(1,2), Range(2,3)); 672 // Save the two arrays to a PPF stream 673 POutPersist pos("aas.ppf"); 674 pos << A << AS; 675 } 676 { 677 // Reading arrays from the previously created PPF file aas.ppf 678 PInPersist pis("aas.ppf"); 679 Matrix B,BS; 680 pis >> B >> BS; 681 // BS is a sub-array of B, modifying BS changes also B 682 BS(1,1) = 98765.; 683 cout << " B , BS after BS(1,1) = 98765. " 684 << B << BS << endl; 685 } 686 \end{verbatim} 687 The execution of this sample code creates the file {\tt aas.ppf} and 688 its output is reproduced here. Notice that the array hierarch is 689 recovered. BS is a sub-array of B, and modifying BS changes also 690 the 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 --- 695 10 15 20 25 696 30 35 40 45 697 50 55 60 98765 698 699 --- TMatrix<double>(NRows=2, NCols=2) ND=2 SizeX*Y*...= 2x2 --- 700 40 45 701 60 98765 702 \end{verbatim} 703 704 \centerline{\bf Warning: } 705 706 There is a drawback in this behaviour: only a single 707 copy of an array is written to a file, even if the array is modified, 708 without being resized and written to a PPF stream. 709 \begin{verbatim} 710 { 711 POutPersist pos("mca.ppf"); 712 TArray<int_4> ia(5,3); 713 ia = 8; 714 pos << ia; 715 ia = 16; 716 pos << ia; 717 ia = 32; 718 pos << ia; 719 } 720 \end{verbatim} 721 722 Only a single copy of the data is effectively written to the output 723 PPF file, corresponding to the value 8 for array elements. When we 724 read the three array from the file mca.ppf, the same array elements 725 are obtained three times (all elements equal to 8): 726 \begin{verbatim} 727 { 728 PInPersist pis("mca.ppf"); 729 TArray<int_4> ib; 730 pis >> ib; 731 cout << " First array read from mca.ppf : " << ib; 732 pis >> ib; 733 cout << " Second array read from mca.ppf : " << ib; 734 pis >> ib; 735 cout << " Third array read from mca.ppf : " << ib; 736 } 737 \end{verbatim} 738 739 \subsubsection{ASCII streams} 740 741 The {\bf WriteASCII} method can be used to dump an array to an ASCII 742 formatted file, while the {\bf ReadASCII} method can be used to decode 743 ASCII formatted files. Space or tabs are the possible separators. 744 Complex numbers should be specified as a pair of comma separated 745 real and imaginary parts, enclosed in parenthesis. 746 747 \begin{verbatim} 748 { 749 // Creating array A and writing it to an ASCII file (aaa.txt) 750 Array A(4,6); 751 A = RegularSequence(0.5, 0.2); 752 ofstream ofs("aaa.txt"); 753 A.WriteASCII(ofs); 754 } 755 { 756 // Decoding the ASCII file aaa.txt 757 ifstream ifs("aaa.txt"); 758 Array B; 759 sa_size_t nr, nc; 760 B.ReadASCII(ifs,nr,nc); 761 cout << " Array B; B.ReadASCII() from file " << endl; 762 cout << B ; 763 } 764 \end{verbatim} 765 766 767 \subsection{Complex arrays} 768 The {\bf TArray} module provides few functions for manipulating 769 arrays of complex numbers (single and double precision). 770 These functions are declared in {\tt matharr.h}. 771 \begin{itemize} 772 \item[\bul] Creating a complex array through the specification of the 773 real and imaginary parts. 774 \item[\bul] Functions returning arrays corresponding to real and imaginary 775 parts of a complex array: {\tt real(za) , imag(za) } 776 ({\bf Warning:} Note that the present implementation does not provide 777 shared memory access to real and imaginary parts.) 778 \item[\bul] Functions returning arrays corresponding to the module, 779 phase, 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 797 The decoding of complex numbers from an ASCII formatted stream 798 is illustrated by the next example. As mentionned already, 799 complex numbers should be specified as a pair of comma separated 800 real and imaginary parts, enclosed in parenthesis. 801 802 \begin{verbatim} 803 csh> 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 809 TArray< complex<r_4> > Z; 810 ifstream ifs("zzz.txt"); 811 ifs >> Z; 812 cout << " TArray< complex<r_4> > Z from file zzz.txt " << Z ; 813 \end{verbatim} 814 632 815 633 816 \subsection{Memory organisation} … … 1205 1388 \end{verbatim} 1206 1389 1390 The class {\bf FITS\_AutoReader} provides a limited FITS files reading 1391 and decoding capabilities. A partial class diagram of FITS persistence 1392 handling 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} 1207 1400 1208 1401 \newpage
Note:
See TracChangeset
for help on using the changeset viewer.