From 732b74a9514e588e5c17e76b65f0f29eb25360e6 Mon Sep 17 00:00:00 2001 From: David McKenna Date: Tue, 8 Oct 2024 15:11:07 +0200 Subject: [PATCH] Channelisation & DADA handling fixes --- src/CLI/lofar_cli_stokes.c | 27 +++++++++++++-------------- src/lib/lofar_udp_reader.c | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/CLI/lofar_cli_stokes.c b/src/CLI/lofar_cli_stokes.c index 4ea14e5b..c8f9d4b2 100644 --- a/src/CLI/lofar_cli_stokes.c +++ b/src/CLI/lofar_cli_stokes.c @@ -699,7 +699,7 @@ int main(int argc, char *argv[]) { fprintf(stderr, "the boxcar window.\n"); window &= (COHERENT_DEDISP & BOXCAR); } - } else if (!windowCheck) { + } else if (!windowCheck && (channelisation > 1 || (downsampling > 1 && temporalDownsample))) { fprintf(stderr, "WARNING: No window was set, falling back to the pulsar window.\n"); window |= PSR_STANDARD; } @@ -726,7 +726,7 @@ int main(int argc, char *argv[]) { return 1; } - if (numStokes == 0) { + if (numStokes == NOSTOKES) { printf("No Stokes configuration provided; defaulting to STOKESI\n"); numStokes = 1; stokesParameters = STOKESI; @@ -745,7 +745,17 @@ int main(int argc, char *argv[]) { channelisation *= downsampling; } - const int32_t noverlap = 2 * channelisation; + if (channelisation < 1) { + fprintf(stderr, "WARNING: Channelisation was set to %d, returning to 1.\n", channelisation); + channelisation = 1; + } else if ((channelisation > 1 && channelisation % 2) != 0) { + fprintf(stderr, "ERROR: Invalid channelisation factor (less than 1, non-factor of 2)\n"); + helpMessages(); + CLICleanup(config, outConfig, fftw, NULL); + return 1; + } + + const int32_t noverlap = 2 * (channelisation ?: 0); const int32_t nbin = nfactor * channelisation; const int32_t nbin_valid = nbin - 2 * noverlap; @@ -756,10 +766,6 @@ int main(int argc, char *argv[]) { } config->packetsPerIteration = (nbin_valid * nforward) / UDPNTIMESLICE; - - if (channelisation < 2) { - channelisation = 1; - } if (channelisation > 1 || window & COHERENT_DEDISP) { // Should no longer be needed; keeping for debug/validation purposes; remove before release int32_t invalidation = (config->packetsPerIteration * UDPNTIMESLICE) % nbin_valid; @@ -777,13 +783,6 @@ int main(int argc, char *argv[]) { } } - if (channelisation < 1 || (channelisation > 1 && channelisation % 2) != 0) { - fprintf(stderr, "ERROR: Invalid channelisation factor (less than 1, non-factor of 2)\n"); - helpMessages(); - CLICleanup(config, outConfig, fftw, NULL); - return 1; - } - if (downsampling < 1) { fprintf(stderr, "ERROR: Invalid downsampling factor (less than 1)\n"); helpMessages(); diff --git a/src/lib/lofar_udp_reader.c b/src/lib/lofar_udp_reader.c index 014831bd..069a9ade 100644 --- a/src/lib/lofar_udp_reader.c +++ b/src/lib/lofar_udp_reader.c @@ -961,12 +961,19 @@ int32_t _lofar_udp_reader_config_check(const lofar_udp_config *config) { } for (int8_t port = 0; port < config->numPorts; port++) { - if (!strlen(config->inputLocations[port])) { - fprintf(stderr, "ERROR: You requested %d ports, but port %d is an empty string, exiting.\n", config->numPorts, port); - return -1; - } else if (access(config->inputLocations[port], F_OK) != 0) { - fprintf(stderr, "ERROR: Failed to open file at %s (port %d), exiting.\n", config->inputLocations[port], port); - return -1; + if (!(config->readerType & DADA_ACTIVE)) { + if (!strlen(config->inputLocations[port])) { + fprintf(stderr, "ERROR: You requested %d ports, but port %d is an empty string, exiting.\n", config->numPorts, port); + return -1; + } else if (access(config->inputLocations[port], F_OK) != 0) { + fprintf(stderr, "ERROR: Failed to open file at %s (port %d), exiting.\n", config->inputLocations[port], port); + return -1; + } + } else { + if (config->inputDadaKeys[port] < 0) { + fprintf(stderr, "ERROR: You requested %d ports, but the DADA key for port %d is unset, exiting.\n", config->numPorts, config->inputDadaKeys[port]); + return -1; + } } }