vignettes/running_processes_examples.R

## ---- include = FALSE---------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----echo=TRUE, eval=FALSE----------------------------------------------------
#  # setup ----
#  library(t3)
#  periode_reference <- as.integer(c(2006,
#                                    2007,
#                                    2008))
#  target_year <- as.integer(2008)
#  period_duration <- as.integer(2)
#  # countries for the France fleet
#  countries <- c("FRA",
#                 "MYT")
#  # code 1 for the Atlantic Ocean
#  ocean <- as.integer(1)
#  # code 1 for landing data
#  sample_type <- as.integer(1)
#  # for french fleet YFT, SKJ, BET, ALB, MIX and LOT
#  species_rf1_fr <- as.integer(c(1, 2, 3, 4, 9, 11))
#  # output directories initiation
#  final_output_path <- initiate_directory(output_path = output_path,
#                                          level = "all")
#  # output format
#  output_format <- "eu"
#  # generation of the confidence interval
#  confidence_interval <- TRUE
#  
#  # model creation ----
#  object_model_data <- t3:::object_model_data$new()
#  # object trips creation
#  object_model_data$trips_object_creation(data_source = "avdth_db",
#                                          periode_reference = periode_reference,
#                                          countries = countries,
#                                          oceans = ocean,
#                                          db_con = database_con)
#  # object activities creation
#  object_model_data$activities_object_creation(data_source = "avdth_db",
#                                               periode_reference = periode_reference,
#                                               countries = countries,
#                                               oceans = ocean,
#                                               db_con = database_con)
#  # object elementarycatches creation
#  object_model_data$elementarycatches_object_creation(data_source = "avdth_db",
#                                                      periode_reference = periode_reference,
#                                                      countries = countries,
#                                                      oceans = ocean,
#                                                      db_con = database_con)
#  # object elementarylandings creation
#  object_model_data$elementarylandings_object_creation(data_source = "avdth_db",
#                                                       periode_reference = periode_reference,
#                                                       countries = countries,
#                                                       oceans = ocean,
#                                                       db_con = database_con)
#  # object wells creation
#  object_model_data$wells_object_creation(data_source = "avdth_db",
#                                          periode_reference = periode_reference,
#                                          countries = countries,
#                                          oceans = ocean,
#                                          sample_type = sample_type,
#                                          db_con = database_con)
#  # model creation: set durations data
#  object_model_data$setdurationrefs_data(data_source = "csv",
#                                         data_path = system.file("setdurationrefs.csv",
#                                                                 package = "t3"),
#                                         periode_reference = periode_reference,
#                                         countries = countries)
#  # model creation: length steps data
#  object_model_data$lengthsteps_data(data_source = "csv",
#                                     data_path = system.file("lengthsteps.csv",
#                                                             package = "t3"))
#  # model creation: sample sets data
#  object_model_data$samplesets_data(data_source = "avdth_db",
#                                    periode_reference = periode_reference,
#                                    countries = countries,
#                                    oceans = ocean,
#                                    db_con = database_con)
#  # model creation: length weight relationships data
#  object_model_data$lengthweightrelationships_data(data_source = "csv",
#                                                   data_path = system.file("lengthweightrelationships.csv",
#                                                                           package = "t3"))
#  # initialisation object for full trips class
#  object_full_trips <- t3:::full_trips$new()
#  # object full_trip creation
#  object_full_trips$create_full_trips(object_trips = object_model_data$.__enclos_env__$private$trips)
#  # add activities to trips selected
#  object_full_trips$add_activities(object_activities = object_model_data$.__enclos_env__$private$activities)
#  # filter by reference year
#  object_full_trips$filter_by_time_period_reference(time_periode_reference = periode_reference)
#  # add elementarycatches to trips selected
#  object_full_trips$add_elementarycatches(object_elementarycatches = object_model_data$.__enclos_env__$private$elementarycatches)
#  # add elementarylandings to trips selected
#  object_full_trips$add_elementarylandings(object_elementarylandings = object_model_data$.__enclos_env__$private$elementarylandings)
#  # add well(s) and sample(s) to trip(s) selected
#  object_full_trips$add_wells_samples(object_wells = object_model_data$.__enclos_env__$private$wells)
#  
#  # level 1 ---
#  # level 1.1: rf1
#  object_full_trips$rf1(species_rf1 = species_rf1_fr,
#                        global_output_path = final_output_path,
#                        output_format = output_format)
#  # level 1.2: rf2
#  object_full_trips$rf2(global_output_path = final_output_path,
#                        output_format = output_format)
#  # level 1.3: logbook weigth categories conversion ----
#  object_full_trips$conversion_weigth_category(global_output_path = final_output_path,
#                                               output_format = output_format)
#  # level 1.4: set count
#  object_full_trips$set_count(global_output_path = final_output_path,
#                              output_format = output_format)
#  # level 1.5: set duration
#  object_full_trips$set_duration(set_duration_ref = object_model_data$.__enclos_env__$private$setdurationrefs,
#                                 global_output_path = final_output_path,
#                                 output_format = output_format)
#  # level 1.6: time at sea
#  object_full_trips$time_at_sea(global_output_path = final_output_path,
#                                output_format = output_format)
#  # level 1.7: fishing time
#  object_full_trips$fishing_time(global_output_path = final_output_path,
#                                 output_format = output_format)
#  # level 1.8: searching time
#  object_full_trips$searching_time(global_output_path = final_output_path,
#                                   output_format = output_format)
#  
#  # level 2 ----
#  # level 2.1: sample length class ld1 to lf conversion
#  object_full_trips$sample_length_class_ld1_to_lf(length_step = object_model_data$.__enclos_env__$private$lengthsteps,
#                                                  global_output_path = final_output_path,
#                                                  output_format = output_format)
#  # level 2.2: sample number measured extrapolation
#  object_full_trips$sample_number_measured_extrapolation(global_output_path = final_output_path,
#                                                         output_format = output_format)
#  # level 2.3: sample step length class standardisation
#  object_full_trips$sample_length_class_step_standardisation(global_output_path = final_output_path,
#                                                             output_format = output_format)
#  # level 2.4: well set weight categories
#  object_full_trips$well_set_weigth_categories(sample_set = object_model_data$.__enclos_env__$private$samplesets,
#                                               global_output_path = final_output_path,
#                                               output_format = output_format)
#  # level 2.5: standardised sample creation
#  object_full_trips$standardised_sample_creation(global_output_path = final_output_path,
#                                                 output_format = output_format)
#  # level 2.6: sample number standardisation
#  object_full_trips$standardised_sample_set_creation(length_weight_relationship_data = object_model_data$.__enclos_env__$private$lengthweightrelationships,
#                                                     global_output_path = final_output_path,
#                                                     output_format = output_format)
#  # level 2.7: raised factors determination
#  object_full_trips$raised_factors_determination(global_output_path = final_output_path,
#                                                 output_format = output_format)
#  # level 2.8: samples number standardisation at set scale
#  object_full_trips$raised_standardised_sample_set(global_output_path = final_output_path,
#                                                   output_format = output_format)
#  
#  # level 3 ----
#  process_level3 <- object_full_trips$path_to_level3()
#  # level 3.1: data preparatory
#  process_level3 <- object_full_trips$data_preparatory(inputs_level3 = process_level3[[1]],
#                                                       output_directory = final_output_path,
#                                                       target_year = target_year,
#                                                       period_duration = period_duration)
#  # level 3.2: random forest models ----
#  process_level3$output_level3_process2 <- object_full_trips$random_forest_models(output_level3_process1 = process_level3$output_level3_process1$data_lb_sample_screened$data4mod)
#  # level 3.3: models checking ----
#  process_level3$output_level3_process3 <- object_full_trips$models_checking(output_level3_process2 = process_level3$output_level3_process2,
#                                                                             output_directory = process_level3$output_directory)
#  # level 3.4: data formatting for predictions ----
#  process_level3$output_level3_process4 <- object_full_trips$data_formatting_for_predictions(inputs_level3 = process_level3$raw_inputs_level3,
#                                                                                             output_level3_process1 = process_level3$output_level3_process1$data_lb_sample_screened$data4mod,
#                                                                                             target_year = target_year)
#  # level 3.5: predictions ----
#  process_level3$output_level3_process5 <- object_full_trips$model_predictions(output_level3_process2 = process_level3$output_level3_process2,
#                                                                               output_level3_process4 = process_level3$output_level3_process4,
#                                                                               output_directory = process_level3$output_directory,
#                                                                               ci = confidence_interval)

