-
Notifications
You must be signed in to change notification settings - Fork 76
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
Standardize use of transmit_frequency_start/stop
and use pulse_form
for BB checks
#1091
Standardize use of transmit_frequency_start/stop
and use pulse_form
for BB checks
#1091
Conversation
… float) and attributes
Codecov Report
@@ Coverage Diff @@
## dev #1091 +/- ##
===========================================
- Coverage 78.19% 60.15% -18.05%
===========================================
Files 65 43 -22
Lines 6247 5067 -1180
===========================================
- Hits 4885 3048 -1837
- Misses 1362 2019 +657
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 49 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Based on #951 (comment), the new checks for broadband channels should use |
I also don't know what "FMD" is, but in the files we have access to it is either 0 or 1. |
I'll add the |
…to strings (CW, FM, FMD)
Renamed EK80 Not really part of the original scope of this PR (it's a follow up to #951), but this change will need to be in place before the new check for BB based on pulse_form (transmit_type) can be implemented. |
I went back to the function _get_chan_dict to check again and think that:
# Use center frequency for each ping to select BB or CW channels
# when all samples are encoded as complex samples
if "frequency_start" in beam and "frequency_end" in beam:
# At least some channels are BB
# frequency_start and frequency_end are NaN for CW channels
freq_center = (beam["frequency_start"] + beam["frequency_end"]) / 2
return {
# For BB: drop channels containing CW samples (nan in freq start/end)
"BB": freq_center.dropna(dim="channel").channel,
# For CW: drop channels containing BB samples (not nan in freq start/end)
"CW": freq_center.where(np.isnan(freq_center), drop=True).channel,
} For 1: I think we should probably document it but not making any changes for the time being. Most of the time things do not get fiddled in the middle of a file, especially because complex data is pretty huge so the number of pings within a typical file, say 100 MB, is pretty small. For 2.: What do you think about the following: if 1 in beam["pulse_form"]:
# At least 1 BB ping exists -- this is analogous to what we had from before
# Before: when at least 1 BB ping exists, "frequency_start" and "frequency_end" will exist
freq_center = (beam["frequency_start"] + beam["frequency_end"]) / 2
# This part below doesn't require changes (so still buggy)
return {
# For BB: drop channels containing CW samples (nan in freq start/end)
"BB": freq_center.dropna(dim="channel").channel,
# For CW: drop channels containing BB samples (not nan in freq start/end)
"CW": freq_center.where(np.isnan(freq_center), drop=True).channel,
} |
Quick note: by coincidence, I discovered that this raw file may be one such case: |
…ize-freq-startend
if 1 in beam["pulse_form"]:
# At least 1 BB ping exists -- this is analogous to what we had from before
# Before: when at least 1 BB ping exists, "frequency_start" and "frequency_end" will exist That'll work. Come to think of it, my use of For this check, though, I know you've said that you haven't encountered the "FMD" ( Now, back to 1. The one above from echopype/echopype/calibrate/calibrate_ek.py Lines 314 to 316 in eb92185
echopype/echopype/echodata/simrad.py Lines 141 to 145 in eb92185
echopype/echopype/convert/set_groups_ek80.py Lines 647 to 653 in eb92185
2. A test for the absence of BB pings (ie, all CW), with two occurrences: echopype/echopype/echodata/simrad.py Lines 121 to 126 in eb92185
echopype/echopype/calibrate/ek80_complex.py Lines 214 to 218 in eb92185
I can now see that this test can be handled with the Ok, I think the path is clear now. Thanks! |
Good point. I guess then it'll be the reverse of the previous code, making it like below: if not np.all(beam["pulse_form"] == 0): |
Oh! ok I'll take a look. Seems that we've not used this file for cal tests, but I suspect that the operations will go through, but the results will be wrong. I can create a new issue for this. |
Nicer and cleaner. But wouldn't it be more expensive computationally than this? 1 in beam["pulse_form"] or 5 in beam["pulse_form"]
# or, more compactly:
np.isin(beam["pulse_form"], [1,5]).any() Update: I've run some comparisons: r = np.random.randint(5, size=(int(1e5)))
%timeit not np.all(r == 0)
24.4 µs ± 565 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
%timeit 1 in r or 4 in r
25.1 µs ± 175 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
%timeit np.isin(r, [1,4]).any()
825 µs ± 17.1 µs per loop (mean ± std. dev. of 7 runs, 1,000 loops each) Interesting! I'll go with your suggestion. |
That's correct: the operations went through. I was using that file (don't remember why I picked it) in my echopype checker, when I noticed the results. |
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.
@emiliom : Thanks for the PR! I think there are a couple places that have bugs. Could you look through my comments and change them?
I think we will have to add a disclaimer in the documentation that the code does not currently handle within-channel FM-CW switches if they are both encoded in complex samples. (I still need to write an issue to keep track of this.)
…nt in tapered_chirp
I've addressed all your comments. Thanks so much! Hopefully the CI will complete w/o issues. I also merged from I'm not sure if the proper Github step here is to "Dismiss" your previous review, or if you should do that after reviewing my changes. I requested another review, but maybe that was unnecessary. Oh well. |
Woo-hoo, the CI tests all passed! |
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.
LGTM, thanks! I suggested a small tweak to just to make things parallel when we get around to fix the within-channel CW-BB switch.
Co-authored-by: Wu-Jung Lee <[email protected]>
Co-authored-by: Wu-Jung Lee <[email protected]>
Thanks! I committed your two inline suggestions here. As soon as the CI is done, I can merge. |
…etailed flag_meanings strings, largely from the convention
…pe into standardize-freq-startend
I've pushed the changes we discussed:
Assuming everything checks out, we can then merge this PR |
Looks good. I'll merge now! |
Addresses #1081 (and has linkage to #951). Specifically:
frequency_start/end
totransmit_frequency_start/stop
int
tofloat
transmit_type
/pulse_form
.BB
, set values tofrequency_nominal
rather thannan
transmit_frequency_start/stop
are set to always exist and always have valid, non-nan
values.transmit_frequency_start/stop
with only achannel
dimension and set their values tofrequency_nominal
transmit_frequency_start/stop
with only achannel
dimension and set their values tofrequency_nominal