ovro-eovsa / ovro-lwa-solar

Calibration, imaging, and analysis of solar data taken by the Owens Valley Long Wavelength Array (OVRO-LWA)
MIT License
5 stars 6 forks source link

Issue with az-el conversion using CASA measures #20

Closed surajit4444mondal closed 8 months ago

surajit4444mondal commented 11 months ago

I found a serious bug in the CASA measures when converting to alt-az coordinates. I was trying to analyse the data for 2023/09/19 and found this issue. Script to reproduce the issue is available in pipeline in /data1/smondal/20230919/slow/coord_debug/test_coords.py The script is also copied and pasted here.

The time of MS is 20:15:42, when we know that the Sun is above horizon. However CASA measures gives a elevation of -29 degrees. Astropy conversion gives an altitude of 53 degrees, which seems to be right, since we that the Sun sets at the OVRO site at about 01:30 or so.. so about 5 hours to go..

from casatools import measures
import sys
sys.path.append('/data1/smondal/ovro-lwa-solar')
import utils
import numpy as np

from astropy.coordinates import EarthLocation,SkyCoord
from astropy.time import Time
from astropy import units as u
from astropy.coordinates import AltAz

msfile='20230919_201542_78MHz.ms'

me=measures()

m=utils.get_sun_pos(msfile,str_output=False)
print (m)
d=me.measure(m,'AZEL')
print (d)
elev = d['m1']['value']*180/np.pi
print (elev)

observing_location = EarthLocation(lat='37.2398', lon='-118.2817', height=0*u.m)
observing_time = Time('2023-09-19 20:15:42')
aa = AltAz(location=observing_location, obstime=observing_time)

coord = SkyCoord(m['m0']['value']*u.rad,m['m1']['value']*u.rad,frame='icrs')
azalt_coord=coord.transform_to(aa)

print (azalt_coord)

The output is

{'m0': {'unit': 'rad', 'value': 3.082542187192992}, 'm1': {'unit': 'rad', 'value': 0.025583106783484105}, 'refer': 'J2000', 'type': 'direction'}
{'m0': {'unit': 'rad', 'value': 1.5258809601195784}, 'm1': {'unit': 'rad', 'value': -0.5064877407641056}, 'refer': 'AZEL', 'type': 'direction'}
-29.01960992089939
<SkyCoord (AltAz: obstime=2023-09-19 20:15:42.000, location=(-2408802.67178089, -4477057.10663524, 3838613.65124065) m, pressure=0.0 hPa, temperature=0.0 deg_C, relative_humidity=0.0, obswl=1.0 micron): (az, alt) in deg
    (192.16558878, 53.48783873)>
binchensun commented 10 months ago

@surajit4444mondal Was this issue already resolved?

surajit4444mondal commented 10 months ago

No.. It is yet to be understood..

surajit4444mondal commented 8 months ago

Peijin also independently found this behaviour on 2023/09/19 data. This was again seen in 2023/12/14 data when I ran image_ms. However Bin was able to successfully run the realtime pipeline for the December 14 data. This is odd and confuses me. I am noting this down for future reference so that we do not forget this odd behaviour.

surajit4444mondal commented 8 months ago

The issue has been resolved in #32