OPERA
1.0
Open source echelle spectrograph reduction pipeline
|
00001 /******************************************************************* 00002 **** OPERA PIPELINE v1.0 **** 00003 ******************************************************************** 00004 Library name: operaEspadonsImage 00005 Version: 1.0 00006 Author(s): CFHT OPERA team 00007 Affiliation: Canada France Hawaii Telescope 00008 Location: Hawaii USA 00009 Date: Jul/2011 00010 00011 Copyright (C) 2011 Opera Pipeline team, Canada France Hawaii Telescope 00012 00013 This program is free software: you can redistribute it and/or modify 00014 it under the terms of the GNU General Public License as published by 00015 the Free Software Foundation, either version 3 of the License, or 00016 (at your option) any later version. 00017 00018 This program is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 GNU General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 along with this program. If not, see: 00025 http://software.cfht.hawaii.edu/licenses 00026 -or- 00027 http://www.gnu.org/licenses/gpl-3.0.html 00028 ********************************************************************/ 00029 00030 #ifndef OPERAESPADONSIMAGE_H 00031 #define OPERAESPADONSIMAGE_H 00032 00033 #include <fitsio.h> 00034 #include "operaFITSImage.h" 00035 #include "operaFITSSubImage.h" 00036 00037 extern "C" { 00038 #include "libraries/operaImage.h" 00039 #include "libraries/operaParameterAccess.h" 00040 #include "libraries/operaConfigurationAccess.h" 00041 } 00042 00043 #define ESPADONS_DEFAULT_NAXIS1 2080 00044 #define ESPADONS_DEFAULT_NAXIS2 4640 00045 00046 using namespace std; 00047 00055 typedef enum { IMTYPE_GENERIC, IMTYPE_BIAS, IMTYPE_FLAT, IMTYPE_COMPARISON, IMTYPE_ALIGN, IMTYPE_OBJECT, IMTYPE_DARK } imtype_t ; 00056 typedef enum { DETECTOR_UNKNOWN, DETECTOR_EEV1, DETECTOR_OLAPA} detector_t; 00057 typedef enum { AMPLIFIER_UNKNOWN, AMPLIFIER_a, AMPLIFIER_ab} amplifier_t; 00058 typedef enum { MODE_UNKNOWN, MODE_STAR_ONLY, MODE_STAR_PLUS_SKY, MODE_POLAR} instrumentmode_t; 00059 typedef enum { SPEED_UNKNOWN, SPEED_FAST, SPEED_NORMAL, SPEED_SLOW} speed_t; 00060 typedef enum { STOKES_UNKNOWN, STOKES_I, STOKES_U, STOKES_Q, STOKES_V} stokes_t; 00061 typedef enum { POLAR_QUAD_UNKNOWN, POLAR_QUAD_1, POLAR_QUAD_2, POLAR_QUAD_3, POLAR_QUAD_4} polarquad_t; 00062 00063 typedef struct DATASEC { 00064 unsigned startx; 00065 unsigned nx; 00066 unsigned starty; 00067 unsigned ny; 00068 } DATASEC_t; 00069 00070 #define ESPADONS_DEFAULT_DATASEC {21,2068,1,4608} 00071 00072 class operaEspadonsImage; 00073 00082 unsigned *where(operaEspadonsImage* b, unsigned *count); 00083 unsigned *where(operaEspadonsImage& b, unsigned *count); 00084 00085 class operaEspadonsImage : public operaFITSImage { 00086 00087 private: 00088 typedef operaFITSImage& super; // a way of referring to the super class 00089 unsigned nx; // x-dimension to be figured out from DATASEC (ncols) 00090 unsigned ny; // y-dimension to be figured out from DATASEC (nrows) 00091 unsigned startx; // first DATASEC pixel in x direction 00092 unsigned starty; // first DATASEC pixel in y direction 00093 unsigned ndpixels; // number of DATASEC pixels 00094 operaFITSSubImage *datasecSubImage; // the datasec subImage 00095 imtype_t imagetype; // (IMTYPE_BIAS, IMTYPE_FLAT, etc) 00096 detector_t detector; // Detector EEV1/OLAPA 00097 amplifier_t amplifier; // a ab 00098 instrumentmode_t mode; // sp1 sp2 pol 00099 speed_t speed; // sequence # of polar image 00100 stokes_t stokes; // (Stokes_(I, U, Q, V)) 00101 polarquad_t sequence; // sequence # of polar image 00102 00103 public: 00110 operaEspadonsImage(); 00111 00119 operaEspadonsImage(string Filename, int mode=READWRITE/*READONLY*/); // constructor to read an existing FITSImage 00129 operaEspadonsImage(string Filename, edatatype Datatype, int mode=READWRITE/*READONLY*/); // read an existing FITSImage from file 00143 operaEspadonsImage(string Filename, unsigned Naxis1, unsigned Naxis2, DATASEC_t &datasec, 00144 edatatype Datatype = tushort, unsigned Compression = 0); // constructor to create an in-memory espadons image with a datasec 00155 operaEspadonsImage(unsigned Naxis1, unsigned Naxis2, DATASEC_t &datasec, 00156 edatatype Datatype = tushort, unsigned Compression = 0); // simply construct an image of a given size 00162 ~operaEspadonsImage(); // destructor 00163 00169 unsigned short* operaEspadonsImageCloneDatasecUSHORT(); // clone the datasec as USHURT 00175 float* operaEspadonsImageCloneDatasec(); // clone the datasec as float 00176 00187 inline unsigned short getpixelUSHORT(unsigned x, unsigned y) {return ((unsigned short *)pixptr)[(nx<<11)+x];}; 00188 inline float getpixel(unsigned x, unsigned y) {return ((float *)pixptr)[(nx<<11)+x];}; 00189 00201 inline void setpixel(unsigned short value, unsigned x, unsigned y) {((unsigned short *)pixptr)[(nx<<11)+x] = value;}; 00202 inline void setpixel(float value, unsigned x, unsigned y) {((float *)pixptr)[(nx<<11)+x] = value;}; 00203 00211 void operaEspadonsImageCopyHeader(operaEspadonsImage *from); // copy header unit 00212 00219 operaEspadonsImage *operaEspadonsImageClone(operaEspadonsImage &imageIn); // clone image object 00220 /* 00221 * getters / setters 00222 */ 00228 operaFITSSubImage *getDatasecSubImage(); 00235 void operaFITSImageSetData(operaFITSSubImage &datasecSubImage); 00241 unsigned getnx(); 00247 unsigned getny(); 00253 unsigned getndpixels(); 00254 00266 unsigned long getsize(); 00267 00268 imtype_t getimtype(); 00274 string getimtypestring(); 00275 00281 detector_t getdetector(); 00287 string getdetectorstring(); 00288 00294 amplifier_t getamplifier(); 00300 string getamplifierstring(); 00301 00307 instrumentmode_t getmode(); 00313 string getmodestring(); 00314 00320 speed_t getspeed(); 00326 string getspeedstring(); 00327 00333 stokes_t getstokes(); 00339 string getstokesstring(); 00340 00346 polarquad_t getpolarquad(); 00352 string getpolarquadstring(); 00353 }; 00354 00355 #endif