diff --git a/RTCP/Cobalt/GPUProc/test/SubbandProcs/tCorrelatorSubbandProcProcessSb.cc b/RTCP/Cobalt/GPUProc/test/SubbandProcs/tCorrelatorSubbandProcProcessSb.cc index 21a4cc8eeeb5baa1e34d9fe243ffd30c04cbf5ac..6244d056365b1a0e5e47135dc73973ac2e16ff4b 100644 --- a/RTCP/Cobalt/GPUProc/test/SubbandProcs/tCorrelatorSubbandProcProcessSb.cc +++ b/RTCP/Cobalt/GPUProc/test/SubbandProcs/tCorrelatorSubbandProcProcessSb.cc @@ -178,7 +178,7 @@ struct SubbandProcWrapper { return norm(inputValue) * scaleFactor * scaleFactor; } - void verifyOutput() const { + void verifyOutput(const fcomplex expectedValue) const { // we don't process the FFT in our reference calculations yet ASSERT(ps.settings.correlator.nrChannels == 1); @@ -187,23 +187,42 @@ struct SubbandProcWrapper { for (size_t c = 0; c < ps.settings.correlator.nrChannels; c++) for (size_t pol0 = 0; pol0 < ps.settings.nrPolarisations; pol0++) for (size_t pol1 = 0; pol1 < ps.settings.nrPolarisations; pol1++) - ASSERTSTR(fpEquals(out.correlatedData.subblocks[0]->visibilities[b][c][pol0][pol1], outputValue()), + ASSERTSTR(fpEquals(out.correlatedData.subblocks[0]->visibilities[b][c][pol0][pol1], expectedValue), "out[" << b << "][" << c << "][" << pol0 << "][" << pol1 << "] = " << out.correlatedData.subblocks[0]->visibilities[b][c][pol0][pol1] << - "; outputValue = " << outputValue()); + "; expectedValue = " << expectedValue); } }; -// Test the output on clean data -TEST(output_noflags) { +// Test the output on clean data -- should produce normal output +TEST(output_noflags_uniform) { Parset ps("tCorrelatorSubbandProcProcessSb.parset"); SubbandProcWrapper wrapper(ps); wrapper.process(); - wrapper.verifyOutput(); + wrapper.verifyOutput(wrapper.outputValue()); } -// Test the output if there is a flagged sample +// Test the output on clean data with a peak -- should produce elevated output +TEST(output_noflags_peak) { + Parset ps("tCorrelatorSubbandProcProcessSb.parset"); + SubbandProcWrapper wrapper(ps); + + // Replace one value with an extreme value to know whether it's actually skipped + for(size_t st = 0; st < ps.settings.antennaFields.size(); st++) { + wrapper.setInputValue(st, 13, 0, fcomplex(100,0)); + wrapper.setInputValue(st, 13, 1, fcomplex(100,0)); + } + + // Each unmodified input value of 1+1i produces a correlation of (1+1i)(1-1i) = 2 + // Each modified input value of 100 produces a correlation of 100 * 100 = 1e4 + // All correlations are averaged and scaled up. + + wrapper.process(); + wrapper.verifyOutput(3011.5); // = ((blockSize-1) * 2 + 1e4) / blockSize * scaleFactor * scaleFactor +} + +// Test the output on clean data with a flaged peak -- should produce normal output TEST(output_flags) { Parset ps("tCorrelatorSubbandProcProcessSb.parset"); SubbandProcWrapper wrapper(ps); @@ -216,7 +235,41 @@ TEST(output_flags) { // process wrapper.process(); - wrapper.verifyOutput(); + wrapper.verifyOutput(wrapper.outputValue()); +} + +// Test the final weights if there is flagged data +TEST(weights_flags_1ch) { + // Override nr channels to 1 + Parset ps("tCorrelatorSubbandProcProcessSb.parset"); + ps.replace("Cobalt.Correlator.nrChannelsPerSubband", "1"); + ps.updateSettings(); + SubbandProcWrapper wrapper(ps); + + // Flag one sample + wrapper.in.inputFlags[0].include(13); + + // process + wrapper.process(); + + // We reuse the flagged sample in all of the blocks, so + // we actually lose "nrBlocks" samples. + const unsigned nrBlocks = ps.settings.correlator.nrBlocksPerIntegration; + const unsigned nrValidSamples = wrapper.ps.settings.correlator.nrSamplesPerIntegration(); + const unsigned nrValidSamplesFlagged = + nrValidSamples + // we lose 1 sample per block for each flagged sample + - nrBlocks * 1; + + LOG_INFO("Verifying output weights ..."); + for (size_t b = 0; b < wrapper.ps.nrBaselines(); b++) { + // baseline 0 and 1 contain station 0 with a flagged sample. + unsigned expected = b < 2 ? nrValidSamplesFlagged : nrValidSamples; + ASSERTSTR(wrapper.out.correlatedData.subblocks[0]->getNrValidSamples(b, 0) == expected, + "nrValidSamples[" << b << "][0] = " + << wrapper.out.correlatedData.subblocks[0]->getNrValidSamples(b, 0) + << "; expected " << expected); + } } // Test the final weights after FFT if there is flagged data diff --git a/RTCP/Cobalt/GPUProc/test/SubbandProcs/tCorrelatorSubbandProcProcessSb.parset b/RTCP/Cobalt/GPUProc/test/SubbandProcs/tCorrelatorSubbandProcProcessSb.parset index a56e0c6d1b99db919b58eace8db85ae6a790230c..38ac7f70550552f8cd6de0d38d3720123caa9275 100644 --- a/RTCP/Cobalt/GPUProc/test/SubbandProcs/tCorrelatorSubbandProcProcessSb.parset +++ b/RTCP/Cobalt/GPUProc/test/SubbandProcs/tCorrelatorSubbandProcProcessSb.parset @@ -1,8 +1,6 @@ -OLAP.CNProc.integrationSteps = 256 Cobalt.Correlator.nrBlocksPerIntegration = 4 Cobalt.correctBandPass = F Observation.nrBitsPerSample = 8 -OLAP.CNProc.nrPPFTaps = 16 Observation.VirtualInstrument.stationList = [CS002] Observation.antennaSet = HBA_DUAL Observation.nrBeams = 1 @@ -17,6 +15,7 @@ Cobalt.delayCompensation = F Observation.nrPolarisations = 2 Cobalt.Correlator.nrChannelsPerSubband = 1 Observation.sampleClock = 200 +Cobalt.blockSize = 1024