TPCCLIB
Loading...
Searching...
No Matches
tacift.c File Reference

Get or set TAC header content from IFT struct stored inside TAC struct. More...

#include "tpcclibConfig.h"
#include "tpcift.h"
#include "tpcisotope.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include "tpctac.h"

Go to the source code of this file.

Functions

int tacGetHeaderStudynr (IFT *h, char *s, TPCSTATUS *status)
int tacSetHeaderStudynr (IFT *h, const char *s)
int tacSetHeaderUnit (IFT *h, int u)
int tacGetHeaderUnit (TAC *tac, TPCSTATUS *status)
int tacSetHeaderTimeunit (IFT *h, int u)
int tacGetHeaderTimeunit (TAC *tac, TPCSTATUS *status)
int tacGetHeaderIsotope (IFT *h, char *s, TPCSTATUS *status)
int tacSetHeaderIsotope (IFT *h, const char *s)
int tacGetHeaderScanstarttime (IFT *h, char *s, TPCSTATUS *status)
int tacSetHeaderScanstarttime (IFT *h, const char *s)
int tacGetHeaderInjectiontime (IFT *h, char *s, TPCSTATUS *status)
int tacSetHeaderInjectiontime (IFT *h, const char *s)
decaycorrection tacGetHeaderDecayCorrection (IFT *h)
int tacSetHeaderDecayCorrection (IFT *h, decaycorrection dc)

Detailed Description

Get or set TAC header content from IFT struct stored inside TAC struct.

Definition in file tacift.c.

Function Documentation

◆ tacGetHeaderDecayCorrection()

decaycorrection tacGetHeaderDecayCorrection ( IFT * h)

Get the status of decay correction from TAC struct header.

Returns
enum DECAY_UNKNOWN, DECAY_NOTCORRECTED, or DECAY_CORRECTED.
Author
Vesa Oikonen
See also
tacSetHeaderDecayCorrection, tacGetHeaderIsotope, tacDecayCorrection
Parameters
hPointer to TAC header structure.

Definition at line 548 of file tacift.c.

551 {
552 if(h==NULL) return(DECAY_UNKNOWN);
553
554 /* Find the item index */
555 int i;
556 i=iftFindKey(h, "decay_correction", 0);
557 if(i<0) i=iftFindKey(h, "decay correction", 0);
558 if(i<0) return(DECAY_UNKNOWN);
559
560 /* Check the contents */
561 if(h->item[i].value==NULL || strlen(h->item[i].value)<1)
562 return(DECAY_UNKNOWN);
563 if(strncasecmp(h->item[i].value, "YES", 1)==0) return(DECAY_CORRECTED);
564 if(strncasecmp(h->item[i].value, "NO", 1)==0) return(DECAY_NOTCORRECTED);
565 if(strcasecmp(h->item[i].value, "ON")==0) return(DECAY_CORRECTED);
566 if(strcasecmp(h->item[i].value, "OFF")==0) return(DECAY_NOTCORRECTED);
567 return(DECAY_UNKNOWN);
568}
int iftFindKey(IFT *ift, const char *key, int start_index)
Definition iftfind.c:30
char * value
Definition tpcift.h:37
IFT_ITEM * item
Definition tpcift.h:57
@ DECAY_UNKNOWN
Not known; usually assumed that data is corrected.
Definition tpcisotope.h:79
@ DECAY_NOTCORRECTED
Data is not corrected for physical decay.
Definition tpcisotope.h:80
@ DECAY_CORRECTED
Data is corrected for physical decay.
Definition tpcisotope.h:81

◆ tacGetHeaderInjectiontime()

int tacGetHeaderInjectiontime ( IFT * h,
char * s,
TPCSTATUS * status )

Get injection time from TAC structure header.

Returns
enum tpcerror (TPCERROR_OK when successful).
Author
Vesa Oikonen
See also
tacSetHeaderInjectiontime, tacSetHeaderScanstarttime, tacDecayCorrection, tacGetHeaderIsotope
Parameters
hPointer to TAC header structure.
sPointer to preallocated string of length 19+1 (at least); enter NULL if you only want to test if header contains injection time.
statusPointer to status data; enter NULL if not needed.

Definition at line 462 of file tacift.c.