## ----echo=TRUE, eval=FALSE----------------------------------------------------
#  # setup ----
#  library(t3)
#  periode_reference <- as.integer(c(2006,
#                                    2007,
#                                    2008))
#  target_year <- as.integer(2008)
#  period_duration <- as.integer(2)
#  # countries for the France fleet
#  countries <- c("FRA",
#                 "MYT")
#  # code 1 for the Atlantic Ocean
#  ocean <- as.integer(1)
#  # code 1 for landing data
#  sample_type <- as.integer(1)
#  # for french fleet YFT, SKJ, BET, ALB, MIX and LOT
#  species_rf1 <- as.integer(c(1, 2, 3, 4, 9, 11))
#  # output directories initiation
#  final_output_path <- initiate_directory(output_path = output_path,
#                                          level = "all")
#  # output format
#  output_format <- "eu"
#  # generation of the confidence interval
#  confidence_interval <- TRUE
#  
#  # data model initialisation ----
#  t3_process <- t3::data_model_initialisation(data_source = "avdth_db",
#                                              db_con = database_con,
#                                              periode_reference = periode_reference,
#                                              countries = countries,
#                                              oceans = ocean,
#                                              sample_type = sample_type)
#  # level 1 ----
#  t3_process[[2]] <- t3::t3_level1(object_model_data = t3_process[[1]],
#                                   object_full_trips = t3_process[[2]],
#                                   species_rf1 = species_rf1,
#                                   output_path = final_output_path,
#                                   output_format = output_format)
#  # level 2 ----
#  t3_process[[2]] <- t3::t3_level2(object_model_data = t3_process[[1]],
#                                   object_full_trips = t3_process[[2]],
#                                   output_path = final_output_path,
#                                   output_format = output_format)
#  # level 3 ----
#  t3_process[[3]] <- t3_process$object_full_trips$path_to_level3()
#  names(t3_process)[3] <- "process_level3"
#  t3_process[[3]] <- t3::t3_level3(inputs_level3 = t3_process[[3]][[1]],
#                                   target_year = target_year,
#                                   period_duration = period_duration,
#                                   ci = confidence_interval,
#                                   output_path = final_output_path,
#                                   output_format = output_format)

