Changeset 3034 in Sophya


Ignore:
Timestamp:
Jul 17, 2006, 7:12:21 PM (19 years ago)
Author:
ansari
Message:

suite documentation SOPHYA overview - section FitsIOServer, Reza 17/7/2006

File:
1 edited

Legend:

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

    r3026 r3034  
    4949\vspace{1cm}
    5050\begin{center}
    51 {\bf \Large Sophya Version: 1.966 (V\_Jun2006) }
     51{\bf \Large Sophya Version: 2.0 (V\_Jul2006) }
    5252% Document revision 1.0 }
    5353\end{center}
     
    312312csh> scanppf -h
    313313 PIOPersist::Initialize() Starting Sophya Persistence management service
    314 SOPHYA Version  1.9 Revision 0 (V_Mai2005) -- May 31 2005 15:11:32 cxx
     314SOPHYA Version  2.0 Revision 0 (V_Jul2006) -- Jul 17 2006 14:13:27 cxx
    315315 Usage: scanppf [flags] filename
    316  flags = -s -n -a0 -a1 -a2 -a3 -lh -lho
     316 flags = -s -n -a0 -a1 -a2 -a3 -lh -lho -lmod
    317317   -s[=default} : Sequential reading of objects
    318318   -n : Object reading at NameTags
     
    320320   -lh : List PPersist handler classes
    321321   -lho : List PPersist handler and dataobj classes
     322   -lmod : List initialized/registered modules
    322323\end{verbatim}
    323324
     
    406407\vspace*{5mm}
    407408
     409\subsection{Initialisation}
     410\index{SophyaInitiator}
     411A number of actions have to be taken before
     412some of the services provided by SOPHYA become operational. This is the case
     413of SOPHYA persistence, as well as FITS I/O facilities.
     414Initialisation of many SOPHYA modules is performed through an initialiser class,
     415which inherits from {\bf SophyaInitiator}. Static instance of each
     416initialiser class exist in the library and the various SOPHYA services
     417should be operational when the user code ({\tt main()}) starts.
     418However, in some cases the run time loader may not perform correctly the static
     419object initialisation. You may thus need to instanciate the initialiser class
     420for the modules you use in the beginning of your main program: \\
     421{\tt TArrayInitiator , HiStatsInitiator , SkyMapInitiator \ldots }
     422%%%
    408423\subsection{SOPHYA persistence}
    409424\label{ppfdesc}
     
    778793\begin{center}
    779794\begin{tabular}{ll}
     795\hline \\
    780796\multicolumn{2}{c}{ {\bf Range} {\tt (start, end, size, step) } } \\[2mm]
    781797\hline \\
     798{\bf Range} {\tt r(7); } &  index range:  \hspace{2mm} 7 \\
    782799{\bf Range} {\tt r(3,6); } &  index range:  \hspace{2mm} 3,4,5,6 \\
    783 {\bf Range} {\tt r(3,6,0,1); } &  index range: \hspace{2mm} 3,4,5,6 \\
     800{\bf Range} {\tt r(3,7,2); } &  index range: \hspace{2mm} 3,5,7 \\
    784801{\bf Range} {\tt r(7,0,3,1); } &  index range: \hspace{2mm} 7,8,9 \\
    785 {\bf Range} {\tt r(10,0,5,2); } &  index range: \hspace{2mm} 10,12,14,16,18 \\
     802{\bf Range} {\tt r(10,0,5,2); } &  index range: \hspace{2mm} 10,12,14,16,18 \\[2mm]
     803\hline
    786804\end{tabular}
    787805\end{center}
     
    11681186
    11691187\subsubsection{DataTables}
     1188\label{datatables}
    11701189\index{DataTable}
    11711190The class {\bf DataTable} extends significantly the functionalities provided by
     
    12041223The class {\bf DataTableRow } is an auxiliary class which simplifies the manipulation
    12051224of BaseDataTable object rows.
    1206 \begin{verbatim}
    1207    #include "datatable.h"
     1225The example below show how to create and filling a table, using a PPF stream as
     1226swap space. In addition, we have used a {\tt DataTableRow} to prepare data
     1227for  each table line.
     1228\begin{verbatim}
     1229   #include "swppfdtable.h"
    12081230   // ...
    1209    // Create a table with 3 columns
    1210    DataTable dtrow(64);
     1231   {
     1232   // ---------- Create an output PPF stream (file)
     1233   POutPersist po("swdtable.ppf");
     1234   // ------------------
     1235   // Create a table with 3 columns, using the above stream as swap space
     1236   SwPPFDataTable dtrow(po, 64);
    12111237   dtrow.AddStringColumn("sline");
    12121238   dtrow.AddIntegerColumn("line");
    1213    dtrow.AddDateTimeColumn("datime");
    1214    
     1239   dtrow.AddDateTimeColumn("datime");   
     1240   //
    12151241   TimeStamp ts, ts2;  // Initialize current date and time
    12161242   string sline;
    1217    // Create a table row with the required structure
     1243   //---- Create a table row with the required structure
    12181244   DataTableRow row = dtrow.EmptyRow();
    1219    // Fill the table
    1220    for(int k = 0; k<25; k++) {
     1245   // ----- Fill the table
     1246   for(int k = 0; k<2500; k++) {
    12211247     sline = "L-";
    12221248     sline += (string)MuTyV(k);
     
    12271253     dtrow.AddRow(row);
    12281254  }
    1229   // Acces and print two of the table rows :
    1230   cout << dtrow.GetRow(6, row) << endl;
    1231   cout << dtrow.GetRow(6, row) << endl; 
    1232 \end{verbatim}
    1233  
     1255  //------ Write the table itself to the stream, before closing the file
     1256  po << PPFNameTag("SwTable") << dtrow;
     1257  }
     1258\end{verbatim}
     1259%%
     1260The  previously created table can easily be read in, as shown below:
     1261%%
     1262\begin{verbatim}
     1263   #include "swppfdtable.h"
     1264   // ...
     1265   {
     1266   // ------ Create the input  PPF stream (file)
     1267   PInPersist pin("swdtable.ppf");
     1268   // ------ Read in the SwPPFDataTable object
     1269   SwPPFDataTable dtr;
     1270   pin >> PPFNameTag("SwTable") >> dtr;
     1271   // ---- Create a table row with the required structure
     1272   DataTableRow row = dtr.EmptyRow();
     1273   // ---- Acces and print two of the table rows :
     1274   cout << dtr.GetRow(6, row) << endl;
     1275   cout << dtr.GetRow(17, row) << endl;   
     1276  }
     1277\end{verbatim}
     1278   
    12341279\subsection{Writing, viewing \dots }
    12351280
     
    16981743\newpage
    16991744\section{Module FitsIOServer}
     1745\subsection{FITS streams}
    17001746\index{FITS} \index{FitsInFile} \index{FitsOutFile}
    17011747This module provides classes for handling file input-output in FITS format using the cfitsio library. Its
     
    17241770\end{figure}
    17251771%%%%
    1726 \par
     1772\subsection{FITS handlers}
    17271773Handlers classes inheriting from {\bf FitsHandlerInterface} perform write/read operations
    17281774for AnyDataObj objects to/from FitsInOutFile streams. The {\bf FitsManager} class provides
     
    17361782{\bf \tcls{FitsArrayHandler}}  and {\bf FitsHandler$<$BaseDataTable$>$}.  \\
    17371783A number of more specific handlers are also available, in particular for NTuple,
    1738 \tcls{SphereHealPix} and \tcls{SphereThetaPhi}.
     1784\tcls{SphereHealPix} and \tcls{SphereThetaPhi}.  \\[2mm]
     1785{\bf Warning:} Some handlers were written with the old FitsIOServer classes and
     1786inherit from the intermediate class {\bf FitsIOHandler}. They 
     1787have been adapted to the new scheme, but may not perform correctly if not used
     1788through the {\bf FitsManager} class. \\[2mm]
    17391789%%%
    1740 The example below illustrates the usage of FitsIOServer classes.
     1790The examples below illustrates the usage of FitsIOServer classes.
    17411791\begin{enumerate}
    17421792\item Saving an array and a HealPix map to a Fits file
    17431793\begin{verbatim}
    17441794#include "fitsioserver.h"
     1795#include "fiosinit.h"
     1796
    17451797// ....
    17461798{
    1747 // Initialize the FitsIOServer module :
     1799// Make sure FitsIOServer module is initialised :
    17481800FitsIOServerInit();
    17491801//  Create and open a fits file named myfile.fits
     
    17591811}
    17601812\end{verbatim}
     1813%%%%
     1814%%%%
     1815\item Reading objects and the header from the previously created fits file:
     1816\begin{verbatim}
     1817{
     1818FitsIOServerInit();   //  Initialisation
     1819// ----  Open the fits file named myfile.fits
     1820FitsInFile fis("myfile.fits");
     1821//---- print file information on cout
     1822cout << fis << endl;
     1823//--- Read in the array
     1824TArray<int_4> arr;
     1825fis >> arr;
     1826arr.Show();
     1827//--- Position on second HDU
     1828fis.MoveAbsToHDU(2);
     1829//--- read and display header information
     1830DVList hdu2;
     1831fis.GetHeaderRecords(hdu2, true, true);
     1832cout << hdu2;
     1833//--- read in the HEALPix map
     1834SphereHEALPix<r_8> sph;
     1835FitsManager::Read(fis, sph);
     1836fis.MoveAbsToHDU(2);
     1837sph.Show();
     1838}
     1839\end{verbatim}
     1840%%%%%%%
     1841%%%
     1842\item DataTable objects can be read from and written to FITS files as ASCII or
     1843binary tables. The example belo show reading the DataTable created in the example
     1844in section \ref{datatables} from a PPF file and saving it to a fits file;
     1845\begin{verbatim}
     1846{
     1847FitsIOServerInit();   //  Initialisation
     1848FitsInOutFile fos("dtable.fits", FitsInOutFile ::Fits_Create);
     1849}
     1850\end{verbatim}
     1851%%%%
    17611852\end{enumerate}
    17621853
    1763 
    1764 \begin{verbatim}
    1765 #include "spherehealpix.h"   
    1766 #include "fitsspherehealpix.h"
    1767 #include "fitstarray.h"
    1768 #include "tmatrix.h"
    1769 //...........................
    1770 
    1771 int m=...;
    1772 SphereHEALPix<r_8> sph(m);
    1773 ................
    1774 int dim1=...;
    1775 int dim2=...;
    1776 TMatrix<r_8> mat(dim1,dim2);
    1777 ............
    1778 
    1779 FITS_SphereHEALPix<r_8> sph_temp(sph);
    1780 FITS_TArray<r_8> mat_temp(mat);
    1781 // writing
    1782 
    1783 FitsOutFile os("myfile.fits");
    1784 sph_temp.Write(os);
    1785 mat_temp.Write(os);
    1786 
    1787 // reading
    1788 FitsInFile is("myfile.fits");
    1789 sph_temp.Read(is);
    1790 mat_temp.Read(is);
    1791 SphereHEALPix<r_8> new_sph=(SphereHEALPix<r_8>)sph_temp;
    1792 TMatrix<r_8> new_mat=(TMatrix<r_8>)mat_temp;
    1793 ................
    1794      
    1795 \end{verbatim}
    1796 
    1797 The operators {\tt operator << (FitsOutFile ...)} and
    1798 {\tt operator >> (FitsInFile ...)} are defined in order
    1799 to facilitate the FITS file operations:
    1800 \begin{verbatim}
    1801 // Writing an array object to a FITS file
    1802 #include "fitstarray.h"
    1803 FitsOutFile fio("arr.fits");
    1804 Matrix m(20,30);
    1805 m = 12345.;
    1806 fio << m;
    1807 // .....
    1808 // Reading a binary table to a XNTuple
    1809 #include "fitsxntuple.h"
    1810 XNTuple xn;
    1811 FitsInFile fii("table.fits");
    1812 fii >> xn;
    1813 \end{verbatim}
    18141854
    18151855A partial class diagram of FITS persistence handling classes is shown below. The
     
    18231863% \dclsb{FITS\_LocalMap}
    18241864\end{figure}
     1865
     1866\subsection{SwFitsDataTable and other classes}
     1867
     1868\subsection{scanfits}
    18251869
    18261870\newpage
Note: See TracChangeset for help on using the changeset viewer.