https://casaguides.nrao.edu/index.php?title=FITStoImage&feed=atom&action=historyFITStoImage - Revision history2024-03-29T02:15:05ZRevision history for this page on the wikiMediaWiki 1.38.6https://casaguides.nrao.edu/index.php?title=FITStoImage&diff=15422&oldid=prevAginsburg: Created a page describing FITS->Image conversion. It's a start, and feedback is welcome... feel free to tell me this is unacceptable, even.2013-12-18T14:36:55Z<p>Created a page describing FITS->Image conversion. It's a start, and feedback is welcome... feel free to tell me this is unacceptable, even.</p>
<p><b>New page</b></p><div>= Converting a FITS cube to a CASA Image =<br />
<br />
If you want to perform analysis on a FITS file in CASA, you first need to import it into `.image` format.<br />
<br />
<code>importfits('file.fits','file.image')</code><br />
<br />
If this works, great! You can move on. CASA will treat NaN values in an image as 'masked'.<br />
<br />
= Dealing with Errors =<br />
<br />
There may be issues with FITS headers. CASA respects a large number of header keys ([http://www.eso.org/projects/alma/arc/tw/pub/External/EUARCCASATutorialJan2012/ImageAnalysis-CASA.pdf reference]).<br />
<br />
There are many ways to edit a FITS header. One of the most straightforward to use is [http://tdc-www.harvard.edu/wcstools/edhead.html edhead]. Otherwise, one can use CASA's [http://casaguides.nrao.edu/index.php?title=Imhead imhead]<br />
<br />
<br />
<table border="1" class="docutils"><br />
<br />
<tr><td>CASA Keyword</td><br />
<td>FITS keyword</td><br />
<td>Description</td><br />
</tr><br />
<tr><td>beammaj</td><br />
<td>BMAJ</td><br />
<td>Major&nbsp;axis&nbsp;of&nbsp;the&nbsp;clean&nbsp;beam</td><br />
</tr><br />
<tr><td>beammin</td><br />
<td>BMIN</td><br />
<td>Minor&nbsp;axis&nbsp;of&nbsp;the&nbsp;clean&nbsp;beam</td><br />
</tr><br />
<tr><td>beampa</td><br />
<td>BPA</td><br />
<td>Position&nbsp;angle&nbsp;of&nbsp;the&nbsp;clean&nbsp;beam</td><br />
</tr><br />
<tr><td>bunit</td><br />
<td>BUNIT</td><br />
<td>Brightness&nbsp;unit&nbsp;(K,&nbsp;Jy/beam,&nbsp;etc)</td><br />
</tr><br />
<tr><td>cdeltn</td><br />
<td>CDELTn</td><br />
<td>Pixel&nbsp;size,&nbsp;nth&nbsp;axis&nbsp;&nbsp;(max&nbsp;n&nbsp;is&nbsp;4)</td><br />
</tr><br />
<tr><td>crpixn</td><br />
<td>CRPIXn</td><br />
<td>Pixel&nbsp;coordinate&nbsp;of&nbsp;reference&nbsp;point,&nbsp;nth&nbsp;axis</td><br />
</tr><br />
<tr><td>crvaln</td><br />
<td>CRVALn</td><br />
<td>Pixel&nbsp;location&nbsp;of&nbsp;reference&nbsp;point,&nbsp;nth&nbsp;axis</td><br />
</tr><br />
<tr><td>ctypen</td><br />
<td>CTYPEn</td><br />
<td>Axis&nbsp;name,&nbsp;nth&nbsp;axis. For FITS, this includes the projection</td><br />
</tr><br />
<tr><td>cunitn</td><br />
<td>CUNITn</td><br />
<td>Pixel&nbsp;units,&nbsp;nth&nbsp;axis</td><br />
</tr><br />
<tr><td>datamax</td><br />
<td>DATAMAX</td><br />
<td>Maximum&nbsp;pixel&nbsp;value&nbsp;in&nbsp;image</td><br />
</tr><br />
<tr><td>datamin</td><br />
<td>DATAMIN</td><br />
<td>Minimum&nbsp;pixel&nbsp;value&nbsp;in&nbsp;image</td><br />
</tr><br />
<tr><td>date-obs</td><br />
<td>DATE-OBS</td><br />
<td>Date&nbsp;of&nbsp;the&nbsp;observation</td><br />
</tr><br />
<tr><td>equinox</td><br />
<td>EQUINOX</td><br />
<td>Reference&nbsp;frame&nbsp;for&nbsp;directional&nbsp;coordinates</td><br />
</tr><br />
<tr><td>imtype</td><br />
<td><ul class="first last simple"><br />
<li></li><br />
</ul><br />
</td><br />
<td>Image&nbsp;type:&nbsp;intensity,</td><br />
</tr><br />
<tr><td>minpos</td><br />
<td><ul class="first last simple"><br />
<li></li><br />
</ul><br />
</td><br />
<td>Position&nbsp;of&nbsp;the&nbsp;minimum&nbsp;value&nbsp;(world&nbsp;unit)</td><br />
</tr><br />
<tr><td>minpixpos</td><br />
<td><ul class="first last simple"><br />
<li></li><br />
</ul><br />
</td><br />
<td>Same&nbsp;in&nbsp;pixel&nbsp;(array)</td><br />
</tr><br />
<tr><td>maxpos</td><br />
<td><ul class="first last simple"><br />
<li></li><br />
</ul><br />
</td><br />
<td>Position&nbsp;of&nbsp;the&nbsp;maximum&nbsp;value&nbsp;(world&nbsp;unit)</td><br />
</tr><br />
<tr><td>maxpixpos</td><br />
<td><ul class="first last simple"><br />
<li></li><br />
</ul><br />
</td><br />
<td>Same&nbsp;in&nbsp;pixel&nbsp;(array)</td><br />
</tr><br />
<tr><td>object</td><br />
<td>OBJECT</td><br />
<td>Source&nbsp;name</td><br />
</tr><br />
<tr><td>observer</td><br />
<td>OBSERVER</td><br />
<td>Observer&nbsp;name</td><br />
</tr><br />
<tr><td>projection</td><br />
<td>CTYPEn</td><br />
<td>Image&nbsp;projection&nbsp;('SIN','TAN',&nbsp;or&nbsp;'ZEA')</td><br />
</tr><br />
<tr><td>reffreqtype</td><br />
<td><ul class="first last simple"><br />
<li></li><br />
</ul><br />
</td><br />
<td>Reference&nbsp;frame&nbsp;for&nbsp;the&nbsp;spectral&nbsp;coordinates</td><br />
</tr><br />
<tr><td>restfreq</td><br />
<td>RESTFREQ</td><br />
<td>Rest&nbsp;Frequency</td><br />
</tr><br />
<tr><td>shape</td><br />
<td>NAXISn</td><br />
<td>Number&nbsp;of&nbsp;pixels&nbsp;along&nbsp;each&nbsp;axis</td><br />
</tr><br />
<tr><td>telescope</td><br />
<td>TELESCOP</td><br />
<td>Telescope&nbsp;name</td><br />
</tr><br />
</table><br />
<br />
<br />
<br />
What does it mean if you get this sort of error?<br />
<br />
<code><br />
CASA <1>: importfits('file.fits','file.image') <br />
2013-12-18 13:06:18 WARN importfits::FITSCoordinateUtil::fromFITSHeader The wcs function failures are too severe to continue ... <br />
2013-12-18 13:06:18 WARN importfits::ImageFITSConverterImpl::FITSToImage (file /var/rpmbuild/BUILD/casapy-stable/casapy-stable-42.0.26945/casacore/images/Images/ImageFITSConverter.tcc, line 71) No proper coordinate system defined in FITS file. Using dummy linear system instead.<br />
</code><br />
<br />
First, go to the `casapy-yyyymmdd-hhmmss.log` file and look at the errors.<br />
<br />
<code><br />
2013-12-18 13:06:18 INFO importfits::FITSCoordinateUtil::fromFITSHeader celfix incurred the error Inconsistent or unrecognized coordinate axis types <br />
2013-12-18 13:06:18 INFO importfits::FITSCoordinateUtil::fromFITSHeader spcfix incurred the error Inconsistent or unrecognized coordinate axis types <br />
2013-12-18 13:06:18 INFO importfits::FITSCoordinateUtil::fromFITSHeader cylfix incurred the error Inconsistent or unrecognized coordinate axis types<br />
</code><br />
<br />
In my case, the error turned out to be that `CTYPE3` was set to `RADI-LSR`, while it should be `VELO-LSR` to be recognized by the CASA system. The velocity convention is, unfortunately, lost.</div>Aginsburg