29 template<class DataType_t>
32 if(wextern) this->data = NULL;
35 if(pts!=NULL)
delete pts;
39 template<
class DataType_t>
44 template<
class DataType_t>
52 this->Size = w->
size();
53 this->Start = w->
start();
59 template<
class DataType_t>
70 template<
class DataType_t>
81 return Draw(NULL,type,options,color);
85 template<
class DataType_t>
97 if(type==
GWAT_TIME) DrawTime(x,options,color);
98 if(type==
GWAT_FFT) DrawFFT(x,options,color);
99 if(type==
GWAT_TF) DrawTF(x,options);
100 if(type==
GWAT_SG) cout <<
"gwavearray<DataType_t>::Draw - Error : draw type "
101 <<
"GWAT_SG" <<
" not allowed" << endl;
105 template<
class DataType_t>
117 return DrawTime(NULL,options,color);
121 template<
class DataType_t>
134 if(this->
rate()<=0) {
135 cout <<
"gwavearray::DrawTime : Error - rate must be >0" << endl;
141 if(options.Contains(
"SAME")&&(pts!=NULL)) {
143 if(pts!=NULL)
delete pts;
144 char name[32];
sprintf(name,
"TIME-gID:%d",
int(gRandom->Rndm(13)*1.e9));
148 if(options.Contains(
"FULL")) {
149 options.ReplaceAll(
"FULL",
"");
150 tStart=this->
start();
153 }
else if(options.Contains(
"CUSTOM")) {
154 options.ReplaceAll(
"CUSTOM",
"");
155 tStart=this->
start();
157 tStart = tMin>tStart&&tMin<tStop ? tMin : tStart;
158 tStop = tMax>tStart&&tMax<tStop ? tMax : tStop;
161 GetTimeRange(tStart, tStop);
167 sprintf(title,
"START : %10.3f (gps) - LENGHT : %g (sec) - RATE : %g (hz)",
168 tf.
start()+tStart,tStop-tStart,tf.
rate());
169 if(!options.Contains(
"SAME")) {
175 if(!options.Contains(
"SAME")) options=options+
TString(
" ALP");
176 options.ReplaceAll(
" ",
"");
178 pts->graph[pts->graph.size()-1]->SetTitle(title);
184 template<
class DataType_t>
198 return DrawFFT(NULL,options,color);
202 template<
class DataType_t>
218 if(options.Contains(
"SAME")&&(pts!=NULL)) {
220 if(pts!=NULL)
delete pts;
221 char name[32];
sprintf(name,
"FFT-gID:%d",
int(gRandom->Rndm(13)*1.e9));
228 bool psd = options.Contains(
"PSD") ?
true :
false;
229 options.ReplaceAll(
"PSD",
"");
230 if(options.Contains(
"FULL")) {
231 options.ReplaceAll(
"FULL",
"");
232 tStart=this->
start();
235 }
else if(options.Contains(
"CUSTOM")) {
236 options.ReplaceAll(
"CUSTOM",
"");
237 tStart=this->
start();
239 tStart = tMin>tStart&&tMin<tStop ? tMin : tStart;
240 tStop = tMax>tStart&&tMax<tStop ? tMax : tStop;
243 GetTimeRange(tStart, tStop);
246 if(options.Contains(
"NOLOGX")) {logx=
false;options.ReplaceAll(
"NOLOGX",
"");}
248 if(options.Contains(
"NOLOGY")) {logy=
false;options.ReplaceAll(
"NOLOGY",
"");}
253 int nb=tStart*tf.
rate();
254 int ne=tStop*tf.
rate();
255 for(
int i=nb;
i<ne;
i++) tf[
i-nb] = tf[
i];
258 sprintf(title,
"START : %10.3f (gps) - LENGHT : %g (sec) - RATE : %g (hz)",
259 tf.
start()+tStart,tStop-tStart,tf.
rate());
261 if(!options.Contains(
"SAME")) options=options+
TString(
" ALP");
262 options.ReplaceAll(
" ",
"");
263 pts->plot(tf,
const_cast<char*>(options.Data()), color, 0, tStop-tStart,
true, fLow, fHigh, psd, 8);
264 pts->graph[pts->graph.size()-1]->SetTitle(title);
265 if(logx) pts->canvas->SetLogx();
266 if(logy) pts->canvas->SetLogy();
272 template<
class DataType_t>
284 return DrawTF(NULL,options);
288 template<
class DataType_t>
302 double fparm=nfact*6;
305 if(options.Contains(
"FULL")) {
306 options.ReplaceAll(
"FULL",
"");
307 tStart=this->
start();
310 }
else if(options.Contains(
"CUSTOM")) {
311 options.ReplaceAll(
"CUSTOM",
"");
312 tStart=this->
start();
314 tStart = tMin>tStart&&tMin<tStop ? tMin : tStart;
315 tStop = tMax>tStart&&tMax<tStop ? tMax : tStop;
318 GetTimeRange(tStart, tStop);
322 if(pts!=NULL)
delete pts;
328 char name[32];
sprintf(name,
"TF-gID:%d",
int(gRandom->Rndm(13)*1.e9));
329 stft =
new CWB::STFT(tf,nfft,noverlap,
"amplitude",
"gauss",fparm,name);
333 stft->
Draw(tStart,tStop,fLow,fHigh,0,0,1);
340 template<
class DataType_t>
359 for(
int j=0;
j<
size;
j++) E += this->data[
j]*this->data[
j];
361 int OS =
int(T*rate);
362 int M = OS<size/2 ? OS : size-
OS;
365 double sum = this->data[
OS]*this->data[
OS];
366 for(
int j=1;
j<
int(M);
j++) {
367 a = this->data[OS-
j];
368 b = this->data[OS+
j];
370 if(sum/E > efraction)
break;
374 tMin = tMin>=0 ? double((OS-I)/rate) : 0.;
375 tMax = tMax<size/rate ? double((OS+I)/rate) : size/
rate;
377 if(sum/E<efraction) {tMin=0.;tMax=size/
rate;}
383 template<
class DataType_t>
402 T = E>0 ?
T/E : 0.5*size/
rate;
408 template<
class DataType_t>
418 if(tShift==0)
return;
421 int ibeg=0;
int iend=0;
423 if(this->data[
i]!=0 && ibeg==0) ibeg=
i;
424 if(this->data[
i]!=0) iend=
i;
426 int ilen=iend-ibeg+1;
429 isize = isize + (isize%4 ? 4 - isize%4 : 0);
431 w.rate(this->
rate()); w=0;
433 for(
int i=0;
i<ilen;
i++) {w[
i+isize/4]=this->data[ibeg+
i];this->data[ibeg+
i]=0;}
439 double df = w.rate()/w.size();
441 for (
int ii=0;ii<(
int)w.size()/2;ii++) {
442 TComplex X(w[2*ii],w[2*ii+1]);
443 X=X*C.Exp(TComplex(0.,-2*pi*ii*df*tShift));
450 for(
int i=0;
i<(
int)w.size();
i++) {
451 int j=ibeg-isize/4+
i;
452 if((j>=0)&&(j<(
int)this->
size())) this->data[
j]=w[
i];
459 template<
class DataType_t>
468 if(pShift==0)
return;
471 int ibeg=0;
int iend=0;
473 if(this->data[
i]!=0 && ibeg==0) ibeg=
i;
474 if(this->data[
i]!=0) iend=
i;
476 int ilen=iend-ibeg+1;
479 isize = isize + (isize%4 ? 4 - isize%4 : 0);
481 w.rate(this->
rate()); w=0;
483 for(
int i=0;
i<ilen;
i++) {w[
i+isize/4]=this->data[ibeg+
i];this->data[ibeg+
i]=0;}
490 for (
int ii=0;ii<(
int)w.size()/2;ii++) {
491 TComplex X(w[2*ii],w[2*ii+1]);
492 X=X*C.Exp(TComplex(0.,-pShift));
499 for(
int i=0;
i<(
int)w.size();
i++) {
500 int j=ibeg-isize/4+
i;
501 if((j>=0)&&(j<(
int)this->
size())) this->data[
j]=w[
i];
507 template <
class DataType_t>
514 if ( (fp = fopen(fname,
"w")) == NULL ) {
515 cout <<
" gwavearray::DumpToFile() error: cannot open file " << fname <<
". \n";
519 double dt= this->
rate() ? 1./this->
rate() : 1.;
520 for (
int i = 0;
i <
n;
i++)
fprintf( fp,
"%e\t%e\n",
i*dt, this->data[
i]);
548 #define CLASS_INSTANTIATION(class_) template class gwavearray< class_ >;
virtual size_t size() const
void PhaseShift(double pShift=0.)
void DumpToFile(char *fname)
fprintf(stdout,"start=%f duration=%f rate=%f\n", x.start(), x.size()/x.rate(), x.rate())
virtual void rate(double r)
wavearray< double > a(hp.size())
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)
void waveAssign(wavearray< Tout > &aout, wavearray< Tin > &ain)
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 TimeShift(double tShift=0.)
double GetTimeRange(double &tMin, double &tMax, double efraction=0.9999999)
double GetCentralTime(wavearray< double > x)
CWB::STFT * DrawTF(TString options="")
double fabs(const Complex &x)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
#define CLASS_INSTANTIATION(class_)
virtual void resize(unsigned int)
watplot * DrawTime(TString options="ALP", Color_t color=kBlack)
void Draw(GWAT_DRAW type=GWAT_TIME, TString options="ALP", Color_t color=kBlack)
watplot * DrawFFT(TString options="ALP", Color_t color=kBlack)