Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coordinate of antenna position in UVFITS? #1486

Open
fxzjshm opened this issue Oct 11, 2024 · 3 comments
Open

Coordinate of antenna position in UVFITS? #1486

fxzjshm opened this issue Oct 11, 2024 · 3 comments
Labels
docs documentation

Comments

@fxzjshm
Copy link

fxzjshm commented Oct 11, 2024

I'm converting some visibility from custom format to UVFITS/MeasurementSets and importing it to CASA. When using UVFITS as intermediate format (write_uvfits) and importing it using CASA task importuvfits, antenna positions are not expected:

Station   Offset from array center (m)       
             East         North     Elevation
E01       -0.0000        0.0000        0.0000
E02        1.5671      -26.6355       29.6190
E04        6.9827     -107.0955      118.4858
E05       10.6311     -160.7576      177.7517
E06       17.6700     -280.8892      311.7160
E07       19.0035     -294.5801      326.2694
E08       23.9970     -361.8501      400.0746
E09       24.4710     -375.0060      415.1973
E10       24.8243     -388.0366      430.3301

When using MS (write_ms), results are expected:

Station Offset from array center (m)       
           East         North     Elevation
E01      0.0000        0.0000        0.0000
E02     39.8547       -0.0939        0.8886
E04    159.8423       -0.2025        2.7755
E05    239.8672       -0.2537        4.0060
E06    419.8971       -0.5340        8.2220
E07    439.9214       -0.5419        7.9621
E08    539.9059       -0.5591        8.9570
E09    559.9360       -0.5795        9.8587
E10    579.8818       -0.6064       10.9127

After some investigation I think it is related to

# AIPS memo #117 says that antenna_positions should be relative to
# the array center, but in a rotated ECEF frame so that the x-axis
# goes through the local meridian.
longitude = self.telescope_location_lat_lon_alt[1]
rot_ecef_positions = uvutils.rotECEF_from_ECEF(self.antenna_positions,
longitude)
col2 = fits.Column(name='STABXYZ', format='3D',
array=rot_ecef_positions)

But it seems that in casacore, array XYZ and antenna XYZ are added without rotation (if not VLA):
https://github.com/casacore/casacore/blob/bf9e411892b3816724eb11737cc32d12f86a6436/msfits/MSFits/MSFitsInput.cc#L2228

Also found a PR related to "modifications to uvfits AN read/write rules": casacore/casacore#400

So is that rotation required/expected? What's best practice to set antenna locations if I want to convert a custom format into UVFITS?

@kartographer
Copy link
Contributor

Hey @fxzjshm! I'll get an answer to the UVFITS question for you here in just a sec, but an immediate question for you: is there some reason why your outputting to UVFITS and importing that via importuvfits rather than writing out a MeasurementSet (via UVData.write_ms) from the get go? The importuvfits has not always been, in my opinion, the most reliable of utilities, and of course is not something that we can fix directly (if it turns out that there's an underlying issue in it) since it's not part of the pyuvdata package.

@fxzjshm
Copy link
Author

fxzjshm commented Oct 12, 2024

I'm new to synthesis imaging and someone told me that MeasurementSet format isn't stable even between minor versions of CASA, so I decided to try UVFITS first..

@bhazelton
Copy link
Member

Hi @fxzjshm, as Karto mentioned above, the importuvfits utility in CASA is known to have some errors, specifically in that it does not always follow the AIPS memo on the UVFITS file convention. We do follow that memo pretty strictly and the memo is pretty clear on this front. Karto and others have done a bunch of testing on the write_ms functionality and I think sticking to that is the safest approach.

We have done loopback tests using the importuvfits CASA task and have identified several mistakes that the importuvfits task makes, but weirdly this isn't one of the ones we've already identified. Thanks for letting us know about this. We'll try to do some testing on this on our end too and we should add some notes in our documentation about the various issues we've found with importuvfits.

@bhazelton bhazelton added the docs documentation label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs documentation
Projects
None yet
Development

No branches or pull requests

3 participants