2baOrNot2ba / dreamBeam

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

Casacore Error: "Cannot convert due to missing frame information" #5

Closed David-McKenna closed 4 years ago

David-McKenna commented 4 years ago

Hey Tobia,

Same command as before with the pointing_jones.py script:

./scripts/pointing_jones.py print LOFAR LBA SE607 Hamaker 2012-04-01T01:02:03 60 1 6.11 1.02 60E6

Raises an error after a call to casacore:

2020-08-27 10:27:09 WARN    MeasIERS::findTab (file /build/casacore-3.3.0/measures/Measures/MeasIERS.cc, line 387)  Requested data table TAI_UTC cannot be found in the searched directories:
2020-08-27 10:27:09 WARN    MeasIERS::findTab (file /build/casacore-3.3.0/measures/Measures/MeasIERS.cc, line 387)+ /usr/share/casacore/data/ephemerides/
2020-08-27 10:27:09 WARN    MeasIERS::findTab (file /build/casacore-3.3.0/measures/Measures/MeasIERS.cc, line 387)+ /usr/share/casacore/data/geodetic/
2020-08-27 10:27:09 SEVERE  MeasTable::dUTC(Double) (file /build/casacore-3.3.0/measures/Measures/MeasTable.cc, line 4281)  Cannot read leap second table TAI_UTC
Traceback (most recent call last):
  File "./scripts/pointing_jones.py", line 224, in <module>
    cli_main()
  File "./scripts/pointing_jones.py", line 218, in cli_main
    main(telescope, stnid, band, antmodel, obstimebeg, duration, steptime,
  File "./scripts/pointing_jones.py", line 112, in main
    on_pointing_axis_tracking(telescopename, stnid, band, antmodel, bTime,
  File "/home/suddenly/.local/lib/python3.8/site-packages/dreamBeam-0.7-py3.8.egg/dreambeam/rime/scenarios.py", line 129, in on_pointing_axis_tracking
    pjonesOfSrc = pjones.op(srcfld)
  File "/home/suddenly/.local/lib/python3.8/site-packages/dreamBeam-0.7-py3.8.egg/dreambeam/rime/jones.py", line 36, in op
    self.computeJonesRes()
  File "/home/suddenly/.local/lib/python3.8/site-packages/dreamBeam-0.7-py3.8.egg/dreambeam/rime/jones.py", line 108, in computeJonesRes
    self.computeJonesRes_overtime()
  File "/home/suddenly/.local/lib/python3.8/site-packages/dreamBeam-0.7-py3.8.egg/dreambeam/rime/jones.py", line 164, in computeJonesRes_overtime
    jonesrbasis_to = np.asmatrix(convertBasis(me, jonesrbasis_from,
  File "/home/suddenly/.local/lib/python3.8/site-packages/dreamBeam-0.7-py3.8.egg/dreambeam/rime/conversion_utils.py", line 60, in convertBasis
    v_sph_me = me.measure(vr_sph_me, to_refFrame)
  File "/home/suddenly/.local/lib/python3.8/site-packages/python_casacore-3.3.1-py3.8-linux-x86_64.egg/casacore/measures/__init__.py", line 120, in measure
    return _measures.measure(self, v, rf, off)
RuntimeError: Cannot convert due to missing frame information

Unforetunately I'm not familiar with Casacore so I can't debug this issue too easily, but if you want me to try get the contents of the args before the call I'll have a look into it.

Cheers

2baOrNot2ba commented 4 years ago

Hi David, just to be clear dreamBeam has not been tested (yet :-) with python3. I think this is a python3 issue between casacore and dB. Having said I really appreciate the python3 treatment :-) You might want to try with python2.7 just so that we are on the same page...

David-McKenna commented 4 years ago

Hey Tobia,

I just spun up a docker container with python 2 and ran into the same error -- it looks like this is completely unrelated to dreamBeam, but is a side effect of python-casacore's pip wheel not containing all of the casa configs it relies upon, so a quick apt install python-casacore python3-casacore seems to have resolved the issue in both Python 2 and 3, apologies for not looking into that sooner!

Cheers

2baOrNot2ba commented 4 years ago

Aha. Ya, there are a few external files that casacore needs. The warnings e.g. are due to an external ephemeris file. If you still get them you need to update (can help with details)

2baOrNot2ba commented 4 years ago

David, I tested this and I discovered that it is an issue in the later releases of python-casacore. I was running a version 2.2.1 before without problems, but when I switched to latest 3.3.1 I got the RuntimeError you quote above. I then discovered that if you do the exact same call a second time it works correctly. Therefore I put a try-except block around it for now as a workaround, until the casacore developers can fix this.

Also tested that it works with python3, at least "pointing_jones" command.

David-McKenna commented 4 years ago

Hey Tobia,

Sorry for the slow response to this and the PR comments; I was a bit distracted near the end of last week and wasn't checking my email.

Cheers for looking into it, that's some odd behaviour, hopefully they can fix it soon.

And thanks for cleaning up that PR, I was looking for a quick fix rather than a proper implementation at the time, your improved code is definitely a better approach than what I submitted! I'll let you know if I run into any other py2/3 oddities in the meantime.

2baOrNot2ba commented 4 years ago

No probs David. I am just about to push intial documentation, which should help to get it to work; so hang in there :-)