AddStep: Create the workflow with the previous defined operation and...

View source: R/AddStep.R

AddStepR Documentation

Create the workflow with the previous defined operation and data.

Description

The step that combines the previous declared data and operation together to create the complete workflow. It is the final step before data processing.

Usage

AddStep(inputs, step_fun, ...)

Arguments

inputs

One or a list of objects of the class 'startR_cube' returned by Start(), indicating the data to be processed.

step_fun

A startR step function as returned by Step().

...

Additional parameters for the inputs of function defined in 'step_fun' by Step().

Value

A list of the class 'startR_workflow' containing all the objects needed for the data operation.

Examples

 data_path <- system.file('extdata', package = 'startR')
 path_obs <- file.path(data_path, 'obs/monthly_mean/$var$/$var$_$sdate$.nc')
 sdates <- c('200011', '200012')
 data <- Start(dat = list(list(path = path_obs)),
               var = 'tos',
               sdate = sdates,
               time = 'all',
               latitude = 'all',
               longitude = 'all',
               return_vars = list(latitude = 'dat',
                                  longitude = 'dat',
                                  time = 'sdate'),
               retrieve = FALSE)
 pi_short <- 3.14
 fun <- function(x, pi_val) {
           lat = attributes(x)$Variables$dat1$latitude
           weight = sqrt(cos(lat * pi_val / 180))
           corrected = Apply(list(x), target_dims = "latitude",
                             fun = function(x) {x * weight})
         }


 step <- Step(fun = fun,
              target_dims = 'latitude',
              output_dims = 'latitude',
              use_libraries = c('multiApply'),
              use_attributes = list(data = "Variables"))
 wf <- AddStep(data, step, pi_val = pi_short)


startR documentation built on May 29, 2024, 5:33 a.m.

Related to AddStep in startR...