#include "chirp.h" /* Returns 1 for fault, 0 for OK */ static int do_file(const char *fname) { char iline[240]; double r[6]; s_state g_state; if (0) printf("File %s\n", fname); FILE *fd = fopen(fname, "r"); if (fd == NULL) return 1; // g_state.npt = 2048; g_state.dt = 2 * 8 * 33 * 14 / 1320e6; g_state.cav_iwf = malloc(g_state.npt * sizeof(double)); g_state.cav_qwf = malloc(g_state.npt * sizeof(double)); g_state.fwd_iwf = malloc(g_state.npt * sizeof(double)); g_state.fwd_qwf = malloc(g_state.npt * sizeof(double)); g_state.dvdt_iwf = malloc(g_state.npt * sizeof(double)); g_state.dvdt_qwf = malloc(g_state.npt * sizeof(double)); // int qx=0; while (fgets(iline, sizeof(iline), fd)) { if (0) printf("%s", iline); if (iline[0] == '#') continue; char *ss = iline; for (unsigned jx=0; jx<6 && ss; jx++) { r[jx] = strtod(ss, &ss); if (0) printf("%d %f\n", jx, r[jx]); } if (qx < g_state.npt) { g_state.cav_iwf[qx] = r[0]; g_state.cav_qwf[qx] = r[1]; g_state.fwd_iwf[qx] = r[2]; g_state.fwd_qwf[qx] = r[3]; } qx++; } if (qx < g_state.npt) return 1; double complex fitc[2]; double fitc_rms[2]; double rms; char debug[240]; int rc = analyze_chirp(&g_state, fitc, &rms, fitc_rms, debug); if (1) printf("file %s coeff %9.2f %9.2f j, %9.4f %9.4f j rms %.3f %8.3f %8.3f\n", fname, creal(fitc[0]), cimag(fitc[0]), creal(fitc[1]), cimag(fitc[1]), rms, sqrt(fitc_rms[0]), sqrt(fitc_rms[1])); if (rc) printf("file %s debug %s\n", fname, debug); return rc; } int main(int argc, char *argv[]) { int ix; int fault = argc < 2; // for (ix=1; ix