source: Sophya/trunk/SophyaExt/FitsIOServer/fabtwriter.h@ 2450

Last change on this file since 2450 was 2450, checked in by cmv, 22 years ago

possibilite d extension fits ds le writer cmv 29/10/2003

File size: 3.9 KB
RevLine 
[1654]1/* Interface Fits BINARY/ASCII Table Writer cmv 26/09/2001 */
2#ifndef FABTWRITER_H_SEEN
3#define FABTWRITER_H_SEEN
4
5#include "machdefs.h"
[2322]6#include <iostream>
[1654]7#include <string.h>
8#include <string>
9
10#include "anydataobj.h"
11#include "tvector.h"
12#include "FitsIO/fitsio.h"
13
14#include <vector>
15
16namespace SOPHYA {
17
18//! Class for writing a FITS ASCII or BINARY table
19class FitsABTWriter : public AnyDataObj {
20public:
21 FitsABTWriter(string fname,int hdutype=BINARY_TBL,int lp=0);
22 FitsABTWriter(const char* cfname,int hdutype=BINARY_TBL,int lp=0);
[2450]23 FitsABTWriter(string fname,bool update,int hdutype=BINARY_TBL,int lp=0);
24 FitsABTWriter(const char* cfname,bool update,int hdutype=BINARY_TBL,int lp=0);
[1654]25 virtual ~FitsABTWriter();
26
[1814]27 void Flush(void);
28
29 //! Write a double value in Fits header.
30 void WriteKey(const char *keyname,double val,char* comment=NULL);
31 //! Write a long value in Fits header.
32 void WriteKey(const char *keyname,long val,char* comment=NULL);
[2450]33 //! Write a string value in Fits header.
34 void WriteKey(const char *keyname,string val,char* comment=NULL);
35 //! Write a character string value in Fits header.
36 inline void WriteKey(const char *keyname,char* val,char* comment=NULL)
37 {string dum=val; WriteKey(keyname,dum,comment);}
[1814]38
[1654]39 //! Add a new column to the FITS table and return its number (see addcol).
[1660]40 inline int AddCol(string label,string tform=string("")
41 ,string tunit=string(""),int datatype=TDOUBLE)
42 {return addcol(label.c_str(),tform.c_str(),tunit.c_str(),datatype);}
[1654]43 //! Add a new column to the FITS table and return its number (see addcol).
[1660]44 inline int AddCol(const char* label,const char* tform=""
45 ,const char* tunit="",int datatype=TDOUBLE)
46 {return addcol(label,tform,tunit,datatype);}
[1654]47
48 //! Set the FITS table extension name
49 inline void SetExtName(string extname=string("")) {ExtName = extname;}
50 //! Set the FITS table extension name
51 inline void SetExtName(char* extname="") {ExtName = extname;}
52 //! Set debug level
[1657]53 inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
[1654]54
[2174]55 void Write(int col,long row,uint_1 val);
[2170]56 void Write(int col,long row,int_2 val);
57 void Write(int col,long row,uint_2 val);
[1657]58 void Write(int col,long row,int_4 val);
[2173]59 void Write(int col,long row,uint_4 val);
[2169]60 void Write(int col,long row,int_8 val);
[1657]61 void Write(int col,long row,float val);
[1654]62 void Write(int col,long row,double val);
[2170]63 long Write(int col,long row,TVector<uint_2>& val);
[1657]64 long Write(int col,long row,TVector<int_4>& val);
[2169]65 long Write(int col,long row,TVector<int_8>& val);
[1657]66 long Write(int col,long row,TVector<float>& val);
67 long Write(int col,long row,TVector<double>& val);
[1654]68 //! Return the number of overflows managed by cfitsio
[1657]69 inline unsigned long GetNOverFlow(void) {return NOverFlow;}
[1654]70
[1673]71 //! Return the number of created columns
72 inline int GetNbCol(void) {return (int) Label.size();}
73
74 //! Print to os
75 virtual void Print(ostream& os,int lp=1) const;
76 //! Print to stdout
77 inline void Print(int lp=1) const {Print(cout,lp);}
78
[1654]79protected:
[1814]80 struct KeyDouble {string keyname; double val; string comment;};
81 struct KeyLong {string keyname; long val; string comment;};
[2450]82 struct KeyString {string keyname; string val; string comment;};
[1814]83
[2450]84 void cr_or_upd_fits(const char *cfname,bool update,int hdutype,int lp);
[1660]85 int addcol(const char* label,const char* tform
86 ,const char* tunit,int datatype);
[1654]87 void createtbl(void);
[1814]88 void writekeys(void);
[1660]89 void printerrorwrite(const char* type,int col,long row,int sta);
[1654]90 void printerror(int sta) const;
91
92 string FitsFN,ExtName;
[2450]93 bool Update;
[1654]94 int HduType;
[1657]95 unsigned short DbgLevel;
[1654]96 fitsfile *FitsPtr;
97 bool FirstTime;
98 vector<string> Label;
99 vector<string> TForm;
100 vector<string> TUnit;
[1657]101 unsigned long NOverFlow;
[1814]102
103 vector<struct KeyDouble> DoubleKey;
104 vector<struct KeyLong> LongKey;
[2450]105 vector<struct KeyString> StringKey;
[1654]106};
107
108} // namespace SOPHYA
109#endif /* FABTWRITER_H_SEEN */
Note: See TracBrowser for help on using the repository browser.