237 |
|
cp = fskip(cp); |
238 |
|
if (cp == NULL) |
239 |
|
break; |
240 |
< |
if (ntp[1] > 1 && sarr[ntp[1]+1] <= sarr[ntp[1]]) { |
240 |
> |
if (ntp[1] > 1 && sarr[ntp[1]+1] <= sarr[ntp[1]]+FTINY) { |
241 |
|
sprintf(errmsg, |
242 |
|
"Phi values not monotinically increasing in sensor file '%s'", |
243 |
|
sfile); |
263 |
|
cp = fskip(cp); |
264 |
|
if (cp == NULL) |
265 |
|
break; |
266 |
< |
if (i && sarr[i] < .0) { |
266 |
> |
if (sarr[i] < .0) { |
267 |
|
if (!warnedneg++) { |
268 |
|
sprintf(errmsg, |
269 |
|
"Negative value(s) in sensor file '%s' (ignored)\n", sfile); |
270 |
|
error(WARNING, errmsg); |
271 |
|
} |
272 |
|
sarr[i] = .0; |
273 |
< |
} else if (i > ntp[0]*(ntp[1]+1) && sarr[i] > FTINY) |
273 |
> |
} else if (sarr[i] > FTINY && i > ntp[0]*(ntp[1]+1)) |
274 |
|
last_pos_val = i; |
275 |
|
++i; |
276 |
|
} |
277 |
< |
if (i == ntp[0]*(ntp[1]+1)) |
277 |
> |
if (i == ntp[0]*(ntp[1]+1)) /* empty line? */ |
278 |
|
break; |
279 |
|
if (ntp[0] > 1 && sarr[ntp[0]*(ntp[1]+1)] <= |
280 |
|
sarr[(ntp[0]-1)*(ntp[1]+1)]) { |
297 |
|
errmsg[0] = '\0'; /* sanity checks */ |
298 |
|
if (!last_pos_val) |
299 |
|
sprintf(errmsg, "no positive sensor values in file '%s'", sfile); |
300 |
– |
if (ntp[0] <= 0) |
301 |
– |
sprintf(errmsg, "no data in sensor file '%s'", sfile); |
300 |
|
else if (fabs(sarr[ntp[1]+1]) > FTINY) |
301 |
|
sprintf(errmsg, "minimum theta must be 0 in sensor file '%s'", |
302 |
|
sfile); |
303 |
|
else if (fabs(sarr[1]) > FTINY) |
304 |
|
sprintf(errmsg, "minimum phi must be 0 in sensor file '%s'", |
305 |
|
sfile); |
306 |
< |
else if (sarr[ntp[1]] <= FTINY) |
306 |
> |
else if (sarr[ntp[1]] < 270.-FTINY) |
307 |
|
sprintf(errmsg, |
308 |
< |
"maximum phi must be positive in sensor file '%s'", |
308 |
> |
"maximum phi must be 270 or greater in sensor file '%s'", |
309 |
|
sfile); |
310 |
< |
else if (sarr[ntp[0]*(ntp[1]+1)] <= FTINY) |
310 |
> |
else if (sarr[ntp[1]] >= 360.-FTINY) |
311 |
|
sprintf(errmsg, |
312 |
< |
"maximum theta (%f) must be positive in sensor file '%s'", |
313 |
< |
sarr[ntp[0]*(ntp[1]+1)], sfile); |
312 |
> |
"maximum phi must be less than 360 in sensor file '%s'", |
313 |
> |
sfile); |
314 |
|
if (errmsg[0]) |
315 |
|
error(USER, errmsg); |
316 |
|
return((float *)realloc((void *)sarr, sizeof(float)*nelem)); |
370 |
|
psize = PI*tsize/maxtheta; |
371 |
|
if (sntp[0]*sntp[1] < samptot) /* don't overdo resolution */ |
372 |
|
samptot = sntp[0]*sntp[1]; |
373 |
< |
ntheta = (int)(sqrt((double)samptot*tsize/psize) + 0.5); |
373 |
> |
ntheta = (int)(sqrt((double)samptot*tsize/psize)*sntp[0]/sntp[1]) + 1; |
374 |
|
if (ntheta > MAXNT) |
375 |
|
ntheta = MAXNT; |
376 |
|
nphi = samptot/ntheta; |