Skip to content

Instantly share code, notes, and snippets.

@astrofrog
Created February 19, 2011 15:34
Show Gist options
  • Select an option

  • Save astrofrog/835125 to your computer and use it in GitHub Desktop.

Select an option

Save astrofrog/835125 to your computer and use it in GitHub Desktop.
Read FITS table using CCFits
#include <CCfits>
int main()
{
CCfits::FITS::setVerboseMode(true);
try
{
// Open file for reading
std::auto_ptr<CCfits::FITS> input_file(new CCfits::FITS("moon.fits",CCfits::Read));
// Create pointer to extension
CCfits::ExtHDU& ephemeris = input_file->extension("EPHEMERIS");
// Declare arrays that will hold values
std::valarray<double> jd;
// Read rows
CCfits::Column& column = ephemeris.column("jd");
column.read(jd, 1, column.rows());
// Print out the first value to check
std::cout << jd[0] << std::endl;
}
catch (CCfits::FitsException&)
{
std::cerr << " Fits Exception Thrown by test function \n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment