HERA-Team / hera_pspec

HERA power spectrum estimation code and data formats
http://hera-pspec.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

Fix uvp_noise_error() for interleaved LSTs #389

Closed jsdillon closed 11 months ago

jsdillon commented 11 months ago

The documentation of utils.uvp_noise_error() suggest that if "power spectra were computed from interleaved times then the supplied auto_Tsys should include all of the times that are present in all of the pairs." For interleaved power spectra, that the number of times in auto_Tsys (a UVData object) might be double (or more, for more interleaves) the number of times in uvp.lst_avg_array.

This creates a problem in the line

Tsys = interp1d(lsts[~Tflag], Tsys[~Tflag], kind='nearest', bounds_error=False, fill_value='extrapolate')(lst_avg)

because lsts is calculated as

lst_indices = np.unique(auto_Tsys.lst_array, return_index=True)[1]
lsts = auto_Tsys.lst_array[sorted(lst_indices)]

while Tflag has a shape determined by the number of times in uvp.time_1_array and uvp.time_2_array. When that number of times don't match, this causes an error in lsts[~Tflag] because Tflag is half the length of lsts (for example).

This PR fixes that bug by ensuring that the range of lsts indexed into by ~Tflag is the precise right shape.

@Kai-FengChen can you review this PR? Also, @aewallwi just wanted to give you a heads up since this might impinge on your work.

codecov[bot] commented 11 months ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (bd65cd8) 95.99% compared to head (9f71ded) 95.99%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #389 +/- ## ======================================= Coverage 95.99% 95.99% ======================================= Files 17 17 Lines 6113 6118 +5 ======================================= + Hits 5868 5873 +5 Misses 245 245 ``` | [Flag](https://app.codecov.io/gh/HERA-Team/hera_pspec/pull/389/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=HERA-Team) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/HERA-Team/hera_pspec/pull/389/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=HERA-Team) | `95.99% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=HERA-Team#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/HERA-Team/hera_pspec/pull/389?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=HERA-Team) | Coverage Δ | | |---|---|---| | [hera\_pspec/utils.py](https://app.codecov.io/gh/HERA-Team/hera_pspec/pull/389?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=HERA-Team#diff-aGVyYV9wc3BlYy91dGlscy5weQ==) | `91.09% <100.00%> (+0.07%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.