-
Notifications
You must be signed in to change notification settings - Fork 8
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
Use filter files #916
Use filter files #916
Conversation
Many of the lines were clipping in my text editor, so I inserted some line breaks to make it more readable.
Also some more cleaning up of the filtering code.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #916 +/- ##
==========================================
- Coverage 97.18% 97.17% -0.01%
==========================================
Files 23 23
Lines 10446 10486 +40
==========================================
+ Hits 10152 10190 +38
- Misses 294 296 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good. Just a handful of minor issues, mostly in documentation and explanations.
For future reference, I'd really prefer if unrelated whitespace changes are put in a separate PR. Putting it all together makes it a lot more time consuming to review because I have to carefully scan for the substantive changes.
hera_cal/frf.py
Outdated
@@ -1572,24 +1574,29 @@ def tophat_frfilter_argparser(mode='clean'): | |||
"and apply independent fringe-rate filters. Default is 1 (no interleaved filters).", | |||
"This does not change the format of the output files but it does change the nature of their content.") | |||
filt_options.add_argument("--ninterleave", default=1, type=int, help=desc) | |||
filt_options.add_argument( | |||
"--param_file", default="", type=str, help="File containing filter parameters" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you say more about the type of file expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, definitely. I kept it terse because I wanted to wait until we agreed on how to format the files.
hera_cal/frf.py
Outdated
have_bl_info.append( | ||
(bl[:2] in filter_antpairs) or (bl[:2][::-1] in filter_antpairs) | ||
) | ||
if not all(have_bl_info): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why track have_bl_info
and then only raise the error at the end, instead of just raising it ass soon as you encounter it? Also, the error message should say which baseline it couldn't find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about I update this so that when it errors it tells the user all of the baselines that couldn't be found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's fine
Thank you for the review @jsdillon! I will make the recommended changes. I apologize for adding a bunch of fluff in the form of whitespace changes, but I develop in vim and it was practically impossible to read the code in the terminal with how much line wrapping there was. I will keep this in mind if I make future additions to the code. Before addressing your comments, I would like to get your opinion on the file format. Ideally, I would access the filter parameters with an antenna pair tuple; however, python tuples are not supported by
Thank you again for the review! I can make all of the requested changes once we settle on a final format for the filter files. |
What do you mean by baseline integers? Like the ones in pyuvdata? Those aren't human readable... |
Yeah, like the ones from
|
OK, I have updated the code so that filter parameter files use strings for the antenna pairs, and there is an extra bit of code that converts those strings into tuples. I have also fleshed out the documentation regarding the parameter files and added an example parameter file. Here is what the sample file looks like:
Please let me know what additional changes you would like to see when you have time to go through the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last request, but after that, good to go!
with open(tmpdir / "filter_info.yaml", "w") as f: | ||
yaml.dump(filter_info, f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One final suggestion: let's use the exmaple_filter_params.yaml in the test (that ensures it's not accidentally deleted in the future)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. How about I use the example filter file in the test for the missing baseline error message? The one that tests the actual performance of the code has two cases to make sure it does things correctly when the antennas are flipped in the filter parameter file, so I'm partial to using a temporary file for those tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine
This PR adds the ability to use the tophat filtering code with
yaml
files containing pre-computed filter parameters. The core assumption here is that there is one filter file per spectral window, and the filter files have the following structure:where
(ant1, ant2)
here is a placeholder for all of the baselines in the array (or a superset of baselines in the array). I am open to changing the file format slightly, sinceyaml.SafeLoader
doesn't know how to interpret python tuples; we would just need to agree on a format to use, document it, and stick with it. I have written simple unit tests for the code functionality, but I haven't yet tried a more sophisticated test (i.e., on something that looks like real data with many baselines).I also added some line breaks here and there because the code was wrapping in my terminal.