| 1 | #ifndef FACT_Fits
|
|---|
| 2 | #define FACT_Fits
|
|---|
| 3 |
|
|---|
| 4 | #include <CCfits/CCfits>
|
|---|
| 5 | #include <vector>
|
|---|
| 6 |
|
|---|
| 7 | #include "Description.h"
|
|---|
| 8 |
|
|---|
| 9 | using namespace CCfits;
|
|---|
| 10 |
|
|---|
| 11 | class Converter;
|
|---|
| 12 |
|
|---|
| 13 | class Fits
|
|---|
| 14 | {
|
|---|
| 15 | private:
|
|---|
| 16 | ///The CCfits object to the FITS file
|
|---|
| 17 | FITS* fFile;
|
|---|
| 18 | ///The CCfits Table
|
|---|
| 19 | Table* fTable;
|
|---|
| 20 | ///The current number of Rows in the table
|
|---|
| 21 | int fNumRows;
|
|---|
| 22 | ///Name of the "standard", i.e. data found in every fits file
|
|---|
| 23 | ///TODO make these variable static so that they are shared by every object.
|
|---|
| 24 | ///TODO add also a static boolean to initialize these only once
|
|---|
| 25 | std::vector<Description> fStandardColDesc;
|
|---|
| 26 | ///Format of the standard columns.
|
|---|
| 27 | std::vector<std::string> fStandardFormats;
|
|---|
| 28 | ///the pointers to the standard variables
|
|---|
| 29 | std::vector<void*> fStandardPointers;
|
|---|
| 30 | ///the number of bytes taken by each standard variable
|
|---|
| 31 | std::vector<int> fStandardNumBytes;
|
|---|
| 32 | ///the vector of data column names
|
|---|
| 33 | std::vector<Description> fDataColDesc;
|
|---|
| 34 | ///the data format of the data columns
|
|---|
| 35 | std::vector<std::string> fDataFormats;
|
|---|
| 36 | ///the pointer to the contiguous memory location where the data is stored (i.e. the dim data pointer)
|
|---|
| 37 | void* fDataPointer;
|
|---|
| 38 | ///the size of the data, in bytes.
|
|---|
| 39 | int fDataNumBytes;
|
|---|
| 40 | ///the copy buffer. Required to put the standard and data variable in contguous memory
|
|---|
| 41 | unsigned char* fCopyBuffer;
|
|---|
| 42 | ///the total number of bytes per FITS row
|
|---|
| 43 | int fTotalNumBytes;
|
|---|
| 44 | ///to keep track of the time of the latest written entry (to update the header when closing the file)
|
|---|
| 45 | double fEndMjD;
|
|---|
| 46 | ///Write the FITS header keys
|
|---|
| 47 | void WriteHeaderKeys();
|
|---|
| 48 |
|
|---|
| 49 | public:
|
|---|
| 50 |
|
|---|
| 51 | Fits() : fFile(NULL),
|
|---|
| 52 | fTable(NULL),
|
|---|
| 53 | fNumRows(0),
|
|---|
| 54 | fDataPointer(NULL),
|
|---|
| 55 | fDataNumBytes(0),
|
|---|
| 56 | fCopyBuffer(NULL),
|
|---|
| 57 | fTotalNumBytes(0),
|
|---|
| 58 | fEndMjD(0.0)
|
|---|
| 59 | {}
|
|---|
| 60 |
|
|---|
| 61 | virtual ~Fits()
|
|---|
| 62 | {
|
|---|
| 63 | if (IsOpen())
|
|---|
| 64 | Close();
|
|---|
| 65 | }
|
|---|
| 66 | ///returns wether or not the file is currently open or not
|
|---|
| 67 | bool IsOpen() {return fFile != NULL;}
|
|---|
| 68 |
|
|---|
| 69 | ///Adds a column that exists in all FITS files
|
|---|
| 70 | void AddStandardColumn(Description& desc, std::string dataFormat, void* dataPointer, long unsigned int numDataBytes);
|
|---|
| 71 |
|
|---|
| 72 | ///Adds columns specific to the service being logged.
|
|---|
| 73 | void InitDataColumns(std::vector<Description> desc, std::vector<std::string>& dataFormat, void* dataPointer, int numDataBytes);
|
|---|
| 74 |
|
|---|
| 75 | ///Opens a FITS file
|
|---|
| 76 | void Open(const std::string& fileName, const std::string& tableName);
|
|---|
| 77 |
|
|---|
| 78 | ///Write one line of data. Use the given converter.
|
|---|
| 79 | void Write(Converter* conv);
|
|---|
| 80 |
|
|---|
| 81 | ///Close the currently opened file.
|
|---|
| 82 | void Close();
|
|---|
| 83 |
|
|---|
| 84 | };//Fits
|
|---|
| 85 |
|
|---|
| 86 | #endif /*FITS_H_*/
|
|---|
| 87 |
|
|---|