## ----echo=TRUE, eval=FALSE----------------------------------------------------
#  # setup ----
#  library(t3)
#  periode_reference <- as.integer(c(2006,
#                                    2007,
#                                    2008))
#  target_year <- as.integer(2008)
#  period_duration <- as.integer(2)
#  # countries for the France fleet
#  countries <- c("FRA",
#                 "MYT")
#  # code 1 for the Atlantic Ocean
#  ocean <- as.integer(1)
#  # code 1 for landing data
#  sample_type <- as.integer(1)
#  # for french fleet YFT, SKJ, BET, ALB, MIX and LOT
#  species_rf1 <- as.integer(c(1, 2, 3, 4, 9, 11))
#  # output format
#  output_format <- "eu"
#  # generation of the confidence interval
#  confidence_interval <- TRUE
#  
#  # process ----
#  t3_process_all <- t3::t3_process(process = "all",
#                                   data_source = "avdth_db",
#                                   db_con = database_con,
#                                   output_path = output_path,
#                                   output_format = "eu",
#                                   periode_reference = periode_reference,
#                                   countries = countries,
#                                   oceans = ocean,
#                                   sample_type = sample_type,
#                                   species_rf1 = species_rf1,
#                                   target_year = target_year,
#                                   period_duration = period_duration,
#                                   ci = confidence_interval)
OB7-IRD/t3 documentation built on May 11, 2024, 7:02 a.m.