Skip to content

Commit

Permalink
spgram/autotest: writing unique filenames to logging directory
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaeddert committed Oct 24, 2023
1 parent 27df99e commit 75fbee3
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/fft/tests/spgram_autotest.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007 - 2022 Joseph Gaeddert
* Copyright (c) 2007 - 2023 Joseph Gaeddert
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -35,8 +35,10 @@ void testbench_spgramcf_noise(unsigned int _nfft,
unsigned int num_samples = 2000*_nfft; // number of samples to generate
float nstd = powf(10.0f,_noise_floor/20.0f); // noise std. dev.
float tol = 0.5f; // error tolerance [dB]
if (liquid_autotest_verbose)
printf(" spgramcf test (noise): nfft=%6u, wtype=%24s, noise floor=%6.1f\n", _nfft, liquid_window_str[_wtype][1], _noise_floor);
if (liquid_autotest_verbose) {
printf(" spgramcf test (noise): nfft=%6u, wtype=%24s, noise floor=%6.1f\n",
_nfft, liquid_window_str[_wtype][1], _noise_floor);
}

// create spectral periodogram
spgramcf q = NULL;
Expand Down Expand Up @@ -92,8 +94,10 @@ void testbench_spgramcf_signal(unsigned int _nfft, int _wtype, float _fc, float
float bw = 0.25f; // signal bandwidth (relative)
unsigned int m = 25;
float beta = 0.2f, n0 = -80.0f, tol = 0.5f;
if (liquid_autotest_verbose)
printf(" spgramcf test (signal): nfft=%6u, wtype=%24s, fc=%6.2f Fs, snr=%6.1f dB\n", _nfft, liquid_window_str[_wtype][1], _fc, _SNRdB);
if (liquid_autotest_verbose) {
printf(" spgramcf test (signal): nfft=%6u, wtype=%24s, fc=%6.2f Fs, snr=%6.1f dB\n",
_nfft, liquid_window_str[_wtype][1], _fc, _SNRdB);
}

// create objects
spgramcf q = spgramcf_create(_nfft, _wtype, _nfft/2, _nfft/4);
Expand Down Expand Up @@ -131,8 +135,13 @@ void testbench_spgramcf_signal(unsigned int _nfft, int _wtype, float _fc, float
{.fmin=_fc-0.4f*bw, .fmax=_fc+0.4f*bw, .pmin=sn-tol, .pmax=sn+tol, .test_lo=1, .test_hi=1},
{.fmin=_fc+0.6f*bw, .fmax=+0.5f, .pmin=n0-tol, .pmax=n0+tol, .test_lo=1, .test_hi=1},
};
char filename[256];
sprintf(filename,"autotest/logs/spgramcf_signal_%s_n%u_f%c%.0f_s%c%.0f.m",
liquid_window_str[_wtype][0], _nfft,
_fc < 0 ? 'm' : 'p', fabsf(_fc*1000),
_SNRdB < 0 ? 'm' : 'p', fabsf(_SNRdB*1000));
liquid_autotest_validate_spectrum(psd, _nfft, regions, 3,
liquid_autotest_verbose ? "autotest/logs/spgramcf_signal.m" : NULL);
liquid_autotest_verbose ? filename : NULL);

// destroy objects
spgramcf_destroy(q);
Expand Down

0 comments on commit 75fbee3

Please sign in to comment.