OPERA
1.0
Open source echelle spectrograph reduction pipeline
|
00001 /******************************************************************* 00002 **** OPERA PIPELINE v1.0 **** 00003 ******************************************************************** 00004 Library name: libOperaImage 00005 Class: operaFITSImage 00006 Version: 1.0 00007 Author(s): CFHT OPERA team 00008 Affiliation: Canada France Hawaii Telescope 00009 Location: Hawaii USA 00010 Date: Aug/2011 00011 00012 Copyright (C) 2011 Opera Pipeline team, Canada France Hawaii Telescope 00013 00014 This program is free software: you can redistribute it and/or modify 00015 it under the terms of the GNU General Public License as published by 00016 the Free Software Foundation, either version 3 of the License, or 00017 (at your option) any later version. 00018 00019 This program is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License 00025 along with this program. If not, see: 00026 http://software.cfht.hawaii.edu/licenses 00027 -or- 00028 http://www.gnu.org/licenses/gpl-3.0.html 00029 ********************************************************************/ 00030 00031 #ifndef OPERAFITSIMAGE_H 00032 #define OPERAFITSIMAGE_H 00033 00034 #include <fitsio.h> 00035 #include <string> 00036 00037 class operaFITSSubImage; 00038 00039 extern "C" { 00040 #include "libraries/operaImage.h" 00041 #include "libraries/operaParameterAccess.h" 00042 #include "libraries/operaConfigurationAccess.h" 00043 } 00044 00045 using namespace std; 00046 00047 enum ebitpix {short_img=SHORT_IMG, ushort_img=USHORT_IMG, float_img=FLOAT_IMG, double_img=DOUBLE_IMG}; 00048 enum edatatype {tshort=TSHORT, tushort=TUSHORT, tstring=TSTRING, tfloat=TFLOAT, tdouble=TDOUBLE}; 00049 00053 typedef unsigned * ImageIndexVector; 00054 00055 unsigned veclen(ImageIndexVector v); 00056 00062 typedef float ** Matrix; 00063 00064 class operaFITSImage; 00071 string trimFITSKeyword(const char *in); // trim single quoates and trailing spaces form a FITS keyword value 00072 00081 ImageIndexVector where(operaFITSImage* b, unsigned *count); 00082 ImageIndexVector where(operaFITSImage& b, unsigned *count); 00083 ImageIndexVector where(operaFITSImage* b); 00084 ImageIndexVector where(operaFITSImage& b); 00085 00086 /* 00087 * operaFITSIMage class 00088 * \author Doug Teeple 00089 * \brief This class encapsulates the FITS image. 00090 * \ingroup libraries 00091 */ 00092 class operaFITSImage { 00093 00094 friend class operaEspadonsImage; 00095 friend class operaFITSSubImage; 00096 00097 private: 00098 string filename; // filename 00099 fitsfile *fptr; // FITS file pointer 00100 ebitpix bitpix; // BITPIX keyword value (SHORT_IMG, USHORT_IMG, FLOAT_IMG, DOUBLE_IMG) 00101 float bzero; // if bzero == 32768. then this is tushort else tshort 00102 float bscale; // if bscale == 1. then this is tushort else tshort 00103 unsigned hdu; // current active extension 00104 long naxes[2]; // FITS image dimension 00105 long naxis; // FITS image dimension 00106 unsigned naxis1; // x-dimension to be figured out from NAXIS1 (ncols) 00107 unsigned naxis2; // y-dimension to be figured out from NAXIS2 (nrows) 00108 unsigned npixels; // number of ccd pixels 00109 unsigned compression;// NULL, GZIP_1, RICE_1, HCOMPRESS_1 or PLIO_1 00110 edatatype datatype; // (TSHORT, TUSHORT, TFLOAT, TDOUBLE) 00111 bool istemp; // set if this instance is a temp created in an expression 00112 void *pixptr; // pixel base 00113 Matrix matrix; // matrix view of an image 00114 00115 00116 void openFITSfile(string Filename, int mode=READWRITE/*READONLY*/); 00117 void readFITSHeaderInfo(); 00118 void readFITSArray(); 00119 00120 protected: 00121 ebitpix tobitpix(edatatype Datatype); 00122 edatatype todatatype(ebitpix Bitpix, float bzero, float bscale); 00123 long toSize(ebitpix bitpix, long npixels); 00124 00125 public: 00131 operaFITSImage(); // simply construct a default image 00139 float *operator[](unsigned i) {return (float *)pixptr+(naxis1*i);}; 00147 //operaFITSSubImage *operator[](ImageIndexVector v) {return new operaFITSSubImage(*this, v);}; 00148 00156 operaFITSImage& operator=(operaFITSImage* b) { 00157 float *p = (float *)pixptr; 00158 float *bp = (float *)b->pixptr; 00159 unsigned n = npixels; 00160 while (n--) *p++ = *bp++; 00161 if (b->istemp) delete b; 00162 return *this; 00163 }; 00171 operaFITSImage& operator=(operaFITSImage& b) { 00172 float *p = (float *)pixptr; 00173 float *bp = (float *)b.pixptr; 00174 unsigned n = npixels; 00175 while (n--) *p++ = *bp++; 00176 if (b.istemp) delete &b; 00177 return *this; 00178 }; 00186 operaFITSImage& operator=(float f) { 00187 float *p = (float *)pixptr; 00188 unsigned n = npixels; 00189 while (n--) *p++ = f; 00190 return *this; 00191 }; 00199 operaFITSImage& operator+=(operaFITSImage* b) { 00200 float *p = (float *)pixptr; 00201 float *bp = (float *)b->pixptr; 00202 unsigned n = npixels; 00203 while (n--) *p++ += *bp++; 00204 if (b->istemp) delete b; 00205 return *this; 00206 }; 00214 operaFITSImage& operator+=(operaFITSImage& b) { 00215 float *p = (float *)pixptr; 00216 float *bp = (float *)b.pixptr; 00217 unsigned n = npixels; 00218 while (n--) *p++ += *bp++; 00219 if (b.istemp) delete &b; 00220 return *this; 00221 }; 00229 operaFITSImage& operator+=(float f) { 00230 float *p = (float *)pixptr; 00231 unsigned n = npixels; 00232 while (n--) *p++ += f; 00233 return *this; 00234 }; 00242 operaFITSImage& operator-=(operaFITSImage* b) { 00243 float *p = (float *)pixptr; 00244 float *bp = (float *)b->pixptr; 00245 unsigned n = npixels; 00246 while (n--) *p++ -= *bp++; 00247 if (b->istemp) delete b; 00248 return *this; 00249 }; 00257 operaFITSImage& operator-=(operaFITSImage& b) { 00258 float *p = (float *)pixptr; 00259 float *bp = (float *)b.pixptr; 00260 unsigned n = npixels; 00261 while (n--) *p++ -= *bp++; 00262 if (b.istemp) delete &b; 00263 return *this; 00264 }; 00272 operaFITSImage& operator-=(float f) { 00273 float *p = (float *)pixptr; 00274 unsigned n = npixels; 00275 while (n--) *p++ -= f; 00276 return *this; 00277 }; 00285 operaFITSImage& operator*=(operaFITSImage* b) { 00286 float *p = (float *)pixptr; 00287 float *bp = (float *)b->pixptr; 00288 unsigned n = npixels; 00289 while (n--) *p++ *= *bp++; 00290 if (b->istemp) delete b; 00291 return *this; 00292 }; 00300 operaFITSImage& operator*=(operaFITSImage& b) { 00301 float *p = (float *)pixptr; 00302 float *bp = (float *)b.pixptr; 00303 unsigned n = npixels; 00304 while (n--) *p++ *= *bp++; 00305 if (b.istemp) delete &b; 00306 return *this; 00307 }; 00315 operaFITSImage& operator*=(float f) { 00316 float *p = (float *)pixptr; 00317 unsigned n = npixels; 00318 while (n--) *p++ *= f; 00319 return *this; 00320 }; 00328 operaFITSImage& operator/=(operaFITSImage* b) { 00329 float *p = (float *)pixptr; 00330 float *bp = (float *)b->pixptr; 00331 unsigned n = npixels; 00332 while (n--) *p++ /= (*bp!=0.0?*bp++:(bp++,1.0)); 00333 if (b->istemp) delete b; 00334 return *this; 00335 }; 00343 operaFITSImage& operator/=(operaFITSImage& b) { 00344 float *p = (float *)pixptr; 00345 float *bp = (float *)b.pixptr; 00346 unsigned n = npixels; 00347 while (n--) *p++ /= (*bp!=0.0?*bp++:(bp++,1.0)); 00348 if (b.istemp) delete &b; 00349 return *this; 00350 }; 00358 operaFITSImage& operator/=(float f) { 00359 float *p = (float *)pixptr; 00360 unsigned n = npixels; 00361 while (n--) *p++ /= (f!=0.0?f:1.0); 00362 return *this; 00363 }; 00371 operaFITSImage* operator*(operaFITSImage* b) { 00372 float *tp; 00373 operaFITSImage *t; 00374 if (this->istemp) { 00375 t = this; 00376 tp = (float *)this->pixptr; 00377 } else { 00378 operaFITSImage *t = operaFITSImageClone(*this); 00379 t->istemp = true; 00380 tp = (float *)t->pixptr; 00381 } 00382 float *p = (float *)this->pixptr; 00383 float *bp = (float *)b->pixptr; 00384 unsigned n = npixels; 00385 while (n--) *tp++ = *p++ * *bp++; 00386 if (b->istemp) delete b; 00387 return t; 00388 }; 00396 operaFITSImage* operator*(operaFITSImage& b) { 00397 float *tp; 00398 operaFITSImage *t; 00399 if (this->istemp) { 00400 t = this; 00401 tp = (float *)this->pixptr; 00402 } else { 00403 operaFITSImage *t = operaFITSImageClone(*this); 00404 t->istemp = true; 00405 tp = (float *)t->pixptr; 00406 } 00407 float *p = (float *)this->pixptr; 00408 float *bp = (float *)b.pixptr; 00409 unsigned n = npixels; 00410 while (n--) *tp++ = *p++ * *bp++; 00411 if (b.istemp) delete &b; 00412 return t; 00413 }; 00421 operaFITSImage* operator*(float f) { 00422 operaFITSImage *t = operaFITSImageClone(*this); 00423 t->istemp = true; 00424 float *tp = (float *)t->pixptr; 00425 float *p = (float *)this->pixptr; 00426 unsigned n = npixels; 00427 while (n--) *tp++ = *p++ * f; 00428 return t; 00429 }; 00437 operaFITSImage* operator/(operaFITSImage* b) { 00438 float *tp; 00439 operaFITSImage *t; 00440 if (this->istemp) { 00441 t = this; 00442 tp = (float *)this->pixptr; 00443 } else { 00444 operaFITSImage *t = operaFITSImageClone(*this); 00445 t->istemp = true; 00446 tp = (float *)t->pixptr; 00447 } 00448 float *p = (float *)this->pixptr; 00449 float *bp = (float *)b->pixptr; 00450 unsigned n = npixels; 00451 while (n--) *tp++ = *p++ / (*bp!=0.0?*bp++:(bp++,1.0)); 00452 if (b->istemp) delete b; 00453 return t; 00454 }; 00462 operaFITSImage* operator/(operaFITSImage& b) { 00463 float *tp; 00464 operaFITSImage *t; 00465 if (this->istemp) { 00466 t = this; 00467 tp = (float *)this->pixptr; 00468 } else { 00469 operaFITSImage *t = operaFITSImageClone(*this); 00470 t->istemp = true; 00471 tp = (float *)t->pixptr; 00472 } 00473 float *p = (float *)this->pixptr; 00474 float *bp = (float *)b.pixptr; 00475 unsigned n = npixels; 00476 while (n--) *tp++ = *p++ / (*bp!=0.0?*bp++:(bp++,1.0)); 00477 if (b.istemp) delete &b; 00478 return t; 00479 }; 00487 operaFITSImage* operator/(float f) { 00488 operaFITSImage *t = operaFITSImageClone(*this); 00489 t->istemp = true; 00490 float *tp = (float *)t->pixptr; 00491 float *p = (float *)this->pixptr; 00492 unsigned n = npixels; 00493 while (n--) *tp++ = *p++ / (f!=0.0?f:1.0); 00494 return t; 00495 }; 00503 operaFITSImage* operator+(operaFITSImage* b) { 00504 float *tp; 00505 operaFITSImage *t; 00506 if (this->istemp) { 00507 t = this; 00508 tp = (float *)this->pixptr; 00509 } else { 00510 operaFITSImage *t = operaFITSImageClone(*this); 00511 t->istemp = true; 00512 tp = (float *)t->pixptr; 00513 } 00514 float *p = (float *)this->pixptr; 00515 float *bp = (float *)b->pixptr; 00516 unsigned n = npixels; 00517 while (n--) *tp++ = *p++ + *bp++; 00518 if (b->istemp) delete b; 00519 return t; 00520 }; 00528 operaFITSImage* operator+(operaFITSImage& b) { 00529 float *tp; 00530 operaFITSImage *t; 00531 if (this->istemp) { 00532 t = this; 00533 tp = (float *)this->pixptr; 00534 } else { 00535 operaFITSImage *t = operaFITSImageClone(*this); 00536 t->istemp = true; 00537 tp = (float *)t->pixptr; 00538 } 00539 float *p = (float *)this->pixptr; 00540 float *bp = (float *)b.pixptr; 00541 unsigned n = npixels; 00542 while (n--) *tp++ = *p++ + *bp++; 00543 if (b.istemp) delete &b; 00544 return t; 00545 }; 00553 operaFITSImage* operator+(float f) { 00554 operaFITSImage *t = operaFITSImageClone(*this); 00555 t->istemp = true; 00556 float *tp = (float *)t->pixptr; 00557 float *p = (float *)this->pixptr; 00558 unsigned n = npixels; 00559 while (n--) *tp++ = *p++ + f; 00560 return t; 00561 }; 00569 operaFITSImage* operator-(operaFITSImage* b) { 00570 float *tp; 00571 operaFITSImage *t; 00572 if (this->istemp) { 00573 t = this; 00574 tp = (float *)this->pixptr; 00575 } else { 00576 operaFITSImage *t = operaFITSImageClone(*this); 00577 t->istemp = true; 00578 tp = (float *)t->pixptr; 00579 } 00580 float *p = (float *)this->pixptr; 00581 float *bp = (float *)b->pixptr; 00582 unsigned n = npixels; 00583 while (n--) *tp++ = *p++ - *bp++; 00584 if (b->istemp) delete b; 00585 return t; 00586 }; 00594 operaFITSImage* operator-(operaFITSImage& b) { 00595 float *tp; 00596 operaFITSImage *t; 00597 if (this->istemp) { 00598 t = this; 00599 tp = (float *)this->pixptr; 00600 } else { 00601 operaFITSImage *t = operaFITSImageClone(*this); 00602 t->istemp = true; 00603 tp = (float *)t->pixptr; 00604 } 00605 float *p = (float *)this->pixptr; 00606 float *bp = (float *)b.pixptr; 00607 unsigned n = npixels; 00608 while (n--) *tp++ = *p++ - *bp++; 00609 if (b.istemp) delete &b; 00610 return t; 00611 }; 00619 operaFITSImage* operator-(float f) { 00620 operaFITSImage *t = operaFITSImageClone(*this); 00621 t->istemp = true; 00622 float *tp = (float *)t->pixptr; 00623 float *p = (float *)this->pixptr; 00624 unsigned n = npixels; 00625 while (n--) *tp++ = *p++ - f; 00626 return t; 00627 }; 00634 operaFITSImage* operator!() { 00635 float *tp; 00636 operaFITSImage *t; 00637 if (this->istemp) { 00638 t = this; 00639 tp = (float *)this->pixptr; 00640 } else { 00641 operaFITSImage *t = operaFITSImageClone(*this); 00642 t->istemp = true; 00643 tp = (float *)t->pixptr; 00644 } 00645 float *p = (float *)this->pixptr; 00646 unsigned n = npixels; 00647 while (n--) *tp++ = (*p++==0.0?1.0:0.0); 00648 return t; 00649 }; 00657 operaFITSImage* operator>(operaFITSImage* b) { 00658 float *tp; 00659 operaFITSImage *t; 00660 if (this->istemp) { 00661 t = this; 00662 tp = (float *)this->pixptr; 00663 } else { 00664 operaFITSImage *t = operaFITSImageClone(*this); 00665 t->istemp = true; 00666 tp = (float *)t->pixptr; 00667 } 00668 float *p = (float *)this->pixptr; 00669 float *bp = (float *)b->pixptr; 00670 unsigned n = npixels; 00671 while (n--) *tp++ = (*p++>*bp++?1.0:0.0); 00672 if (b->istemp) delete b; 00673 return t; 00674 }; 00682 operaFITSImage* operator>(operaFITSImage& b) { 00683 float *tp; 00684 operaFITSImage *t; 00685 if (this->istemp) { 00686 t = this; 00687 tp = (float *)this->pixptr; 00688 } else { 00689 operaFITSImage *t = operaFITSImageClone(*this); 00690 t->istemp = true; 00691 tp = (float *)t->pixptr; 00692 } 00693 float *p = (float *)this->pixptr; 00694 float *bp = (float *)b.pixptr; 00695 unsigned n = npixels; 00696 while (n--) *tp++ = (*p++>*bp++?1.0:0.0); 00697 if (b.istemp) delete &b; 00698 return t; 00699 }; 00707 operaFITSImage* operator>(float f) { 00708 operaFITSImage *t = operaFITSImageClone(*this); 00709 t->istemp = true; 00710 float *tp = (float *)t->pixptr; 00711 float *p = (float *)this->pixptr; 00712 unsigned n = npixels; 00713 while (n--) *tp++ = (*p++>f?1.0:0.0); 00714 return t; 00715 }; 00723 operaFITSImage* operator>=(operaFITSImage* b) { 00724 float *tp; 00725 operaFITSImage *t; 00726 if (this->istemp) { 00727 t = this; 00728 tp = (float *)this->pixptr; 00729 } else { 00730 operaFITSImage *t = operaFITSImageClone(*this); 00731 t->istemp = true; 00732 tp = (float *)t->pixptr; 00733 } 00734 float *p = (float *)this->pixptr; 00735 float *bp = (float *)b->pixptr; 00736 unsigned n = npixels; 00737 while (n--) *tp++ = (*p++>=*bp++?1.0:0.0); 00738 if (b->istemp) delete b; 00739 return t; 00740 }; 00748 operaFITSImage* operator>=(operaFITSImage& b) { 00749 float *tp; 00750 operaFITSImage *t; 00751 if (this->istemp) { 00752 t = this; 00753 tp = (float *)this->pixptr; 00754 } else { 00755 operaFITSImage *t = operaFITSImageClone(*this); 00756 t->istemp = true; 00757 tp = (float *)t->pixptr; 00758 } 00759 float *p = (float *)this->pixptr; 00760 float *bp = (float *)b.pixptr; 00761 unsigned n = npixels; 00762 while (n--) *tp++ = (*p++>=*bp++?1.0:0.0); 00763 if (b.istemp) delete &b; 00764 return t; 00765 }; 00773 operaFITSImage* operator>=(float f) { 00774 operaFITSImage *t = operaFITSImageClone(*this); 00775 t->istemp = true; 00776 float *tp = (float *)t->pixptr; 00777 float *p = (float *)this->pixptr; 00778 unsigned n = npixels; 00779 while (n--) *tp++ = (*p++>=f?1.0:0.0); 00780 return t; 00781 }; 00789 operaFITSImage* operator<(operaFITSImage* b) { 00790 float *tp; 00791 operaFITSImage *t; 00792 if (this->istemp) { 00793 t = this; 00794 tp = (float *)this->pixptr; 00795 } else { 00796 operaFITSImage *t = operaFITSImageClone(*this); 00797 t->istemp = true; 00798 tp = (float *)t->pixptr; 00799 } 00800 float *p = (float *)this->pixptr; 00801 float *bp = (float *)b->pixptr; 00802 unsigned n = npixels; 00803 while (n--) *tp++ = (*p++<*bp++?1.0:0.0); 00804 if (b->istemp) delete b; 00805 return t; 00806 }; 00814 operaFITSImage* operator<(operaFITSImage& b) { 00815 float *tp; 00816 operaFITSImage *t; 00817 if (this->istemp) { 00818 t = this; 00819 tp = (float *)this->pixptr; 00820 } else { 00821 operaFITSImage *t = operaFITSImageClone(*this); 00822 t->istemp = true; 00823 tp = (float *)t->pixptr; 00824 } 00825 float *p = (float *)this->pixptr; 00826 float *bp = (float *)b.pixptr; 00827 unsigned n = npixels; 00828 while (n--) *tp++ = (*p++<*bp++?1.0:0.0); 00829 if (b.istemp) delete &b; 00830 return t; 00831 }; 00839 operaFITSImage* operator<(float f) { 00840 operaFITSImage *t = operaFITSImageClone(*this); 00841 t->istemp = true; 00842 float *tp = (float *)t->pixptr; 00843 float *p = (float *)this->pixptr; 00844 unsigned n = npixels; 00845 while (n--) *tp++ = (*p++<f?1.0:0.0); 00846 return t; 00847 }; 00855 operaFITSImage* operator<=(operaFITSImage* b) { 00856 float *tp; 00857 operaFITSImage *t; 00858 if (this->istemp) { 00859 t = this; 00860 tp = (float *)this->pixptr; 00861 } else { 00862 operaFITSImage *t = operaFITSImageClone(*this); 00863 t->istemp = true; 00864 tp = (float *)t->pixptr; 00865 } 00866 float *p = (float *)this->pixptr; 00867 float *bp = (float *)b->pixptr; 00868 unsigned n = npixels; 00869 while (n--) *tp++ = (*p++<=*bp++?1.0:0.0); 00870 if (b->istemp) delete b; 00871 return t; 00872 }; 00880 operaFITSImage* operator<=(operaFITSImage& b) { 00881 float *tp; 00882 operaFITSImage *t; 00883 if (this->istemp) { 00884 t = this; 00885 tp = (float *)this->pixptr; 00886 } else { 00887 operaFITSImage *t = operaFITSImageClone(*this); 00888 t->istemp = true; 00889 tp = (float *)t->pixptr; 00890 } 00891 float *p = (float *)this->pixptr; 00892 float *bp = (float *)b.pixptr; 00893 unsigned n = npixels; 00894 while (n--) *tp++ = (*p++<=*bp++?1.0:0.0); 00895 if (b.istemp) delete &b; 00896 return t; 00897 }; 00905 operaFITSImage* operator<=(float f) { 00906 operaFITSImage *t = operaFITSImageClone(*this); 00907 t->istemp = true; 00908 float *tp = (float *)t->pixptr; 00909 float *p = (float *)this->pixptr; 00910 unsigned n = npixels; 00911 while (n--) *tp++ = (*p++<f?1.0:0.0); 00912 return t; 00913 }; 00921 operaFITSImage* operator&&(operaFITSImage* b) { 00922 float *tp; 00923 operaFITSImage *t; 00924 if (this->istemp) { 00925 t = this; 00926 tp = (float *)this->pixptr; 00927 } else { 00928 operaFITSImage *t = operaFITSImageClone(*this); 00929 t->istemp = true; 00930 tp = (float *)t->pixptr; 00931 } 00932 float *p = (float *)this->pixptr; 00933 float *bp = (float *)b->pixptr; 00934 unsigned n = npixels; 00935 while (n--) *tp++ = (*p++!=0.0&&*bp++!=0.0?1.0:0.0); 00936 if (b->istemp) delete b; 00937 return t; 00938 }; 00946 operaFITSImage* operator&&(operaFITSImage& b) { 00947 float *tp; 00948 operaFITSImage *t; 00949 if (this->istemp) { 00950 t = this; 00951 tp = (float *)this->pixptr; 00952 } else { 00953 operaFITSImage *t = operaFITSImageClone(*this); 00954 t->istemp = true; 00955 tp = (float *)t->pixptr; 00956 } 00957 float *p = (float *)this->pixptr; 00958 float *bp = (float *)b.pixptr; 00959 unsigned n = npixels; 00960 while (n--) *tp++ = (*p++!=0.0&&*bp++!=0.0?1.0:0.0); 00961 if (b.istemp) delete &b; 00962 return t; 00963 }; 00971 operaFITSImage* operator||(operaFITSImage* b) { 00972 float *tp; 00973 operaFITSImage *t; 00974 if (this->istemp) { 00975 t = this; 00976 tp = (float *)this->pixptr; 00977 } else { 00978 operaFITSImage *t = operaFITSImageClone(*this); 00979 t->istemp = true; 00980 tp = (float *)t->pixptr; 00981 } 00982 float *p = (float *)this->pixptr; 00983 float *bp = (float *)b->pixptr; 00984 unsigned n = npixels; 00985 while (n--) *tp++ = (*p++!=0.0||*bp++!=0.0?1.0:0.0); 00986 if (b->istemp) delete b; 00987 return t; 00988 }; 00996 operaFITSImage* operator||(operaFITSImage& b) { 00997 float *tp; 00998 operaFITSImage *t; 00999 if (this->istemp) { 01000 t = this; 01001 tp = (float *)this->pixptr; 01002 } else { 01003 operaFITSImage *t = operaFITSImageClone(*this); 01004 t->istemp = true; 01005 tp = (float *)t->pixptr; 01006 } 01007 float *p = (float *)this->pixptr; 01008 float *bp = (float *)b.pixptr; 01009 unsigned n = npixels; 01010 while (n--) *tp++ = (*p++!=0.0||*bp++!=0.0?1.0:0.0); 01011 if (b.istemp) delete &b; 01012 return t; 01013 }; 01014 01025 operaFITSImage(unsigned Naxis1, unsigned Naxis2, 01026 edatatype Datatype = tushort, unsigned Compression = 0); // simply construct an image of a given size 01039 operaFITSImage(string Filename, unsigned Naxis1, unsigned Naxis2, 01040 edatatype Datatype = tushort, unsigned Compression = 0); // create a new empty FITSImage 01049 operaFITSImage(string Filename, edatatype Datatype, int mode=READWRITE/*READONLY*/); // read an existing FITSImage from file 01060 operaFITSImage(string Filename, int mode=READWRITE/*READONLY*/); // read an existing FITSImage from file 01067 ~operaFITSImage(); // destructor 01068 01077 void operaFITSImageSave(); // save a FITSImage 01085 void operaFITSImageSaveAs(string newFilename); // save as 01092 operaFITSImage *operaFITSImageClone(operaFITSImage &imageIn); // clone image object 01098 unsigned short* operaFITSImageClonePixelsUSHORT(); // clone ccd pixels 01108 unsigned short* operaFITSImageClonePixelsUSHORT(unsigned x, unsigned y, unsigned nx, unsigned ny); // clone subimage 01114 float* operaFITSImageClonePixels(); // clone image pixels 01124 float* operaFITSImageClonePixels(unsigned x, unsigned y, unsigned nx, unsigned ny); // clone subwindow 01133 void operaFITSImageSetData(operaFITSSubImage &subImage, unsigned X, unsigned Y); 01140 void operaFITSImageSetData(unsigned short* data); // set pixptr to a data buffer 01147 void operaFITSImageSetData(float* data); // set pixptr to a data buffer 01154 string operaFITSGetHeaderValue(string keyword); // return header kweyword value as string 01162 string operaFITSGetRawHeaderValue(string keyword); // return raw header kweyword value as string 01172 void operaFITSSetHeaderValue(string keyword, string value, string comment); // set header kweyword value as string 01181 void operaFITSSetHeaderValue(string keyword, unsigned short value, string comment); // set header keyword value as ushort 01191 void operaFITSSetHeaderValue(string keyword, float value, string comment); // set header keyword value as float 01201 void operaFITSSetHeaderValue(string keyword, double value, string comment); // set header keyword value as double 01209 void operaFITSImageCopyHeader(operaFITSImage *from); // copy header unit 01217 void operaFITSImageConvertImage(edatatype todatatype); // convert image type and values 01223 void transpose(); 01229 void operaFITSImageClose(); // close 01230 01238 inline unsigned short getpixelUSHORT(unsigned x, unsigned y) {return ((unsigned short *)pixptr)[(naxis1*y)+x];}; 01239 inline float getpixel(unsigned x, unsigned y) {return ((float *)pixptr)[(naxis1*y)+x];}; 01240 01249 inline void setpixel(unsigned short value, unsigned x, unsigned y) {((unsigned short *)pixptr)[(naxis1*y)+x] = value;}; 01250 inline void setpixel(float value, unsigned x, unsigned y) {((float *)pixptr)[(naxis1*y)+x] = value;}; 01251 01252 /* getters and setters */ 01253 01260 void setfilename(string name); 01266 string getfilename(); 01272 fitsfile *getfitsfileptr(); 01278 void *getpixels(); 01284 Matrix getmatrix(); 01290 unsigned getnaxis(); 01296 unsigned getnaxis1(); 01302 unsigned getnaxis2(); 01308 unsigned getnpixels(); 01314 unsigned long getsize(); 01320 unsigned getelementsize(); 01326 unsigned getCompression(); 01333 void setCompression(unsigned Compression); 01339 edatatype getdatatype(); 01345 ebitpix getbitpix(); 01351 bool getIstemp() {return istemp;}; 01352 01353 }; 01354 01355 #endif