Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: RstoxBase
Version: 2.2.1
Date: 2026-06-25
Date: 2026-07-06
Title: Base StoX Functions
Authors@R: c(
person(given = "Arne Johannes",
Expand Down Expand Up @@ -47,7 +47,7 @@ Imports:
jsonlite (>= 1.6),
lwgeom (>= 0.2-0),
maps (>= 0.2-0),
RstoxData (>= 2.2.0),
RstoxData (>= 2.2.1),
sf (>= 0.9.0),
stringi (>= 1.4.0),
units (>= 0.7),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# RstoxBase v2.2.1 (2026-07-04)
* Fixed bug in SuperIndividuals() due to SampleWeight or SampleNumber = 0. This is now OK if there are no individuals with length in the sample.


# RstoxBase v2.2.1-9006 (2026-06-22)
* Reduced processing time for the functions MeanNASC, AcousticDensity, MeanDensity and Abundance to approximately 30% for a StoX project with large acoustic data (regular survey with 10 m channels and 0.1 nautical mile log distance). This can lead to approximately 50 % reduction in Bootstrap time.

Expand Down
1 change: 1 addition & 0 deletions R/Abundance.R
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ SuperIndividuals <- function(
SuperIndividualsData[, Abundance := Abundance * individualWeightFactor]

# Test whether the sum of the Abundance is equal to that of the QuantityData. Note that if all SuperIndividualsData$Abundance and all QuantityData$Data$Abundance are NA, the totalAbundanceInSuperIndividualsData and totalAbundanceInQuantityData will be 0 due to the na.rm = TRUE. Before, testEqualTo1() was used here, but this returned NA for 0 / 0 = NaN, and the condition in the test failed. Thus the testEqual() is used instead:

totalAbundanceInSuperIndividualsData <- sum(SuperIndividualsData$Abundance, na.rm = TRUE)
totalAbundanceInQuantityData <- sum(QuantityData$Data$Abundance, na.rm = TRUE)
if(!testEqual(totalAbundanceInSuperIndividualsData, totalAbundanceInQuantityData)) {
Expand Down
7 changes: 4 additions & 3 deletions R/LengthDistribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,13 @@ LengthDistribution <- function(
#LengthDistributionData <- addLayerProcessData(LengthDistributionData, dataType = "LengthDistributionData", layerProcessData = if(IncludeLayer) BioticLayer)
######################################################


#######################################################
##### 5. Aggregate multiple samples to each haul: #####
#######################################################
# Create a data table of different raising factors in the columns:
raisingFactorTable <- data.frame(
Weight = LengthDistributionData$CatchFractionWeight / LengthDistributionData$SampleWeight,
Number = LengthDistributionData$CatchFractionNumber / LengthDistributionData$SampleNumber#,
Weight = ifelse(LengthDistributionData$SampleWeight == 0, NA, LengthDistributionData$CatchFractionWeight / LengthDistributionData$SampleWeight),
Number = ifelse(LengthDistributionData$SampleNumber == 0, NA, LengthDistributionData$CatchFractionNumber / LengthDistributionData$SampleNumber)#,
#Percent = 1
)

Expand All @@ -177,6 +176,8 @@ LengthDistribution <- function(
raisingFactorIndex <- apply(raisingFactorTable, 1, getIndexOfFirstNonNA, LengthDistributionType = LengthDistributionType)
LengthDistributionData$raisingFactor <- raisingFactorTable[cbind(seq_along(raisingFactorIndex), raisingFactorIndex)]



# Set raisingFactor to 1 if LengthDistributionType == "Percent" and only one sample:
if(LengthDistributionType == "Percent") {
LengthDistributionData[numberOfSubSamples == 1 & is.na(raisingFactor), raisingFactor := 1]
Expand Down
Loading