2 #include "TPaletteAxis.h"
6 isLogz(false),
title(
"") {
13 if(ztype.CompareTo(
"amplitude")==0) iztype=1;
14 if(ztype.CompareTo(
"energy")==0) iztype=2;
15 if(iztype==0) {cout <<
"CWB::STFT::STFT: Error wrong ztype (amplitude/energy)" << endl;
exit(1);}
17 if (nfft<=0) {cout <<
"CWB::STFT::STFT: Error nfft must be positive" << endl;
exit(1);}
18 if (noverlap<=0||noverlap>=nfft) {cout <<
"CWB::STFT::STFT: Error noverlap must be > 0 & < nfft" << endl;
exit(1);}
19 if (x.
rate()<=0) {cout <<
"CWB::STFT::STFT: Error sample rate must be > 0" << endl;
exit(1);}
20 if (x.
start()<0) {cout <<
"CWB::STFT::STFT: Error start time must be positive" << endl;
exit(1);}
21 if (
int(x.
size())<nfft) {cout <<
"CWB::STFT::STFT: Error size must be > nfft " << endl;
exit(1);}
32 double df=(double)x.
rate()/(double)(nfft);
36 int N=
int(nfft/nshift);
48 double norm=sqrt(x.
rate());
49 for (
int n=0;
n<N*loops;
n++) {
51 if(shift+nfft>
int(x.
size()))
break;
55 double time = (shift+nfft/2)*dt;
57 double psd=sqrt(pow(y.data[
i],2)+pow(y.data[
i+1],2))*sqrt(1/df);
60 if(iztype==2) psd*=
psd;
61 h2->SetBinContent(
int(nT*time/(Tmax-x.
start())),
int(nF*frequency/Fmax),
psd);
70 if(h2!=NULL)
delete h2;
72 if(window!=NULL)
delete [] window;
77 int dpaletteId, Option_t* goption) {
83 canvas =
new TCanvas(
name,
"LVC experiment", 300,40, 800, 600);
85 canvas->ToggleEventStatus();
89 canvas->SetFillColor(kWhite);
90 canvas->SetRightMargin(0.10);
91 canvas->SetLeftMargin(0.10);
92 canvas->SetBottomMargin(0.13);
98 gStyle->SetFrameBorderMode(0);
101 gStyle->SetTitleH(0.050);
102 gStyle->SetTitleW(0.95);
103 gStyle->SetTitleY(0.98);
104 gStyle->SetTitleFont(12,
"D");
105 gStyle->SetTitleColor(kBlue,
"D");
106 gStyle->SetTextFont(12);
107 gStyle->SetTitleFillColor(kWhite);
108 gStyle->SetLineColor(kWhite);
109 gStyle->SetNumberContours(256);
112 gStyle->SetCanvasColor(kWhite);
113 gStyle->SetStatBorderSize(1);
117 SetPlotStyle(paletteId);
119 gStyle->SetPalette(1,0);
123 SetPlotStyle(dpaletteId);
125 gStyle->SetPalette(1,0);
132 h2->SetStats(kFALSE);
133 h2->SetTitleFont(12);
135 h2->SetFillColor(kWhite);
137 h2->GetXaxis()->SetNdivisions(506);
138 h2->GetXaxis()->SetLabelFont(42);
139 h2->GetXaxis()->SetLabelOffset(0.014);
140 h2->GetXaxis()->SetTitleOffset(1.4);
141 h2->GetYaxis()->SetTitleOffset(1.2);
142 h2->GetYaxis()->SetNdivisions(506);
143 h2->GetYaxis()->SetLabelFont(42);
144 h2->GetYaxis()->SetLabelOffset(0.01);
145 h2->GetZaxis()->SetLabelFont(42);
146 h2->GetZaxis()->SetNoExponent(
false);
147 h2->GetZaxis()->SetNdivisions(506);
149 h2->GetXaxis()->SetTitleFont(42);
150 h2->GetXaxis()->SetTitle(
"Time (sec)");
151 h2->GetXaxis()->CenterTitle(
true);
153 h2->GetYaxis()->SetTitleFont(42);
154 h2->GetYaxis()->SetTitle(
"Frequency (Hz)");
155 h2->GetYaxis()->CenterTitle(
true);
160 h2->GetZaxis()->SetTitleOffset(0.6);
161 h2->GetZaxis()->SetTitleFont(42);
163 h2->GetZaxis()->CenterTitle(
true);
165 h2->GetXaxis()->SetLabelSize(0.03);
166 h2->GetYaxis()->SetLabelSize(0.03);
167 h2->GetZaxis()->SetLabelSize(0.03);
169 if(
title.Sizeof()==1) {
171 sprintf(stitle,
"Spectrogram (Normalized tile %s)",ztype.Data());
172 h2->SetTitle(stitle);
174 double dt=h2->GetXaxis()->GetBinWidth(0);
175 double df=h2->GetYaxis()->GetBinWidth(0);
178 int nt2=h2->GetNbinsX();
180 int nf2=h2->GetNbinsY();
182 if(t2>t1) nt1=
int((t1-h2->GetXaxis()->GetXmin())/dt);
183 if(t2>t1) nt2=
int((t2-h2->GetXaxis()->GetXmin())/dt);
184 if(f2>f1) nf1=
int(f1/df);
185 if(f2>f1) nf2=
int(f2/df);
188 for (
int i=nt1;
i<nt2;
i++) {
189 for (
int j=nf1;
j<nf2;
j++) {
190 double binc=h2->GetBinContent(
i,
j);
191 if(binc>h2max) h2max=binc;
195 h2->GetZaxis()->SetRangeUser(0,h2max);
197 if(t2>t1) h2->GetXaxis()->SetRangeUser(t1,t2);
198 if(f2>f1) h2->GetYaxis()->SetRangeUser(f1,f2);
199 if(z2>z1) h2->GetZaxis()->SetRangeUser(z1,z2);
205 TPaletteAxis *
palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject(
"palette");
206 palette->SetX1NDC(0.91);
207 palette->SetX2NDC(0.933);
208 palette->SetTitleOffset(0.92);
209 palette->GetAxis()->SetTickSize(0.01);
220 const Int_t
NRGBs = 5;
221 const Int_t
NCont = 255;
223 if (
fabs(paletteId)==1) {
224 Double_t
stops[
NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
225 Double_t
red[
NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
226 Double_t
green[
NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
227 Double_t
blue[
NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
229 TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
231 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
234 if (
fabs(paletteId)==2) {
235 Double_t
stops[
NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
236 Double_t
red[
NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
238 Double_t
green[
NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
240 Double_t
blue[
NRGBs] = { 1.00, 1.00, 0.00, 0.00, 0.00 };
242 TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
244 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
247 if (
fabs(paletteId)==3) {
248 Double_t
stops[
NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
249 Double_t
red[
NRGBs] = { 0.00, 0.09, 0.18, 0.09, 0.00 };
250 Double_t
green[
NRGBs] = { 0.01, 0.02, 0.39, 0.68, 0.97 };
251 Double_t
blue[
NRGBs] = { 0.17, 0.39, 0.62, 0.79, 0.97 };
253 TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
255 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
258 if (
fabs(paletteId)==4) {
259 Double_t
stops[
NRGBs] = { 0.00, 0.50, 0.75, 0.875, 1.00 };
260 Double_t
red[
NRGBs] = { 1.00, 1.00, 1.00, 1.00, 1.00 };
261 Double_t
green[
NRGBs] = { 1.00, 0.75, 0.50, 0.25, 0.00 };
262 Double_t
blue[
NRGBs] = { 0.00, 0.00, 0.00, 0.00, 0.00 };
264 TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
266 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
269 if (
fabs(paletteId)==5) {
270 Double_t
stops[
NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
271 Double_t
red[
NRGBs] = { 1.00, 0.84, 0.61, 0.34, 0.00 };
272 Double_t
green[
NRGBs] = { 1.00, 0.84, 0.61, 0.34, 0.00 };
273 Double_t
blue[
NRGBs] = { 1.00, 0.84, 0.61, 0.34, 0.00 };
275 TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
277 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
280 if (
fabs(paletteId)==57) {
281 Double_t
stops[9] = { 0., 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0};
282 Double_t
red[9] = { 0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764};
283 Double_t
green[9] = { 0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832};
284 Double_t
blue[9] = { 0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539};
286 TColor::CreateGradientColorTable(9, stops, blue, green, red, NCont);
288 TColor::CreateGradientColorTable(9, stops, red, green, blue, NCont);
291 gStyle->SetNumberContours(NCont);
virtual size_t size() const
virtual void rate(double r)
void Print(TString pname)
cout<< "skymap size : "<< L<< endl;for(int l=0;l< L;l++) sm.set(l, l);sm > const_cast< char * >("skymap.dat")
cout<< endl;cout<< "ts size = "<< ts.size()<< " ts rate = "<< ts.rate()<< endl;tf.Forward(ts, wdm);int levels=tf.getLevel();cout<< "tf size = "<< tf.size()<< endl;double dF=tf.resolution();double dT=1./(2 *dF);cout<< "rate(hz) : "<< RATE<< "\t layers : "<< nLAYERS<< "\t dF(hz) : "<< dF<< "\t dT(ms) : "<< dT *1000.<< endl;int itime=TIME_PIXEL_INDEX;int ifreq=FREQ_PIXEL_INDEX;int index=(levels+1)*itime+ifreq;double time=itime *dT;double freq=(ifreq >0)?ifreq *dF:dF/4;cout<< endl;cout<< "PIXEL TIME = "<< time<< " sec "<< endl;cout<< "PIXEL FREQ = "<< freq<< " Hz "<< endl;cout<< endl;wavearray< double > x
wavearray< double > psd(33)
virtual void start(double s)
double GetValue(unsigned i)
void Draw(double t1=0.0, double t2=0.0, double f1=0.0, double f2=0.0, double z1=0.0, double z2=0.0, int dpaletteId=DUMMY_PALETTE_ID, Option_t *option="colfz")
void SetPlotStyle(int paletteId=1)
double fabs(const Complex &x)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
STFT(wavearray< double > x, int nfft, int noverlap, TString ztype="amplitude", TString fwindow="hann", double fparam=0.0, TString name="stft")