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

feat: new simultaneous inpainter #951

Merged
merged 9 commits into from
Jun 18, 2024
Merged

Conversation

steven-murray
Copy link
Contributor

This puts @tyler-a-cox's new simultaneous inpainter into hera_cal.lst_stack.averaging.

I refactored it a little so that the algorithm itself, that acts on a single baseline, is its own function. This makes testing it much easier, since you just have to create data arrays that are shape (nnights, nfreqs).

I've put a number of test cases in (as of now, not all of them pass...)

Copy link

codecov bot commented Jun 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.20%. Comparing base (dac1027) to head (5d006e0).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #951      +/-   ##
==========================================
+ Coverage   97.18%   97.20%   +0.01%     
==========================================
  Files          30       30              
  Lines       10728    10793      +65     
==========================================
+ Hits        10426    10491      +65     
  Misses        302      302              
Flag Coverage Δ
unittests 97.20% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jsdillon jsdillon left a comment

Choose a reason for hiding this comment

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

Just some minor comments, but this generally looks good to me. Thanks @steven-murray!

stackf: np.ndarray,
stackn: np.ndarray,
base_noise_var: np.ndarray,
df: un.Quantity['frequency'],
Copy link
Member

Choose a reason for hiding this comment

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

I think this should just be a float for this function. At minimum, I don't want to force us to use .value... maybe we can make it flexible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made it flexible (if a float, assume it's in Hz) and added docs.

hera_cal/lst_stack/averaging.py Show resolved Hide resolved
max_convolved_flag_frac: float = 0.667,
use_unbiased_estimator: bool = False,
sample_cov_fraction: float = 0.0,
filter_half_widths: Sequence[float] = [0.1],
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is a reasonable default...

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if it should have a default, TBH.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right -- I've removed the default.

sample_cov_fraction : float
A factor to use to down-weight off-diagonal elements of the sample covariance.
filter_half_widths : Sequence[float]
The half-widths of the DPSS filters.
Copy link
Member

Choose a reason for hiding this comment

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

What units?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added that info to the docstring.


# Get median nsamples across the band
nsamples_by_night = np.median(stackn, axis=1, keepdims=True)
assert np.all(nsamples_by_night == stackn), 'This code assumes that nsamples is constant over frequency for a given night and baseline.'
Copy link
Member

Choose a reason for hiding this comment

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

We should probably turn this into a proper raised error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup. Done.

continue

# if there are too-large flag gaps even after a simple LST-stacking, continue
max_allowed_gap_size = max_gap_factor * filter_half_widths[0]**-1 / df.value
Copy link
Member

Choose a reason for hiding this comment

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

See above note about df.value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

hera_cal/lst_stack/averaging.py Show resolved Hide resolved
@steven-murray steven-murray merged commit 8a58c70 into main Jun 18, 2024
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants