Sophia - 6 days ago

I fixed it! Here's my complete bug report and patch submission:

Bug: when running dspsr in cyclic spectroscopy mode (-cyclic) on LOFAR data (lofar_dal backend), dspsr fails with:

  dsp::Observation::get_unswapped_ichan
  Error::InvalidState
  nsub_swap=10240 is not less than nchan=10240

I narrowed down the bug to Signal/Pulsar/CyclicFold.C, where set_nsub_swap is called with out->get_nchan() (the expanded cyclic output channel count, N_subbands x N_cyclic) instead of in->get_nchan() (the number of physical input subbands). Since get_unswapped_ichan requires nsub_swap < nchan and uses nsub_swap to compute the number of cyclic channels per physical subband, passing the full output nchan causes nsub_swap = nchan, which always fails the check.

Patch: The fix is a one-line change: replaceout->get_nchan() with in->get_nchan() in the set_nsub_swap call. With this fix, nsub_swap correctly equals the number of subbands (e.g. 20 for LOFAR), and get_unswapped_ichan correctly applies the frequency reversal within each block of N_cyclic channels.

Non-cyclic folding of LOFAR data is unaffected (a different code does the subband swap at read time). The bug only pops up when you use a combination of lofar_dal + cyclic mode.

I tested this on dspsr commit 93ff8b39 with 20-subband LOFAR HBA data at 141 MHz (PSR B0329+54). I'm attaching the diff file I created for CyclicFold.C using Git.