Display fits files with AstroRoot

Hello,

I am using a macro called image_display1() to transform fits files in AstroImages. I downloaded the macro from the AstroRoot homepage
My question is how to decide myself the palette scale in order to be able to plot the image over more orders of magnitude. I attached a plot called example.eps. What I would like to do is to plot this image over values ranging between 0.01 and 4.5.
Cheers,

Sabrina

image_display1()
{
// create an astronomical image display directly from a FITS file
// and display it.

// The image we want to display is the third HDU in the file
// image.fits.
AstroImage * disp = new AstroImage(“image.fits”, NULL, 3);

// read a color palette, it was written to the file via the
// color editor (Save button)
TFile *fpal = new TFile(“image.pal.root”, “READ”);
TImagePalette palette = (TImagePalette)fpal->Get(“TImagePalette”);
delete fpal;

// use the palette for this image
disp->SetPalette(palette);
delete palette;

// draw the image and open its palette editor
disp->Draw();
disp->StartPaletteEditor();
}

I think the attachment did not work.

Thanks a lot. I attached the plot again. Eps files are not allowed.
Sabrina


May be you can do as in: $ROOTSYS/ tutorials/image/hist2image.C
using img->StartPaletteEditor();

Thanks a lot for the reply.

I have already used the img->StartPaletteEditor() but I cannot change the range. Probably I am overlooking something very easy.

Sabrina

[quote=“couet”]May be you can do as in: $ROOTSYS/ tutorials/image/hist2image.C
using img->StartPaletteEditor();[/quote]

I do not know a lot about AstroImage but if you look at the example I mentioned before, the axis value along the palette axis come directly from the original histogram content. So I guess that’s the same in your case. May be I am missing something.

That’s right. It is the same in my case.

S

Hi Sabrina,
it’s not clear for me.
Do you want to set palette range programically
(not via palette editor)?

Regards. Valeriy

Yes. That’s right.
Cheers,
Sabrina

[quote=“Valeriy Onuchin”]Hi Sabrina,
it’s not clear for me.
Do you want to set palette range programically
(not via palette editor)?

Regards. Valeriy[/quote]

Check how it is done here
root.cern.ch/root/html/src/TASPa … tml#aAwNfE
you can create a new palette or modify existent

Regards. Valeriy

Many thanks. I tried to look for this, but I could not find it.
Cheers,

Sabrina

[quote=“Valeriy Onuchin”]Check how it is done here
root.cern.ch/root/html/src/TASPa … tml#aAwNfE
you can create a new palette or modify existent

Regards. Valeriy[/quote]

Hello Valeriy,

sorry for disturbing you again. I tried to create the new palette range, but I failed, mostly due to my ignorance of Root. Unfortunately I still code mostly in fortran77 and fortran90. Could you tell me where I can find an example of how to insert such a procedure like
TASPaletteEditor::UpdateRange() within the astro_image package ?
Cheers,

Sabrina

[quote=“Valeriy Onuchin”]Check how it is done here
root.cern.ch/root/html/src/TASPa … tml#aAwNfE
you can create a new palette or modify existent

Regards. Valeriy[/quote]

Hello,

what I would like to do with the astroImage class is something similar to what the hist class can do. I understand that the AstroImage class and hist class are different, but it would be be good to have for instance the possibility to have a log z axis, and at the same time the coordinate system facilities which AstroImage has. For instance it seems to me that AstroImage does not allow any log z axis. To give you an example of what I would like to do with AstroImage I copy and paste here a short code which I wrote to plot a fits file with the hist class. Thanks a lot !
Sabrina


#include “Riostream.h”
#include “TROOT.h”
#include “TPaletteAxis.h”
#include “TVirtualPad.h”
#include “TStyle.h”
#include “TMath.h”
#include “TView.h”
#include “TH1.h”
#include “TGaxis.h”

image_pion_decay_conv()
{
// read a FITS image, convert it into a
// ROOT histogram and display it

const Int_t NRGBs = 5;
const Int_t NCont = 255;

Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs]   = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs]  = { 0.51, 1.00, 0.12, 0.00, 0.00 };
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
gStyle->SetNumberContours(NCont);

TFFloatImg * img =TFReadImage(“cosmicInjectorCONT10000yrGamma2PSFCTA.fits”,"", (UInt_t)1);
UInt_t begin[2] = {0,0};
UInt_t end[2] = {149,149};
img->MakeSubSection(begin, end);

TH2D *hist = img->MakeHisto();

int iold,jold;
TH2D *hist2 = new
TH2D(“hist2”,“pion_decay_conv”,150,340.06667,350,150,-5,4.93333);
for (int j=1; j<=hist->GetNbinsY(); j++) {
for (int i=1; i<=hist->GetNbinsX(); i++) {
hist2->SetBinContent(i,j,hist->GetBinContent(i,j));
}
}

TCanvas * win = new TCanvas();
win->SetLogz(1);

//   gStyle->SetPalette(0);

double zMin(1.e-9), zMax(1.e-2);
hist2->GetZaxis()->SetRangeUser(zMin, zMax);

hist2->SetXTitle(“Galactic Longitude (deg)”);
hist2->SetYTitle(“Galactic Latitude (deg)”);
hist2->SetStats(0);
hist2->SetContour(99);
hist2->Draw(“colz”);
hist2->Write();
f1->Close();

TPaletteAxis palette = (TPaletteAxis)hist2->GetListOfFunctions()->FindObject(“palette”);
palette->SetLabelColor(0);
palette->SetLineColor(0);
palette->SetX1NDC(0.83);
palette->SetX2NDC(0.86);
palette->SetY1NDC(0.33);
palette->SetY2NDC(0.83);
palette->SetTitleSize(0.035);
palette->SetLabelSize(0.035);
palette->SetTitleOffset(1.5);
palette->SetTitle(“Gamma Spectrum”);

}

[quote=“Valeriy Onuchin”]Check how it is done here
root.cern.ch/root/html/src/TASPa … tml#aAwNfE
you can create a new palette or modify existent

Regards. Valeriy[/quote][/quote]