470 {
471 int verbose=0; if(status!=NULL) verbose=status->verbose;
472 if(s!=NULL) *s='\0';
473 if(h==NULL) {
474 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_DATA);
475 return TPCERROR_NO_DATA;
476 }
477 if(verbose>0) printf("%s()\n", __func__);
478
479 /* Find the item index */
480 int i;
481 i=iftFindKey(h, "injection_time", 0);
482 if(i<0) i=iftFindKey(h, "injection time", 0);
483 if(i<0) i=iftFindKey(h, "injectiontime", 0);
484 if(i<0) {
485 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_KEY);
486 return TPCERROR_NO_KEY;
487 }
488 /* Check that item has content */
489 size_t len;
490 if(h->item[i].value==NULL) len=0;
491 else len=strlen(h->item[i].value);
492 if(len<1) {
493 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_VALUE);
494 return TPCERROR_NO_VALUE;
495 }
496 if(len>19) {
497 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_INVALID_VALUE);
499 }
500 /* All fine, then copy it */
501 if(s!=NULL) strcpy(s, h->item[i].value);
502
503 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_OK);
504 return(TPCERROR_OK);
505}
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
Definition statusmsg.c:142
int verbose
Verbose level, used by statusPrint() etc.
@ TPCERROR_INVALID_VALUE
Invalid value.
@ TPCERROR_NO_VALUE
Value not found.
@ TPCERROR_NO_KEY
Key not found.
@ TPCERROR_OK
No error.
@ TPCERROR_NO_DATA
File contains no data.

◆ tacGetHeaderIsotope()

int tacGetHeaderIsotope ( IFT * h,
char * s,
TPCSTATUS * status )

Get isotope from TAC struct header.

See also
tacGetIsotope, tacDecayCorrection, isotopeIdentify, tacGetHeaderDecayCorrection
Returns
enum tpcerror (TPCERROR_OK when successful).
Author
Vesa Oikonen
Parameters
hPointer to TAC header structure.
sPointer to preallocated string of length MAX_ISOTOPE_LEN+1 (at least); enter NULL if you only want to test if header contains isotope code.
statusPointer to status data; enter NULL if not needed.

Definition at line 290 of file tacift.c.

298 {
299 int verbose=0; if(status!=NULL) verbose=status->verbose;
300 if(s!=NULL) *s='\0';
301 if(h==NULL) {
302 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_DATA);
303 return TPCERROR_NO_DATA;
304 }
305 if(verbose>0) printf("%s()\n", __func__);
306
307 /* Find the item index */
308 int i;
309 i=iftFindKey(h, "isotope", 0);
310 if(i<0) {
311 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_KEY);
312 return TPCERROR_NO_KEY;
313 }
314 /* Check that item has content */
315 size_t len;
316 if(h->item[i].value==NULL) len=0;
317 else len=strlen(h->item[i].value);
318 if(len<1) {
319 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_VALUE);
320 return TPCERROR_NO_VALUE;
321 }
322 if(len>MAX_ISOTOPE_LEN) {
323 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_INVALID_VALUE);
325 }
326 /* All fine, then copy isotope */
327 if(s!=NULL) strlcpy(s, h->item[i].value, MAX_ISOTOPE_LEN);
328
329 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_OK);
330 return(TPCERROR_OK);
331}
size_t strlcpy(char *dst, const char *src, size_t dstsize)
Definition stringext.c:632
#define MAX_ISOTOPE_LEN
Max string length for PET isotope.
Definition tpcisotope.h:41

Referenced by abssWrite(), tacGetIsotope(), tacReadSIF(), and tacWriteSIF().

◆ tacGetHeaderScanstarttime()

int tacGetHeaderScanstarttime ( IFT * h,
char * s,
TPCSTATUS * status )

Get scan start time from TAC structure header.

Returns
enum tpcerror (TPCERROR_OK when successful).
Author
Vesa Oikonen
See also
tacSetHeaderScanstarttime, tacGetHeaderInjectiontime, tacDecayCorrection, tacGetHeaderIsotope
Parameters
hPointer to TAC header structure.
sPointer to preallocated string of length 19+1 (at least); enter NULL if you only want to test if header contains scan start time.
statusPointer to status data; enter NULL if not needed.

Definition at line 372 of file tacift.c.

