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