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

MS writer improvements #1363

Merged
merged 9 commits into from
Dec 7, 2023
Merged

MS writer improvements #1363

merged 9 commits into from
Dec 7, 2023

Conversation

kartographer
Copy link
Contributor

Description

Adds some functionality to the write_ms method, which enforces that CASA-preferred polarization ordering is used on write, and allows the user to specify whether to flip the baseline conjugation scheme used.

Motivation and Context

This addresses some issues that LWA users were running into when passing data through puvdata. Two issues in particular were identified in #1355. First, some CASA tasks clearly want the polarization order to be set up in a particular way, so the writer now always writes out in "CASA order". Second, there's an open question as to if some methods and functions (both internal and external to the CASA package) require different baseline conventions, which would be understandable given the conflicting documentation. Though I believe the pyuvdata standard is correct for most applications, I've added a switch that users can use to flip the convention.

In the course of addressing the above, I did make a few small tweaks to the writer and added/modified a couple of functions in utils to help with polarization ordering and to make indexing faster under most circumstances via use of slices.

Closes #1355.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

Bug fix checklist:

  • My fix includes a new test that breaks as a result of the bug (if possible).
  • All new and existing tests pass.
  • I have updated the CHANGELOG.

Copy link

codecov bot commented Dec 6, 2023

Codecov Report

Merging #1363 (eb3c56c) into main (bd03009) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1363   +/-   ##
=======================================
  Coverage   99.92%   99.92%           
=======================================
  Files          36       36           
  Lines       20202    20228   +26     
=======================================
+ Hits        20186    20212   +26     
  Misses         16       16           
Files Coverage Δ
pyuvdata/utils.py 100.00% <100.00%> (ø)
pyuvdata/uvdata/ms.py 99.89% <100.00%> (+<0.01%) ⬆️
pyuvdata/uvdata/uvdata.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd03009...eb3c56c. Read the comment docs.

pyuvdata/utils.py Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@bhazelton bhazelton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kartographer ! Just a few comments.

@bhazelton
Copy link
Member

@rlbyrne we'd be happy to hear any feedback from you on this if you have time to look at it or test it.

Copy link
Member

@bhazelton bhazelton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@bhazelton bhazelton merged commit 0b98ea0 into main Dec 7, 2023
53 checks passed
@bhazelton bhazelton deleted the ms_writer_updates branch December 7, 2023 17:17
@rlbyrne
Copy link
Contributor

rlbyrne commented Dec 11, 2023

@kartographer Apologies that I'm only getting around to testing this now.

I am getting an error with the new ms writer. When I read an .uvfits file and then immediately write to an .ms file, I get this message:

  File "<stdin>", line 1, in <module>
  File "/opt/devel/rbyrne/envs/pyuvdata/lib/python3.8/site-packages/pyuvdata/uvdata/uvdata.py", line 12731, in write_ms
    ms_obj.write_ms(
  File "/opt/devel/rbyrne/envs/pyuvdata/lib/python3.8/site-packages/pyuvdata/uvdata/ms.py", line 1219, in write_ms
    ms.putcol(col, temp_vals)
  File "/opt/devel/rbyrne/envs/pyuvdata/lib/python3.8/site-packages/casacore/tables/table.py", line 1155, in putcol
    self._putcol(columnname, startrow, nrow, rowincr, value)
RuntimeError: ArrayColumn::putColumn - column DATA has 62128, array has 4 rows: Table array conformance error

If I run uv.reorder_pols(order="CASA", run_check=False) before writing I do not get the error. Any thoughts? I can put this in an issue as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reading and writing ms files does not preserve data
3 participants