ices-eg / ICES-VMS-and-Logbook-Data-Call

GNU General Public License v3.0
4 stars 5 forks source link

SAR Calculation into National Report #9

Open neilcampbelll opened 9 months ago

neilcampbelll commented 9 months ago

Suggestion from the group to include the SAR calculation in the QC report stage. Need to think on this a bit...

neilcampbelll commented 9 months ago

Proposal is that data submitters calculate SAR and include it in their submission, and QC map is of this...

neilcampbelll commented 9 months ago

Figure out a way for submitters to provide fishing speed and mean gear widths per metier. New "table 3" or just extra columns in table 1.

neilcampbelll commented 8 months ago

@PatrikJonssonLL comment on calculating swept area, rather than SAR. makes things clearer. SAR calculation comes later.

jepol77 commented 5 months ago

Here is a method that can add gearwidth and then calculate swept area to the tacsateflalo file:

add_gearwidth <- function(x, met_name = "LE_MET", oal_name = "VE_LEN", kw_name = "VE_KW"){

require(data.table) require(dplyr) require(sfdSAR) require(icesVMS)

setDT(x) ID <- c(oal_name, kw_name) x[,(ID):= lapply(.SD, as.numeric), .SDcols = ID] x[, Metier_level6 := get(met_name)]

Updated metiers

metier_lookup <- fread("https://raw.githubusercontent.com/ices-eg/RCGs/master/Metiers/Reference_lists/RDB_ISSG_Metier_list.csv")

if(any(x[, get(met_name)] %!in% metier_lookup$Metier_level6)) stop(paste("Non valid metiers in tacsatEflalo:", paste(x[x[, get(met_name)] %!in% metier_lookup$Metier_level6][, get(met_name)], collapse = ", ")))

gear_widths <- get_benthis_parameters()

aux_lookup <- data.table(merge(gear_widths, metier_lookup, by.x = "benthisMet", by.y = "Benthis_metiers", all.y = T)) aux_lookup <- aux_lookup[,.(Metier_level6, benthisMet, avKw, avLoa, avFspeed, subsurfaceProp, gearWidth, firstFactor, secondFactor, gearModel, gearCoefficient, contactModel)]

aux_lookup <<- unique(aux_lookup)

aux_lookup <- data.table(merge(gear_widths, metier_lookup, by.x = "benthisMet", by.y = "Benthis_metiers", all.y = T)) aux_lookup <- aux_lookup[,.(Metier_level6, benthisMet, avKw, avLoa, avFspeed, subsurfaceProp, gearWidth, firstFactor, secondFactor, gearModel, gearCoefficient, contactModel)]

aux_lookup[gearCoefficient == "avg_kw", gearCoefficient := kw_name] aux_lookup[gearCoefficient == "avg_oal", gearCoefficient := oal_name]

aux_lookup <- unique(aux_lookup)

vms <- x |> left_join(aux_lookup, by = "Metier_level6")

vms$gearWidth_model <- predict_gear_width(vms$gearModel, vms$gearCoefficient, vms)

if("avg_gearWidth" %!in% names(vms)) vms[, avg_gearWidth := NA]

gearWidth_filled <- with(vms, ifelse(!is.na(avg_gearWidth), avg_gearWidth, ifelse(!is.na(gearWidth_model), gearWidth_model, gearWidth) ))

return(gearWidth_filled) }

Add the calculated gearwidth to each fishingpoint

tacsatEflalo$SI_GEARWIDTH <- add_gearwidth(tacsatEflalo, met_name = "LE_MET", oal_name = "VE_LEN", kw_name = "VE_KW")

Add swept area(m2) for each point in the tacsateflalo

tacsatEflalo$SA_M2 <- tacsatEflalo$SI_GEARWIDTH tacsatEflalo$INTV tacsatEflalo$SI_SP *1852