[1306] | 1 | #include <stdio.h>
|
---|
| 2 | #include <stdlib.h>
|
---|
| 3 | #include <math.h>
|
---|
| 4 | #include <iostream.h>
|
---|
| 5 |
|
---|
| 6 | #include "histinit.h"
|
---|
| 7 | #include "dvlist.h"
|
---|
| 8 | #include "ntuple.h"
|
---|
| 9 | #include "xntuple.h"
|
---|
| 10 | #include "fitsxntuple.h"
|
---|
| 11 | #include "fitsntuple.h"
|
---|
| 12 |
|
---|
[1441] | 13 | /*!
|
---|
| 14 | \ingroup PrgUtil
|
---|
| 15 | \file scanfits.cc
|
---|
| 16 | \brief \b scanfits: Check and scan FITS files
|
---|
| 17 |
|
---|
| 18 | Scan FITS files and prints information on each FITS bloc in file.
|
---|
| 19 | Uses the FitsIOServer module.
|
---|
| 20 |
|
---|
| 21 | \verbatim
|
---|
| 22 | Usage: scanfits FITSFilename
|
---|
| 23 | \endverbatim
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | string FITSExtType2String(FitsFile::FitsExtensionType exttype)
|
---|
| 27 | {
|
---|
| 28 | if (exttype == FitsFile::FitsExtensionType_IMAGE) return("IMAGE");
|
---|
| 29 | else if (exttype == FitsFile::FitsExtensionType_ASCII_TBL) return("ASCII_TBL");
|
---|
| 30 | else if (exttype == FitsFile::FitsExtensionType_BINARY_TBL) return("BINARY_TBL");
|
---|
| 31 | else if (exttype == FitsFile::FitsExtensionType_EOF) return("EOF");
|
---|
| 32 | else if (exttype == FitsFile::FitsExtensionType_ERROR) return("ERROR");
|
---|
| 33 | else return("Unknown?");
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | string FITSDataType2String(FitsFile::FitsDataType datatype)
|
---|
| 37 | {
|
---|
| 38 | if (datatype == FitsFile::FitsDataType_double) return("double");
|
---|
| 39 | else if (datatype == FitsFile::FitsDataType_float) return("float");
|
---|
| 40 | else if (datatype == FitsFile::FitsDataType_int) return("int");
|
---|
| 41 | else if (datatype == FitsFile::FitsDataType_long) return("long");
|
---|
| 42 | else if (datatype == FitsFile::FitsDataType_byte) return("byte");
|
---|
| 43 | else if (datatype == FitsFile::FitsDataType_char) return("char");
|
---|
| 44 | else if (datatype == FitsFile::FitsDataType_ASCII) return("ASCII");
|
---|
| 45 | else if (datatype == FitsFile::FitsDataType_NULL) return("NULL");
|
---|
| 46 | else return("Unknown?");
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[1306] | 49 | int main(int narg, char *arg[])
|
---|
| 50 | {
|
---|
| 51 | if (narg < 2) {
|
---|
| 52 | cerr << "scanfits/Erreur arg - Usage scanfits nomfits \n" << endl;
|
---|
| 53 | exit(0);
|
---|
| 54 | }
|
---|
| 55 | try {
|
---|
| 56 | SophyaInit();
|
---|
| 57 | string flnm = arg[1];
|
---|
| 58 | int nbblk = FitsInFile::NbBlocks(arg[1]);
|
---|
[1441] | 59 | cout << " :::::::: File " << flnm << " has " << nbblk << " blocks "
|
---|
| 60 | << " :::::::: " << endl;
|
---|
[1306] | 61 |
|
---|
[1441] | 62 | // cout << " FitsFile::FitsExtensionType : FitsExtensionType_IMAGE= " <<
|
---|
| 63 | // (int)FitsFile::FitsExtensionType_IMAGE <<
|
---|
| 64 | // " FitsExtensionType_ASCII_TBL= " << (int)FitsFile::FitsExtensionType_ASCII_TBL <<
|
---|
| 65 | // " FitsExtensionType_BINARY_TBL= " << (int)FitsFile::FitsExtensionType_BINARY_TBL << endl;
|
---|
| 66 | // cout << " FitsFile::FitsDataType: FitsDataType_double= " <<
|
---|
| 67 | // (int)FitsFile::FitsDataType_double <<
|
---|
| 68 | // " FitsDataType_float= " << (int)FitsFile::FitsDataType_float <<
|
---|
| 69 | // " FitsDataType_int= " << (int)FitsFile::FitsDataType_int <<
|
---|
| 70 | // " FitsDataType_char= " << (int)FitsFile::FitsDataType_char <<
|
---|
| 71 | // " FitsDataType_ASCII= " << (int)FitsFile::FitsDataType_ASCII << endl << endl;
|
---|
[1306] | 72 |
|
---|
| 73 | for(int i=1; i<=nbblk; i++) {
|
---|
[1441] | 74 | int naxis;
|
---|
| 75 | vector<int> axis;
|
---|
| 76 | DVList header;
|
---|
| 77 | FitsFile::FitsExtensionType exttype;
|
---|
| 78 | FitsFile::FitsDataType datatype;
|
---|
| 79 |
|
---|
[1306] | 80 | FitsInFile::GetBlockType(arg[1], i, exttype, naxis, axis, datatype, header);
|
---|
[1441] | 81 | cout << "\n--------- Header Num " << i << " Type " << FITSExtType2String(exttype)
|
---|
| 82 | << " --- NAxis= " << naxis
|
---|
| 83 | << " DataType= " << FITSDataType2String(datatype) << endl;
|
---|
| 84 | if (axis.size() > 0) {
|
---|
| 85 | cout << " >> Axis Sizes: " ;
|
---|
| 86 | for(int j=0; j<axis.size(); j++) {
|
---|
| 87 | if (j > 0) cout << " x " ;
|
---|
| 88 | cout << axis[j] ;
|
---|
| 89 | }
|
---|
| 90 | cout << endl;
|
---|
| 91 | }
|
---|
| 92 | cout << " >>> Header info : " ;
|
---|
[1306] | 93 | cout << header << endl;
|
---|
[1441] | 94 | cout << "----------------------------------------------------------------------"
|
---|
| 95 | << endl;
|
---|
[1306] | 96 | }
|
---|
| 97 |
|
---|
| 98 | }
|
---|
| 99 | catch (PThrowable & exc) {
|
---|
[1441] | 100 | cerr << "sanfits: Catched Exception " << (string)typeid(exc).name()
|
---|
| 101 | << "\n .... Msg= " << exc.Msg() << endl;
|
---|
[1306] | 102 | }
|
---|
| 103 | catch (...) {
|
---|
| 104 | cerr << " some other exception was caught ! " << endl;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | }
|
---|