2baOrNot2ba / dreamBeam

Radio telescope beam modeling framework
https://dreambeam.readthedocs.io
ISC License
5 stars 6 forks source link

Workaround (on_pointing_axis_tracking): Take a minimum of 2 timesteps to prevent axes loss to ravels #10

Open David-McKenna opened 1 year ago

David-McKenna commented 1 year ago

Hey Tobia,

Ran into a lovely bug in on_pointing_axis_tracking where by if some floating point math causes the observation duration to fall below the observation integration value, dreamBeam exits as a result of the time axes being deleted in a squeeze on a working array.

This PR is a workaround for the issue, by requiring at least 2 timesteps be generated for every input, preventing the axes loss and runtime error as a result. I attempted to follow through the code path and see if I could, for example, swap the wildcard indices on jones.py:220 for elipses, but that just caused worse issues later on (0-dim arrays).

A better solution would likely be to manually delete/index axes at jones.py:309 and jones.py:429, but from a brief inspection I wasn't sure which axes you were attempting to get rid of there, leading to this interim patch.

Cheers, David

Here's the full stack of the original error:

  File "/mnt/ucc4_data3/data/David/scripts/genericFuncs.py", line 118, in cachedAxisLookup
    return on_pointing_axis_tracking(telescopename = tele, stnid = stn, band = antennaSet, antmodel = mdl, obstimebeg = Time(time).datetime, obsdur = dur, obstimestp = integ, pointingdir = pnt, do_parallactic_rot
=do_parallactic_rot)
  File "/usr/local/lib/python3.6/dist-packages/dreambeam/rime/scenarios.py", line 131, in on_pointing_axis_tracking
    pjonesOfSrc = pjones.op(srcfld)
  File "/usr/local/lib/python3.6/dist-packages/dreambeam/rime/jones.py", line 38, in op
    self.computeJonesRes()
  File "/usr/local/lib/python3.6/dist-packages/dreambeam/rime/jones.py", line 108, in computeJonesRes
    self.computeJonesRes_overfield()
  File "/usr/local/lib/python3.6/dist-packages/dreambeam/rime/jones.py", line 220, in computeJonesRes_overfield
    jonesrbasis_from[idxi, idxj, :, :],
IndexError: too many indices for array: array is 2-dimensional, but 4 were indexed