47 template<
class DataType_t>
50 if(wextern) this->data = NULL;
53 if(pts!=NULL)
delete pts;
57 template<
class DataType_t>
62 template<
class DataType_t>
77 template<
class DataType_t>
88 template<
class DataType_t>
99 return Draw(NULL,type,options,color);
103 template<
class DataType_t>
118 if(type==
GWAT_SG) cout <<
"gwavearray<DataType_t>::Draw - Error : draw type " 119 <<
"GWAT_SG" <<
" not allowed" << endl;
123 template<
class DataType_t>
135 return DrawTime(NULL,options,color);
139 template<
class DataType_t>
152 if(this->
rate()<=0) {
153 cout <<
"gwavearray::DrawTime : Error - rate must be >0" << endl;
159 if(options.Contains(
"SAME")&&(
pts!=NULL)) {
162 char name[32];
sprintf(name,
"TIME-gID:%d",
int(gRandom->Rndm(13)*1.e9));
163 pts =
new watplot(const_cast<char*>(name),200,20,800,500);
166 if(options.Contains(
"FULL")) {
167 options.ReplaceAll(
"FULL",
"");
168 tStart=this->
start();
171 }
else if(options.Contains(
"CUSTOM")) {
172 options.ReplaceAll(
"CUSTOM",
"");
173 tStart=this->
start();
185 sprintf(title,
"START : %10.3f (gps) - LENGHT : %g (sec) - RATE : %g (hz)",
186 tf.
start()+tStart,tStop-tStart,tf.
rate());
187 if(!options.Contains(
"SAME")) {
193 if(!options.Contains(
"SAME")) options=options+
TString(
" ALP");
194 options.ReplaceAll(
" ",
"");
195 pts->
plot(tf, const_cast<char*>(options.Data()), color, tStart, tStop);
202 template<
class DataType_t>
216 return DrawFFT(NULL,options,color);
220 template<
class DataType_t>
236 if(options.Contains(
"SAME")&&(
pts!=NULL)) {
239 char name[32];
sprintf(name,
"FFT-gID:%d",
int(gRandom->Rndm(13)*1.e9));
240 pts =
new watplot(const_cast<char*>(name),200,20,800,500);
246 bool psd = options.Contains(
"PSD") ? true :
false;
247 options.ReplaceAll(
"PSD",
"");
248 if(options.Contains(
"FULL")) {
249 options.ReplaceAll(
"FULL",
"");
250 tStart=this->
start();
253 }
else if(options.Contains(
"CUSTOM")) {
254 options.ReplaceAll(
"CUSTOM",
"");
255 tStart=this->
start();
264 if(options.Contains(
"NOLOGX")) {logx=
false;options.ReplaceAll(
"NOLOGX",
"");}
266 if(options.Contains(
"NOLOGY")) {logy=
false;options.ReplaceAll(
"NOLOGY",
"");}
271 int nb=tStart*tf.
rate();
272 int ne=tStop*tf.
rate();
273 for(
int i=nb;
i<ne;
i++) tf[
i-nb] = tf[
i];
276 sprintf(title,
"START : %10.3f (gps) - LENGHT : %g (sec) - RATE : %g (hz)",
277 tf.
start()+tStart,tStop-tStart,tf.
rate());
279 if(!options.Contains(
"SAME")) options=options+
TString(
" ALP");
280 options.ReplaceAll(
" ",
"");
281 pts->
plot(tf, const_cast<char*>(options.Data()), color, 0, tStop-tStart,
true, fLow, fHigh, psd, 8);
290 template<
class DataType_t>
302 return DrawTF(NULL,options);
306 template<
class DataType_t>
320 double fparm=nfact*6;
323 if(options.Contains(
"FULL")) {
324 options.ReplaceAll(
"FULL",
"");
325 tStart=this->
start();
328 }
else if(options.Contains(
"CUSTOM")) {
329 options.ReplaceAll(
"CUSTOM",
"");
330 tStart=this->
start();
346 char name[32];
sprintf(name,
"TF-gID:%d",
int(gRandom->Rndm(13)*1.e9));
347 stft =
new CWB::STFT(tf,nfft,noverlap,
"amplitude",
"gauss",fparm,name);
351 stft->
Draw(tStart,tStop,fLow,fHigh,0,0,1);
358 template<
class DataType_t>
379 int OS =
int(T*rate);
380 int M = OS<size/2 ?
OS : size-
OS;
384 for(
int j=1;
j<
int(M);
j++) {
385 a = this->data[OS-
j];
386 b = this->data[OS+
j];
388 if(sum/E > efraction)
break;
392 tMin = tMin>=0 ? double((OS-I)/rate) : 0.;
393 tMax = tMax<size/rate ? double((OS+I)/rate) : size/
rate;
395 if(sum/E<efraction) {tMin=0.;tMax=size/
rate;}
401 template<
class DataType_t>
420 T = E>0 ?
T/E : 0.5*size/
rate;
426 template<
class DataType_t>
436 if(tShift==0)
return;
439 int ibeg=0;
int iend=0;
441 if(this->
data[
i]!=0 && ibeg==0) ibeg=
i;
442 if(this->
data[
i]!=0) iend=
i;
444 int ilen=iend-ibeg+1;
447 isize = isize + (isize%4 ? 4 - isize%4 : 0);
449 w.rate(this->
rate()); w=0;
451 for(
int i=0;
i<ilen;
i++) {w[
i+isize/4]=this->
data[ibeg+
i];this->
data[ibeg+
i]=0;}
457 double df = w.rate()/w.size();
459 for (
int ii=0;ii<(
int)w.size()/2;ii++) {
460 TComplex X(w[2*ii],w[2*ii+1]);
461 X=X*C.Exp(TComplex(0.,-2*pi*ii*df*tShift));
468 for(
int i=0;
i<(
int)w.size();
i++) {
469 int j=ibeg-isize/4+
i;
477 template<
class DataType_t>
486 if(pShift==0)
return;
489 int ibeg=0;
int iend=0;
491 if(this->
data[
i]!=0 && ibeg==0) ibeg=
i;
492 if(this->
data[
i]!=0) iend=
i;
494 int ilen=iend-ibeg+1;
497 isize = isize + (isize%4 ? 4 - isize%4 : 0);
499 w.rate(this->
rate()); w=0;
501 for(
int i=0;
i<ilen;
i++) {w[
i+isize/4]=this->
data[ibeg+
i];this->
data[ibeg+
i]=0;}
508 for (
int ii=0;ii<(
int)w.size()/2;ii++) {
509 TComplex X(w[2*ii],w[2*ii+1]);
510 X=X*C.Exp(TComplex(0.,-pShift));
517 for(
int i=0;
i<(
int)w.size();
i++) {
518 int j=ibeg-isize/4+
i;
525 template <
class DataType_t>
532 if ( (fp = fopen(fname,
"w")) == NULL ) {
533 cout <<
" gwavearray::DumpToFile() error: cannot open file " << fname <<
". \n";
537 double dt= this->
rate() ? 1./this->
rate() : 1.;
566 #define CLASS_INSTANTIATION(class_) template class gwavearray< class_ >;
void PhaseShift(double pShift=0.)
void DumpToFile(char *fname)
virtual void rate(double r)
wavearray< double > a(hp.size())
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<< "\ layers : "<< nLAYERS<< "\ dF(hz) : "<< dF<< "\ 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)
std::vector< TGraph * > graph
virtual void start(double s)
void plot(wavearray< double > &, char *=NULL, int=1, double=0., double=0., bool=false, float=0., float=0., bool=false, float=0., bool=false)
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")
fprintf(stdout,"start=%f duration=%f rate=%f\, x.start(), x.size()/x.rate(), x.rate())
virtual size_t size() const
virtual double rate() const
void TimeShift(double tShift=0.)
virtual double start() const
double GetTimeRange(double &tMin, double &tMax, double efraction=0.9999999)
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)