CIRADA-Tools / FRion

Ionospheric Faraday rotation correction for Stokes Q/U cubes
MIT License
7 stars 4 forks source link

Cannot convert due to missing frame information #1

Closed AlecThomson closed 1 year ago

AlecThomson commented 3 years ago

Hi @Cameron-Van-Eck ,

I'm trying to run the following prediction:

    times, RMs, theta = predict.calculate_modulation(
        start_time=start_time.fits,
        end_time=end_time.fits,
        freq_array=freq.to(u.Hz).value,
        telescope_location=predict.get_telescope_coordinates('ASKAP'),
        ra=field_data['RA_DEG'],
        dec=field_data['DEC_DEG'],
        timestep=300.0,
        ionexPath=os.path.join(outdir, 'IONEXdata')
    )

But, I'm getting the following error:

2021-08-06 06:37:17     WARN    MeasIERS::findTab (file /code/measures/Measures/MeasIERS.cc, line 387)  Requested data table TAI_UTC cannot be found in the searched directories:
2021-08-06 06:37:17     WARN    MeasIERS::findTab (file /code/measures/Measures/MeasIERS.cc, line 387)+ /usr/share/casacore/data/ephemerides/
2021-08-06 06:37:17     WARN    MeasIERS::findTab (file /code/measures/Measures/MeasIERS.cc, line 387)+ /usr/share/casacore/data/geodetic/
2021-08-06 06:37:17     SEVERE  MeasTable::dUTC(Double) (file /code/measures/Measures/MeasTable.cc, line 4281)  Cannot read leap second table TAI_UTC
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-13-133da31bf1e9> in <module>
----> 1 times, RMs, theta = predict.calculate_modulation(
      2     start_time=start_time.fits,
      3     end_time=end_time.fits,
      4     freq_array=freq.to(u.Hz).value,
      5     telescope_location=predict.get_telescope_coordinates('ASKAP'),

/group/askap/athomson/miniconda3/envs/spice/lib/python3.8/site-packages/FRion/predict.py in calculate_modulation(start_time, end_time, freq_array, telescope_location, ra, dec, timestep, ionexPath)
     79 
     80     #Get RMExract to generate it's RM predictions
---> 81     predictions=RME.getRM(ionexPath=ionexPath, radec=np.deg2rad([ra,dec]), 
     82                           timestep=timestep,
     83                           timerange = timerange,

/group/askap/athomson/miniconda3/envs/spice/lib/python3.8/site-packages/RMextract/getRM.py in getRM(MS, server, prefix, ionexPath, earth_rot, timerange, use_azel, ha_limit, use_filter, **kwargs)
    185               flags[station].append(1)
    186             else:
--> 187                az,el = PosTools.getAzEl(pointing,time,position,ha_limit)
    188                if az==-1 and el==-1:
    189                   return

/group/askap/athomson/miniconda3/envs/spice/lib/python3.8/site-packages/RMextract/PosTools.py in getAzEl(pointing, time, position, ha_limit)
    576     if HAS_PYRAP:
    577         if ha_limit==-1000:
--> 578             azel=radec2azel(pointing[0],pointing[1],time=str(time)+'s',pos=position);
    579             az=azel['m0']['value']
    580             el=azel['m1']['value']

/group/askap/athomson/miniconda3/envs/spice/lib/python3.8/site-packages/RMextract/PosTools.py in radec2azel(ra, dec, time, pos)
    401     me.do_frame(p);
    402     #print ("input radec2azel",phasedir,ra,dec,p,t)
--> 403     azel = me.measure(phasedir,'AZELGEO');
    404     return azel;
    405 

/group/askap/athomson/miniconda3/envs/spice/lib/python3.8/site-packages/casacore/measures/__init__.py in measure(self, v, rf, off)
    118                 if dq.is_quantity(v[key]):
    119                     v[key] = v[key].to_dict()
--> 120         return _measures.measure(self, v, rf, off)
    121 
    122     def direction(self, rf='', v0='0..', v1='90..', off=None):

RuntimeError: Cannot convert due to missing frame information

It looks like some data is missing from casacore, which I installed with conda. Any thoughts on what's going wrong here?

Cameron-Van-Eck commented 3 years ago

Hi Alec:

I think Wasim had the same issue; it seems to be a problem with RM-extract. The solution he found was to install casa-data (from what I can find online, I think it's as simple as pip install --index-url https://casa-pip.nrao.edu/repository/pypi-casa-release/simple casadata?). I guess that should be added as a dependency. The alternative (I think; I've not tested it) is to go into RMextract's PosTools.py and comment out the first block of trying to import pyrap. That should force it to use pyephem, which seems more reliable.

Cheers, Cameron

DavidGMcConnell commented 1 year ago

I encountered this problem, and tried the remedy suggested above by Cameron. casadata was successfully installed, but the problem persists. At present I get past it by pip uninstall python-casacore.

AlecThomson commented 1 year ago

Wow this is an old one! Sorry for not coming back earlier. I did get this sorted with a combo of the casadata install and directly downloading the Measures data. What a mess!

It is painful, however, that RMextract has so many ways of doing things. Would be nice to get things cleaner upstream