TPCCLIB
Loading...
Searching...
No Matches
mtga.c
Go to the documentation of this file.
1
5/*****************************************************************************/
6#include "libtpcmodel.h"
7/*****************************************************************************/
8
9/*****************************************************************************/
24 int data_nr,
26 double *i,
29 double *ii,
31 double *c,
34 double *x,
37 double *y
38) {
39 int fi, plot_nr=0;
40 double divider_limit=1.0E-12;
41
42 if(data_nr<0 || i==NULL || ii==NULL || c==NULL || x==NULL || y==NULL)
43 return -1;
44 for(fi=0; fi<data_nr; fi++) {
45 // check that all measured data is available
46 if(isnan(i[fi]) || isnan(ii[fi]) || isnan(c[fi])) continue;
47 if(!(i[fi]>-1.0E+20 && i[fi]<+1.0E+20)) continue;
48 if(!(ii[fi]>-1.0E+20 && ii[fi]<+1.0E+20)) continue;
49 if(!(c[fi]>-1.0E+20 && c[fi]<+1.0E+20)) continue;
50 // check that integral has been >=0 all the time
51 if(ii[fi]<0.0) {plot_nr=0; continue;}
52 // check that dividers are not too close to zero
53 if(fabs(i[fi])<divider_limit) continue;
54 // calculate plot x axis value
55 x[plot_nr]=ii[fi]/i[fi];
56 if(!(x[plot_nr]>-1.0E+20 && x[plot_nr]<+1.0E+20)) continue;
57 if(x[plot_nr]<0.0) continue;
58 // calculate plot y axis value
59 y[plot_nr]=c[fi]/i[fi];
60 if(!(y[plot_nr]>-1.0E+20 && y[plot_nr]<+1.0E+20)) continue;
61 // so this plot data point is fine
62 plot_nr++;
63 }
64 return(plot_nr);
65}
66/*****************************************************************************/
67
68/*****************************************************************************/
83 int data_nr,
85 double *i,
88 double *ii,
90 double *c,
92 double *ci,
94 double k2,
96 double *x,
98 double *y
99) {
100 int fi, plot_nr=0;
101 double divider_limit=1.0E-18;
102
103 if(data_nr<0 || i==NULL || ii==NULL || c==NULL || ci==NULL) return -1;
104 if(x==NULL || y==NULL) return -1;
105
106 for(fi=0; fi<data_nr; fi++) {
107 // check that all measured data is available
108 if(isnan(i[fi]) || isnan(ii[fi]) || isnan(c[fi]) || isnan(ci[fi])) continue;
109 if(!(i[fi]>-1.0E+30 && i[fi]<+1.0E+30)) continue;
110 if(!(ii[fi]>-1.0E+30 && ii[fi]<+1.0E+30)) continue;
111 if(!(c[fi]>-1.0E+30 && c[fi]<+1.0E+30)) continue;
112 if(!(ci[fi]>-1.0E+30 && ci[fi]<+1.0E+30)) continue;
113 // check that integrals have been >=0 all the time
114 if(ii[fi]<0.0) {plot_nr=0; continue;}
115 if(ci[fi]<0.0) {plot_nr=0; continue;}
116 // check that dividers are not too close to zero
117 if(fabs(c[fi])<divider_limit) continue;
118 // calculate plot x axis value
119 if(k2>0.0) x[plot_nr]=(ii[fi]+i[fi]/k2)/c[fi];
120 else x[plot_nr]=ii[fi]/c[fi];
121 if(!(x[plot_nr]>-1.0E+30 && x[plot_nr]<+1.0E+30)) continue;
122 // calculate plot y axis value
123 y[plot_nr]=ci[fi]/c[fi];
124 if(!(y[plot_nr]>-1.0E+30 && y[plot_nr]<+1.0E+30)) continue;
125 // so this plot data point is fine
126 plot_nr++;
127 }
128 return(plot_nr);
129}
130/*****************************************************************************/
131
132/*****************************************************************************/
143 double *x,
145 double *y,
147 int nr,
149 double *slope,
151 double *ic,
153 double *ssd,
155 int *fnr
156) {
157 int from, to, ret, from_min, to_min;
158 double lic, lslope, lssd, ssd_min;
159
160 /* Search the plot range that gives the lowest ssd */
161 ssd_min=9.99E+99; from_min=to_min=-1;
162 for(from=0, to=nr-1; ((to-from)+1)>=MTGA_BEST_MIN_NR; from++) {
163 ret=llsqperp(x+from, y+from, (to-from)+1, &lslope, &lic, &lssd);
164 if(ret==0 && lssd<ssd_min) {
165 ssd_min=lssd; from_min=from; to_min=to;
166 *slope=lslope; *ic=lic; if(ssd!=NULL) *ssd=lssd;
167 }
168 }
169 if(from_min<0) {
170 if(fnr!=NULL) *fnr=0;
171 if(ssd!=NULL) *ssd=0.0;
172 return(5);
173 }
174 if(fnr!=NULL) *fnr=(to_min-from_min)+1;
175 return(0);
176}
177/*****************************************************************************/
178
179/*****************************************************************************/
Header file for libtpcmodel.
int llsqperp(double *x, double *y, int nr, double *slope, double *ic, double *ssd)
Definition llsqwt.c:382
#define MTGA_BEST_MIN_NR
int patlak_data(int data_nr, double *i, double *ii, double *c, double *x, double *y)
Definition mtga.c:22
int mtga_best_perp(double *x, double *y, int nr, double *slope, double *ic, double *ssd, int *fnr)
Definition mtga.c:141
int logan_data(int data_nr, double *i, double *ii, double *c, double *ci, double k2, double *x, double *y)
Definition mtga.c:81