FIMS  v0.10.0
Loading...
Searching...
No Matches
fims_popdy::SizeBinMapping Struct Reference

Helper for mapping population biological size bins to observed fleet bins. More...

#include <size_bin_mapping.hpp>

Static Public Member Functions

static double OverlapWidth (double left_a, double right_a, double left_b, double right_b)
 Return the overlap width between two 1-D closed-open intervals.
 
static bool HasStrictlyIncreasingEdges (const fims::Vector< double > &edges)
 Check that a bin-edge vector is usable for geometric mapping.
 
static fims::Vector< fims::Vector< double > > BuildRebinWeights (const fims::Vector< double > &source_edges, const fims::Vector< double > &destination_edges)
 Build overlap-based rebin weights from source bins to destination bins.
 
static bool DestinationCoversSourceRange (const fims::Vector< double > &source_edges, const fims::Vector< double > &destination_edges)
 Check that the destination edges fully cover the source-bin range.
 
static fims::Vector< double > ExpandDestinationEdgesToCoverSourceRange (const fims::Vector< double > &source_edges, const fims::Vector< double > &destination_edges)
 Return explicit mapping edges whose support covers the source range while preserving the canonical destination bin breaks.
 
template<typename Type >
static fims::Vector< Type > ApplyRebinWeights (const fims::Vector< fims::Vector< double > > &weights, const fims::Vector< Type > &source_mass)
 Apply a source-to-destination bin mapping to a size-mass vector.
 

Detailed Description

Helper for mapping population biological size bins to observed fleet bins.

This helper operates only on bin geometry. It does not depend on growth, age-to-length conversion, selectivity, or catch-at-age logic.

Member Function Documentation

◆ ApplyRebinWeights()

template<typename Type >
static fims::Vector< Type > fims_popdy::SizeBinMapping::ApplyRebinWeights ( const fims::Vector< fims::Vector< double > > &  weights,
const fims::Vector< Type > &  source_mass 
)
inlinestatic

Apply a source-to-destination bin mapping to a size-mass vector.

The source vector contains probability mass or another size-indexed quantity on the population biological size grid. The weight matrix must have been created by BuildRebinWeights(), so each row corresponds to one destination bin and each column corresponds to one source bin. For each destination bin, this function multiplies the source mass in every source bin by its overlap fraction and sums the results. In matrix notation, the returned vector is destination_mass = weights * source_mass.

In the growth-derived age-to-length path, the source vector is the population-level age-to-size probability row and the destination vector is the fleet-specific age-to-length probability row. The caller may first use ExpandDestinationEdgesToCoverSourceRange() to extend the outer destination edges, then use BuildRebinWeights() to construct the geometric mapping. This function performs only the weighted aggregation; it does not validate or normalize the resulting row.

Parameters
weightsOverlap weights stored as [destination_bin][source_bin], typically returned by BuildRebinWeights().
source_massMass or probability values indexed by source bin.
Returns
Values aggregated onto the destination bins, in destination-bin order.
Exceptions
std::runtime_errorIf a weight row has a different number of columns than source_mass.
See also
BuildRebinWeights()
ExpandDestinationEdgesToCoverSourceRange()
AgeToLengthConversionDerived::BuildMappedFleetAgeToLengthConversionRow()

◆ BuildRebinWeights()

static fims::Vector< fims::Vector< double > > fims_popdy::SizeBinMapping::BuildRebinWeights ( const fims::Vector< double > &  source_edges,
const fims::Vector< double > &  destination_edges 
)
inlinestatic

Build overlap-based rebin weights from source bins to destination bins.

Parameters
source_edgesPopulation biological size-grid edges.
destination_edgesFleet observation-bin edges.
Returns
Matrix of weights stored as [destination_bin][source_bin].

Convert a probability distribution from FIMS's internal biological size grid into the same bins as observed by a fleet using geometric mass conservation when translating the growth-derived biological size distribution into the bins actually observed by a fleet. It requires destination support to cover source support and does not apply higher-level tail handling such as biological plus-group interpretation or observation-side compression rules.

◆ DestinationCoversSourceRange()

static bool fims_popdy::SizeBinMapping::DestinationCoversSourceRange ( const fims::Vector< double > &  source_edges,
const fims::Vector< double > &  destination_edges 
)
inlinestatic

Check that the destination edges fully cover the source-bin range.

Parameters
source_edgesPopulation biological size-grid edges.
destination_edgesFleet observation-bin edges.
Returns
True when the destination range contains the full source range.

◆ ExpandDestinationEdgesToCoverSourceRange()

static fims::Vector< double > fims_popdy::SizeBinMapping::ExpandDestinationEdgesToCoverSourceRange ( const fims::Vector< double > &  source_edges,
const fims::Vector< double > &  destination_edges 
)
inlinestatic

Return explicit mapping edges whose support covers the source range while preserving the canonical destination bin breaks.

Parameters
source_edgesPopulation biological size-grid edges that must be covered.
destination_edgesFleet observation-bin edges.
Returns
Copy of destination edges with only the outer edges widened as needed to cover the full source-bin range.

This is an explicit higher-level mapping policy. It does not redefine the canonical destination geometry itself; it only prepares a temporary edge vector for geometric translation when destination support is narrower than source support.

◆ HasStrictlyIncreasingEdges()

static bool fims_popdy::SizeBinMapping::HasStrictlyIncreasingEdges ( const fims::Vector< double > &  edges)
inlinestatic

Check that a bin-edge vector is usable for geometric mapping.

Parameters
edgesBin edges to validate.
Returns
True when there are at least 2 edges and they are strictly increasing.

◆ OverlapWidth()

static double fims_popdy::SizeBinMapping::OverlapWidth ( double  left_a,
double  right_a,
double  left_b,
double  right_b 
)
inlinestatic

Return the overlap width between two 1-D closed-open intervals.

Parameters
left_aLeft edge of interval A.
right_aRight edge of interval A.
left_bLeft edge of interval B.
right_bRight edge of interval B.
Returns
Non-negative overlap width.

The documentation for this struct was generated from the following file: