You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improved internal algorithm for generalized sizecomp #751
A user configured a generalized sizecomp with narrow weight bins for the data. SS3 crashed without providing warning. The problem is that when the setup is using weight bins, a narrow population length bin can translate to weight range that is wider than the user-specified weight bins. @N-DucharmeBarth-NOAA
The code is designed to detect where the population bin is completely within a data bin and assign all of that pop bin to the data bin, and to detect when there are multiple consecutive pop bins that fall within the same data bin range and assign all of them to that range. It also can detect when a pop bin stradles the upper edge of a data bin and apportion that pop bin to the current and nect data bin, then to correctly move on to the next pop bin.
However, the code cannot detect when the upper edge of a pop bin would skip over a data bin. When this happens, no warning is issued and a crash typically occurs.
Resolution: Completely replace the legacy sizefreq translation matrix with the rebin method. This is more efficient and completely robust to bin width specifications.
C++ Routine: Linear Area Rebinning
This implementation takes two vectors representing the boundaries (edges) of the source and destination bins, and one vector for the source counts.
#include
#include
/**
Rebins frequency data from one set of boundaries to another.
@PARAM src_edges Boundaries of the original bins (size N+1).
@PARAM src_counts Frequency/counts in original bins (size N).
@PARAM dest_edges Boundaries of the new bins (size M+1).
@return Vector of rebinned frequency data (size M).
*/
std::vector rebin(const std::vector& src_edges,
const std::vector& src_counts,
const std::vector& dest_edges) {
changed the title [-]need warning and improved logic for generalized sizecomp[/-][+]Improved internal algorithm for generalized sizecomp[/+]on Oct 26, 2026
Activity
Rick-Methot-NOAA commentedon Feb 2, 2026
This routine might be the solution:
C++ Routine: Linear Area Rebinning
This implementation takes two vectors representing the boundaries (edges) of the source and destination bins, and one vector for the source counts.
#include
#include
/**
Rebins frequency data from one set of boundaries to another.
@PARAM src_edges Boundaries of the original bins (size N+1).
@PARAM src_counts Frequency/counts in original bins (size N).
@PARAM dest_edges Boundaries of the new bins (size M+1).
@return Vector of rebinned frequency data (size M).
*/
std::vector rebin(const std::vector& src_edges,
const std::vector& src_counts,
const std::vector& dest_edges) {
std::vector dest_counts(dest_edges.size() - 1, 0.0);
for (size_t i = 0; i < dest_counts.size(); ++i) {
double d_low = dest_edges[i];
double d_high = dest_edges[i + 1];
}
return dest_counts;
}
[-]need warning and improved logic for generalized sizecomp[/-][+]Improved internal algorithm for generalized sizecomp[/+]