diff options
author | Keith Packard <keithp@keithp.com> | 2009-09-06 20:26:17 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-09-06 20:26:17 -0700 |
commit | 932f1539b38567e565fd484171c13539b1467308 (patch) | |
tree | 485485df3cef45614c861da39b987bedb0aec190 /ao-tools/lib/cc-integrate.c | |
parent | 9177f5f4e9d832558ddd9ab227c4511f6201e7e5 (diff) |
Color plots, integrate only flight portion of data.
Telemetry files have piles of pad data which shouldn't be integrated
into the velocity data as it tends to generate huge values from the
noise of the sensor.
Also make the data lines colored to keep them visually distinct from
the rest of the plot image.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'ao-tools/lib/cc-integrate.c')
-rw-r--r-- | ao-tools/lib/cc-integrate.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/ao-tools/lib/cc-integrate.c b/ao-tools/lib/cc-integrate.c index f9793dcd..ba50761b 100644 --- a/ao-tools/lib/cc-integrate.c +++ b/ao-tools/lib/cc-integrate.c @@ -37,24 +37,27 @@ cc_timedata_convert(struct cc_timedata *d, double (*f)(double v, double a), doub } struct cc_timedata * -cc_timedata_integrate(struct cc_timedata *d) +cc_timedata_integrate(struct cc_timedata *d, double min_time, double max_time) { struct cc_timedata *i; - int n; + int n, m; + int start, stop; + cc_timedata_limits(d, min_time, max_time, &start, &stop); i = calloc (1, sizeof (struct cc_timedata)); - i->num = d->num; - i->size = d->num; + i->num = stop - start + 1; + i->size = i->num; i->data = calloc (i->size, sizeof (struct cc_timedataelt)); - i->time_offset = d->time_offset; - for (n = 0; n < d->num; n++) { - i->data[n].time = d->data[n].time; + i->time_offset = d->data[start].time; + for (n = 0; n < i->num; n++) { + m = n + start; + i->data[n].time = d->data[m].time; if (n == 0) { i->data[n].value = 0; } else { i->data[n].value = i->data[n-1].value + - (d->data[n].value + d->data[n-1].value) / 2 * - ((d->data[n].time - d->data[n-1].time) / 100.0); + (d->data[m].value + d->data[m-1].value) / 2 * + ((d->data[m].time - d->data[m-1].time) / 100.0); } } return i; |