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

Add an option to use the HERA gridding algorithm to find redundancies #1403

Merged
merged 6 commits into from
Feb 22, 2024

Conversation

bhazelton
Copy link
Member

@bhazelton bhazelton commented Feb 13, 2024

Description

This adds a new option for redundancy finding to use the HERA gridding algorithm rather than the existing clustering algorithm. This has some advantages, it's faster and will not throw errors, but it might not handle non-redundant arrays well and the tolerance needs to be well specified to be less than half the minimal antenna spacing.

I also fixed what I am pretty convinced is a bug for data sets that are not rectangular in the basline-times where baselines could be compared at different times. I now use the antenna positions to get ENU baseline vectors if the object is not rectangular in baseline-times. This bug surfaced when I was testing the new HERA algorithm.

Questions for this PR:
We could decide to just replace the existing algorithm with the HERA algorithm rather than making it an option. Or we could default it to the HERA algorithm. I'm open to any of these options. I haven't yet updated the changelog because I wasn't sure which direction we wanted to go.

We decided to make the new method the default but with a warning message that the default had changed.

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation change (documentation changes only)
  • Version change
  • Build or continuous integration change

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.

@bhazelton bhazelton requested a review from jpober February 13, 2024 17:29
@bhazelton bhazelton added the HERA Things needed to support HERA development. label Feb 13, 2024
Copy link

codecov bot commented Feb 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b448881) 99.92% compared to head (2db05bb) 99.92%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1403   +/-   ##
=======================================
  Coverage   99.92%   99.92%           
=======================================
  Files          37       37           
  Lines       20767    20807   +40     
=======================================
+ Hits        20751    20791   +40     
  Misses         16       16           
Files Coverage Δ
pyuvdata/utils.py 100.00% <100.00%> (ø)
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 b448881...2db05bb. Read the comment docs.

@jpober
Copy link
Member

jpober commented Feb 13, 2024

@baron-de-montblanc can you take a look at this code and see if it works any better (or worse) on MWA Phase 2? It may simplify redundancy finding (i.e. no need to throw out the core antennas first).

@bhazelton
Copy link
Member Author

bhazelton commented Feb 13, 2024

It won't error on core antennas, but it could inappropriately group them in with the hex tiles. The tolerance parameter will be key to that, I haven't messed with this much for non-redundant arrays.

@baron-de-montblanc
Copy link

@baron-de-montblanc can you take a look at this code and see if it works any better (or worse) on MWA Phase 2? It may simplify redundancy finding (i.e. no need to throw out the core antennas first).

Yes, this works well for my Phase 2 data. I set tol=3 (the minimum antenna spacing in the file was 8m) and it didn't throw any errors. In total it got rid of about 1/3 of the baselines. Interestingly enough, after the initial compression, I ran it a few more times, gradually increasing the tolerance. I increased until tol=1000 and no additional baselines were thrown out (and no errors thrown either).

@bhazelton
Copy link
Member Author

Yes, this works well for my Phase 2 data. I set tol=3 (the minimum antenna spacing in the file was 8m) and it didn't throw any errors. In total it got rid of about 1/3 of the baselines. Interestingly enough, after the initial compression, I ran it a few more times, gradually increasing the tolerance. I increased until tol=1000 and no additional baselines were thrown out (and no errors thrown either).

great! Thanks for the report.

@bhazelton
Copy link
Member Author

@jpober I think the biggest question I have is should we just replace the old clustering method with this HERA-based gridding method or should we keep them both around? And if the latter, what should the default method be. I'm sort of leaning towards just replacing it but I haven't thought about this super deeply.

@jpober
Copy link
Member

jpober commented Feb 16, 2024

I don't have a strong opinion. I'm slightly reluctant to remove functionality until we have dug a little deeper and confirmed the results are (dare I say) redundant. That said, the redundancy finder was already a little confusing since we had calculations using uvws and antenna positions as separate options. Adding a third sounds like too much. So I'm ok with just replacing it, but maybe add a warning that there's been an update and that it's not guaranteed to reproduce older results?

@bhazelton bhazelton force-pushed the add_hera_redundancy_option branch from 909cafa to d7b248a Compare February 20, 2024 18:27
@bhazelton bhazelton marked this pull request as ready for review February 21, 2024 00:17
@bhazelton
Copy link
Member Author

On the telecon we decided to make the new method be the default but with a warning that the default has changed.

@bhazelton
Copy link
Member Author

@jpober I made the change we discussed in the telecon yesterday -- I defaulted it to use the HERA algorithm but with a warning.

Copy link
Member

@jpober jpober left a comment

Choose a reason for hiding this comment

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

I'm all for giving credit to the HERA team, but do we want the warnings to refer to this as the "HERA gridding based algorithm"? I feel like for the average user this might sound like it's the algorithm for use with the HERA array, not a general algorithm from the HERA team. Maybe we could say "Defaulting to True to use the new gridding based algorithm (developed by the HERA team) rather than the older clustering based algorithm" or something?

@bhazelton
Copy link
Member Author

I'm all for giving credit to the HERA team, but do we want the warnings to refer to this as the "HERA gridding based algorithm"? I feel like for the average user this might sound like it's the algorithm for use with the HERA array, not a general algorithm from the HERA team. Maybe we could say "Defaulting to True to use the new gridding based algorithm (developed by the HERA team) rather than the older clustering based algorithm" or something?

Yep, sounds good. I'll make that change.

@bhazelton bhazelton force-pushed the add_hera_redundancy_option branch 2 times, most recently from 31ae537 to 9223ff3 Compare February 22, 2024 06:49
@bhazelton bhazelton force-pushed the add_hera_redundancy_option branch from 9223ff3 to 2db05bb Compare February 22, 2024 06:59
@jpober jpober self-requested a review February 22, 2024 11:37
Copy link
Member

@jpober jpober 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. Can you confirm that the error in the build against HERA Cal is expected? If so, I'll go ahead and merge.

@bhazelton bhazelton merged commit df6b902 into main Feb 22, 2024
51 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug enhancement HERA Things needed to support HERA development. UVData
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants