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

Write linear plot data and fitted lines in HTML tables or SVG plots. More...

#include "libtpcmodext.h"

Go to the source code of this file.

Functions

int plot_svg (DFT *dft, RES *res, int first, int last, char *main_title, char *x_title, char *y_title, int color_scale, char *fname, int verbose)
 
int plotdata (DFT *dft, RES *res, int first, int last, char *mtitle, char *xtitle, char *ytitle, char *fname)
 
int plotdata_as_dft (DFT *dft, char *fname)
 

Detailed Description

Write linear plot data and fitted lines in HTML tables or SVG plots.

Author
Vesa Oikonen

Definition in file plotdata.c.

Function Documentation

◆ plot_svg()

int plot_svg ( DFT * dft,
RES * res,
int first,
int last,
char * main_title,
char * x_title,
char * y_title,
int color_scale,
char * fname,
int verbose )

Writes graphical analysis plots in SVG 1.1 format. Assumes that line slope and ic are in res->parameter[0] and [1].

Returns
Returns 0 if successful, otherwise nonzero.
See also
plot_fit_svg, plot_fitrange_svg
Parameters
dftPlot points: X in y2, Y in y3.
resResults containing parameters of line.
firstFirst sample (starting from 0) used in linear fit.
lastlast sample (starting from 0) used in linear fit.
main_titleString for plot main title, or NULL.
x_titleString for X axis title, or NULL.
y_titleString for Y axis title, or NULL.
color_scaleColour-scale: 0=colour, 2=black-and-white.
fnameFile name for SVG; existing file is renamed as *.bak.
verboseVerbose level; if zero, then nothing is printed to stderr or stdout.

Definition at line 17 of file plotdata.c.

38 {
39 int n, ri, fi, ret;
40 char tac_id[32], tac_title[64];
41 double maxPlotX=0, maxy;
42 double px[2], py[2];
43 struct svg_viewports viewports; svg_init_viewports(&viewports);
44 int max_color_nr, color_nr;
45 int max_symbol_nr, symbol_nr;
46 SVG_LEGENDS legends; svg_init_legends(&legends);
47 FILE *fp_svg=NULL;
48
49 if(verbose>0) {
50 printf("%s(dft, res, %d, %d, mt, xt, yt, fn, cs, %d)\n", __func__, first, last, verbose);
51 }
52
53 /* Check data */
54 if(dft==NULL || dft->voiNr<1) return(1);
55 if(res==NULL || res->voiNr!=dft->voiNr) return(1);
56 if(first>last) return(1);
57
58 int is_label=0; if(dft->voiNr>1) is_label=1;
59 if(color_scale!=0 && color_scale!=2) color_scale=0;
60
61 /* Check if file exists; backup, if necessary */
62 backupExistingFile(fname, NULL, NULL);
63
64 /* Search the largest plot x-value to be used as line end point */
65 for(ri=0; ri<dft->voiNr; ri++) for(fi=0; fi<dft->frameNr; fi++)
66 if(dft->voi[ri].y2[fi]>maxPlotX) maxPlotX=dft->voi[ri].y2[fi];
67 /* Get maxy */
68 maxy=0.0;
69 for(ri=0; ri<dft->voiNr; ri++) for(fi=0; fi<dft->frameNr; fi++)
70 if(dft->voi[ri].y3[fi]>maxy) maxy=dft->voi[ri].y3[fi];
71
72 /* Calculate the axis ticks */
73 viewports.label_area_viewport.is=is_label; // needed for x axis ticks
74 viewports.x.fixed_min=0; viewports.y.fixed_min=0;
75 viewports.x.min=0.0; viewports.x.max=maxPlotX;
76 viewports.y.min=0.0; viewports.y.max=maxy;
77 ret=svg_calculate_axes(&viewports, verbose-3);
78 if(ret) return(2);
79
80 /* Set the plot window and window area sizes */
81 ret=svg_define_viewports(0, 0, strlen(main_title), strlen(y_title),
82 strlen(x_title), is_label, &viewports, verbose-3);
83 if(ret) return(3);
84
85 /* Initiate graphics file */
86 fp_svg=svg_initiate(fname, 0, 0, &viewports, NULL, verbose-3);
87 if(fp_svg==NULL) return(4);
88
89 /* Put the graph titles into their own viewports */
90 ret=svg_create_main_title(fp_svg, main_title, "", &viewports, NULL,verbose-3);
91 if(ret) return(5);
92 ret=svg_create_yaxis_title(fp_svg, y_title, &viewports, NULL, verbose-3);
93 if(ret) return(6);
94 ret=svg_create_xaxis_title(fp_svg, x_title, &viewports, NULL, verbose-3);
95 if(ret) return(7);
96
97 /* Put the plot into its own viewport */
98 ret=svg_start_plot_viewport(fp_svg, &viewports, NULL, verbose-3);
99 if(ret) return(8);
100
101 /* Start coordinate area viewport */
102 ret=svg_start_coordinate_viewport(fp_svg, &viewports, NULL, verbose-3);
103 if(ret) return(9);
104
105 /* Write plot axes */
106 ret=svg_write_axes(fp_svg, &viewports, NULL, verbose-3);
107 if(ret) return(10);
108
109 /*
110 * Draw the plots
111 */
112 int symbol_fill=SYMBOLFILLED;
113 if(color_scale==2) { // black-and-white
114 symbol_fill=SYMBOLOPEN;
115 max_color_nr=1;
116 } else { // colour
117 max_color_nr=0; while(svgColorName(max_color_nr)!=NULL) max_color_nr++;
118 }
119 if(max_color_nr==0) max_color_nr=1; // remainder works only if 2nd operator>0
120 if(verbose>3) printf("max_color_nr := %d\n", max_color_nr);
121 max_symbol_nr=0; while(svgSymbolName(max_symbol_nr)!=NULL) max_symbol_nr++;
122 if(max_symbol_nr==0) max_symbol_nr=1; // remainder works only if 2nd operator>0
123 if(verbose>3) printf("max_symbol_nr := %d\n", max_symbol_nr);
124 if(dft->voiNr==1) color_nr=0; else color_nr=1;
125 symbol_nr=0;
126 for(ri=0, n=0; ri<dft->voiNr; ri++) {
127 sprintf(tac_id, "plot_%d", n);
128 //printf("ri=%d color_nr=%d symbol_nr=%d\n", ri, color_nr, symbol_nr);
129/*
130 if(strlen(dft->studynr)>0 && strcmp(dft->studynr, ".")!=0)
131 sprintf(tac_title, "%s: %s", dft->studynr, dft->voi[ri].name);
132 else strcpy(tac_title, dft->voi[ri].name);
133*/
134 rnameRmDots(dft->voi[ri].name, tac_title);
135 /*printf("tac_title := %s ; color := %s ; symbol := %d\n",
136 tac_title, svgcolor[color_nr%max_color_nr], symbol_nr%(max_symbol_nr+1));*/
137 /* Draw symbols */
138 if(dft->frameNr<150) {
139 /* plot symbols only if less than 150 samples */
140 ret=svg_write_tac(fp_svg, &viewports, 2, tac_id, tac_title,
141 dft->voi[ri].y2, dft->voi[ri].y3, dft->frameNr,
142 svgColorName(color_nr%max_color_nr), symbol_nr%max_symbol_nr, symbol_fill,
143 NULL, verbose-3);
144 } else {
145 /* plot samples as line if 150 samples or more */
146 ret=svg_write_tac(fp_svg, &viewports, 1, tac_id, tac_title,
147 dft->voi[ri].y2, dft->voi[ri].y3, dft->frameNr,
148 svgColorName(color_nr%max_color_nr), symbol_nr%max_symbol_nr, symbol_fill,
149 NULL, verbose-3);
150 }
151 if(ret) {svg_legend_empty(&legends); return(21);}
152 /* Draw the line */
153 px[0]=0.0; py[0]=res->voi[ri].parameter[1];
154 px[1]=maxPlotX;
155 py[1]=maxPlotX*res->voi[ri].parameter[0]+res->voi[ri].parameter[1];
156 sprintf(tac_id, "line_%d", n);
157 ret=svg_write_tac(fp_svg, &viewports, 1, tac_id, tac_title,
158 px, py, 2,
159 svgColorName(color_nr%max_color_nr), symbol_nr%max_symbol_nr, symbol_fill,
160 NULL, verbose-3);
161 if(ret) {svg_legend_empty(&legends); return(22);}
162 /* Set legend too, if requested */
163 if(is_label!=0) {
164 svg_legend_add(&legends, 0, symbol_nr%max_symbol_nr, symbol_fill, color_nr%max_color_nr, tac_title);
165 }
166
167 /* Prepare for the next plot */
168 if(color_scale==0) {
169 color_nr++;
170 if(color_nr==max_color_nr) {symbol_nr++; color_nr=0;}
171 if(symbol_nr==max_symbol_nr) symbol_nr=0;
172 }
173 if(color_scale==2) {
174 symbol_nr++;
175 if(symbol_nr==max_symbol_nr) {
176 if(symbol_fill==SYMBOLOPEN) symbol_fill=SYMBOLFILLED; else symbol_fill=SYMBOLOPEN;
177 symbol_nr=0;
178 }
179 }
180 n++;
181 }
182
183 /* Close the coordinate viewport */
184 ret=svg_end_coordinate_viewport(fp_svg, NULL, verbose-3);
185 if(ret) {svg_legend_empty(&legends); return(91);}
186
187 /* Write the axis ticks */
188 if(svg_write_xticks(fp_svg, &viewports, NULL, verbose-3)!=0) {
189 svg_legend_empty(&legends); return(92);}
190 if(svg_write_yticks(fp_svg, &viewports, NULL, verbose-3)!=0) {
191 svg_legend_empty(&legends); return(93);}
192
193 /* Close the plot viewport */
194 ret=svg_end_plot_viewport(fp_svg, NULL, verbose-3);
195 if(ret) {svg_legend_empty(&legends); return(94);}
196
197 /* Make the plot legends into their own viewport */
198 if(viewports.label_area_viewport.is!=0) {
199 if(verbose>2) printf("creating plot legends\n");
200 ret=svg_create_legends(fp_svg, &viewports, &legends, NULL, verbose-3);
201 if(ret) {svg_legend_empty(&legends); return(95);}
202 }
203 svg_legend_empty(&legends);
204
205 /* Close the SVG file */
206 ret=svg_close(fp_svg, NULL, verbose-3); if(ret) return(101);
207 return(0);
208}
int backupExistingFile(char *filename, char *backup_ext, char *status)
Definition backup.c:14
int rnameRmDots(char *rname1, char *rname2)
Definition rname.c:99
void svg_legend_empty(SVG_LEGENDS *legends)
Definition svg_legend.c:26
int svg_write_xticks(FILE *fp, struct svg_viewports *vp, char *errmsg, int verbose)
Definition svg_plot.c:555
void svg_init_legends(SVG_LEGENDS *legends)
Definition svg_legend.c:14
int svg_create_xaxis_title(FILE *fp, const char *title_text, struct svg_viewports *vp, char *errmsg, int verbose)
Definition svg_title.c:126
char * svgColorName(const svgColor index)
Definition svg_defs.c:38
int svg_create_main_title(FILE *fp, const char *main_title_text, const char *sub_title_text, struct svg_viewports *vp, char *errmsg, int verbose)
Definition svg_title.c:17
int svg_legend_add(SVG_LEGENDS *legends, const int plot_type, const int symbol_type, const svgSymbolFill symbol_fill, const int color, const char *text)
Definition svg_legend.c:43
char * svgSymbolName(const svgSymbolType index)
Definition svg_defs.c:67
int svg_define_viewports(const int main_viewport_width, const int main_viewport_height, const int is_main_title, const int is_yaxis_title, const int is_xaxis_title, const int is_label_area, struct svg_viewports *vp, int verbose)
Definition svg_vport.c:65
int svg_end_plot_viewport(FILE *fp, char *errmsg, int verbose)
Definition svg_plot.c:238
int svg_start_coordinate_viewport(FILE *fp, struct svg_viewports *vp, char *errmsg, int verbose)
Definition svg_plot.c:276
int svg_create_legends(FILE *fp, struct svg_viewports *vp, SVG_LEGENDS *legends, char *errmsg, int verbose)
Definition svg_legend.c:76
void svg_init_viewports(struct svg_viewports *p)
Definition svg_vport.c:43
FILE * svg_initiate(const char *filename, const double height, const double width, struct svg_viewports *vp, char *errmsg, int verbose)
Definition svg_file.c:22
int svg_calculate_axes(struct svg_viewports *vp, int verbose)
Definition svg_plot.c:364
int svg_write_axes(FILE *fp, struct svg_viewports *vp, char *errmsg, int verbose)
Definition svg_plot.c:437
int svg_end_coordinate_viewport(FILE *fp, char *errmsg, int verbose)
Definition svg_plot.c:327
int svg_start_plot_viewport(FILE *fp, struct svg_viewports *vp, char *errmsg, int verbose)
Definition svg_plot.c:181
int svg_create_yaxis_title(FILE *fp, const char *title_text, struct svg_viewports *vp, char *errmsg, int verbose)
Definition svg_title.c:197
int svg_write_yticks(FILE *fp, struct svg_viewports *vp, char *errmsg, int verbose)
Definition svg_plot.c:655
int svg_write_tac(FILE *fp, struct svg_viewports *vp, const int plot_type, const char *tac_id, const char *tac_title, double *x, double *y, const int data_nr, const char *color, const svgSymbolType symbol_type, const svgSymbolFill symbol_fill, char *errmsg, int verbose)
Definition svg_plot.c:746
int svg_close(FILE *fp, char *errmsg, int verbose)
Definition svg_file.c:107
Voi * voi
int voiNr
int frameNr
int voiNr
ResVOI * voi
double parameter[MAX_RESPARAMS]
double * y2
char name[MAX_REGIONNAME_LEN+1]
double * y3

◆ plotdata()

int plotdata ( DFT * dft,
RES * res,
int first,
int last,
char * mtitle,
char * xtitle,
char * ytitle,
char * fname )

Write plot and line fit data in XHTML 1.1. Strict table format. Assumes that line slope and ic are in res->parameter[0] and [1].

Returns
Returns 0 if successful, otherwise non-zero.
See also
plotdata_as_dft
Parameters
dftPlot points: X in y2, Y in y3.
resResults containing parameters of line.
firstFirst sample (starting from 0) used in linear fit.
lastlast sample (starting from 0) used in linear fit.
mtitleString for plot main title, or NULL.
xtitleString for X axis title, or NULL.
ytitleString for Y axis title, or NULL.
fnameFilename for plot data; existing file is renamed as *%. If extension is .dft, plot data (excluding lines) is written in DFT format with x values as separate columns before corresponding y values.

Definition at line 217 of file plotdata.c.

236 {
237 int n, ri, row, fi;
238 char tmp[FILENAME_MAX], *cptr=NULL;
239 FILE *fp;
240 double maxPlotX=0, maxRegX=0, maxFitX=0, f;
241
242
243 /* Check data */
244 if(dft==NULL || dft->voiNr<1) return(1);
245 if(res==NULL || res->voiNr!=dft->voiNr) return(1);
246 if(first>last) return(1);
247
248 /* Get filename extension to determine output type */
249 cptr=strrchr(fname, '.');
250 if(cptr!=NULL && strcasecmp(cptr, ".DFT")==0) {
251 /* Write in DFT if required */
252 return(plotdata_as_dft(dft, fname));
253 }
254
255 /* Check if file exists; backup, if necessary */
256 backupExistingFile(fname, NULL, NULL);
257
258 /* Search the largest plot x-value to be used as line end point */
259 for(ri=0; ri<dft->voiNr; ri++) for(fi=0; fi<dft->frameNr; fi++)
260 if(dft->voi[ri].y2[fi]>maxPlotX) maxPlotX=dft->voi[ri].y2[fi];
261
262 /* Open output file */
263 if((fp = fopen(fname, "w")) == NULL) return(3);
264
265 /* Write XHTML doctype and head */
266// n=fprintf(fp, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"ht
267//tp://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n");
268 n=fprintf(fp, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"");
269 if(n<10) return(4);
270 n=fprintf(fp, " \"https://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n");
271 if(n<10) return(4);
272 n=fprintf(fp, "<html xmlns=\"https://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n\n");
273 if(n<20) return(4);
274 /* Write XHTML header */
275 n=fprintf(fp, "<head>\n"); if(n<6) return(4);
276 fprintf(fp, " <title>Graphical analysis plot</title>\n");
277// fprintf(fp, " <meta http-equiv=\"content-type\" cont
278//ent=\"text/html; charset=iso-8859-1\" />\n");
279 fprintf(fp, " <meta http-equiv=\"content-type\" content=\"text/html;");
280 fprintf(fp, " charset=iso-8859-1\" />\n");
281
282 fprintf(fp, " <meta http-equiv=\"content-language\" content=\"en-gb\" />\n");
283 fprintf(fp, " <meta name=\"ProgId\" content=\"Excel.Sheet\" />\n");
284/*
285 fprintf(fp, " <link rel=\"icon\" href=\"https://www.turkupetcentre.
286net/favicon.ico\" type=\"image/x-icon\" />\n");
287 fprintf(fp, " <link rel=\"shortcut icon\" href=\"https://www.turkupetcentre.
288net/favicon.ico\" type=\"image/x-icon\" />\n");
289*/
290 fprintf(fp, " <link rel=\"icon\" href=\"https://www.turkupetcentre.net/");
291 fprintf(fp, "favicon.ico\" type=\"image/x-icon\" />\n");
292 fprintf(fp, " <link rel=\"shortcut icon\" href=\"https://www.turkupet");
293 fprintf(fp, "centre.net/favicon.ico\" type=\"image/x-icon\" />\n");
294
295 fprintf(fp, " <style type=\"text/css\">\n");
296 fprintf(fp, " thead {background-color:#999999; color:black;}\n");
297/* fprintf(fp, " table {text-align:left; width:100%%;
298border-collapse:collapse; empty-cells:show;}\n");*/
299 fprintf(fp, " table {text-align:left; width:100%%;");
300 fprintf(fp, " border-collapse:collapse; empty-cells:show;}\n");
301
302 fprintf(fp, " td {border:1px solid black;}\n");
303 fprintf(fp, " <!--table\n");
304 fprintf(fp, " {mso-displayed-decimal-separator:\"\\.\";\n");
305 fprintf(fp, " mso-displayed-thousand-separator:\" \";}\n");
306 fprintf(fp, " -->\n");
307 fprintf(fp, " </style>\n");
308 fprintf(fp, "</head>\n");
309
310 /* Start writing the body of the HTML file */
311 fprintf(fp, "\n<body>\n");
312
313 /* Start the div for tables */
314 fprintf(fp, "\n<div id=\"tables\">\n");
315
316 /* Write information on the graphical analysis */
317 fprintf(fp, "<table>\n");
318 fprintf(fp, "<tbody>\n");
319 fprintf(fp, "<tr><th>Main title</th><th>%s</th></tr>\n", mtitle);
320 fprintf(fp, "<tr><th>X title</th><th>%s</th></tr>\n", xtitle);
321 fprintf(fp, "<tr><th>Y title</th><th>%s</th></tr>\n", ytitle);
322 if(ctime_r_int(&res->time, tmp))
323 fprintf(fp, "<tr><th>Date</th><th>%s</th></tr>\n", tmp);
324 fprintf(fp, "</tbody>\n");
325 fprintf(fp, "</table>\n");
326
327 /* Write the plots, each to their own table */
328 for(ri=0; ri<dft->voiNr; ri++) {
329 /* Search the largest regional plot x-value to be used as line end points */
330 for(fi=0, maxRegX=maxFitX=0; fi<dft->frameNr; fi++) {
331 if(dft->voi[ri].y2[fi]>maxRegX) maxRegX=dft->voi[ri].y2[fi];
332 if(fi>=first && fi<=last && dft->voi[ri].y2[fi]>maxFitX) maxFitX=dft->voi[ri].y2[fi];
333 }
334 /* Begin a new table */
335 fprintf(fp, "<table>\n");
336 /* Write the title row */
337 fprintf(fp, "<thead>\n");
338 fprintf(fp, "<tr><th>%s %s %s</th>", dft->voi[ri].voiname,
339 dft->voi[ri].hemisphere, dft->voi[ri].place);
340 fprintf(fp, "<th>symbol open</th><th>symbol filled</th><th>text</th>");
341 fprintf(fp, "<th>X</th><th>line</th>");
342 fprintf(fp, "</tr>\n");
343 fprintf(fp, "</thead>\n");
344 /* Write the plot rows */
345 fprintf(fp, "<tbody>\n");
346 row=0;
347 for(fi=0; fi<(dft->frameNr>2?dft->frameNr:2); fi++)
348 if(!isnan(dft->voi[ri].y2[fi]) && !isnan(dft->voi[ri].y3[fi]))
349 {
350 fprintf(fp, "<tr>");
351 if(fi<dft->frameNr) {
352 fprintf(fp, "<th>%g</th>", dft->voi[ri].y2[fi]); /* x-axis value */
353 fprintf(fp, "<th>%g</th>", dft->voi[ri].y3[fi]); /* y-axis value */
354 } else {
355 fprintf(fp, "<th> </th>");
356 fprintf(fp, "<th> </th>");
357 }
358 /* If included in the fit, y-axis value again */
359 if(fi>=first && fi<=last)
360 fprintf(fp, "<th>%g</th>", dft->voi[ri].y3[fi]);
361 else fprintf(fp, "<th></th>");
362 if(fi<dft->frameNr)
363 fprintf(fp, "<th>%g</th>", dft->x[fi]); /* Frame time as text */
364 else
365 fprintf(fp, "<th> </th>");
366 /* Line points */
367 if(row==0) { /* line start */
368 fprintf(fp, "<th>0</th>"); /* x-axis value */
369 fprintf(fp, "<th>%g</th>", res->voi[ri].parameter[1]); /* y-axis value */
370 } else if(row==1) { /* line point at the end of fitted range */
371 fprintf(fp, "<th>%g</th>", maxFitX); /* x-axis value */
372 f=maxFitX*res->voi[ri].parameter[0]+res->voi[ri].parameter[1];
373 fprintf(fp, "<th>%g</th>", f); /* y-axis value */
374 } else if(row==2) { /* line "mid" point at the end of regional data */
375 fprintf(fp, "<th>%g</th>", maxRegX); /* x-axis value */
376 f=maxRegX*res->voi[ri].parameter[0]+res->voi[ri].parameter[1];
377 fprintf(fp, "<th>%g</th>", f); /* y-axis value */
378 } else if(row==3) { /* line end point at the end of all plots */
379 fprintf(fp, "<th>%g</th>", maxPlotX); /* x-axis value */
380 f=maxPlotX*res->voi[ri].parameter[0]+res->voi[ri].parameter[1];
381 fprintf(fp, "<th>%g</th>", f); /* y-axis value */
382 }
383 fprintf(fp, "</tr>\n");
384 row++;
385 }
386 fprintf(fp, "</tbody>\n");
387
388 /* End the data table */
389 fprintf(fp, "</table>\n");
390
391 } /* next region plot */
392
393 /* End the div for tables */
394 fprintf(fp, "</div>\n");
395
396 /* Stop writing the body of the HTML file, and end the file */
397 n=fprintf(fp, "</body></html>\n");
398 if(n==0) return(4);
399
400 /* Close file */
401 fclose(fp);
402
403 return(0);
404}
char * ctime_r_int(const time_t *t, char *buf)
Convert calendard time t into a null-terminated string of the form YYYY-MM-DD hh:mm:ss,...
Definition datetime.c:110
int plotdata_as_dft(DFT *dft, char *fname)
Definition plotdata.c:412
double * x
time_t time
char voiname[MAX_REGIONSUBNAME_LEN+1]
char hemisphere[MAX_REGIONSUBNAME_LEN+1]
char place[MAX_REGIONSUBNAME_LEN+1]

