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

Minor fixes for handling of older SMA data #1399

Merged
merged 6 commits into from
Feb 13, 2024
Merged

Minor fixes for handling of older SMA data #1399

merged 6 commits into from
Feb 13, 2024

Conversation

kartographer
Copy link
Contributor

@kartographer kartographer commented Feb 11, 2024

Fixes a few issues that became apparent after #1371 was merged.

Description

There are a couple of changes that have been made here:

  • Some fixtures in test_mir_parser that were redundant have been removed.
  • Reading in of MIR data has been reordered so that data-like attributes are read in last (which is helpful in testing/debugging)
  • A bug has been fixed in MirParser._make_v3_compliant where MJDs were not calculated correctly (forgot to convert UTC back to TT, which is the MIR standard).
  • Changed the way that Mir determines whether or not a data set should be flex-pol.
  • When reading in MIR datasets, the corresponding value for UVData.lst_array is now filled by set_lsts_from_time_array under most circumstances.

Motivation and Context

The change in flex-pol handling primarily affects reading in of older, pre-V3 MIR-formatted SMA data. Specifically, "gunnLO" was not consistently filled/used in pre-V3 data, whereas "fsky" has historically always been present, hence switching from the former to the latter.

The change in LST-handling arises from nuisance warnings about errors in the LSTs, which after #1356 have reduced somewhat in frequency for MIR data sets, but still regularly arise. I believe this is due to how these values are presently calculated, as a polled average rather than directly calculated at the integration mid-point, producing errors of up to 25 ms. Given that this is a long-standing feature, the reader now defaults to using pyuvdata-calculated LST values so long as they agree w/ the recorded values to within this precision limit. This has the advantage of providing "truer-to-observed" values while reducing the erroneous warnings. When the recorded values are not within the precision limit, they are plugged into lst_array so that a warning is appropriately raised (and the issue can be handled by the user accordingly).

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 Feb 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ea458fb) 99.92% compared to head (f7db089) 99.92%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1399   +/-   ##
=======================================
  Coverage   99.92%   99.92%           
=======================================
  Files          37       37           
  Lines       20763    20766    +3     
=======================================
+ Hits        20747    20750    +3     
  Misses         16       16           
Files Coverage Δ
pyuvdata/uvdata/mir.py 100.00% <100.00%> (ø)
pyuvdata/uvdata/mir_parser.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 ea458fb...f7db089. Read the comment docs.

@kartographer kartographer requested a review from e-koch February 11, 2024 18:41
@bhazelton bhazelton added UVData SMA Issues related to handling of SMA data labels Feb 12, 2024
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 -- It wasn't clear to me from the warning messages how the lst offset warnings and what to check are getting communicated back to the user.

):
if not np.allclose(val, mir_data.sp_data[item][data_mask]):
warnings.warn(
"Discrepancy in %s for win %i sb %i pol %i." % (item, *spdx)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest adding some guidance in the warning message on whether this is a small discrepancy vs. something critical with the data.

Or would that be caught in the checks elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I extended the error message here in aa4bd2f -- the one time I saw this pop up (which used to throw an AssertionError) it was because a single record was bad, but it can also get triggered if there's a more significant issue to be checked. In the end I figured probably best to just point the user to what values should be looked at...

if not np.allclose(lst_array, self.lst_array, rtol=0, atol=np.pi / 1728000.0):
# If this check fails, it means that there's something off w/ the lst values
# (to a larger degree than expected), and we'll pass them back to the user,
# who can inspect them directly and decide what to do.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should get printed somewhere with suggestions on what to check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I've added a warning message here in aa4bd2f -- it's a little on the long side, although it hopefully gives enough guidance to the user on what to do and when to worry (it looks like the polling rate wasn't always 20 Hz, so this still triggers for some older data sets, but still in most cases it's just a problem with the metadata, not actually the visibilities).

@kartographer kartographer requested a review from e-koch February 13, 2024 12:08
@kartographer kartographer merged commit 7b5333f into main Feb 13, 2024
51 of 53 checks passed
@kartographer kartographer deleted the sma_dev branch February 13, 2024 13:52
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 UVData
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants