R/s2fit_to_s2ts.R

Defines functions s2fit_to_s2ts

# Internal function which will be used as methods of the upcoming class "s2fit"

#' @import data.table

s2fit_to_s2ts <- function(fit) {
  # Avoid check notes for data.table related variables
  value <- NULL
  # Check s2fit format
  # TODO
  rbindlist(lapply(names(fit), function(sel_id) {
    rbindlist(lapply(names(fit[[sel_id]]), function(sel_year) {
    rbindlist(lapply(names(fit[[sel_id]][[sel_year]]), function(sel_cycle) {
      fit[[sel_id]][[sel_year]][[sel_cycle]][["ts"]][
        ,list("id" = sel_id, "year" = sel_year, "cycle" = sel_cycle, date, value)
        ]
    }))
    }))
  }))
}
ranghetti/sen2rts documentation built on March 31, 2024, 1:18 a.m.