source: Sophya/trunk/AddOn/TAcq/minifits.h@ 3683

Last change on this file since 3683 was 3683, checked in by ansari, 16 years ago

Mise a jour et ajout de fichier pour taritement multifibres apres

prise de donnees de Nov2009 a Pittsburgh

  • Introduction des classes BRMultiFitsReader et BRBaseProcessor Reza, 27/11/2009
File size: 3.5 KB
RevLine 
[3537]1#ifndef MINIFITS_H_SEEN
2#define MINIFITS_H_SEEN
3
4#include <stdio.h>
[3658]5#include <exception>
[3537]6#include <string>
7
8#include "brtypes.h"
9
10/*
11 Classe d'I/O simplifie FITS pour ACQ BAO-radio
12 R. Ansari, C. Magneville - Fev 2008
13*/
14
15using namespace std;
16
[3658]17#define MFEX_MAXMSGLEN 160
18
19class MiniFITSException : public std::exception {
[3537]20 public:
[3658]21 explicit MiniFITSException(const char * m) throw() ;
22 explicit MiniFITSException(const string& m) throw() ;
23 virtual ~MiniFITSException() throw() ;
24 //! Implementation of std::exception what() method, returning the exception message
25 virtual const char* what() const throw();
26 virtual string const Msg() const ;
[3537]27 private:
[3658]28 char msg_[MFEX_MAXMSGLEN];
[3537]29};
30
31
32enum MiniFITS_DT { MF_Byte, MF_Int16, MF_Float32 };
33enum MiniFITS_Mode { MF_Read, MF_Write };
34
35class MiniFITSFile {
36 public:
37 MiniFITSFile();
38 MiniFITSFile(string const & nom, MiniFITS_Mode rwm);
39 MiniFITSFile(const char* nom, MiniFITS_Mode rwm);
40
41 ~MiniFITSFile();
42
43 void Open(const char* nom, MiniFITS_Mode rwm);
44 inline void Open(string const & nom, MiniFITS_Mode rwm)
45 { return Open(nom.c_str(), rwm); }
46
47 void Close();
48
[3683]49 inline bool IsOpen() { return (fip!=NULL) ; }
[3537]50 inline MiniFITS_DT DataType() { return dtype; }
51 string DataTypeToString();
52
53 size_t NAxis1() { return nax1; }
54 size_t NAxis2() { return nax2; }
55
56 void setDTypeNaxis(MiniFITS_DT dt, size_t na1, size_t na2);
57
58 // Lecture avec indication de la taille (nb d'elements) et offset
59 int Read(void* data, size_t sz, size_t offset=0);
60 inline int ReadB(Byte* data, size_t nel, size_t offsel=0)
61 { return ( Read((void *)data, nel, offsel) ); }
62 inline int ReadI(Int16* data, size_t nel, size_t offsel=0)
63 { return ( Read((void *)data, nel*sizeof(Int16), offsel*sizeof(Int16)) ); }
64 inline int ReadF(Float32* data, size_t nel, size_t offsel=0)
65 { return ( Read((void *)data, nel*sizeof(Float32), offsel*sizeof(Float32)) ); }
66
67 // Ecriture en mode append (fin de fichier)
68 int Write(void* data, size_t sz);
69 inline int WriteB(Byte* data, size_t nel)
70 { return ( Write((void *)data, nel) ); }
71 inline int WriteI(Int16* data, size_t nel)
72 { return ( Write((void *)data, nel*sizeof(Int16)) ); }
73 inline int WriteF(Float32* data, size_t nel)
74 { return ( Write((void *)data, nel*sizeof(Float32)) ); }
75
[3658]76 // Ajout de mots-cle a l'entete FITS
77 int AddKeyI(const char* key, long val, const char* comm=NULL);
78 inline int AddKeyI(string const& key, long val)
79 { return AddKeyI(key.c_str(), val); }
80 inline int AddKeyI(string const& key, long val, string const& comm)
81 { return AddKeyI(key.c_str(), val, comm.c_str()); }
82 int AddKeyD(const char* key, double val, const char* comm=NULL);
83 inline int AddKeyD(string const& key, double val)
84 { return AddKeyD(key.c_str(), val); }
85 inline int AddKeyD(string const& key, double val, string const& comm)
86 { return AddKeyD(key.c_str(), val, comm.c_str()); }
87 int AddKeyS(const char* key, const char* val, const char* comm=NULL);
88 inline int AddKeyS(string const& key, string const& val)
89 { return AddKeyS(key.c_str(), val.c_str()); }
90 inline int AddKeyS(string const& key, string const& val, string const& comm)
91 { return AddKeyS(key.c_str(), val.c_str(), comm.c_str()); }
92
[3537]93 // string getKey(string& key);
94 protected:
95 void FillHeader();
96 void DecodeHeader();
97 void Init();
98
99 FILE* fip;
100 MiniFITS_Mode rwmode;
101 MiniFITS_DT dtype;
102 size_t nax1, nax2;
103 size_t totwsz; // total bytes ecrits
104 char* header; // entete FITS
[3658]105 int nkeya_; //
[3537]106};
107
108#endif
Note: See TracBrowser for help on using the repository browser.