◆ plotdata_as_dft()

int plotdata_as_dft ( DFT * dft,
char * fname )

Write plot data in DFT format with x values as separate columns before corresponding y values.

Returns
Returns 0 if successful, otherwise non-zero.
See also
plotdata
Parameters
dftPlot points: X in y2, Y in y3.
fnameFile name for plot data.

Definition at line 412 of file plotdata.c.

417 {
418 int ri, rj, fi, ret;
419 DFT plot;
420
421 /* Check input data */
422 if(dft==NULL || dft->voiNr<1) return(1);
423 /* Create the plot data */
424 dftInit(&plot);
425 ret=dftSetmem(&plot, dft->frameNr, 2*dft->voiNr); if(ret) return(ret);
426 ret=dftCopymainhdr(dft, &plot); if(ret) {dftEmpty(&plot); return(ret);}
427 for(ri=rj=0; ri<dft->voiNr; ri++) {
428 /* x */
429 strcpy(plot.voi[rj].voiname, "X");
430 strcpy(plot.voi[rj].name, plot.voi[rj].voiname);
431 for(fi=0; fi<dft->frameNr; fi++) plot.voi[rj].y[fi]=dft->voi[ri].y2[fi];
432 rj++;
433 /* y */
434 dftCopyvoihdr(dft, ri, &plot, rj);
435 for(fi=0; fi<dft->frameNr; fi++) plot.voi[rj].y[fi]=dft->voi[ri].y3[fi];
436 rj++;
437 }
438 for(fi=0; fi<dft->frameNr; fi++) {
439 plot.x[fi]=dft->x[fi]; plot.x1[fi]=dft->x1[fi]; plot.x2[fi]=dft->x2[fi];
440 }
441 plot.voiNr=2*dft->voiNr; plot.frameNr=dft->frameNr;
442 /* Save plot data */
443 strcpy(plot.comments, "");
444 ret=dftWrite(&plot, fname);
445 dftEmpty(&plot);
446 return(ret);
447}
int dftCopyvoihdr(DFT *dft1, int from, DFT *dft2, int to)
Definition dft.c:623
void dftInit(DFT *data)
Definition dft.c:38
int dftSetmem(DFT *data, int frameNr, int voiNr)
Definition dft.c:57
void dftEmpty(DFT *data)
Definition dft.c:20
int dftCopymainhdr(DFT *dft1, DFT *dft2)
Definition dft.c:561
int dftWrite(DFT *data, char *filename)
Definition dftio.c:594
double * x1
char comments[_DFT_COMMENT_LEN+1]
double * x2
double * y

Referenced by plotdata().