Logo coherent WaveBurst  
Library Reference Guide
Logo
DrawSmoothFits.C
Go to the documentation of this file.
1 //
2 // this example show how to applies filters to the healpix skymap
3 // Author : Gabriele Vedovato
4 // fitsName = fits file name
5 
6 
7 //#define SMOOTHING 0.4 // gaussian filter with radius = 0.4 degrees
8 //#define MEDIAN 0.4 // median filter with radius = 0.4 degrees
9 //#define ALMS // setting cuts using spherical harmonic coefficients
10 
11 #define NLMAX 256 // l max of spherical harmonic coefficients
12 #define NLMAX_THR 256 // l threshold of spherical harmonic coefficients
13 
14 #define GETSKYAREA // compute the sky area error from probability.fits skymap
15 
16 #define TH_INJ (90-30) // theta source direction
17 #define PH_INJ 60 // phy source direction
18 
19 void DrawSmoothFits(TString fitsName) {
20 
21  #include <complex>
22 
23  skymap sm(const_cast<char*>(fitsName.Data()));
24 #ifdef SMOOTHING
25  int nlmax = 256;
26  int num_iter = 0;
27  double fwhm = SMOOTHING; // degrees
28  sm.smoothing(fwhm, nlmax, num_iter);
29 #endif
30 #ifdef MEDIAN
31  double radius = MEDIAN; // degrees
32  sm.median(radius);
33 #endif
34 #ifdef ALMS
35  int order = sm.getOrder();
36  // get number of rings
37  int rings=1;
38  for(int i=0;i<=order;i++) rings=2*rings+1;
39  cout << "rings " << rings << endl;
40  if(NLMAX>(rings+1)/2) {
41  cout << "Error : helpix resolution is " << order
42  << " number of rings " << rings << endl;
43  cout << " NLMAX=" << NLMAX << " must be <= (rings+1)/2=" << (rings+1)/2 << endl;
44  exit(1);
45  }
46  // set alm=0 for l>NLMAX_THR
47  wat::Alm alm = sm.getAlm(NLMAX);
48  for(int l=0;l<=alm.Lmax();l++) {
49  int limit = TMath::Min(l,alm.Mmax());
50  for (int m=0; m<=limit; m++) if(l>NLMAX_THR) alm(l,m)=0;
51  //for (int m=0; m<=limit; m++) cout << alm(l,m).real() << " " << alm(l,m).imag() << endl;
52  }
53  sm.setAlm(alm);
54 #endif
55 
56  gskymap* gsm = new gskymap(sm);
57  gsm->Draw();
58 
59  int L = sm.size();
60 
61  double ds = 4*TMath::Pi()*(180.*180./(TMath::Pi()*TMath::Pi()))/L;
62 
63  cout << "L = " << L << endl;
64  cout << "sqrt(ds) = " << sqrt(ds) << endl;
65 
66 #ifdef GETSKYAREA
67 
68  double th_inj = TH_INJ;
69  double ph_inj = PH_INJ;
70 
71  int l_inj = sm.getSkyIndex(th_inj, ph_inj);
72 
73  int* index = new int[L];
74  double* prob = new double[L];
75  for(int l=0; l<L; l++) prob[l] = sm.get(l);
76  TMath::Sort(L, prob, index, true);
77 
78  int l_max=0;
79  double vol = 0.;
80  for(int l=0; l<L; l++) {
81  vol += ds;
82  if(l<20) cout << l << " " << index[l] << " " << prob[index[l]] << endl;
83  if(index[l] == l_inj) {l_max=l;break;}
84  }
85  double eA = sqrt(vol);
86  cout << "eA = " << eA << " l_inj " << l_inj << " l_max " << l_max << endl;
87 
88 #endif
89 
90  // find max
91  double max=-100;
92  int imax=0;
93  for(int l=0;l<L;l++) if(sm.get(l)>max) {max=sm.get(l);imax=l;}
94  double th = sm.getTheta(imax);
95  double ph = sm.getPhi(imax);
96  CwbToGeographic(ph,th,ph,th);
97  gsm->DrawMarker(ph,th, 29, 2.0, kBlack);
98 
99  th_inj = TH_INJ;
100  ph_inj = PH_INJ;
101  CwbToGeographic(ph_inj,th_inj,ph_inj,th_inj);
102  gsm->DrawMarker(ph_inj,th_inj, 29, 2.0, kWhite);
103 
104 }
int Mmax() const
Returns the maximum m.
Definition: alm.hh:72
TString("c")
#define NLMAX_THR
void DrawMarker(double phi, double theta, int marker, Size_t msize=1, Color_t tcolor=1)
Definition: gskymap.cc:742
TH2F * ph
double getTheta(size_t i)
Definition: skymap.hh:224
void Draw(int dpaletteId=1, Option_t *option="colfz")
Definition: gskymap.cc:460
int m
Definition: cwb_net.C:28
i drho i
void DrawSmoothFits(TString fitsName)
#define NLMAX
size_t getSkyIndex(double th, double ph)
param: theta param: phi
Definition: skymap.cc:720
#define TH_INJ
int Lmax() const
Returns the maximum l.
Definition: alm.hh:70
double Pi
int getOrder()
Definition: skymap.hh:314
int l
Definition: skymap.hh:63
Definition: alm.hh:193
double getPhi(size_t i)
Definition: skymap.hh:164
#define PH_INJ
wavearray< int > index
void CwbToGeographic(double ilongitude, double ilatitude, double &olongitude, double &olatitude)
Definition: skycoord.hh:414
double get(size_t i)
param: sky index
Definition: skymap.cc:699
size_t size()
Definition: skymap.hh:136
exit(0)