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

Improved UVData to MirParser interface #1282

Merged
merged 32 commits into from
Apr 10, 2023
Merged

Improved UVData to MirParser interface #1282

merged 32 commits into from
Apr 10, 2023

Conversation

kartographer
Copy link
Contributor

Updates the interface between UVData.read method and the MirParser module.

Description

Overhauls the read_mir method inside of Mir. This includes being able to sub-select desired data on read (rather than after-the-fact), with keywords matched to those typically used inside of UVData.read. Additionally, some updates to the MirParser and Mir modules have been made to improve speed/memory performance (by up to a factor of two). The UVData.read and UVData.select have also had the catalog_names keyword added, which allows users to select sources/phase centers by their names rather than their ID numbers (the latter of which are sometimes arbitrarily assigned).

Motivation and Context

This PR covers a final suite of changes that are needed for moving support for MIR data for general users of SMA -- in this case, primarily via improving the interface between the UVData and MIR-type files. Previously, in order to handle MIR files without loading the whole dataset first, one needed to pass forward specific indexing codes that were not necessarily known by lay-users of the telescope.

After this PR is closed, I'd like to request a new pyuvdata version be spun up.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

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.

New feature checklist:

  • I have added or updated the docstrings associated with my feature using the numpy docstring format.
  • I have updated the tutorial to highlight my new feature (if appropriate).
  • I have added tests to cover my new feature.
  • All new and existing tests pass.
  • I have updated the CHANGELOG.

…g select capabilities phase on phase center name.
… for MIR files, on in weights normalization for MIR
@kartographer kartographer added the SMA Issues related to handling of SMA data label Apr 4, 2023
@kartographer kartographer requested a review from e-koch April 4, 2023 19:05
@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Merging #1282 (1d715c5) into main (505b35c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main    #1282    +/-   ##
========================================
  Coverage   99.91%   99.91%            
========================================
  Files          33       33            
  Lines       19328    19459   +131     
========================================
+ Hits        19312    19443   +131     
  Misses         16       16            
Impacted Files Coverage Δ
pyuvdata/uvdata/uvfits.py 100.00% <ø> (ø)
pyuvdata/uvdata/uvh5.py 100.00% <ø> (ø)
pyuvdata/uvdata/mir.py 100.00% <100.00%> (ø)
pyuvdata/uvdata/mir_meta_data.py 100.00% <100.00%> (ø)
pyuvdata/uvdata/mir_parser.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 505b35c...1d715c5. Read the comment docs.

Copy link
Contributor

@e-koch e-koch left a comment

Choose a reason for hiding this comment

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

@kartographer -- Found just a few minor things!

self._add_phase_center(
mir_data.codes_data["source"][sou_id],
cat_type="sidereal",
cat_lon=np.median(icrs_ra),
Copy link
Contributor

Choose a reason for hiding this comment

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

For future proofing, I wonder about setting a check that np.ptp of the ra, dec varies less than some reasonable amount.

I think this would only matter for concatenated tracks (in which case, is that already handled when a phase center has the same name but different coordinates?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point! I've added a check immediately after the code highlighted here, which raises a warning if a change of > 1 arcmin is seen (> 1 primary beam for SMA, which is pretty uncommon for standard sources).

@@ -1144,6 +1154,8 @@ def get_value(
idx_arr = self._index_query(use_mask, where, and_where_args, header_key, index)

if isinstance(field_name, (list, set, tuple)):
if return_tuples is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the default changed to None? Can the kwarg in the function call just be True?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I'm using None here as a stand-in for what the typical usage is inside of MirParser, which is that if multiple fields have been requested, to return tuples (as they're often used for indexing via hashmap), but in cases where single field is requested, just to return the array of values. This is more of a convenience thing inside of MirParser rather than anything else -- it just helped to remove about two dozen extra keyword calls inside the code.

@kartographer
Copy link
Contributor Author

Thanks @e-koch! I think I've responded to everything you've commented on, but let me know if you see something that needs further attention.

e-koch
e-koch previously approved these changes Apr 5, 2023
e-koch
e-koch previously approved these changes Apr 5, 2023
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 good to me, just a couple questions

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.

This looks good to me. Thanks for all the hard work @kartographer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SMA Issues related to handling of SMA data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants