<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>CCfits: ImageExt.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> </ul> </div> <h1>ImageExt.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Read the documentation to learn more about C++ code generator</span> <a name="l00002"></a>00002 <span class="comment">// versioning.</span> <a name="l00003"></a>00003 <span class="comment">// This is version 2.2 release dated Sep 2009</span> <a name="l00004"></a>00004 <span class="comment">// Astrophysics Science Division,</span> <a name="l00005"></a>00005 <span class="comment">// NASA/ Goddard Space Flight Center</span> <a name="l00006"></a>00006 <span class="comment">// HEASARC</span> <a name="l00007"></a>00007 <span class="comment">// http://heasarc.gsfc.nasa.gov</span> <a name="l00008"></a>00008 <span class="comment">// e-mail: ccfits@legacy.gsfc.nasa.gov</span> <a name="l00009"></a>00009 <span class="comment">//</span> <a name="l00010"></a>00010 <span class="comment">// Original author: Ben Dorman</span> <a name="l00011"></a>00011 <a name="l00012"></a>00012 <span class="preprocessor">#ifndef IMAGEEXT_H</span> <a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#define IMAGEEXT_H 1</span> <a name="l00014"></a>00014 <span class="preprocessor"></span> <a name="l00015"></a>00015 <span class="comment">// ExtHDU</span> <a name="l00016"></a>00016 <span class="preprocessor">#include "ExtHDU.h"</span> <a name="l00017"></a>00017 <span class="comment">// HDUCreator</span> <a name="l00018"></a>00018 <span class="preprocessor">#include "HDUCreator.h"</span> <a name="l00019"></a>00019 <span class="comment">// Image</span> <a name="l00020"></a>00020 <span class="preprocessor">#include "Image.h"</span> <a name="l00021"></a>00021 <span class="comment">// FITSUtil</span> <a name="l00022"></a>00022 <span class="preprocessor">#include "FITSUtil.h"</span> <a name="l00023"></a>00023 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#include "MSconfig.h"</span> <span class="comment">// for truncation warning</span> <a name="l00025"></a>00025 <span class="preprocessor">#endif</span> <a name="l00026"></a>00026 <span class="preprocessor"></span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="keyword">namespace </span>CCfits { <a name="l00029"></a>00029 <a name="l00058"></a>00058 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00059"></a><a class="code" href="classCCfits_1_1ImageExt.html">00059</a> <span class="keyword">class </span><a class="code" href="classCCfits_1_1ImageExt.html">ImageExt</a> : <span class="keyword">public</span> <a class="code" href="classCCfits_1_1ExtHDU.html" title="base class for all FITS extension HDUs, i.e. Image Extensions and Tables.">ExtHDU</a> <span class="comment">//## Inherits: <unnamed>%3804A11121D8</span> <a name="l00060"></a>00060 { <a name="l00061"></a>00061 <a name="l00062"></a>00062 <span class="keyword">public</span>: <a name="l00063"></a>00063 <span class="keyword">virtual</span> <a class="code" href="classCCfits_1_1ImageExt.html#a036e9a9301d0a8c5cfb2045168bf752e" title="destructor">~ImageExt</a>(); <a name="l00064"></a>00064 <a name="l00065"></a>00065 <span class="keyword">virtual</span> <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt<T></a> * <a class="code" href="classCCfits_1_1ImageExt.html#a50f37e2cb14259f534b6bd88bc853da7" title="virtual copy constructor">clone</a> (FITSBase* p) <span class="keyword">const</span>; <a name="l00066"></a>00066 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCCfits_1_1ImageExt.html#a0f74472174c571dea4e7faa0cb23eae8" title="read Image extension HDU data">readData</a> (<span class="keywordtype">bool</span> readFlag = <span class="keyword">false</span>, <span class="keyword">const</span> std::vector<String>& keys = std::vector<String>()); <a name="l00067"></a>00067 <span class="keyword">const</span> std::valarray<T>& <a class="code" href="classCCfits_1_1ImageExt.html#ace83a5e81e20d8210bf04ab2fd03aaa4" title="return the image data">image</a> () <span class="keyword">const</span>; <a name="l00068"></a>00068 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCCfits_1_1ImageExt.html#a53d36df4ae92f58771a25559120bacb9" title="return the BZERO keyword value">zero</a> (<span class="keywordtype">double</span> value); <a name="l00069"></a>00069 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classCCfits_1_1ImageExt.html#a1eb7b465140aa151e2f7272c977846cd" title="return the BSCALE keyword value">scale</a> (<span class="keywordtype">double</span> value); <a name="l00070"></a>00070 <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classCCfits_1_1ImageExt.html#a53d36df4ae92f58771a25559120bacb9" title="return the BZERO keyword value">zero</a> () <span class="keyword">const</span>; <a name="l00071"></a>00071 <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classCCfits_1_1ImageExt.html#a1eb7b465140aa151e2f7272c977846cd" title="return the BSCALE keyword value">scale</a> () <span class="keyword">const</span>; <a name="l00072"></a>00072 <a name="l00073"></a>00073 <span class="comment">// Additional Public Declarations</span> <a name="l00074"></a>00074 <a name="l00075"></a>00075 <span class="keyword">protected</span>: <a name="l00076"></a>00076 <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt</a> (FITSBase* p, <span class="keyword">const</span> String &hduName, <span class="keywordtype">bool</span> readDataFlag = <span class="keyword">false</span>, <span class="keyword">const</span> std::vector<String>& keys = std::vector<String>(), <span class="keywordtype">int</span> <a class="code" href="classCCfits_1_1ExtHDU.html#a5e2785377c404f05dc948db844c6eec7" title="return the extension version number.">version</a> = 1); <a name="l00077"></a>00077 <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt</a> (FITSBase* p, <span class="keyword">const</span> String &hduName, <span class="keywordtype">int</span> bpix, <span class="keywordtype">int</span> naxis, <span class="keyword">const</span> std::vector<long>& <a class="code" href="classCCfits_1_1HDU.html#a2e02db0df89451736c7863963170a081" title="return the HDU data axis array.">naxes</a>, <span class="keywordtype">int</span> <a class="code" href="classCCfits_1_1ExtHDU.html#a5e2785377c404f05dc948db844c6eec7" title="return the extension version number.">version</a> = 1); <a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="comment">// Additional Protected Declarations</span> <a name="l00080"></a>00080 <span class="keyword">virtual</span> <span class="keywordtype">void</span> checkExtensionType() <span class="keyword">const</span>; <a name="l00081"></a>00081 <span class="keyword">private</span>: <a name="l00082"></a>00082 <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt</a>(<span class="keyword">const</span> <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt< T ></a> &right); <a name="l00083"></a>00083 <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt< T ></a> & operator=(<span class="keyword">const</span> <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt< T ></a> &right); <a name="l00084"></a>00084 <a name="l00085"></a>00085 <span class="keyword">virtual</span> <span class="keywordtype">void</span> initRead (); <a name="l00086"></a>00086 <span class="keyword">virtual</span> std::ostream & put (std::ostream &s) <span class="keyword">const</span>; <a name="l00087"></a>00087 <span class="comment">// Read data reads the image if readFlag is true and</span> <a name="l00088"></a>00088 <span class="comment">// optional keywords if supplied. Thus, with no arguments,</span> <a name="l00089"></a>00089 <span class="comment">// readData() does nothing.</span> <a name="l00090"></a>00090 <span class="keyword">virtual</span> <span class="keyword">const</span> std::valarray<T>& readImage (<span class="keywordtype">long</span> first, <span class="keywordtype">long</span> nElements, T* nullValue); <a name="l00091"></a>00091 <span class="comment">// Read data reads the image if readFlag is true and</span> <a name="l00092"></a>00092 <span class="comment">// optional keywords if supplied. Thus, with no arguments,</span> <a name="l00093"></a>00093 <span class="comment">// readData() does nothing.</span> <a name="l00094"></a>00094 <span class="keyword">virtual</span> <span class="keyword">const</span> std::valarray<T>& readImage (<span class="keyword">const</span> std::vector<long>& firstVertex, <span class="keyword">const</span> std::vector<long>& lastVertex, <span class="keyword">const</span> std::vector<long>& stride, T* nullValue); <a name="l00095"></a>00095 <span class="comment">// Read data reads the image if readFlag is true and</span> <a name="l00096"></a>00096 <span class="comment">// optional keywords if supplied. Thus, with no arguments,</span> <a name="l00097"></a>00097 <span class="comment">// readData() does nothing.</span> <a name="l00098"></a>00098 <span class="keyword">virtual</span> <span class="keywordtype">void</span> writeImage (<span class="keywordtype">long</span> first, <span class="keywordtype">long</span> nElements, <span class="keyword">const</span> std::valarray<T>& inData, T* nullValue = 0); <a name="l00099"></a>00099 <span class="comment">// Read data reads the image if readFlag is true and</span> <a name="l00100"></a>00100 <span class="comment">// optional keywords if supplied. Thus, with no arguments,</span> <a name="l00101"></a>00101 <span class="comment">// readData() does nothing.</span> <a name="l00102"></a>00102 <span class="keyword">virtual</span> <span class="keywordtype">void</span> writeImage (<span class="keyword">const</span> std::vector<long>& firstVertex, <span class="keyword">const</span> std::vector<long>& lastVertex, <span class="keyword">const</span> std::valarray<T>& inData); <a name="l00103"></a>00103 <span class="keyword">const</span> Image<T>& data () <span class="keyword">const</span>; <a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="comment">// Additional Private Declarations</span> <a name="l00106"></a>00106 <a name="l00107"></a>00107 <span class="keyword">private</span>: <span class="comment">//## implementation</span> <a name="l00108"></a>00108 <span class="comment">// Data Members for Associations</span> <a name="l00109"></a>00109 Image<T> m_data; <a name="l00110"></a>00110 <a name="l00111"></a>00111 <span class="comment">// Additional Implementation Declarations</span> <a name="l00112"></a>00112 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classCCfits_1_1ExtHDU.html" title="base class for all FITS extension HDUs, i.e. Image Extensions and Tables.">ExtHDU</a>; <a name="l00113"></a>00113 <span class="keyword">friend</span> <span class="keyword">class </span>HDUCreator; <a name="l00114"></a>00114 }; <a name="l00115"></a>00115 <a name="l00116"></a>00116 <span class="comment">// Parameterized Class CCfits::ImageExt </span> <a name="l00117"></a>00117 <a name="l00118"></a>00118 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00119"></a>00119 <span class="keyword">inline</span> std::ostream & <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt<T>::put</a> (std::ostream &s)<span class="keyword"> const</span> <a name="l00120"></a>00120 <span class="keyword"> </span>{ <a name="l00121"></a>00121 s << <span class="stringliteral">"Image Extension:: "</span> << <span class="stringliteral">" Name: "</span> << <a class="code" href="classCCfits_1_1ExtHDU.html#af1128c49f0381473feff2cd9e5650dce" title="return the name of the extension.">name</a>() << <span class="stringliteral">" Extension: "</span> << <a class="code" href="classCCfits_1_1ExtHDU.html#ad3a43454577309abb2ec1ebe97d3375b" title="return the extension type">xtension</a>() <a name="l00122"></a>00122 << <span class="stringliteral">" BITPIX "</span><< <a class="code" href="classCCfits_1_1HDU.html#a81a2d5b001c0ae7d0a298942940189d8" title="return the data type keyword.">bitpix</a>() << <span class="charliteral">'\n'</span>; <a name="l00123"></a>00123 <a name="l00124"></a>00124 s << <span class="stringliteral">" Axis Lengths: \n"</span>; <a name="l00125"></a>00125 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j =1; j < static_cast<size_t>( <a class="code" href="classCCfits_1_1HDU.html#a18bd99b5d72ace7e7b353102eb80793a" title="return the number of axes in the HDU data section (always 2 for tables).">axes</a>() ) ; j++) <a name="l00126"></a>00126 { <a name="l00127"></a>00127 s << <span class="stringliteral">" Axis: "</span> << j << <span class="stringliteral">" "</span> << <a class="code" href="classCCfits_1_1HDU.html#a9e19372a1a01046420c6ba4393bb5674" title="return the size of axis numbered index [zero based].">axis</a>(j-1) << <span class="charliteral">'\n'</span>; <a name="l00128"></a>00128 } <a name="l00129"></a>00129 <a name="l00130"></a>00130 <a name="l00131"></a>00131 <a name="l00132"></a>00132 s << <span class="stringliteral">"Image Extension:: Version: "</span> << <a class="code" href="classCCfits_1_1ExtHDU.html#a5e2785377c404f05dc948db844c6eec7" title="return the extension version number.">version</a>() << <span class="stringliteral">" HDU number: "</span> << <a class="code" href="classCCfits_1_1HDU.html#a111434a1e35e2453237f86b30b3f4a8d" title="return the HDU number">index</a>() << <span class="charliteral">'\n'</span>; <a name="l00133"></a>00133 <a name="l00134"></a>00134 s << <span class="stringliteral">" HISTORY: "</span> << <a class="code" href="classCCfits_1_1HDU.html#a7acddc0c108bc9504a3a342b010ec9a1" title="return the history string previously read by getHistory()">history</a>() << <span class="charliteral">'\n'</span>; <a name="l00135"></a>00135 s << <span class="stringliteral">" COMMENTS: "</span> <<<a class="code" href="classCCfits_1_1HDU.html#aecb532b753cd3460568e49e64df19ee5" title="return the comment string previously read by getComment()">comment</a>() << <span class="charliteral">'\n'</span>; <a name="l00136"></a>00136 <a name="l00137"></a>00137 s << <span class="stringliteral">"BinTable:: nKeywords: "</span> << <a class="code" href="classCCfits_1_1HDU.html#a011149805ffb96031218739369863e17" title="return the associative array containing the HDU keywords so far read.">keyWord</a>().size() << <span class="charliteral">'\n'</span>; <a name="l00138"></a>00138 <a name="l00139"></a>00139 <span class="keywordflow">return</span> s; <a name="l00140"></a>00140 } <a name="l00141"></a>00141 <a name="l00142"></a>00142 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00143"></a>00143 <span class="keyword">inline</span> <span class="keyword">const</span> Image<T>& ImageExt<T>::data ()<span class="keyword"> const</span> <a name="l00144"></a>00144 <span class="keyword"> </span>{ <a name="l00145"></a>00145 <span class="keywordflow">return</span> m_data; <a name="l00146"></a>00146 } <a name="l00147"></a>00147 <a name="l00148"></a>00148 <span class="comment">// Parameterized Class CCfits::ImageExt </span> <a name="l00149"></a>00149 <a name="l00150"></a>00150 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00151"></a>00151 ImageExt<T>::ImageExt(<span class="keyword">const</span> ImageExt<T> &right) <a name="l00152"></a>00152 : ExtHDU(right), m_data(right.m_data) <a name="l00153"></a>00153 { <a name="l00154"></a>00154 } <a name="l00155"></a>00155 <a name="l00156"></a>00156 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00157"></a>00157 ImageExt<T>::ImageExt (FITSBase* p, <span class="keyword">const</span> String &hduName, <span class="keywordtype">bool</span> readDataFlag, <span class="keyword">const</span> std::vector<String>& keys, <span class="keywordtype">int</span> version) <a name="l00158"></a>00158 : ExtHDU(p,ImageHdu,hduName,version), m_data() <a name="l00159"></a>00159 { <a name="l00160"></a>00160 initRead(); <a name="l00161"></a>00161 <span class="keywordflow">if</span> (readDataFlag || keys.size() ) <a class="code" href="classCCfits_1_1ImageExt.html#a0f74472174c571dea4e7faa0cb23eae8" title="read Image extension HDU data">readData</a>(readDataFlag,keys); <a name="l00162"></a>00162 } <a name="l00163"></a>00163 <a name="l00164"></a>00164 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00165"></a>00165 ImageExt<T>::ImageExt (FITSBase* p, <span class="keyword">const</span> String &hduName, <span class="keywordtype">int</span> bpix, <span class="keywordtype">int</span> naxis, <span class="keyword">const</span> std::vector<long>& naxes, <span class="keywordtype">int</span> version) <a name="l00166"></a>00166 : ExtHDU(p,ImageHdu,hduName,bpix,naxis,naxes,version), m_data() <a name="l00167"></a>00167 { <a name="l00168"></a>00168 <span class="comment">// resize m_image according to naxes, and data according to m_image,</span> <a name="l00169"></a>00169 <span class="comment">// and equate them. Valarray = must be performed on items of the same</span> <a name="l00170"></a>00170 <span class="comment">// size according to the standard.</span> <a name="l00171"></a>00171 <span class="keywordtype">int</span> status (0); <a name="l00172"></a>00172 FITSUtil::CVarray<long> convert; <a name="l00173"></a>00173 FITSUtil::auto_array_ptr<long> <a class="code" href="classCCfits_1_1HDU.html#a9e19372a1a01046420c6ba4393bb5674" title="return the size of axis numbered index [zero based].">axis</a>(convert(naxes)); <a name="l00174"></a>00174 <span class="keyword">static</span> <span class="keywordtype">char</span> EXTNAME[] = <span class="stringliteral">"EXTNAME"</span>; <a name="l00175"></a>00175 <span class="keyword">static</span> <span class="keywordtype">char</span> HDUVERS[] = <span class="stringliteral">"HDUVERS"</span>; <a name="l00176"></a>00176 <a name="l00177"></a>00177 <span class="keywordflow">if</span> ( fits_create_img(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(), bpix, naxis, <a class="code" href="classCCfits_1_1HDU.html#a9e19372a1a01046420c6ba4393bb5674" title="return the size of axis numbered index [zero based].">axis</a>.get(), &status) ) <a name="l00178"></a>00178 { <a name="l00179"></a>00179 <a name="l00180"></a>00180 <span class="keywordflow">throw</span> FitsError(status); <a name="l00181"></a>00181 } <a name="l00182"></a>00182 <span class="keywordflow">else</span> <a name="l00183"></a>00183 { <a name="l00184"></a>00184 <span class="keywordtype">char</span> * <a class="code" href="classCCfits_1_1HDU.html#aecb532b753cd3460568e49e64df19ee5" title="return the comment string previously read by getComment()">comment</a> = 0; <a name="l00185"></a>00185 <span class="keywordflow">if</span> (fits_write_key(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(),Tstring,EXTNAME, <a name="l00186"></a>00186 const_cast<char*>(hduName.c_str()), comment,&status)) <a name="l00187"></a>00187 { <a name="l00188"></a>00188 <span class="keywordflow">throw</span> FitsError(status); <a name="l00189"></a>00189 } <a name="l00190"></a>00190 <span class="keywordflow">if</span> (version != 0 && fits_write_key(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(),Tint,HDUVERS,&version, <a name="l00191"></a>00191 comment,&status)) <span class="keywordflow">throw</span> FitsError(status); <a name="l00192"></a>00192 } <a name="l00193"></a>00193 } <a name="l00194"></a>00194 <a name="l00195"></a>00195 <a name="l00196"></a>00196 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00197"></a><a class="code" href="classCCfits_1_1ImageExt.html#a036e9a9301d0a8c5cfb2045168bf752e">00197</a> <a class="code" href="classCCfits_1_1ImageExt.html#a036e9a9301d0a8c5cfb2045168bf752e" title="destructor">ImageExt<T>::~ImageExt</a>() <a name="l00198"></a>00198 { <a name="l00199"></a>00199 } <a name="l00200"></a>00200 <a name="l00201"></a>00201 <a name="l00202"></a>00202 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00203"></a>00203 <span class="keywordtype">void</span> <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt<T>::initRead</a> () <a name="l00204"></a>00204 { <a name="l00205"></a>00205 } <a name="l00206"></a>00206 <a name="l00207"></a>00207 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00208"></a><a class="code" href="classCCfits_1_1ImageExt.html#a50f37e2cb14259f534b6bd88bc853da7">00208</a> <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt<T></a> * <a class="code" href="classCCfits_1_1ImageExt.html#a50f37e2cb14259f534b6bd88bc853da7" title="virtual copy constructor">ImageExt<T>::clone</a> (FITSBase* p)<span class="keyword"> const</span> <a name="l00209"></a>00209 <span class="keyword"> </span>{ <a name="l00210"></a>00210 <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt<T></a>* cloned = <span class="keyword">new</span> <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt<T></a>(*this); <a name="l00211"></a>00211 cloned-><a class="code" href="classCCfits_1_1HDU.html#a3b547e893d364ebc570f2998a6b193bd" title="return reference to the pointer representing the FITSBase object containing the HDU...">parent</a>() = p; <a name="l00212"></a>00212 <span class="keywordflow">return</span> cloned; <a name="l00213"></a>00213 } <a name="l00214"></a>00214 <a name="l00215"></a>00215 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00216"></a><a class="code" href="classCCfits_1_1ImageExt.html#a0f74472174c571dea4e7faa0cb23eae8">00216</a> <span class="keywordtype">void</span> <a class="code" href="classCCfits_1_1ImageExt.html#a0f74472174c571dea4e7faa0cb23eae8" title="read Image extension HDU data">ImageExt<T>::readData</a> (<span class="keywordtype">bool</span> readFlag, <span class="keyword">const</span> std::vector<String>& keys) <a name="l00217"></a>00217 { <a name="l00218"></a>00218 <span class="comment">// Default reading mode. Read everything if readFlag is true.</span> <a name="l00219"></a>00219 <span class="comment">// this is identical to the equivalent method for PrimaryHDU<T>,</span> <a name="l00220"></a>00220 <span class="comment">// so will one day turn this into a simple call that shares the code.</span> <a name="l00221"></a>00221 <a class="code" href="classCCfits_1_1ExtHDU.html#a16730a075858cd50bfa3daad60c0a1c0" title="move the fitsfile pointer to this current HDU.">makeThisCurrent</a>(); <a name="l00222"></a>00222 <a name="l00223"></a>00223 <span class="keywordflow">if</span> ( keys.size() > 0) <a name="l00224"></a>00224 { <a name="l00225"></a>00225 std::list<string> keyList; <a name="l00226"></a>00226 <span class="comment">// keys is converted to a list so that any keys not in the header</span> <a name="l00227"></a>00227 <span class="comment">// can be easily erased. internally an exception will be thrown,</span> <a name="l00228"></a>00228 <span class="comment">// on a missing key, and its catch clause will print a message.</span> <a name="l00229"></a>00229 <span class="keywordflow">for</span> (std::vector<string>::const_iterator j = keys.begin(); j != keys.end(); ++j) <a name="l00230"></a>00230 { <a name="l00231"></a>00231 keyList.push_back(*j); <a name="l00232"></a>00232 } <a name="l00233"></a>00233 readKeywords(keyList); <a name="l00234"></a>00234 } <a name="l00235"></a>00235 <a name="l00236"></a>00236 <span class="keywordflow">if</span> ( readFlag) <span class="comment">// read the entire image, setting null values to FLT_MIN.</span> <a name="l00237"></a>00237 { <a name="l00238"></a>00238 <a name="l00239"></a>00239 FITSUtil::FitsNullValue<T> null; <a name="l00240"></a>00240 T nulval = null(); <a name="l00241"></a>00241 <span class="keywordtype">long</span> first(1); <a name="l00242"></a>00242 <span class="keywordtype">long</span> nelements(1); <a name="l00243"></a>00243 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < <a class="code" href="classCCfits_1_1HDU.html#a2e02db0df89451736c7863963170a081" title="return the HDU data axis array.">naxes</a>().size(); i++) nelements *= <a class="code" href="classCCfits_1_1HDU.html#a2e02db0df89451736c7863963170a081" title="return the HDU data axis array.">naxes</a>(i); <a name="l00244"></a>00244 m_data.readImage(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(),first,nelements,&nulval,<a class="code" href="classCCfits_1_1HDU.html#a2e02db0df89451736c7863963170a081" title="return the HDU data axis array.">naxes</a>(),anynul()); <a name="l00245"></a>00245 <a name="l00246"></a>00246 } <a name="l00247"></a>00247 } <a name="l00248"></a>00248 <a name="l00249"></a>00249 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00250"></a><a class="code" href="classCCfits_1_1ImageExt.html#ace83a5e81e20d8210bf04ab2fd03aaa4">00250</a> <span class="keyword">const</span> std::valarray<T>& <a class="code" href="classCCfits_1_1ImageExt.html#ace83a5e81e20d8210bf04ab2fd03aaa4" title="return the image data">ImageExt<T>::image</a> ()<span class="keyword"> const</span> <a name="l00251"></a>00251 <span class="keyword"> </span>{ <a name="l00252"></a>00252 <a name="l00253"></a>00253 <span class="keywordflow">return</span> m_data.image(); <a name="l00254"></a>00254 } <a name="l00255"></a>00255 <a name="l00256"></a>00256 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00257"></a>00257 <span class="keyword">const</span> std::valarray<T>& <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt<T>::readImage</a> (<span class="keywordtype">long</span> first, <span class="keywordtype">long</span> nElements, T* nullValue) <a name="l00258"></a>00258 { <a name="l00259"></a>00259 checkExtensionType(); <a name="l00260"></a>00260 <span class="keywordflow">return</span> m_data.readImage(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(),first,nElements,nullValue,<a class="code" href="classCCfits_1_1HDU.html#a2e02db0df89451736c7863963170a081" title="return the HDU data axis array.">naxes</a>(),anynul()); <a name="l00261"></a>00261 } <a name="l00262"></a>00262 <a name="l00263"></a>00263 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00264"></a>00264 <span class="keyword">const</span> std::valarray<T>& ImageExt<T>::readImage (<span class="keyword">const</span> std::vector<long>& firstVertex, <span class="keyword">const</span> std::vector<long>& lastVertex, <span class="keyword">const</span> std::vector<long>& stride, T* nullValue) <a name="l00265"></a>00265 { <a name="l00266"></a>00266 checkExtensionType(); <a name="l00267"></a>00267 <span class="keywordflow">return</span> m_data.readImage(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(),firstVertex,lastVertex,stride,nullValue,<a class="code" href="classCCfits_1_1HDU.html#a2e02db0df89451736c7863963170a081" title="return the HDU data axis array.">naxes</a>(),anynul()); <a name="l00268"></a>00268 } <a name="l00269"></a>00269 <a name="l00270"></a>00270 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00271"></a>00271 <span class="keywordtype">void</span> ImageExt<T>::writeImage (<span class="keywordtype">long</span> first, <span class="keywordtype">long</span> nElements, <span class="keyword">const</span> std::valarray<T>& inData, T* nullValue) <a name="l00272"></a>00272 { <a name="l00273"></a>00273 checkExtensionType(); <a name="l00274"></a>00274 m_data.writeImage(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(),first,nElements,inData,<a class="code" href="classCCfits_1_1HDU.html#a2e02db0df89451736c7863963170a081" title="return the HDU data axis array.">naxes</a>(),nullValue); <a name="l00275"></a>00275 } <a name="l00276"></a>00276 <a name="l00277"></a>00277 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00278"></a>00278 <span class="keywordtype">void</span> ImageExt<T>::writeImage (<span class="keyword">const</span> std::vector<long>& firstVertex, <span class="keyword">const</span> std::vector<long>& lastVertex, <span class="keyword">const</span> std::valarray<T>& inData) <a name="l00279"></a>00279 { <a name="l00280"></a>00280 checkExtensionType(); <a name="l00281"></a>00281 m_data.writeImage(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(),firstVertex,lastVertex,inData,<a class="code" href="classCCfits_1_1HDU.html#a2e02db0df89451736c7863963170a081" title="return the HDU data axis array.">naxes</a>()); <a name="l00282"></a>00282 } <a name="l00283"></a>00283 <a name="l00284"></a>00284 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00285"></a><a class="code" href="classCCfits_1_1ImageExt.html#aa6d47bd83e9538694ee7d4f4d70ef33b">00285</a> <span class="keywordtype">void</span> <a class="code" href="classCCfits_1_1ImageExt.html#a53d36df4ae92f58771a25559120bacb9" title="return the BZERO keyword value">ImageExt<T>::zero</a> (<span class="keywordtype">double</span> value) <a name="l00286"></a>00286 { <a name="l00287"></a>00287 <a class="code" href="classCCfits_1_1ExtHDU.html#a16730a075858cd50bfa3daad60c0a1c0" title="move the fitsfile pointer to this current HDU.">makeThisCurrent</a>(); <a name="l00288"></a>00288 <span class="keywordflow">if</span> (checkImgDataTypeChange(value, <a class="code" href="classCCfits_1_1ImageExt.html#a1eb7b465140aa151e2f7272c977846cd" title="return the BSCALE keyword value">scale</a>())) <a name="l00289"></a>00289 { <a name="l00290"></a>00290 <span class="keywordflow">if</span> (naxis()) <a name="l00291"></a>00291 { <a name="l00292"></a>00292 <span class="keywordtype">int</span> status(0); <a name="l00293"></a>00293 <span class="keywordflow">if</span> (fits_update_key(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(), Tdouble, BZERO, &value, 0, &status)) <a name="l00294"></a>00294 <span class="keywordflow">throw</span> <a class="code" href="classCCfits_1_1FitsError.html" title="FitsError is the exception thrown by non-zero cfitsio status codes.">FitsError</a>(status); <a name="l00295"></a>00295 fits_flush_file(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(), &status); <a name="l00296"></a>00296 <a class="code" href="classCCfits_1_1ImageExt.html#a53d36df4ae92f58771a25559120bacb9" title="return the BZERO keyword value">HDU::zero</a>(value); <a name="l00297"></a>00297 } <a name="l00298"></a>00298 } <a name="l00299"></a>00299 <span class="keywordflow">else</span> <a name="l00300"></a>00300 { <a name="l00301"></a>00301 <span class="keywordtype">bool</span> silent=<span class="keyword">false</span>; <a name="l00302"></a>00302 <span class="keywordtype">string</span> msg(<span class="stringliteral">"CCfits Error: Cannot set BZERO to a value which will change image data\n"</span>); <a name="l00303"></a>00303 msg += <span class="stringliteral">" from integer type to floating point type."</span>; <a name="l00304"></a>00304 <span class="keywordflow">throw</span> <a class="code" href="classCCfits_1_1FitsException.html" title="FitsException is the base class for all exceptions thrown by this library.">FitsException</a>(msg,silent); <a name="l00305"></a>00305 } <a name="l00306"></a>00306 } <a name="l00307"></a>00307 <a name="l00308"></a>00308 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00309"></a><a class="code" href="classCCfits_1_1ImageExt.html#ad0531bb4a797027e6ff77517d2e09cc6">00309</a> <span class="keywordtype">void</span> <a class="code" href="classCCfits_1_1ImageExt.html#a1eb7b465140aa151e2f7272c977846cd" title="return the BSCALE keyword value">ImageExt<T>::scale</a> (<span class="keywordtype">double</span> value) <a name="l00310"></a>00310 { <a name="l00311"></a>00311 <a class="code" href="classCCfits_1_1ExtHDU.html#a16730a075858cd50bfa3daad60c0a1c0" title="move the fitsfile pointer to this current HDU.">makeThisCurrent</a>(); <a name="l00312"></a>00312 <span class="keywordflow">if</span> (checkImgDataTypeChange(<a class="code" href="classCCfits_1_1ImageExt.html#a53d36df4ae92f58771a25559120bacb9" title="return the BZERO keyword value">zero</a>(), value)) <a name="l00313"></a>00313 { <a name="l00314"></a>00314 <span class="keywordflow">if</span> (naxis()) <a name="l00315"></a>00315 { <a name="l00316"></a>00316 <span class="keywordtype">int</span> status(0); <a name="l00317"></a>00317 <span class="keywordflow">if</span> (fits_update_key(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(), Tdouble, BSCALE, &value, 0, &status)) <a name="l00318"></a>00318 <span class="keywordflow">throw</span> <a class="code" href="classCCfits_1_1FitsError.html" title="FitsError is the exception thrown by non-zero cfitsio status codes.">FitsError</a>(status); <a name="l00319"></a>00319 fits_flush_file(<a class="code" href="classCCfits_1_1HDU.html#a37bec2db64600e489eb8efa8a001f73d" title="return the fitsfile pointer for the FITS object containing the HDU">fitsPointer</a>(), &status); <a name="l00320"></a>00320 <a class="code" href="classCCfits_1_1ImageExt.html#a1eb7b465140aa151e2f7272c977846cd" title="return the BSCALE keyword value">HDU::scale</a>(value); <a name="l00321"></a>00321 } <a name="l00322"></a>00322 } <a name="l00323"></a>00323 <span class="keywordflow">else</span> <a name="l00324"></a>00324 { <a name="l00325"></a>00325 <span class="keywordtype">bool</span> silent=<span class="keyword">false</span>; <a name="l00326"></a>00326 <span class="keywordtype">string</span> msg(<span class="stringliteral">"CCfits Error: Cannot set BSCALE to a value which will change image data\n"</span>); <a name="l00327"></a>00327 msg += <span class="stringliteral">" from integer type to floating point type."</span>; <a name="l00328"></a>00328 <span class="keywordflow">throw</span> <a class="code" href="classCCfits_1_1FitsException.html" title="FitsException is the base class for all exceptions thrown by this library.">FitsException</a>(msg,silent); <a name="l00329"></a>00329 } <a name="l00330"></a>00330 } <a name="l00331"></a>00331 <a name="l00332"></a>00332 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00333"></a><a class="code" href="classCCfits_1_1ImageExt.html#a53d36df4ae92f58771a25559120bacb9">00333</a> <span class="keywordtype">double</span> <a class="code" href="classCCfits_1_1ImageExt.html#a53d36df4ae92f58771a25559120bacb9" title="return the BZERO keyword value">ImageExt<T>::zero</a> ()<span class="keyword"> const</span> <a name="l00334"></a>00334 <span class="keyword"> </span>{ <a name="l00335"></a>00335 <a name="l00336"></a>00336 <span class="keywordflow">return</span> <a class="code" href="classCCfits_1_1ImageExt.html#a53d36df4ae92f58771a25559120bacb9" title="return the BZERO keyword value">HDU::zero</a>(); <a name="l00337"></a>00337 } <a name="l00338"></a>00338 <a name="l00339"></a>00339 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00340"></a><a class="code" href="classCCfits_1_1ImageExt.html#a1eb7b465140aa151e2f7272c977846cd">00340</a> <span class="keywordtype">double</span> <a class="code" href="classCCfits_1_1ImageExt.html#a1eb7b465140aa151e2f7272c977846cd" title="return the BSCALE keyword value">ImageExt<T>::scale</a> ()<span class="keyword"> const</span> <a name="l00341"></a>00341 <span class="keyword"> </span>{ <a name="l00342"></a>00342 <a name="l00343"></a>00343 <span class="keywordflow">return</span> <a class="code" href="classCCfits_1_1ImageExt.html#a1eb7b465140aa151e2f7272c977846cd" title="return the BSCALE keyword value">HDU::scale</a>(); <a name="l00344"></a>00344 } <a name="l00345"></a>00345 <a name="l00346"></a>00346 <span class="comment">// Additional Declarations</span> <a name="l00347"></a>00347 <span class="keyword">template</span> <<span class="keyword">typename</span> T> <a name="l00348"></a>00348 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classCCfits_1_1ImageExt.html">ImageExt<T>::checkExtensionType</a>()<span class="keyword"> const</span> <a name="l00349"></a>00349 <span class="keyword"> </span>{ <a name="l00350"></a>00350 <a name="l00351"></a>00351 } <a name="l00352"></a>00352 } <span class="comment">// namespace CCfits</span> <a name="l00353"></a>00353 <a name="l00354"></a>00354 <a name="l00355"></a>00355 <span class="preprocessor">#endif</span> </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated on Wed Sep 9 11:59:41 2009 for CCfits by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>