next up previous contents index
Next: LinAlg and IFFTW modules Up: sophya Previous: Module SkyT   Contents   Index

Module FitsIOServer

\begin{figure}
\framebox [40mm][c]{\mbox{\rule[-1mm]{0mm}{5mm} \bf FitsFile} }$...
...ox [40mm][c]{\mbox{\rule[-1mm]{0mm}{5mm} \bf FitsOutFile} }\\ [2mm]
\end{figure}

This module provides classes for handling file input-output in FITS format using the cfitsio library. It works like the SOPHYA persistence (see Module SysTools), using delegate objects, but its design is simpler. The following example writes a matrix (see module TArray) and a spherical map (see module SkyMap) on a FITS file and reads back from FITS file and creates new objects :

#include "spherehealpix.h"   
#include "fitsspherehealpix.h" 
#include "fitstarray.h" 
#include "tmatrix.h" 
//...........................

int m=...;
SphereHEALPix<r_8> sph(m);
................
int dim1=...;
int dim2=...;
TMatrix<r_8> mat(dim1,dim2);
............

FITS_SphereHEALPix<r_8> sph_temp(sph);
FITS_TArray<r_8> mat_temp(mat);
// writing

FitsOutFile os("myfile.fits");
sph_temp.Write(os);
mat_temp.Write(os);

// reading
FitsInFile is("myfile.fits");
sph_temp.Read(is);
mat_temp.Read(is);
SphereHEALPix<r_8> new_sph=(SphereHEALPix<r_8>)sph_temp;
TMatrix<r_8> new_mat=(TMatrix<r_8>)mat_temp;
................

The operators operator << (FitsOutFile ...) and operator >> (FitsInFile ...) are defined in order to facilitate the FITS file operations:


// Writing an array object to a FITS file
#include "fitstarray.h" 
FitsOutFile fio("arr.fits");
Matrix m(20,30);
m = 12345.;
fio << m;
// .....
// Reading a binary table to a XNTuple
#include "fitsxntuple.h" 
XNTuple xn;
FitsInFile fii("table.fits");
fii >> xn;



Reza Ansari
2001-03-07