00001
00002
00003 void FITS_tutorial1()
00004 {
00005 printf("\n\n--------------------------------\n");
00006 printf("WELCOME TO FITS tutorial #1 !!!!\n");
00007 printf("--------------------------------\n");
00008 printf("We're gonna open a FITS file that contains only the\n");
00009 printf("primary HDU, consisting on an image.\n");
00010 printf("The object you will see is a snapshot of the NGC7662 nebula,\n");
00011 printf("which was taken by the author on November 2009 in Barcelona (CATALONIA).\n\n");
00012
00013 if (!gROOT->IsBatch()) {
00014
00015 }
00016
00017
00018 TFITSHDU *hdu = new TFITSHDU("sample1.fits");
00019 if (hdu == 0) {
00020 printf("ERROR: could not access the HDU\n"); return;
00021 }
00022 printf("File successfully open!\n");
00023
00024
00025
00026
00027
00028 hdu->Print("F+");
00029
00030 printf("....................................\n");
00031
00032
00033 printf("Exposure time = %s\n", hdu->GetKeywordValue("EXPTIME").Data());
00034
00035
00036
00037
00038
00039
00040 printf("....................................\n");
00041 printf("We can read the image as a matrix of values.\n");
00042 printf("This feature is useful to do image processing, e.g:\n");
00043 printf("histogram equalization, custom filtering, ...\n");
00044
00045
00046 TMatrixD *mat = hdu->ReadAsMatrix(0);
00047 mat->Print();
00048 delete mat;
00049
00050
00051
00052 printf("....................................\n");
00053 printf("Now the primary array will be read both as an image and as a histogram,\n");
00054 printf("and they will be shown in a canvas.\n");
00055
00056
00057 TASImage *im = hdu->ReadAsImage(0);
00058
00059
00060
00061
00062 TH1 *hist = hdu->ReadAsHistogram();
00063
00064
00065 TCanvas *c = new TCanvas("c1", "FITS tutorial #1", 800, 300);
00066 c->Divide(2,1);
00067 c->cd(1);
00068 im->Draw();
00069 c->cd(2);
00070 hist->Draw("COL");
00071
00072
00073 delete hdu;
00074 }
00075
00076