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

Last change on this file since 3538 was 3538, checked in by ansari, 17 years ago

This commit was generated by cvs2svn to compensate for changes in r3537,
which included commits to RCS files with non-trunk default branches.

File size: 2.2 KB
Line 
1#ifndef MINIFITS_H_SEEN
2#define MINIFITS_H_SEEN
3
4#include <stdio.h>
5#include <string>
6
7#include "brtypes.h"
8
9/*
10 Classe d'I/O simplifie FITS pour ACQ BAO-radio
11 R. Ansari, C. Magneville - Fev 2008
12*/
13
14using namespace std;
15
16class MiniFITSException {
17 public:
18 explicit MiniFITSException(const char * m) { msg = m; }
19 explicit MiniFITSException(const string& m) { msg = m; }
20 virtual string const& Msg() const {return msg;}
21 private:
22 string msg;
23};
24
25
26enum MiniFITS_DT { MF_Byte, MF_Int16, MF_Float32 };
27enum MiniFITS_Mode { MF_Read, MF_Write };
28
29class MiniFITSFile {
30 public:
31 MiniFITSFile();
32 MiniFITSFile(string const & nom, MiniFITS_Mode rwm);
33 MiniFITSFile(const char* nom, MiniFITS_Mode rwm);
34
35 ~MiniFITSFile();
36
37 void Open(const char* nom, MiniFITS_Mode rwm);
38 inline void Open(string const & nom, MiniFITS_Mode rwm)
39 { return Open(nom.c_str(), rwm); }
40
41 void Close();
42
43 inline MiniFITS_DT DataType() { return dtype; }
44 string DataTypeToString();
45
46 size_t NAxis1() { return nax1; }
47 size_t NAxis2() { return nax2; }
48
49 void setDTypeNaxis(MiniFITS_DT dt, size_t na1, size_t na2);
50
51 // Lecture avec indication de la taille (nb d'elements) et offset
52 int Read(void* data, size_t sz, size_t offset=0);
53 inline int ReadB(Byte* data, size_t nel, size_t offsel=0)
54 { return ( Read((void *)data, nel, offsel) ); }
55 inline int ReadI(Int16* data, size_t nel, size_t offsel=0)
56 { return ( Read((void *)data, nel*sizeof(Int16), offsel*sizeof(Int16)) ); }
57 inline int ReadF(Float32* data, size_t nel, size_t offsel=0)
58 { return ( Read((void *)data, nel*sizeof(Float32), offsel*sizeof(Float32)) ); }
59
60 // Ecriture en mode append (fin de fichier)
61 int Write(void* data, size_t sz);
62 inline int WriteB(Byte* data, size_t nel)
63 { return ( Write((void *)data, nel) ); }
64 inline int WriteI(Int16* data, size_t nel)
65 { return ( Write((void *)data, nel*sizeof(Int16)) ); }
66 inline int WriteF(Float32* data, size_t nel)
67 { return ( Write((void *)data, nel*sizeof(Float32)) ); }
68
69 // string getKey(string& key);
70 protected:
71 void FillHeader();
72 void DecodeHeader();
73 void Init();
74
75 FILE* fip;
76 MiniFITS_Mode rwmode;
77 MiniFITS_DT dtype;
78 size_t nax1, nax2;
79 size_t totwsz; // total bytes ecrits
80 char* header; // entete FITS
81};
82
83#endif
Note: See TracBrowser for help on using the repository browser.