Skip to content

Commit

Permalink
Merge pull request #380 from StoXProject/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
arnejohannesholmin authored Nov 29, 2024
2 parents f51ebfa + 25c8a5f commit 8d90de3
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
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.1.0
Date: 2024-11-05
Version: 2.1.1-9001
Date: 2024-11-27
Title: Base StoX Functions
Authors@R: c(
person(given = "Arne Johannes",
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# RstoxBase v2.1.1-9001 (2024-11-13)
* Fixed bug in MeanNASC() causing StratumPolygon to show in the Function inputs if the user first selects PSUDefinition = "FunctionParameter" and PSUDefinitionMethod = "EDSUToPSU" and then changing to PSUDefinition = "FunctionInput".
* Fixed bug in DefineAcousticTargetStrength() where when specifying a table with the columns AcousticCategory, Frequency, TotalLength and TargetStrength in the case of AcousticTargetStrengthModel = "TargetStrengthByLength" resulted in the error message "The output from DefineAcousticTargetStrength() contains duplicated keys (AcousticCategory, Frequency) in rows 1, 2.". The reason was that only the first two columns were considered as grouping variables, whereas all three first columns should (specifying different lengths, and a target strength per length).


# RstoxBase v2.1.0 (2024-11-04)
* Final release for StoX 4.1.0.
* Fixed bug in DefineBioticAssignment() where empty BioticAssignment led to an error in DefineBioticAssignment_Warnings() and caused StoX to believe that the process had not bee run.
Expand Down
5 changes: 4 additions & 1 deletion R/Abundance.R
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,10 @@ SuperIndividuals <- function(
!is.na(SpeciesCategory)
)]
if(length(atMissisngLengthButPresentAbundance)) {
warning("StoX: There are rows of the QuantityData with positive Abundance for a species that cannot be matched to any individuals of the IndividualsData. The reason for this may be that there are samples in the StoxBioticData used as input to the LengthDistribution process earlier in the Baseline model that have positive SampleNumber but no individuals. The consequence is that Abundance is set to NA in SuperIndividualsData for the following Stratum Layer and SpeciesCategory, resulting in loss of Abundance: ", paste(SuperIndividualsData[atMissisngLengthButPresentAbundance, paste0("Stratum: ", Stratum, ", Layer: ", Layer, ", SpeciesCategory: ", SpeciesCategory)], collapse = "\n"))
# Report unique combinations of Stratum, Layer and SpeciesCategory with a problem:
badStratumLayerSpeciesCategory <- unique(SuperIndividualsData[atMissisngLengthButPresentAbundance, paste0("Stratum: ", Stratum, ", Layer: ", Layer, ", SpeciesCategory: ", SpeciesCategory)])

warning("StoX: There are rows of the QuantityData with positive Abundance for a species that cannot be matched to any individuals of the IndividualsData.\nDetails: One reason may be different length resolutions in the LengthDistributionData, which causes problems for the SuperIndividuals function when trying to distribute Abundance into length intervals. A different reason may be that there are samples in the StoxBioticData used as input to the LengthDistribution process positive SampleNumber but no individuals. The consequence is that Abundance is set to NA in SuperIndividualsData for the following Stratum Layer and SpeciesCategory, resulting in loss of Abundance: ", paste(badStratumLayerSpeciesCategory, collapse = "\n"))
}

# Sum the haul densities (stored as WeightedNumber) over all hauls of each Stratum/Layer/SpeciesCategory/TempLengthGroupUsedInSuperIndividuals/Frequency/Beam:
Expand Down
3 changes: 2 additions & 1 deletion R/Definitions.R
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,8 @@ initiateRstoxBase <- function(){
LengthDependent = c("TargetStrength0", "LengthExponent"),
LengthAndDepthDependent = c("TargetStrength0", "LengthExponent", "DepthExponent"),
LengthExponent = "LengthExponent",
TargetStrengthByLength = c("TargetStrength", "TotalLength")
#TargetStrengthByLength = c("TargetStrength", "TotalLength")
TargetStrengthByLength = c("TargetStrength")
),
Regression = list(
SimpleLinear = c("Intercept", "Slope"),
Expand Down
4 changes: 2 additions & 2 deletions R/Density.R
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ getTargetStrengthByLengthFunction <- function(AcousticTargetStrengthTable, metho

# Define the columns to modify:
functionColumns <- c("TotalLength", "TargetStrength")
by <- setdiff(names(AcousticTargetStrength), functionColumns)
by <- setdiff(names(AcousticTargetStrengthTable), functionColumns)

# Add mid points to the AcousticTargetStrength to facilitate use of approxfun with method = "constant":
# Add mid points to the AcousticTargetStrengthTable to facilitate use of approxfun with method = "constant":
AcousticTargetStrengthTable <- expandTargetStrengthTable(AcousticTargetStrengthTable, by = by)

# Get one function for each combination of the columns given by 'by':
Expand Down
2 changes: 2 additions & 0 deletions R/stoxFunctionAttributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -835,9 +835,11 @@ stoxFunctionAttributes <- list(
PSUDefinition = "FunctionParameter"
),
StratumPolygon = list(
PSUDefinition = "FunctionParameter",
PSUDefinitionMethod = "EDSUToPSU"
),
StratumPolygon = list(
SurveyDefinition = "FunctionParameter",
SurveyDefinitionMethod = "Table"
),
# Survey:
Expand Down

0 comments on commit 8d90de3

Please sign in to comment.