380 {
381 int verbose=0; if(status!=NULL) verbose=status->verbose;
382 if(s!=NULL) *s='\0';
383 if(h==NULL) {
384 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_DATA);
385 return TPCERROR_NO_DATA;
386 }
387 if(verbose>0) printf("%s()\n", __func__);
388
389 /* Find the item index */
390 int i;
391 i=iftFindKey(h, "scan_start_time", 0);
392 if(i<0) i=iftFindKey(h, "scan start time", 0);
393 if(i<0) i=iftFindKey(h, "scan_start", 0);
394 if(i<0) i=iftFindKey(h, "scan start", 0);
395 if(i<0) i=iftFindKey(h, "scantime", 0);
396 if(i<0) {
397 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_KEY);
398 return TPCERROR_NO_KEY;
399 }
400 /* Check that item has content */
401 size_t len;
402 if(h->item[i].value==NULL) len=0;
403 else len=strlen(h->item[i].value);
404 if(len<1) {
405 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_VALUE);
406 return TPCERROR_NO_VALUE;
407 }
408 if(len>19) {
409 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_INVALID_VALUE);
411 }
412 /* All fine, then copy it */
413 if(s!=NULL) strcpy(s, h->item[i].value);
414
415 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_OK);
416 return(TPCERROR_OK);
417}

Referenced by abssWrite(), imgFromSIF(), tacReadSIF(), and tacWriteSIF().

◆ tacGetHeaderStudynr()

int tacGetHeaderStudynr ( IFT * h,
char * s,
TPCSTATUS * status )

Get study number from TAC struct header.

Returns
enum tpcerror (TPCERROR_OK when successful).
Author
Vesa Oikonen
See also
tacSetHeaderStudynr, parIsStudyNr
Parameters
hPointer to TAC header struct
sPointer to preallocated string of length MAX_STUDYNR_LEN+1 (at least); enter NULL if you only want to test whether header contains studynr
statusPointer to status data; enter NULL if not needed

Definition at line 26 of file tacift.c.

34 {
35 int verbose=0; if(status!=NULL) verbose=status->verbose;
36 if(s!=NULL) *s='\0';
37 if(h==NULL) {
38 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_DATA);
39 return TPCERROR_NO_DATA;
40 }
41 if(verbose>0) printf("%s()\n", __func__);
42
43 /* Find the item index */
44 int i;
45 i=iftFindKey(h, "studynr", 0);
46 if(i<0) i=iftFindKey(h, "study_number", 0);
47 if(i<0) i=iftFindKey(h, "study number", 0);
48 if(i<0) {
49 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_KEY);
50 return TPCERROR_NO_KEY;
51 }
52 /* Check that item has content */
53 size_t len;
54 if(h->item[i].value==NULL) len=0;
55 else len=strlen(h->item[i].value);
56 if(len<1) {
57 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_VALUE);
58 return TPCERROR_NO_VALUE;
59 }
60 if(len>MAX_STUDYNR_LEN) {
61 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_INVALID_VALUE);
63 }
64 /* All fine, then copy studynr */
65 if(s!=NULL) strlcpy(s, h->item[i].value, MAX_STUDYNR_LEN);
66
67 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_OK);
68 return(TPCERROR_OK);
69}
#define MAX_STUDYNR_LEN
Define max study number length.

Referenced by abssWrite(), imgFromSIF(), tacRead(), tacReadSIF(), tacWriteCSV(), tacWriteDFT(), and tacWriteSIF().

◆ tacGetHeaderTimeunit()

int tacGetHeaderTimeunit ( TAC * tac,
TPCSTATUS * status )

Get time (x) unit from TAC struct header and write to main TAC struct.

Returns
enum tpcerror (TPCERROR_OK when successful).
Author
Vesa Oikonen
Parameters
tacPointer to TAC struct
statusPointer to status data; enter NULL if not needed

Definition at line 234 of file tacift.c.

239 {
240 int verbose=0; if(status!=NULL) verbose=status->verbose;
241 if(tac==NULL) {
242 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_FAIL);
243 return TPCERROR_FAIL;
244 }
245 if(verbose>0) printf("%s()\n", __func__);
246 tac->tunit=UNIT_UNKNOWN;
247
248 /* Find the item index */
249 int i;
250 i=iftFindKey(&tac->h, "timeunit", 0);
251 if(i<0) i=iftFindKey(&tac->h, "time_unit", 0);
252 if(i<0) i=iftFindKey(&tac->h, "time unit", 0);
253 if(i<0) i=iftFindKey(&tac->h, "time units", 0);
254 if(i<0) {
255 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_KEY);
256 return TPCERROR_NO_KEY;
257 }
258 /* Check that item has content */
259 size_t len;
260 if(tac->h.item[i].value==NULL) len=0;
261 else len=strlen(tac->h.item[i].value);
262 if(len<1) {
263 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_VALUE);
264 return TPCERROR_NO_VALUE;
265 }
266
267 /* Identify unit string */
268 tac->tunit=unitIdentify(tac->h.item[i].value);
269
270 /* Delete unit strings from header */
272
273 /* If unit was unknown, then return error */
274 if(tac->tunit==UNIT_UNKNOWN) {
275 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_INVALID_VALUE);
277 }
278 /* Otherwise ok */
279 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_OK);
280 return(TPCERROR_OK);
281}
IFT h
Optional (but often useful) header information.
Definition tpctac.h:141
unit tunit
Definition tpctac.h:109
int tacSetHeaderTimeunit(IFT *h, int u)
Definition tacift.c:201
@ UNIT_UNKNOWN
Unknown unit.
@ TPCERROR_FAIL
General error.
int unitIdentify(const char *s)
Definition units.c:162

