Create a vector thdnm from THD calculation, e.g. thd11

New vector fournosave: if set, suppress creation of
vectors thd11 and fourier, usefull when writing a raw file.
This commit is contained in:
Holger Vogt 2025-03-10 12:53:40 +01:00
parent 83d3890490
commit 16fbe0fb8b
1 changed files with 41 additions and 24 deletions

View File

@ -50,6 +50,7 @@ fourier(wordlist *wl, struct plot *current_plot)
char xbuf[20];
int shift;
int rv = 1;
bool foursave = TRUE;
struct dvec *n;
int newveccount = 1;
@ -71,6 +72,8 @@ fourier(wordlist *wl, struct plot *current_plot)
polydegree = 1;
if (!cp_getvar("fourgridsize", CP_NUM, &fourgridsize, 0) || fourgridsize < 1)
fourgridsize = DEF_FOURGRIDSIZE;
if (cp_getvar("fournosave", CP_BOOL, NULL, 0))
foursave = FALSE;
time = current_plot->pl_scale;
if (!isreal(time)) {
@ -188,6 +191,19 @@ fourier(wordlist *wl, struct plot *current_plot)
}
fputs("\n", cp_out);
if (foursave) {
/* create a vector for THD */
n = dvec_alloc(tprintf("thd%d%d", callstof, newveccount),
SV_NOTYPE,
VF_REAL | VF_PERMANENT,
1, NULL);
n->v_numdims = 1;
vec_new(n);
n->v_realdata[0] = thd;
/* create and assign a new vector n */
/* with size 3 * nfreqs in current plot */
/* generate name for new vector, using vec->name */
@ -218,6 +234,7 @@ fourier(wordlist *wl, struct plot *current_plot)
data = NULL;
}
}
}
callstof++;
rv = 0;