157 {
158 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
159 if(tac==NULL) {
162 }
163 if(verbose>0) printf("%s()\n", __func__);
164
166
170 }
171
172
173 int isframe=-1;
174 if(strncasecmp(csv->
c[0].
content,
"Time", 4)==0) isframe=0;
175 else if(strncasecmp(csv->
c[0].
content,
"Start", 5)==0 &&
176 strncasecmp(csv->
c[1].
content,
"End", 3)==0) isframe=1;
177 if(isframe<0) {
180 }
181
182
183 int n, ret;
184 n=csv->
col_nr-1;
if(isframe==1) n--;
185 if(n<1) {
188 }
190 statusSet(status, __func__, __FILE__, __LINE__, ret);
194
195
197
198
199 char *cptr;
200 cptr=strchr(csv->
c[0].
content,
'[');
201 if(cptr==NULL) {
202 cptr=strchr(csv->
c[0].
content,
'(');
203 if(cptr==NULL) {
205 }
206 }
207 if(cptr!=NULL) {
209 cptr=strrchr(tmp, ']'); if(cptr==NULL) cptr=strrchr(tmp, ')');
210 if(cptr!=NULL) *cptr='\0';
212 free(tmp);
213 }
214
215
216 cptr=strchr(csv->
c[1].
content,
'[');
217 if(cptr==NULL) {
219 } else {
221 cptr=strrchr(tmp, ']'); if(cptr!=NULL) *cptr='\0';
223 free(tmp);
224 }
225
226
227 int i;
228 n=0; if(isframe==0) i=1; else i=2;
229 for(; i<csv->
nr; i++) {
230 if(csv->
c[i].
row!=0 || n>=tac->
tacNr)
break;
231
232 if(strchr(csv->
c[i].
content,
'[')) {
234 cptr=strchr(tmp, '['); *cptr='\0';
236 free(tmp);
237 } else {
239 }
240 if(strcmp(tac->
c[n].
name,
".")==0) strcpy(tac->
c[n].
name,
"");
241 n++;
242 }
243 if(n<1) {
246 }
248 if(verbose>2) printf(
" tacNr=%d\n sampleNr=%d\n", tac->
tacNr, tac->
sampleNr);
249
250
251 int fi=0, ri=0, oknr=0;
252 ret=0;
253 double v;
254 for(i=0; i<csv->
nr; i++)
if(csv->
c[i].
row==1)
break;
255 for(; i<csv->
nr; i++) {
256 if(verbose>10) printf(
"i=%d\trow=%d\tcol=%d\n", i, csv->
c[i].
row, csv->
c[i].
col);
257 fi=csv->
c[i].
row-1;
if(fi<0 || fi>=tac->
sampleNr) {ret++;
continue;}
258 if(csv->
c[i].
col<0) {ret++;
continue;}
260 if(ri>=tac->
tacNr) {ret++;
continue;}
262 if(verbose>10) printf(" -> fi=%d\tri=%d\t=\t%g\n", fi, ri, v);
263 if(ri<0) {
265 if(ri==-2) tac->
x1[fi]=v;
else if(ri==-1) tac->
x2[fi]=v;
267 }
else tac->
c[ri].
y[fi]=v;
268 }
269 if(verbose>0 && ret>0) printf("%d error(s) in reading PMOD file format.\n", ret);
270 if(oknr<1) {
273 }
274
277 tac->
x[fi]=0.5*(tac->
x1[fi]+tac->
x2[fi]);
278
279
281 while(ci>0) {
282 if(strlen(tac->
c[ci].
name)>0)
break;
283 int i;
284 for(i=0; i<tac->
sampleNr; i++)
if(isfinite(tac->
c[ci].
y[i]))
break;
285 if(i<tac->sampleNr) break;
287 }
288
289
294
295
299 statusSet(status, __func__, __FILE__, __LINE__, ret);
300 return(ret);
301 }
302 }
306 }
307
311}
double atofVerified(const char *s)
int iftDuplicate(IFT *ift1, IFT *ift2)
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
char * strdup(const char *s)
size_t strlcpy(char *dst, const char *src, size_t dstsize)
char name[MAX_TACNAME_LEN+1]
IFT h
Optional (but often useful) header information.
int verbose
Verbose level, used by statusPrint() etc.
int tacAllocate(TAC *tac, int sampleNr, int tacNr)
int tacGetHeaderUnit(TAC *tac, TPCSTATUS *status)
int tacGetHeaderTimeunit(TAC *tac, TPCSTATUS *status)
int tacSetHeaderTimeunit(IFT *h, int u)
int tacSetHeaderUnit(IFT *h, int u)
int tacWMove(TAC *tac, int ow, TPCSTATUS *status)
#define MAX_TACNAME_LEN
Max length of TAC ID name (not including trailing zero).
@ UNIT_UNKNOWN
Unknown unit.
@ TPCERROR_FAIL
General error.
@ TPCERROR_INVALID_FORMAT
Invalid file format.
@ TPCERROR_NO_WEIGHTS
File contains no weights.
@ TPCERROR_NO_DATA
File contains no data.
int unitIdentify(const char *s)
@ TAC_FORMAT_PMOD
PMOD TAC format.