Referenced by tacReadCSV(), tacReadDFT(), tacReadPMOD(), and tacReadSimple().

◆ tacGetHeaderUnit()

int tacGetHeaderUnit ( TAC * tac,
TPCSTATUS * status )

Get concentration (y) unit from TAC struct header and write to main TAC struct.

Returns
enum tpcerror (TPCERROR_OK when successful).
Author
Vesa Oikonen
Parameters
tacPointer to TAC struct
statusPointer to status data; enter NULL if not needed

Definition at line 145 of file tacift.c.

150 {
151 int verbose=0; if(status!=NULL) verbose=status->verbose;
152 if(tac==NULL) {
153 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_FAIL);
154 return TPCERROR_FAIL;
155 }
156 if(verbose>0) printf("%s()\n", __func__);
157 tac->cunit=UNIT_UNKNOWN;
158
159 /* Find the item index */
160 int i;
161 i=iftFindKey(&tac->h, "unit", 0);
162 if(i<0) i=iftFindKey(&tac->h, "calibration_unit", 0);
163 if(i<0) i=iftFindKey(&tac->h, "activity_units", 0);
164 if(i<0) i=iftFindKey(&tac->h, "activity units", 0);
165 if(i<0) {
166 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_KEY);
167 return TPCERROR_NO_KEY;
168 }
169 /* Check that item has content */
170 size_t len;
171 if(tac->h.item[i].value==NULL) len=0;
172 else len=strlen(tac->h.item[i].value);
173 if(len<1) {
174 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_NO_VALUE);
175 return TPCERROR_NO_VALUE;
176 }
177
178 /* Identify unit string */
179 tac->cunit=unitIdentify(tac->h.item[i].value);
180
181 /* Delete unit strings from header */
183
184 /* If unit was unknown, then return error */
185 if(tac->cunit==UNIT_UNKNOWN) {
186 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_INVALID_VALUE);
188 }
189 /* Otherwise ok */
190 statusSet(status, __func__, __FILE__, __LINE__, TPCERROR_OK);
191 return(TPCERROR_OK);
192}
unit cunit
Definition tpctac.h:105
int tacSetHeaderUnit(IFT *h, int u)
Definition tacift.c:112

Referenced by tacReadCSV(), tacReadDFT(), tacReadPMOD(), and tacReadSimple().

◆ tacSetHeaderDecayCorrection()

int tacSetHeaderDecayCorrection ( IFT * h,
decaycorrection dc )

Set the status of decay correction in TAC structure header. Any previous status is deleted.

Returns
enum tpcerror (TPCERROR_OK when successful).
Author
Vesa Oikonen
See also
tacGetHeaderDecayCorrection, tacSetHeaderIsotope, tacDecayCorrection
Parameters
hPointer to TAC header structure.
dcStatus of decay correction: DECAY_UNKNOWN, DECAY_NOTCORRECTED, or DECAY_CORRECTED.

Definition at line 578 of file tacift.c.

583 {
584 if(h==NULL) return TPCERROR_FAIL;
585
586 /* Find and delete previous status */
587 int i=0, start=0;
588 while(1) {
589 i=iftFindKey(h, "decay_correction", start);
590 if(i<0) i=iftFindKey(h, "decay correction", start);
591 if(i<0) break;
592 iftDelete(h, i); if(i>start) start=i;
593 }
594
595 /* Create new key and value */
596 if(dc==DECAY_CORRECTED)
597 return (iftPut(h, "decay_correction", "yes", (char)1, NULL));
598 else if(dc==DECAY_NOTCORRECTED)
599 return (iftPut(h, "decay_correction", "no", (char)1, NULL));
600
601 /* If unknown, then just return */
602 return(TPCERROR_OK);
603}
int iftPut(IFT *ift, const char *key, const char *value, char comment, TPCSTATUS *status)
Definition ift.c:63
int iftDelete(IFT *ift, int index)
Definition ift.c:206

Referenced by tacDecayCorrection().

◆ tacSetHeaderInjectiontime()

int tacSetHeaderInjectiontime ( IFT * h,
const char * s )

Set injection time in TAC structure header. Any previous injection time items are deleted.

Returns
enum tpcerror (TPCERROR_OK when successful).
See also
tacGetHeaderInjectiontime, tacGetHeaderScanstarttime, tacDecayCorrection, tacSetHeaderIsotope
Author
Vesa Oikonen
Parameters
hPointer to TAC header structure.
sPointer to string containing the injection time in international format YYYY-MM-DD hh:mm:ss ; enter NULL or "" if you only want to delete it in header.

Definition at line 515 of file tacift.c.

521 {
522 if(h==NULL) return TPCERROR_FAIL;
523
524 /* Find and delete previous scan start time(s) */
525 int i=0, start=0;
526 while(1) {
527 i=iftFindKey(h, "injection_time", start);
528 if(i<0) i=iftFindKey(h, "injection time", start);
529 if(i<0) i=iftFindKey(h, "injectiontime", start);
530 if(i<0) break;
531 iftDelete(h, i); if(i>start) start=i;
532 }
533
534 /* If new scan start time is empty, then just return */
535 if(s==NULL || *s=='\0') return(TPCERROR_OK);
536
537 /* Otherwise create new key and value */
538 return (iftPut(h, "injection_time", s, (char)1, NULL));
539}

◆ tacSetHeaderIsotope()

int tacSetHeaderIsotope ( IFT * h,
const char * s )

Set isotope in TAC structure header. Any previous isotope items are deleted.

See also
tacSetIsotope
Returns
enum tpcerror (TPCERROR_OK when successful).
Author
Vesa Oikonen
Parameters
hPointer to TAC header structure.
sPointer to string containing the isotope; enter NULL or "" if you only want to delete isotope in header.

Definition at line 341 of file tacift.c.

347 {
348 if(h==NULL) return TPCERROR_FAIL;
349
350 /* Find and delete previous isotope(s) */
351 int i=0, start=0;
352 while(1) {
353 i=iftFindKey(h, "isotope", start);
354 if(i<0) break;
355 iftDelete(h, i); if(i>start) start=i;
356 }
357
358 /* If new isotope is empty, then just return */
359 if(s==NULL || *s=='\0') return(TPCERROR_OK);
360
361 /* Otherwise create new key and value */
362 return (iftPut(h, "isotope", s, (char)1, NULL));
363}

Referenced by tacReadSIF(), and tacSetIsotope().

◆ tacSetHeaderScanstarttime()

int tacSetHeaderScanstarttime ( IFT * h,
const char * s )

Set scan start time in TAC structure header. Any previous scan start items are deleted.

Returns
enum tpcerror (TPCERROR_OK when successful).
See also
tacGetHeaderScanstarttime, tacSetHeaderInjectiontime, tacDecayCorrection, tacSetHeaderIsotope
Author
Vesa Oikonen
Parameters
hPointer to TAC header structure.
sPointer to string containing the scan start time in international format YYYY-MM-DD hh:mm:ss ; enter NULL or "" if you only want to delete it in header.

Definition at line 427 of file tacift.c.

433 {
434 if(h==NULL) return TPCERROR_FAIL;
435
436 /* Find and delete previous scan start time(s) */
437 int i=0, start=0;
438 while(1) {
439 i=iftFindKey(h, "scan_start_time", start);
440 if(i<0) i=iftFindKey(h, "scan start time", start);
441 if(i<0) i=iftFindKey(h, "scan_start", start);
442 if(i<0) i=iftFindKey(h, "scan start", start);
443 if(i<0) i=iftFindKey(h, "scantime", start);
444 if(i<0) break;
445 iftDelete(h, i); if(i>start) start=i;
446 }
447
448 /* If new scan start time is empty, then just return */
449 if(s==NULL || *s=='\0') return(TPCERROR_OK);
450
451 /* Otherwise create new key and value */
452 return (iftPut(h, "scan_start_time", s, (char)1, NULL));
453}

