5#include "tpcclibConfig.h"
31 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
32 if(verbose>0) printf(
"%s()\n", __func__);
52 fi=0;
if(d->
isframe==0) p=d->
x[fi];
else p=0.5*(d->
x1[fi]+d->
x2[fi]);
54 if(d->
isframe==0) s=d->
x[fi];
else s=0.5*(d->
x1[fi]+d->
x2[fi]);
56 if(verbose>2) printf(
"x[%d]=%g\nx[%d]=%g\n", fi-1, p, fi, s);
80 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
81 if(verbose>0) printf(
"%s()\n", __func__);
83 if(d==NULL || d->
tacNr<1) {
99 if(d->
isframe==0) {a1=d->
x[fi]; a2=d->
x[fj];}
100 else {a1=0.5*(d->
x1[fi]+d->
x2[fi]); a2=0.5*(d->
x1[fj]+d->
x2[fj]);}
102 s=d->
x[fi]; d->
x[fi]=d->
x[fj]; d->
x[fj]=s;
103 s=d->
x1[fi]; d->
x1[fi]=d->
x1[fj]; d->
x1[fj]=s;
104 s=d->
x2[fi]; d->
x2[fi]=d->
x2[fj]; d->
x2[fj]=s;
105 s=d->
w[fi]; d->
w[fi]=d->
w[fj]; d->
w[fj]=s;
106 for(ri=0; ri<d->
tacNr; ri++) {
108 s=c->
y[fi]; c->
y[fi]=c->
y[fj]; c->
y[fj]=s;
130 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
131 if(verbose>0) printf(
"%s()\n", __func__);
133 if(d==NULL || d->
tacNr<1) {
148 a1=d->
c[i].
y[fi]; a2=d->
c[i].
y[fj];
150 s=d->
x[fi]; d->
x[fi]=d->
x[fj]; d->
x[fj]=s;
151 s=d->
x1[fi]; d->
x1[fi]=d->
x1[fj]; d->
x1[fj]=s;
152 s=d->
x2[fi]; d->
x2[fi]=d->
x2[fj]; d->
x2[fj]=s;
153 s=d->
w[fi]; d->
w[fi]=d->
w[fj]; d->
w[fj]=s;
154 for(ri=0; ri<d->
_tacNr; ri++) {
156 s=c->
y[fi]; c->
y[fi]=c->
y[fj]; c->
y[fj]=s;
166static int tacQSortName(
const void *c1,
const void *c2)
169 res=strcasecmp( ((
TACC*)c1)->name, ((
TACC*)c2)->name );
184 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
185 if(verbose>0) printf(
"%s()\n", __func__);
193 qsort(d->
c, d->
tacNr,
sizeof(
TACC), tacQSortName);
211 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
212 if(verbose>0) printf(
"%s()\n", __func__);
221 double auc[d->
tacNr], fdur, v;
223 for(i=0; i<d->
tacNr; i++) {
226 fdur=d->
x2[0]-d->
x1[0]; v=d->
c[i].
y[j];
227 if(isnan(fdur) || isnan(v))
continue;
233 for(i=0; i<d->
tacNr-1; i++)
234 for(j=i+1; j<d->
tacNr; j++)
237 a=auc[i]; auc[i]=auc[j]; auc[j]=a;
265 taccSize=
sizeof(
TACC);
266 memcpy(&tacc, d->
c+from, taccSize);
267 if(from>to)
for(i=from; i>to; i--)
268 memcpy(d->
c+i, d->
c+(i-1), taccSize);
269 else for(i=from; i<to; i++)
270 memcpy(d->
c+i, d->
c+(i+1), taccSize);
271 memcpy(d->
c+i, &tacc, taccSize);
296 taccSize=
sizeof(
TACC);
297 memcpy(&tacc, d->
c+i1, taccSize);
298 memcpy(d->
c+i1, d->
c+i2, taccSize);
299 memcpy(d->
c+i2, &tacc, taccSize);
347 if(verbose>0) {printf(
"\n%s(%d)\n", __func__, fixMode); fflush(stdout);}
350 if(fixMode!=0 && (d1==NULL || d2==NULL || d1->
sampleNr<1))
return(2);
355 const double simlim=1.0E-03;
if(verbose>1) printf(
" limit := %g\n", simlim);
359 for(
int i=0; i<d1->
sampleNr-1 && !isMultiple; i++) {
360 double t1;
if(d1->
isframe) t1=0.5*(d1->
x1[i]+d1->
x2[i]);
else t1=d1->
x[i];
361 for(
int j=i+1; j<d1->
sampleNr; j++) {
362 double t2;
if(d1->
isframe) t2=0.5*(d1->
x1[j]+d1->
x2[j]);
else t2=d1->
x[j];
363 double dt=fabs(t2-t1);
364 if(verbose>4) printf(
" |%g - %g| = %g\n", t1, t2, dt);
365 if(dt<simlim) {isMultiple=1;
break;}
368 if(verbose>1) {printf(
" isMultiple := %d\n", isMultiple); fflush(stdout);}
369 if(fixMode==0)
return(isMultiple);
389 for(
int r=0; r<itac.
tacNr; r++)
397 int i=
tacMinX(&itac);
if(i<0)
break;
398 if(verbose>3) printf(
" smallest x[%d]=%g\n", i, itac.
x[i]);
401 int rn[itac.
tacNr];
for(
int r=0; r<itac.
tacNr; r++) rn[r]=0;
402 for(
int r=0; r<itac.
tacNr; r++)
403 if(isfinite(itac.
c[r].
y[i])) {
408 double t1;
if(itac.
isframe) t1=0.5*(itac.
x1[i]+itac.
x2[i]);
else t1=itac.
x[i];
414 int i=
tacMinX(&itac);
if(i<0)
break;
415 if(verbose>3) printf(
" smallest x[%d]=%g\n", i, itac.
x[i]);
416 double t2;
if(itac.
isframe) t2=0.5*(itac.
x1[i]+itac.
x2[i]);
else t2=itac.
x[i];
417 double dt=fabs(t2-t1);
if(verbose>4) printf(
" |%g - %g| = %g\n", t1, t2, dt);
418 if(!(dt<simlim))
break;
420 for(
int r=0; r<itac.
tacNr; r++)
421 if(isfinite(itac.
c[r].
y[i])) {
429 for(
int r=0; r<itac.
tacNr; r++) d2->
c[r].
y[d2->
sampleNr]/=(
double)rn[r];
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
int verbose
Verbose level, used by statusPrint() etc.
int tacDuplicate(TAC *tac1, TAC *tac2)
Make a duplicate of TAC structure.
int tacAllocate(TAC *tac, int sampleNr, int tacNr)
int tacCopyTacchdr(TACC *d1, TACC *d2)
int tacCopyHdr(TAC *tac1, TAC *tac2)
Copy TAC header data from tac1 to tac2.
int tacSortByTime(TAC *d, TPCSTATUS *status)
int tacSortByConc(TAC *d, const int i, TPCSTATUS *status)
int tacSortByAUC(TAC *d, TPCSTATUS *status)
int tacSortByName(TAC *d, TPCSTATUS *status)
int tacDeleteTACC(TAC *d, int i)
int tacVerifyTimeOrder(TAC *d, TPCSTATUS *status)
int tacSwapTACCs(TAC *d, int i1, int i2)
int tacMultipleSamples(TAC *d1, const int fixMode, TAC *d2, const int verbose)
Check TAC data for multiple samples with the same sample time. Optionally replace the multiple sample...
int tacMoveTACC(TAC *d, int from, int to)
int tacDeleteMissingSamples(TAC *d)
Delete those samples (time frames) from TAC structure, which contain only missing y values,...
int tacMinX(TAC *d)
Get the minimum x value in TAC structure.
int tacDeleteSample(TAC *d, int i)
Delete a certain sample (time frame) from TAC structure.
int tacIsX(TAC *d)
Verify if TAC structure contains reasonable x values (times).
@ WEIGHTING_OFF
Not weighted or weights not available (weights for all included samples are 1.0).
@ TPCERROR_OVERLAPPING_DATA
Overlapping data.
@ TPCERROR_FAIL
General error.
@ TPCERROR_NO_DATA
File contains no data.
@ TPCERROR_MISSING_DATA
File contains missing values.
Header file for library libtpctac.