Precompute __antpair2ind_cache - #420
Conversation
This can save ~10 minutes per simulation setup when preparing full HERA-scale simulations.
for more information, see https://pre-commit.ci
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #420 +/- ##
==========================================
+ Coverage 93.47% 93.49% +0.02%
==========================================
Files 25 25
Lines 3371 3384 +13
Branches 562 566 +4
==========================================
+ Hits 3151 3164 +13
Misses 115 115
Partials 105 105
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks @r-pascua --- yeah I think your solution in the OP is the easiest/best way to go. You're right that it would fail in that case, but that case is INVALID DATA anyway (unfortunately, it's possible to get into situations where data is invalid in pyuvdata -- this is due to the ability to update attributes in-place, which is always a tricky thing to manage). |
|
In that case, I figure I should just implement the suggested change in the OP and add some tests to ensure that it works for valid |
|
Yeah -- I reckon use your more simple example to fix this. If there's another place we can use the cache, let's use it there! The reorder_vis function is stupidly slow (when it's not short-circuited). |
Validating the
ModelDataobject can be needlessly expensive when setting up simulations at the scale of full HERA because of the check that only one of(ai, aj)or(aj, ai)show up for any antenna pair. This workaround can avoid the problem by precomputing the antenna pair to baseline-time index cache.Unfortunately, after writing and testing this, I have come to the realization that we can probably speed up the code block in the validation section (e.g., here) with something like
instead of checking that either
uvdata.antpair2ind(ai,aj)oruvdata.antpair2ind(aj,ai)returnsNone. The only corner case that I think I can see where this fails would be something like the"nontrivial"case in my tests that exclude setting theblts_are_rectangularattribute toFalse(while also having time as the fast part of the baseline-time axis). Although I think that case would fail silently, as it would ultimately tie back touvdata.get_antpairs()not returning the full list of antenna pairs.