Referenced by imgToSIF(), tacReadAllogg(), tacReadGEMS(), tacReadOldAllogg(), tacReadScanditronics(), and tacReadSIF().

◆ tacSetHeaderStudynr()

int tacSetHeaderStudynr ( IFT * h,
const char * s )

Set study number in TAC struct header. Any previous studynr items are deleted.

Returns
enum tpcerror (TPCERROR_OK when successful).
Author
Vesa Oikonen
See also
tacGetHeaderStudyNr, parSetStudyNr, studynrFromFilename
Parameters
hPointer to TAC header struct
sPointer to string containing the study number; enter NULL or "" if you only want to delete studynr in header

Definition at line 79 of file tacift.c.

85 {
86 if(h==NULL) return TPCERROR_FAIL;
87
88 /* Find and delete previous studynr(s) */
89 int i=0, start=0;
90 while(1) {
91 i=iftFindKey(h, "studynr", start);
92 if(i<0) i=iftFindKey(h, "study_number", start);
93 if(i<0) i=iftFindKey(h, "study number", start);
94 if(i<0) break;
95 iftDelete(h, i); if(i>start) start=i;
96 }
97
98 /* If new studynr is empty, then just return */
99 if(s==NULL || *s=='\0') return(TPCERROR_OK);
100
101 /* Otherwise create new key and value */
102 return (iftPut(h, "studynr", s, (char)1, NULL));
103}

Referenced by imgToSIF(), tacRead(), tacReadAllogg(), tacReadCSV(), tacReadDFT(), tacReadGEMS(), tacReadMat(), tacReadScanditronics(), tacReadSIF(), and tacWriteDFT().

◆ tacSetHeaderTimeunit()

int tacSetHeaderTimeunit ( IFT * h,
int u )

Set time (x) unit in TAC struct header. Any previous x units are deleted.

Returns
enum tpcerror (TPCERROR_OK when successful).
Author
Vesa Oikonen
Parameters
hPointer to TAC header struct
uUnit enum

Definition at line 201 of file tacift.c.

206 {
207 if(h==NULL) return TPCERROR_FAIL;
208
209 /* Find and delete previous time unit(s) */
210 int i=0, start=0;
211 while(1) {
212 i=iftFindKey(h, "timeunit", start);
213 if(i<0) i=iftFindKey(h, "time_unit", start);
214 if(i<0) i=iftFindKey(h, "time unit", start);
215 if(i<0) i=iftFindKey(h, "time units", start);
216 if(i<0) break;
217 iftDelete(h, i); if(i>start) start=i;
218 }
219
220 /* If new unit is unknown, then just return */
221 if(u<=UNIT_UNKNOWN || u>=UNIT_LAST) return(TPCERROR_OK);
222
223 /* Otherwise create new key and value */
224 return (iftPut(h, "timeunit", unitName(u), (char)1, NULL));
225}
@ UNIT_LAST
end of list
char * unitName(int unit_code)
Definition units.c:143

Referenced by tacGetHeaderTimeunit(), tacReadCSV(), tacReadDFT(), and tacReadPMOD().

◆ tacSetHeaderUnit()

int tacSetHeaderUnit ( IFT * h,
int u )

Set concentration (y) unit in TAC struct header. Any previous y unit items are deleted.

Returns
enum tpcerror (TPCERROR_OK when successful).
Author
Vesa Oikonen
Parameters
hPointer to TAC header struct
uUnit enum

Definition at line 112 of file tacift.c.

117 {
118 if(h==NULL) return TPCERROR_FAIL;
119
120 /* Find and delete previous unit(s) */
121 int i=0, start=0;
122 while(1) {
123 i=iftFindKey(h, "unit", start);
124 if(i<0) i=iftFindKey(h, "calibration_unit", start);
125 if(i<0) i=iftFindKey(h, "activity_units", start);
126 if(i<0) i=iftFindKey(h, "activity units", start);
127 if(i<0) break;
128 iftDelete(h, i); if(i>start) start=i;
129 }
130
131 /* If new unit is unknown, then just return */
132 if(u<=UNIT_UNKNOWN || u>=UNIT_LAST) return(TPCERROR_OK);
133
134 /* Otherwise create new key and value */
135 return (iftPut(h, "unit", unitName(u), (char)1, NULL));
136}

Referenced by tacGetHeaderUnit(), tacReadCSV(), tacReadDFT(), tacReadPMOD(), and tacWriteDFT().