Changes between Version 9 and Version 10 of InstallingHealpixForMars


Ignore:
Timestamp:
10/04/19 19:15:07 (5 years ago)
Author:
tbretz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • InstallingHealpixForMars

    v9 v10  
    2525}}}
    2626
    27 An example of reading and writing is available in !RootHealPix/tutorials/[ReadAndWrite.C].
     27The following example onreading and writing is adapted from !RootHealPix/tutorials/ReadAndWrite.C.
     28
     29{{{!#Spoiler
     30{{{!#c++
     31void ReadAndWrite()
     32{
     33  THealPixD hpd1("hpd1", "data1", 5);
     34  THealPixD hpd2("hpd2", "data2", 4);
     35  hpd1.SetUnit("MeV"); // Set the unit of entries
     36  hpd2.SetUnit("GeV");
     37  hpd1.SetDegree(); // change the unit of Fill(theta, phi)
     38  hpd2.SetDegree();
     39
     40  for(Int_t i = 0; i<1800; i++)
     41  {
     42     for(Int_t j = 0; j<3600; j++)
     43     {
     44        hpd1.Fill(i/10., j/10., 1);
     45        hpd2.Fill(i/10., j/10., 5);
     46     }
     47  }
     48
     49  std::vector<THealPix*> vec;
     50  vec.push_back(&hpd1);
     51  vec.push_back(&hpd2);
     52
     53  THealUtil::SaveToFits("!test.fits", vec); // hpd1/2 are saved in one file
     54
     55  // Read only "data2" from FITS file
     56  THealPixD* hpd = THealPixD::ReadFits("test.fits", "data2");
     57
     58  std::cout << "Order: " << hpd->GetOrder() << std::endl;
     59  std::cout << "Nside: " << hpd->GetNside() << std::endl;
     60  std::cout << "Npix : " << hpd->GetNpix()  << std::endl;
     61  std::cout << "Unit : " << hpd->GetUnit()  << std::endl;
     62  std::cout << "Title: " << hpd->GetTitle() << std::endl;
     63}
     64}}}
     65}}}
    2866
    2967The documentation is not very complete, but you can find it here: