lofar-astron / RMextract

extract TEC, vTEC, Earthmagnetic field and Rotation Measures from GPS and WMM data for radio interferometry observations
GNU General Public License v3.0
31 stars 22 forks source link

casacore measures missing frame information in PosTools.py #43

Closed bennahugo closed 1 year ago

bennahugo commented 1 year ago

I'm running a set of comparative experiments with ALBUS and I've run into this when using casacore measures. The workaround is to uninstall casacore and install pyephem but should probably be fixed.

pyrap will be used to compute positions
[3.539257786786284, 0.5324852164475642]
2023-04-11 11:16:23     WARN    MeasIERS::findTab (file /code/measures/Measures/MeasIERS.cc, line 389)       Requested data table TAI_UTC cannot be found in the searched directories:
2023-04-11 11:16:23     WARN    MeasIERS::findTab (file /code/measures/Measures/MeasIERS.cc, line 389)+      /usr/share/casacore/data/ephemerides/
2023-04-11 11:16:23     WARN    MeasIERS::findTab (file /code/measures/Measures/MeasIERS.cc, line 389)+      /usr/share/casacore/data/geodetic/
2023-04-11 11:16:23     SEVERE  MeasTable::dUTC(Double) (file /code/measures/Measures/MeasTable.cc, line 4283)       Cannot read leap second table TAI_UTC
Traceback (most recent call last):
  File "mk_3C286.py", line 24, in <module>
    RMdict = gt.getRM(ionexPath='./IONEXdata/', radec=pointing, timestep=100, timerange = [starttime, endtime], stat_positions=[statpos,])
  File "/home/bhugo/workspace/venvrmextract/lib/python3.8/site-packages/RMextract/getRM.py", line 191, in getRM
    az,el = PosTools.getAzEl(pointing,time,position,ha_limit)
  File "/home/bhugo/workspace/venvrmextract/lib/python3.8/site-packages/RMextract/PosTools.py", line 578, in getAzEl
    azel=radec2azel(pointing[0],pointing[1],time=str(time)+'s',pos=position);
  File "/home/bhugo/workspace/venvrmextract/lib/python3.8/site-packages/RMextract/PosTools.py", line 403, in radec2azel
    azel = me.measure(phasedir,'AZELGEO');
  File "/home/bhugo/workspace/venvrmextract/lib/python3.8/site-packages/casacore/measures/__init__.py", line 120, in measure
    return _measures.measure(self, v, rf, off)
RuntimeError: Cannot convert due to missing frame information

example script:

import RMextract.getRM as gt
from astropy.time import Time
from astropy.coordinates import SkyCoord
import numpy as np

# L Short
# START_TIME="2021/05/22 22:23:37.3"
# END_TIME="2021/05/22 22:33:29.5"
starttime='2021-05-22T22:23:37.3'
endtime='2021-05-22T22:33:29.5'

#--- DO NOT MOD ---
pos = SkyCoord("13h31m08.28811s 30d30m32.9600s", frame='fk5') #3C286
st = Time(starttime,format='isot',scale ='utc')
et = Time(endtime,format='isot',scale ='utc')
duration = (et - st).to_value('s')
starttime = st.mjd*24*3600.  # getRM still wants MJD time in seconds (casacore definition)
endtime = starttime + duration # one hour of data
statpos = [5.10927e+06,2.00681e+06,-3.23913e+06] # MK station m000
pointing=[ np.deg2rad(pos.ra.value),  np.deg2rad(pos.dec.value) ] 
print (pointing)

RMdict = gt.getRM(ionexPath='./IONEXdata/', radec=pointing, timestep=100, timerange = [starttime, endtime], stat_positions=[statpos,])

times=RMdict['times']
RM = RMdict['RM']['st1']

print ("TIME(mjd)     RM (rad/m^2)")
for tm,rm in zip(times,RM):
    print ("%5.2f        %1.3f"%(tm/(3600*24.),rm))

I had python-casacore-3.5.2 (python3.8) installed

gmloose commented 1 year ago

I'm not sure what distribution you're using. So, I'm assuming you're on Debian or some of its derivatives (like Ubuntu). There are two ways to solve this:

  1. Install casacore-data from the package repository:
    apt install casacore-data
  2. Download and install the most up-to-date measures:
    wget -qO - ftp://ftp.astron.nl/outgoing/Measures/WSRT_Measures.ztar | sudo tar -C /usr/share/casacore/data -xzf -

    If you don't have root access to your machine, you may want to store the measures file in a different directory. In that case, you must create a file .casarc in your home directory with the following content:

    measures.directory: /path/to/casacore/data
bennahugo commented 1 year ago

Thanks a lot - I was under the impression the latest python-casacore depended on casacore-data. Clearly a blunder on my part.

On Tue, 11 Apr 2023, 15:11 Marcel Loose, @.***> wrote:

I'm not sure what distribution you're using. So, I'm assuming you're on Debian or some of its derivatives (like Ubuntu). There are two ways to solve this:

  1. Install casacore-data from the package repository:

apt install casacore-data

  1. Download and install the most up-to-date measures:

wget -qO - ftp://ftp.astron.nl/outgoing/Measures/WSRT_Measures.ztar | sudo tar -C /usr/share/casacore/data -xzf -

If you don't have root access to your machine, you may want to store the measures file in a different directory. In that case, you must create a file .casarc in your home directory with the following content:

measures.directory: /path/to/casacore/data

— Reply to this email directly, view it on GitHub https://github.com/lofar-astron/RMextract/issues/43#issuecomment-1503324889, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4RE6TLXE7I7THLFM324ZTXAVJ6XANCNFSM6AAAAAAW2EJ4LI . You are receiving this because you authored the thread.Message ID: @.***>

gmloose commented 1 year ago

No problem.