FITS_tutorial2.C

Go to the documentation of this file.
00001 // Open a FITS file whose primary array represents
00002 // a spectrum (flux vs wavelength)
00003 void FITS_tutorial2()
00004 {
00005    printf("\n\n--------------------------------\n");
00006    printf("WELCOME TO FITS tutorial #2 !!!!\n");
00007    printf("--------------------------------\n");
00008    printf("We're gonna open a FITS file that contains the\n");
00009    printf("primary HDU and a little data table.\n");
00010    printf("The primary HDU is an array of 2 rows by 2040 columns, and\n");
00011    printf("they represent a radiation spectrum. The first row contains\n");
00012    printf("the flux data, whereas the second row the wavelengths.\n");
00013    printf("Data copyright: NASA\n\n");
00014    
00015    if (!gROOT->IsBatch()) {
00016       //printf("Press ENTER to start..."); getchar();
00017    }
00018 
00019    // Open primary HDU from file
00020    TFITSHDU *hdu = new TFITSHDU("sample2.fits");
00021    if (hdu == 0) {
00022       printf("ERROR: could not access the HDU\n"); return;
00023    }
00024    printf("File successfully open!\n");
00025    
00026    
00027    // Dump the HDUs within the FITS file
00028    // and also their metadata
00029    //printf("Press ENTER to see summary of all data stored in the file:"); getchar();
00030    hdu->Print("F+");
00031    
00032    printf("....................................\n");
00033    printf("We are going to generate a TGraph from vectors\n");
00034    //printf("within the primary array. Press ENTER to continue.."); getchar();
00035    
00036    TVectorD *Y = hdu->GetArrayRow(0);
00037    TVectorD *X = hdu->GetArrayRow(1);
00038    TGraph *gr = new TGraph(*X,*Y);
00039       
00040    // Show the graphic
00041    TCanvas *c = new TCanvas("c1", "FITS tutorial #2", 800, 800);
00042    gr->Draw("BA");
00043    
00044          
00045    // Clean up
00046    delete X;
00047    delete Y;
00048    delete hdu;
00049 }
00050 
00051  

Generated on Tue Jul 5 15:44:11 2011 for ROOT_528-00b_version by  doxygen 1.5.1