TPCCLIB
Loading...
Searching...
No Matches
fit_xsur.c
Go to the documentation of this file.
1
8/*****************************************************************************/
9#include "tpcclibConfig.h"
10/*****************************************************************************/
11#include <stdio.h>
12#include <stdlib.h>
13#include <string.h>
14#include <math.h>
15/*****************************************************************************/
16#include "tpcextensions.h"
17#include "tpcift.h"
18#include "tpctac.h"
19#include "tpcpar.h"
20#include "tpcli.h"
21#include "tpccm.h"
22#include "tpctacmod.h"
23#include "tpclinopt.h"
24#include "tpcrand.h"
25#include "tpcnlopt.h"
26/*****************************************************************************/
27
28/*****************************************************************************/
29/* Local functions */
30double func_xsurge(int parNr, double *p, void*);
31/*****************************************************************************/
32typedef struct FITDATA {
34 unsigned int in;
36 double *ix;
38 double *iy;
40 double *kernel;
42 double *cy;
43
45 unsigned int n;
47 double *x;
49 double *y;
51 double *ysim;
53 double *w;
55 int verbose;
56} FITDATA;
57/*****************************************************************************/
58
59/*****************************************************************************/
60static char *info[] = {
61 "Non-linear fitting of the parameters of response function, convolved with",
62 "input TAC, to reproduce given output TAC:",
63 " output(t) = input(t) (x) h(t)",
64 "Response function is:",
65 " h(t) = a*t*exp(-b*t)*b^2",
66 ", where a is the integral of response function from zero to infinity.",
67 " ",
68 "Usage: @P [Options] inputfile outputfile [parfile]",
69 " ",
70 "Options:",
71 " -a=<value>",
72 " Constrain parameter a to specified value; fitted by default.",
73 " -amin=<value>",
74 " Minimum value for parameter a; by default 0.5.",
75 " -amax=<value>",
76 " Maximum value for parameter a; by default 1.0.",
77 " -w1",
78 " All weights are set to 1.0 (no weighting); by default, weights in",
79 " output data file are used, if available.",
80 " -wf",
81 " Weight by output TAC sampling interval.",
82 " -svg=<Filename>",
83 " Fitted and measured TACs are plotted in specified SVG file.",
84 " -i=<Interval>",
85 " Sample time interval (sec) in convolution; by default the shortest",
86 " interval in the input data; too long interval as compared to b leads",
87 " to bias.",
88 " -stdoptions", // List standard options like --help, -v, etc
89 " ",
90 "If TAC files contain more than one TAC, only the first is used.",
91 " ",
92 "See also: convsurg, convexpf, sim_av, fit_suri",
93 " ",
94 "Keywords: TAC, curve fitting, convolution",
95 0};
96/*****************************************************************************/
97
98/*****************************************************************************/
99/* Turn on the globbing of the command line, since it is disabled by default in
100 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
101 In Unix&Linux wildcard command line processing is enabled by default. */
102/*
103#undef _CRT_glob
104#define _CRT_glob -1
105*/
106int _dowildcard = -1;
107/*****************************************************************************/
108
109/*****************************************************************************/
113int main(int argc, char **argv)
114{
115 int ai, help=0, version=0, verbose=1;
116 char inpfile[FILENAME_MAX], outfile[FILENAME_MAX], parfile[FILENAME_MAX], svgfile[FILENAME_MAX];
117 int weights=0; // 0=default, 1=no weighting, 2=frequency
118 double amin=0.5, amax=1.0;
119 double interval=nan("");
120 int ret;
121
122
123 /*
124 * Get arguments
125 */
126 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
127 inpfile[0]=outfile[0]=parfile[0]=svgfile[0]=(char)0;
128 /* Options */
129 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
130 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
131 char *cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!*cptr) continue;
132 if(strcasecmp(cptr, "W1")==0) {
133 weights=1; continue;
134 } else if(strcasecmp(cptr, "WF")==0) {
135 weights=2; continue;
136 } else if(strncasecmp(cptr, "SVG=", 4)==0 && strlen(cptr)>4) {
137 strlcpy(svgfile, cptr+4, FILENAME_MAX); continue;
138 } else if(strncasecmp(cptr, "AMIN=", 5)==0) {
139 amin=atofVerified(cptr+5); if(amin>0.0) continue;
140 } else if(strncasecmp(cptr, "AMAX=", 5)==0) {
141 amax=atofVerified(cptr+5); if(amax>0.0) continue;
142 } else if(strncasecmp(cptr, "A=", 2)==0) {
143 amin=amax=atofVerified(cptr+2); if(amin>0.0) continue;
144 } else if(strncasecmp(cptr, "I=", 2)==0) {
145 interval=atofVerified(cptr+2); if(interval>0.0) continue;
146 }
147 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
148 return(1);
149 } else break;
150
151 TPCSTATUS status; statusInit(&status);
152 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
153 status.verbose=verbose-3;
154
155 /* Print help or version? */
156 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
157 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
158 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
159
160 /* Process other arguments, starting from the first non-option */
161 if(ai<argc) strlcpy(inpfile, argv[ai++], FILENAME_MAX);
162 if(ai<argc) strlcpy(outfile, argv[ai++], FILENAME_MAX);
163 if(ai<argc) strlcpy(parfile, argv[ai++], FILENAME_MAX);
164 if(ai<argc) {
165 fprintf(stderr, "Error: invalid argument '%s'.\n", argv[ai]);
166 return(1);
167 }
168 /* Did we get all the information that we need? */
169 if(!outfile[0]) { // note that parameter file is optional
170 fprintf(stderr, "Error: missing command-line argument; use option --help\n");
171 return(1);
172 }
173 /* Check parameters */
174 if(amin>amax) {
175 fprintf(stderr, "Error: invalid limits for a.\n");
176 return(1);
177 }
178
179 /* In verbose mode print arguments and options */
180 if(verbose>1) {
181 printf("inpfile := %s\n", inpfile);
182 printf("outfile := %s\n", outfile);
183 if(parfile[0]) printf("parfile := %s\n", parfile);
184 if(svgfile[0]) printf("svgfile := %s\n", svgfile);
185 printf("amin := %g\n", amin);
186 printf("amax := %g\n", amax);
187 printf("weights := %d\n", weights);
188 if(!isnan(interval)) printf("interval := %g\n", interval);
189 fflush(stdout);
190 }
191
192
193 /*
194 * Read input and output data
195 */
196 if(verbose>1) printf("reading TAC data\n");
197 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
198 TAC itac, otac; tacInit(&itac); tacInit(&otac);
199 int fitSampleNr;
200 double fitdur=1.0E+12;
201 ret=tacReadModelingData(outfile, inpfile, NULL, NULL, &fitdur, 0,
202 &fitSampleNr, &otac, &itac, &status);
203 if(ret!=TPCERROR_OK) {
204 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
205 tacFree(&itac); tacFree(&otac); return(2);
206 }
207 if(verbose>2) {
208 printf("fileformat := %s\n", tacFormattxt(itac.format));
209 printf("inp.sampleNr := %d\n", itac.sampleNr);
210 printf("out.sampleNr := %d\n", otac.sampleNr);
211 printf("fitSampleNr := %d\n", fitSampleNr);
212 printf("xunit := %s\n", unitName(itac.tunit));
213 printf("yunit := %s\n", unitName(itac.cunit));
214 printf("fitdur := %g s\n", fitdur);
215 }
216 if(fitSampleNr<4 || itac.sampleNr<4) {
217 fprintf(stderr, "Error: too few samples.\n");
218 tacFree(&itac); tacFree(&otac); return(2);
219 }
220 /* Set second output TAC to place fitted data into */
221 otac.tacNr=1;
222 ret=tacAllocateMore(&otac, 1);
223 if(ret!=TPCERROR_OK) {
224 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
225 tacFree(&itac); tacFree(&otac); return(2);
226 }
227 /* Check and set weights */
228 if(weights==0) {
229 if(!tacIsWeighted(&otac)) {
231 for(int i=0; i<otac.sampleNr; i++) otac.w[i]=1.0;
232 }
233 } else if(weights==1) {
235 for(int i=0; i<otac.sampleNr; i++) otac.w[i]=1.0;
236 } else if(weights==2) {
237 ret=tacWByFreq(&otac, ISOTOPE_UNKNOWN, &status);
238 if(ret!=TPCERROR_OK) {
239 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
240 tacFree(&itac); tacFree(&otac); return(2);
241 }
242 }
243
244 /* Sample times should now be in minutes; convert interval to minutes, too. */
245 if(interval>0.0) {
246 interval/=60.0;
247
248 if(interval>0.1*itac.x[itac.sampleNr-1]) {
249 fprintf(stderr, "Error: too long interval time.\n");
250 tacFree(&itac); tacFree(&otac); return(2);
251 }
252 if(interval>0.01*itac.x[itac.sampleNr-1]) {
253 if(verbose>0) fprintf(stderr, "Warning: interval time may be too long.\n");
254 }
255 }
256
257 /*
258 * Interpolate data with even sample intervals for convolution
259 */
260 TAC iitac; tacInit(&iitac);
261 if(tacInterpolateToEqualLengthFrames(&itac, interval, interval, &iitac, &status)!=TPCERROR_OK) {
262 fprintf(stderr, "Error: cannot interpolate data to even sample times.\n");
263 tacFree(&itac); tacFree(&otac); return(3);
264 }
265 /* Get the sample interval in interpolated data */
266 double freq=iitac.x2[0]-iitac.x1[0];
267 if(verbose>1) {
268 printf("sample_intervals_in_convolution := %g\n", freq);
269 printf("interpolated data range: %g - %g\n", iitac.x1[0], iitac.x2[itac.sampleNr-1]);
270 }
271
272
273 if(verbose>0) fprintf(stdout, "allocate memory for kernel...\n");
274 double *kernel=(double*)malloc(2*iitac.sampleNr*sizeof(double));
275 if(kernel==NULL) {
276 fprintf(stderr, "Error: out of memory.\n");
277 tacFree(&itac); tacFree(&otac); tacFree(&iitac); return(4);
278 }
279 double *cy=kernel+iitac.sampleNr;
280
281
282
283
284
285 /*
286 * Fitting
287 */
288 if(verbose>1) printf("preparing for fitting\n");
289
290 /* Set data pointers for the fit */
291 FITDATA fitdata;
292 fitdata.verbose=0;
293 fitdata.kernel=kernel;
294 fitdata.in=iitac.sampleNr;
295 fitdata.ix=iitac.x;
296 fitdata.iy=iitac.c[0].y;
297 fitdata.cy=cy;
298
299 fitdata.n=otac.sampleNr;
300 fitdata.x=otac.x;
301 fitdata.y=otac.c[0].y;
302 fitdata.ysim=otac.c[1].y;
303 fitdata.w=otac.w;
304
305
306
307 /* Set parameters for nonlinear optimization */
308 if(verbose>2) printf("process initial parameter values\n");
309 NLOPT nlo; nloptInit(&nlo);
310 ret=nloptAllocate(&nlo, 2); // a, b
311 if(ret!=TPCERROR_OK) {
312 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
313 tacFree(&itac); tacFree(&otac); tacFree(&iitac); return(5);
314 }
315 /* Set function */
316 nlo._fun=func_xsurge;
317 nlo.fundata=&fitdata;
318 nlo.totalNr=2;
319 {
320 nlo.xlower[0]=amin; nlo.xupper[0]=amax;
321 nlo.xlower[1]=1.0/itac.x[itac.sampleNr-1]; nlo.xupper[1]=1.0/freq;
322 for(unsigned int i=0; i<nlo.totalNr; i++) {
323 nlo.xfull[i]=0.5*(nlo.xlower[i]+nlo.xupper[i]);
324 nlo.xdelta[i]=0.05*(nlo.xupper[i]-nlo.xlower[i]);
325 nlo.xtol[i]=fabs(0.002*nlo.xdelta[i]);
326 }
327 }
328 nlo.maxFunCalls=5000;
329
330 /* Get nr of fixed parameters */
331 unsigned int fixedNr=nloptFixedNr(&nlo);
332 if(verbose>2) printf("fixedNr := %d\n", fixedNr);
333
334// call function for testing
335// func_xsurge(2, nlo.xfull, &fitdata);
336
337 drandSeed(1);
338
339 /* Fit */
340 if(verbose>4) nloptWrite(&nlo, stdout);
341 if(nloptIATGO(&nlo, 1, 0, 0.3, &status)!=TPCERROR_OK) {
342 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
343 tacFree(&itac); tacFree(&otac); tacFree(&iitac); nloptFree(&nlo); return(6);
344 }
345 nlo._fun(nlo.totalNr, nlo.xfull, nlo.fundata);
346 if(verbose>2) nloptWrite(&nlo, stdout);
347 if(verbose>0) {
348 printf("measured and fitted TAC:\n");
349 for(int i=0; i<otac.sampleNr; i++)
350 printf("\t%g\t%g\t%g\n", otac.x[i], otac.c[0].y[i], otac.c[1].y[i]);
351 }
352 if(verbose>2) printf(" wss := %g\n", nlo.funval);
353
354
355 /*
356 * Copy function parameters into PAR structure for printing and saving
357 */
358 PAR par; parInit(&par);
359 ret=parAllocateWithTAC(&par, &otac, nlo.totalNr, &status);
360 if(ret!=TPCERROR_OK) {
361 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
362 tacFree(&itac); tacFree(&otac); tacFree(&iitac); nloptFree(&nlo); return(7);
363 }
364 /* set time and program name */
365 {
366 char buf[256];
367 time_t t=time(NULL);
368 iftPut(&par.h, "analysis_time", ctime_r_int(&t, buf), 0, NULL);
369 tpcProgramName(argv[0], 1, 1, buf, 256);
370 iftPut(&par.h, "program", buf, 0, NULL);
371 }
372 par.tacNr=1; par.parNr=nlo.totalNr;
374 par.r[0].model=modelCodeIndex("surge");
375 par.r[0].dataNr=tacWSampleNr(&otac);
376 par.r[0].start=otac.x[0];
377 par.r[0].end=otac.x[otac.sampleNr-1];
378 par.r[0].wss=nlo.funval;
379 par.r[0].fitNr=nlo.totalNr-fixedNr;
380 /* Set parameter names and units */
381 for(int i=0; i<par.parNr; i+=2) {
382 sprintf(par.n[i].name, "a");
383 sprintf(par.n[i+1].name, "b");
384 par.n[i].unit=UNIT_UNITLESS;
385 par.n[i+1].unit=unitInverse(otac.tunit);
386 }
387 /* Set parameters */
388 par.r[0].p[0]=nlo.xfull[0];
389 par.r[0].p[1]=nlo.xfull[1];
390 /* Set TAC name if missing */
391 if(strlen(par.r[0].name)<1) strcpy(par.r[0].name, "1");
392 /* set file names */
393 iftPut(&par.h, "inputfile", inpfile, 0, NULL);
394 iftPut(&par.h, "datafile", outfile, 0, NULL);
395
396 /* Print and save */
397 if(verbose>0) parWrite(&par, stdout, PAR_FORMAT_TSV_UK, 1, NULL);
398 if(parfile[0]) {
399 /* Save file */
400 if(verbose>1) printf(" saving %s\n", parfile);
401 FILE *fp;
402 fp=fopen(parfile, "w");
403 if(fp==NULL) {
404 fprintf(stderr, "Error: cannot open file for writing.\n");
405 tacFree(&itac); tacFree(&otac); tacFree(&iitac); nloptFree(&nlo); parFree(&par); return(11);
406 }
407 ret=parWrite(&par, fp, PAR_FORMAT_TSV_UK, 1, &status);
408 fclose(fp);
409 if(ret!=TPCERROR_OK) {
410 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
411 tacFree(&itac); tacFree(&otac); tacFree(&iitac); nloptFree(&nlo); parFree(&par); return(12);
412 }
413 if(verbose>0) printf("parameters saved in %s\n", parfile);
414 }
415
416
417
418 /*
419 * Plot measured and fitted data, if requested
420 */
421 if(svgfile[0]) {
422 if(verbose>1) printf("plotting measured and fitted data\n");
423 for(unsigned int i=0; i<fitdata.in; i++) iitac.c[0].y[i]=fitdata.cy[i];
424 /* Plot */
425 ret=tacPlotFitSVG(&otac, &iitac, "", nan(""), nan(""), nan(""), nan(""), svgfile, &status);
426 if(ret!=TPCERROR_OK) {
427 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
428 tacFree(&itac); tacFree(&otac); tacFree(&iitac); nloptFree(&nlo); parFree(&par);
429 return(24);
430 }
431
432 if(verbose>0) printf("Measured and fitted data plotted in %s\n", svgfile);
433 }
434
435
436
437 nloptFree(&nlo); parFree(&par);
438 tacFree(&itac); tacFree(&otac); tacFree(&iitac);
439
440 return(0);
441}
442/*****************************************************************************/
443
444/*****************************************************************************
445 *
446 * Functions to be minimized
447 *
448 *****************************************************************************/
449double func_xsurge(int parNr, double *p, void *fdata)
450{
451 FITDATA *d=(FITDATA*)fdata;
452
453 if(d->verbose>0) {printf("%s()\n", __func__); fflush(stdout);}
454
455 /*
456 * Calculate the response function for convolution
457 */
458 if(d->verbose>1) {fprintf(stdout, "computing the kernel...\n"); fflush(stdout);}
459 double a=p[0], b=p[1];
460 if(d->verbose>2) printf("a=%g b=%g\n", a, b);
461 double ksum=0.0;
462 double freq=d->ix[1]-d->ix[0];
463 if(d->verbose>6) printf("\nData\tKernel:\n");
464 for(unsigned int i=0; i<d->in; i++) {
465 double t1=d->ix[i]-0.5*freq;
466 double t2=d->ix[i]+0.5*freq;
467 d->kernel[i] = a * ((1.0+b*t1)*exp(-b*t1) - (1.0+b*t2)*exp(-b*t2));
468 ksum+=d->kernel[i];
469 if(d->verbose>6) printf("%g\t%g\n", d->ix[i], d->kernel[i]);
470 }
471 if(d->verbose>2) printf("Sum of response function := %g\n", ksum);
472 if(!isnormal(ksum)) {
473 fprintf(stderr, "Error: invalid kernel contents.\n");
474 return(nan(""));
475 }
476
477 /*
478 * Convolution
479 */
480 if(d->verbose>1) {fprintf(stdout, "convolution...\n"); fflush(stdout);}
481 if(convolve1D(d->iy, d->in, d->kernel, d->in, d->cy)!=0) {
482 fprintf(stderr, "Error: cannot convolve the data.\n");
483 return(nan(""));
484 }
485 if(d->verbose>4) {
486 printf("\nData x\ty\tKernel\tConvolved\n");
487 for(unsigned int i=0; i<d->in; i++)
488 printf("%g\t%g\t%g\t%g\n", d->ix[i], d->iy[i], d->kernel[i], d->cy[i]);
489 }
490
491 /* Interpolate to output sample times */
492 if(d->verbose>1) {fprintf(stdout, "interpolation...\n"); fflush(stdout);}
493 if(liInterpolate(d->ix, d->cy, d->in, d->x, d->ysim, NULL, NULL, d->n, 0, 0, 0)!=0) {
494 fprintf(stderr, "Error: cannot interpolate.\n");
495 return(nan(""));
496 }
497 if(d->verbose>3) {
498 printf("\nData x\ty\tSimulated\n");
499 for(unsigned int i=0; i<d->n; i++)
500 printf("%g\t%g\t%g\n", d->x[i], d->y[i], d->ysim[i]);
501 }
502
503 /* Calculate the weighted SS */
504 if(d->verbose>1) {fprintf(stdout, "computing WSS...\n"); fflush(stdout);}
505 double wss=0.0;
506 for(unsigned i=0; i<d->n; i++) {
507 double v=d->ysim[i] - d->y[i];
508 wss+=d->w[i]*v*v;
509 }
510 if(d->verbose>1) {
511 for(int i=0; i<parNr; i++) printf(" %g", p[i]);
512 printf(" -> %g\n", wss);
513 }
514
515 return(wss);
516}
517/*****************************************************************************/
518
519/*****************************************************************************/
int convolve1D(double *data, const int n, double *kernel, const int m, double *out)
Calculates the convolution sum of a discrete real data set data[0..n-1] and a discretized response fu...
Definition convolut.c:27
char * ctime_r_int(const time_t *t, char *buf)
Convert calendar time t into a null-terminated string of the form YYYY-MM-DD hh:mm:ss,...
Definition datetime.c:119
double atofVerified(const char *s)
Definition decpoint.c:75
unsigned int drandSeed(short int seed)
Make and optionally set the seed for rand(), drand, drandRange, and drandGaussian().
Definition gaussdev.c:27
int iftPut(IFT *ift, const char *key, const char *value, char comment, TPCSTATUS *status)
Definition ift.c:63
int liInterpolate(double *x, double *y, const int nr, double *newx, double *newy, double *newyi, double *newyii, const int newnr, const int se, const int ee, const int verbose)
Linear interpolation and/or integration with trapezoidal method.
int tacInterpolateToEqualLengthFrames(TAC *inp, double minfdur, double maxfdur, TAC *tac, TPCSTATUS *status)
Definition lisim.c:214
unsigned int modelCodeIndex(const char *s)
Definition modell.c:237
void nloptInit(NLOPT *nlo)
Definition nlopt.c:25
int nloptAllocate(NLOPT *nlo, unsigned int parNr)
Definition nlopt.c:74
unsigned int nloptFixedNr(NLOPT *d)
Definition nlopt.c:354
void nloptFree(NLOPT *nlo)
Definition nlopt.c:52
void nloptWrite(NLOPT *d, FILE *fp)
Definition nlopt.c:302
void parFree(PAR *par)
Definition par.c:75
void parInit(PAR *par)
Definition par.c:25
int parWrite(PAR *par, FILE *fp, parformat format, int extra, TPCSTATUS *status)
Definition pario.c:148
int parAllocateWithTAC(PAR *par, TAC *tac, int parNr, TPCSTATUS *status)
Allocate PAR based on data in TAC.
Definition partac.c:90
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:47
void tpcProgramName(const char *program, int version, int copyright, char *prname, int n)
Definition proginfo.c:406
int tpcHtmlUsage(const char *program, char *text[], const char *path)
Definition proginfo.c:169
void tpcPrintBuild(const char *program, FILE *fp)
Definition proginfo.c:339
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
Definition proginfo.c:114
void statusInit(TPCSTATUS *s)
Definition statusmsg.c:104
char * errorMsg(tpcerror e)
Definition statusmsg.c:68
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
Definition statusmsg.c:142
size_t strlcpy(char *dst, const char *src, size_t dstsize)
Definition stringext.c:632
double(* _fun)(int, double *, void *)
Definition tpcnlopt.h:42
double funval
Definition tpcnlopt.h:50
unsigned int maxFunCalls
Definition tpcnlopt.h:46
double * xupper
Definition tpcnlopt.h:33
double * xlower
Definition tpcnlopt.h:31
void * fundata
Definition tpcnlopt.h:44
double * xfull
Definition tpcnlopt.h:29
double * xdelta
Definition tpcnlopt.h:36
double * xtol
Definition tpcnlopt.h:39
unsigned int totalNr
Definition tpcnlopt.h:27
Definition tpcpar.h:100
int format
Definition tpcpar.h:102
IFT h
Optional (but often useful) header information.
Definition tpcpar.h:147
int parNr
Definition tpcpar.h:108
int tacNr
Definition tpcpar.h:104
PARR * r
Definition tpcpar.h:114
PARN * n
Definition tpcpar.h:112
int unit
Definition tpcpar.h:86
char name[MAX_PARNAME_LEN+1]
Definition tpcpar.h:82
double wss
Definition tpcpar.h:72
int fitNr
Definition tpcpar.h:58
char name[MAX_TACNAME_LEN+1]
Definition tpcpar.h:50
int dataNr
Definition tpcpar.h:62
unsigned int model
Definition tpcpar.h:48
double * p
Definition tpcpar.h:64
double start
Definition tpcpar.h:52
double end
Definition tpcpar.h:54
double * y
Definition tpctac.h:75
Definition tpctac.h:87
double * x
Definition tpctac.h:97
unit cunit
Definition tpctac.h:105
tacformat format
Definition tpctac.h:93
int sampleNr
Definition tpctac.h:89
double * w
Definition tpctac.h:111
TACC * c
Definition tpctac.h:117
weights weighting
Definition tpctac.h:115
double * x2
Definition tpctac.h:101
unit tunit
Definition tpctac.h:109
double * x1
Definition tpctac.h:99
int tacNr
Definition tpctac.h:91
int verbose
Verbose level, used by statusPrint() etc.
tpcerror error
Error code.
void tacFree(TAC *tac)
Definition tac.c:106
void tacInit(TAC *tac)
Definition tac.c:24
int tacAllocateMore(TAC *tac, int tacNr)
Definition tac.c:178
int tacPlotFitSVG(TAC *tac1, TAC *tac2, const char *main_title, const double x1, const double x2, const double y1, const double y2, const char *fname, TPCSTATUS *status)
Definition tacfitplot.c:27
char * tacFormattxt(tacformat c)
Definition tacio.c:98
int tacReadModelingData(const char *tissuefile, const char *inputfile1, const char *inputfile2, const char *inputfile3, double *fitdur, int cutInput, int *fitSampleNr, TAC *tis, TAC *inp, TPCSTATUS *status)
Read tissue and input data for modelling.
int tacIsWeighted(TAC *tac)
Definition tacw.c:24
unsigned int tacWSampleNr(TAC *tac)
Definition tacw.c:219
int tacWByFreq(TAC *tac, isotope isot, TPCSTATUS *status)
Definition tacw.c:134
int nloptIATGO(NLOPT *nlo, const int doLocal, unsigned int maxIterNr, double neighFract, TPCSTATUS *status)
Definition tgo.c:681
Header file for libtpccm.
Header file for library libtpcextensions.
weights
Is data weighted, or are weight factors available with data?
@ WEIGHTING_OFF
Not weighted or weights not available (weights for all included samples are 1.0).
@ UNIT_UNITLESS
Unitless.
int unitInverse(int u)
Definition units.c:654
@ TPCERROR_OK
No error.
char * unitName(int unit_code)
Definition units.c:143
Header file for library libtpcift.
@ ISOTOPE_UNKNOWN
Unknown.
Definition tpcisotope.h:51
Header file for libtpcli.
Header file for libtpclinopt.
Header file for library libtpcnlopt.
Header file for libtpcpar.
@ PAR_FORMAT_TSV_UK
UK TSV (point as decimal separator).
Definition tpcpar.h:35
Header file for libtpcrand.
Header file for library libtpctac.
Header file for libtpctacmod.