Main Page   Compound List   File List   Compound Members   File Members  

fits_read_header.c

Go to the documentation of this file.
00001 
00028 #include <string.h>
00029 #include <stdio.h>
00030 #include <fitsio.h>
00031 #include <malloc.h>
00032 
00033 #include "mex.h"
00034 #include "matrix.h"
00035 #include "mfitsio.h"
00036 
00047 void
00048 mexFunction (int nlhs, mxArray * plhs[], int nrhs, const mxArray * prhs[])
00049 {
00050   int buflen, status;
00051   char *filename;
00052   mfitsio_header *header;
00053 
00054   /* Check proper input and output */
00055   if (nrhs != 1)
00056     mexErrMsgTxt ("One input required.");
00057   else if (nlhs > 1)
00058     mexErrMsgTxt ("Too many output arguments.");
00059   else if (!mxIsChar (prhs[0]))
00060     mexErrMsgTxt ("Input must be a string (filename).");
00061 
00062   if (mxGetM (prhs[0]) != 1)
00063     mexErrMsgTxt ("Input must be a row vector string (filename).");
00064 
00065   buflen = (mxGetM (prhs[0]) * mxGetN (prhs[0])) + 1;
00066 
00067   filename = mxCalloc (buflen, sizeof (char));
00068   status = mxGetString (prhs[0], filename, buflen);
00069 
00070   header = mfitsio_read_header (filename);
00071   if (header != 0)
00072   {
00073     plhs[0] = mfitsio_adapt_fheader (header);
00074     mfitsio_free_header (header);
00075   }
00076   else
00077   {
00078     mexErrMsgTxt ("Unable to open FITS file.");
00079   }
00080 
00081   return;
00082 }


Operated by University of California for the National Nuclear Security Administration of the US Department of Energy. Copyright © 2002-2003 UC | Disclaimer/Privacy
This website has been approved for unlimited release with associated LA-UR number LA-UR-03-0949.