Commit 06406453 authored by nperez's avatar nperez
Browse files

Merge branch 'master' into develop-verification

parents 3436bc42 ec8ebfba
Pipeline #6565 passed with stage
in 57 minutes and 52 seconds
......@@ -16,6 +16,8 @@
#'@param file_selectors A charcter vector indicating the information of the path of
#' the file parameter 'data_array' comes from. See details in the documentation of
#' the parameter 'transform' of the function Start(). The default value is NULL.
#'@param crop_domain A list of the transformed domain of each transform
#' variable, automatically provided by Start().
#'@param \dots A list of additional parameters to adjust the transform process,
#' as provided in the parameter 'transform_params' in a Start() call. See details
#' in the documentation of the parameter 'transform' of the function Start().
......@@ -42,8 +44,7 @@
#' longitude_reorder = CircularSort(-180, 180),
#' transform = CDORemapper,
#' transform_params = list(grid = 'r360x181',
#' method = 'conservative',
#' crop = c(-120, 120, -60, 60)),
#' method = 'conservative'),
#' transform_vars = c('latitude', 'longitude'),
#' return_vars = list(latitude = 'dat',
#' longitude = 'dat',
......@@ -52,7 +53,8 @@
#' }
#'@importFrom s2dv CDORemap
#'@export
CDORemapper <- function(data_array, variables, file_selectors = NULL, ...) {
CDORemapper <- function(data_array, variables, file_selectors = NULL,
crop_domain = NULL, ...) {
file_dims <- names(file_selectors)
known_lon_names <- startR:::.KnownLonNames()
known_lat_names <- startR:::.KnownLatNames()
......@@ -89,11 +91,33 @@ CDORemapper <- function(data_array, variables, file_selectors = NULL, ...) {
}
}
extra_params <- list(...)
if (!all(c('grid', 'method', 'crop') %in% names(extra_params))) {
stop("Parameters 'grid', 'method' and 'crop' must be specified for the ",
if (!all(c('grid', 'method') %in% names(extra_params))) {
stop("Parameters 'grid' and 'method' must be specified for the ",
"CDORemapper, via the 'transform_params' argument.")
}
result <- s2dv::CDORemap(data_array, lons, lats, ...)
# Use crop_domain to get 'crop'
if (!is.null(crop_domain)) {
## lon
known_lon_names <- startR:::.KnownLonNames()
lon_name <- names(crop_domain)[which(names(crop_domain) %in% known_lon_names)]
crop_lon <- unlist(crop_domain[[lon_name]])
## lat
known_lat_names <- startR:::.KnownLatNames()
lat_name <- names(crop_domain)[which(names(crop_domain) %in% known_lat_names)]
crop_lat <- unlist(crop_domain[[lat_name]])
crop_values <- c(crop_lon, crop_lat)
if ('crop' %in% names(extra_params)) {
.warning("Argument 'crop' in 'transform_params' for CDORemapper() is ",
"deprecated. It is automatically assigned as the selected .",
"domain in Start() call.")
}
extra_params[['crop']] <- crop_values
}
result <- do.call(s2dv::CDORemap, c(list(data_array, lons, lats), extra_params))
return_variables <- list(result$lons, result$lats)
names(return_variables) <- c(lon_name, lat_name)
list(data_array = result$data_array, variables = return_variables)
......
......@@ -1803,6 +1803,7 @@ Start <- function(..., # dim = indices/selectors,
picked_vars <- lapply(picked_vars, setNames, names(return_vars))
}
picked_vars_ordered <- picked_vars
picked_vars_unorder_indices <- picked_vars
for (i in 1:length(dat)) {
......@@ -2003,10 +2004,68 @@ Start <- function(..., # dim = indices/selectors,
# picked_common_vars
vars_to_transform <- generate_vars_to_transform(vars_to_transform, picked_common_vars, transform_vars, picked_common_vars_ordered)
# Save the crop domain from selectors of transformed vars
# PROB: It doesn't consider aiat. If aiat, the indices are for
# after transformed data; we don't know the corresponding
# values yet.
transform_crop_domain <- vector('list')
for (transform_var in transform_vars) {
transform_crop_domain[[transform_var]] <- dat[[i]][['selectors']][[transform_var]][[1]]
# Turn indices into values
if (attr(transform_crop_domain[[transform_var]], 'indices')) {
if (transform_var %in% names(common_return_vars)) {
if (transform_var %in% names(dim_reorder_params)) {
transform_crop_domain[[transform_var]] <-
generate_transform_crop_domain_values(
transform_crop_domain[[transform_var]],
picked_vars = picked_common_vars_ordered[[transform_var]])
} else {
transform_crop_domain[[transform_var]] <-
generate_transform_crop_domain_values(
transform_crop_domain[[transform_var]],
picked_vars = picked_common_vars[[transform_var]])
}
} else { # return_vars
if (transform_var %in% names(dim_reorder_params)) {
transform_crop_domain[[transform_var]] <-
generate_transform_crop_domain_values(
transform_crop_domain[[transform_var]],
picked_vars = picked_vars_ordered[[i]][[transform_var]])
} else {
transform_crop_domain[[transform_var]] <-
generate_transform_crop_domain_values(
transform_crop_domain[[transform_var]],
picked_vars = picked_vars[[i]][[transform_var]])
}
}
} else if (is.atomic(transform_crop_domain[[transform_var]])) {
# if it is values but vector
transform_crop_domain[[transform_var]] <-
c(transform_crop_domain[[transform_var]][1],
tail(transform_crop_domain[[transform_var]], 1))
}
# For CDORemapper (not sure if it's also suitable for other transform functions):
# If lon_reorder is not used + lon selector is from big to small,
# lonmax and lonmin need to be exchanged. The ideal way is to
# exchange in CDORemapper(), but lon_reorder is used or not is not
# known by CDORemapper().
# NOTE: lat's order doesn't matter, big to small and small to big
# both work. Since we shouldn't assume transform_var in Start(),
# e.g., transform_var can be anything transformable in the assigned transform function,
# we exchange whichever parameter here anyway.
if (!transform_var %in% names(dim_reorder_params) &
diff(unlist(transform_crop_domain[[transform_var]])) < 0) {
transform_crop_domain[[transform_var]] <- rev(transform_crop_domain[[transform_var]])
}
}
# Transform the variables
transformed_data <- do.call(transform, c(list(data_array = NULL,
variables = vars_to_transform,
file_selectors = selectors_of_first_files_with_data[[i]]),
file_selectors = selectors_of_first_files_with_data[[i]],
crop_domain = transform_crop_domain),
transform_params))
# Discard the common transformed variables if already transformed before
if (!is.null(transformed_common_vars)) {
......@@ -2506,6 +2565,7 @@ Start <- function(..., # dim = indices/selectors,
selector_store_position[names(selector_indices_to_take)] <- selector_indices_to_take
sub_array_of_selectors <- Subset(selector_array, names(selector_indices_to_take),
as.list(selector_indices_to_take), drop = 'selected')
if (debug) {
if (inner_dim %in% dims_to_check) {
print("-> ITERATING OVER FILE DIMENSIONS OF THE SELECTORS.")
......@@ -2775,7 +2835,6 @@ Start <- function(..., # dim = indices/selectors,
sub_array_of_fri <- generate_sub_array_of_fri(
with_transform, goes_across_prime_meridian, sub_array_of_indices, n, beta,
is_circular_dim)
# May be useful for crop = T. 'subset_vars_to_transform' may not need
# to include extra cells, but currently it shows mistake if not include.
sub_array_of_fri_no_beta <- generate_sub_array_of_fri(
......@@ -2810,33 +2869,11 @@ Start <- function(..., # dim = indices/selectors,
inner_dim, sub_array_of_fri)
}
}
# Change the order of longitude crop if no reorder + from big to small.
# cdo -sellonlatbox, the lon is west, east (while lat can be north
# to south or opposite)
# Before changing crop, first we need to find the name of longitude.
# NOTE: The potential bug here (also the bug for CDORemapper): the lon name
# is limited (only the ones listed in .KnownLonNames() are available.
known_lon_names <- startR:::.KnownLonNames()
lon_name <- names(subset_vars_to_transform)[which(names(subset_vars_to_transform) %in% known_lon_names)[1]]
# NOTE: The cases not considered: (1) if lon reorder(decreasing = T)
# It doesn't make sense, but if someone uses it, here should
# occur error. (2) crop = TRUE/FALSE
if ('crop' %in% names(transform_params) & var_with_selectors_name == lon_name & is.null(dim_reorder_params[[inner_dim]])) {
if (is.numeric(class(transform_params$crop))) {
if (transform_params$crop[1] > transform_params$crop[2]) {
tmp <- transform_params$crop[1]
transform_params$crop[1] <- transform_params$crop[2]
transform_params$crop[2] <- tmp
}
}
}
transformed_subset_var <- do.call(transform, c(list(data_array = NULL,
variables = subset_vars_to_transform,
file_selectors = selectors_of_first_files_with_data[[i]]),
file_selectors = selectors_of_first_files_with_data[[i]],
crop_domain = transform_crop_domain),
transform_params))$variables[[var_with_selectors_name]]
# Sorting the transformed variable and working out the indices again after transform.
if (!is.null(dim_reorder_params[[inner_dim]])) {
......@@ -2918,11 +2955,28 @@ Start <- function(..., # dim = indices/selectors,
# will miss. 'previous_sri' is checked and will be included if this
# situation happens, but don't know if the transformed result is
# correct or not.
# NOTE: The chunking criteria may not be 100% correct. The current way
# is to pick the sri that larger than the minimal sub_sub_array_of_values
# and smaller than the maximal sub_sub_array_of_values; if it's
# the first chunk, make sure the 1st sri is included; if it's the
# last chunk, make sure the last sri is included.
if (chunks[[inner_dim]]["n_chunks"] > 1) {
sub_array_of_sri_complete <- sub_array_of_sri
if (is.list(sub_sub_array_of_values)) { # list
sub_array_of_sri <-
which(transformed_subset_var >= min(unlist(sub_sub_array_of_values)) &
transformed_subset_var <= max(unlist(sub_sub_array_of_values)))
# if it's 1st chunk & the first sri is not included, include it.
if (chunks[[inner_dim]]["chunk"] == 1 &
!(sub_array_of_sri_complete[1] %in% sub_array_of_sri)) {
sub_array_of_sri <- c(sub_array_of_sri_complete[1], sub_array_of_sri)
}
# if it's last chunk & the last sri is not included, include it.
if (chunks[[inner_dim]]["chunk"] == chunks[[inner_dim]]["n_chunks"] &
!(tail(sub_array_of_sri_complete, 1) %in% sub_array_of_sri)) {
sub_array_of_sri <- c(sub_array_of_sri, tail(sub_array_of_sri_complete, 1))
}
# Check if sub_array_of_sri perfectly connects to the previous sri.
# If not, inlclude the previous sri.
#NOTE 1: don't know if the transform for the previous sri is
......@@ -2931,7 +2985,13 @@ Start <- function(..., # dim = indices/selectors,
# Don't know if the cropping will miss some sri or not.
if (sub_array_of_sri[1] != 1) {
if (!is.null(previous_sub_sub_array_of_values)) {
previous_sri <- max(which(transformed_subset_var <= previous_sub_sub_array_of_values))
# if decreasing = F
if (transformed_subset_var[1] < transformed_subset_var[2]) {
previous_sri <- max(which(transformed_subset_var <= previous_sub_sub_array_of_values))
} else {
# if decreasing = T
previous_sri <- max(which(transformed_subset_var >= previous_sub_sub_array_of_values))
}
if (previous_sri + 1 != sub_array_of_sri[1]) {
sub_array_of_sri <- (previous_sri + 1):sub_array_of_sri[length(sub_array_of_sri)]
}
......@@ -2941,6 +3001,10 @@ Start <- function(..., # dim = indices/selectors,
} else { # is vector
tmp <- which(transformed_subset_var >= min(sub_sub_array_of_values) &
transformed_subset_var <= max(sub_sub_array_of_values))
# Ensure tmp and sub_array_of_sri are both ascending or descending
if (is.unsorted(tmp) != is.unsorted(sub_array_of_sri)) {
tmp <- rev(tmp)
}
# Include first or last sri if tmp doesn't have. It's only for
# ""vectors"" because vectors look for the closest value.
#NOTE: The condition here is not correct. The criteria should be
......@@ -2961,14 +3025,21 @@ Start <- function(..., # dim = indices/selectors,
# Don't know if the cropping will miss some sri or not.
if (sub_array_of_sri[1] != 1) {
if (!is.null(previous_sub_sub_array_of_values)) {
previous_sri <- max(which(transformed_subset_var <= previous_sub_sub_array_of_values))
if (previous_sri + 1 != sub_array_of_sri[1]) {
# if decreasing = F
if (transformed_subset_var[1] < transformed_subset_var[2]) {
previous_sri <- max(which(transformed_subset_var <= previous_sub_sub_array_of_values))
} else {
# if decreasing = T
previous_sri <- max(which(transformed_subset_var >= previous_sub_sub_array_of_values))
}
if (previous_sri + 1 != which(sub_array_of_sri[1] == sub_array_of_sri_complete)) {
sub_array_of_sri <- (previous_sri + 1):sub_array_of_sri[length(sub_array_of_sri)]
}
}
}
}
}
ordered_sri <- sub_array_of_sri
sub_array_of_sri <- transformed_subset_var_unorder[sub_array_of_sri]
......@@ -3600,6 +3671,7 @@ Start <- function(..., # dim = indices/selectors,
synonims = synonims,
transform = transform,
transform_params = transform_params,
transform_crop_domain = transform_crop_domain,
silent = silent, debug = debug)
} else {
cluster <- parallel::makeCluster(num_procs, outfile = "")
......@@ -3611,6 +3683,7 @@ Start <- function(..., # dim = indices/selectors,
synonims = synonims,
transform = transform,
transform_params = transform_params,
transform_crop_domain = transform_crop_domain,
silent = silent, debug = debug)
})
parallel::stopCluster(cluster)
......@@ -3811,7 +3884,7 @@ Start <- function(..., # dim = indices/selectors,
# piece.
.LoadDataFile <- function(work_piece, shared_matrix_pointer,
file_data_reader, synonims,
transform, transform_params,
transform, transform_params, transform_crop_domain = NULL,
silent = FALSE, debug = FALSE) {
#warning(attr(shared_matrix_pointer, 'description')$sharedName)
# suppressPackageStartupMessages({library(bigmemory)})
......@@ -3850,7 +3923,8 @@ Start <- function(..., # dim = indices/selectors,
}
sub_array <- do.call(transform, c(list(data_array = sub_array,
variables = work_piece[['vars_to_transform']],
file_selectors = work_piece[['file_selectors']]),
file_selectors = work_piece[['file_selectors']],
crop_domain = transform_crop_domain),
transform_params))
if (debug) {
if (all(unlist(store_indices[1:6]) == 1)) {
......
......@@ -560,6 +560,22 @@ generate_vars_to_transform <- function(vars_to_transform, picked_vars, transform
return(vars_to_transform)
}
# Turn indices to values for transform_crop_domain
generate_transform_crop_domain_values <- function(transform_crop_domain, picked_vars) {
if (transform_crop_domain == 'all') {
transform_crop_domain <- c(picked_vars[1], tail(picked_vars, 1))
} else { # indices()
if (is.list(transform_crop_domain)) {
transform_crop_domain <- picked_vars[unlist(transform_crop_domain)]
} else { # vector
transform_crop_domain <-
c(picked_vars[transform_crop_domain[1]],
picked_vars[tail(transform_crop_domain, 1)])
}
}
return(transform_crop_domain)
}
# Out-of-range warning
show_out_of_range_warning <- function(inner_dim, range, bound) {
# bound: 'lower' or 'upper'
......@@ -582,12 +598,24 @@ generate_sub_sub_array_of_values <- function(input_array_of_values, sub_array_of
sub_sub_array_of_values <- list(input_array_of_values[sub_array_of_indices[[1]]],
input_array_of_values[sub_array_of_indices[[2]]])
if (number_of_chunk > 1) {
previous_sub_sub_array_of_values <- input_array_of_values[sub_array_of_indices[[1]] - 1]
if (diff(unlist(sub_array_of_indices)) > 0) {
previous_sub_sub_array_of_values <-
input_array_of_values[sub_array_of_indices[[1]] - 1]
} else {
previous_sub_sub_array_of_values <-
input_array_of_values[sub_array_of_indices[[1]] + 1]
}
}
} else { # is vector
sub_sub_array_of_values <- input_array_of_values[sub_array_of_indices]
if (number_of_chunk > 1) {
previous_sub_sub_array_of_values <- input_array_of_values[sub_array_of_indices[1] - 1]
if (diff(sub_array_of_indices[1:2]) > 0) {
previous_sub_sub_array_of_values <-
input_array_of_values[sub_array_of_indices[1] - 1]
} else {
previous_sub_sub_array_of_values <-
input_array_of_values[sub_array_of_indices[1] + 1]
}
}
}
......
......@@ -4,7 +4,13 @@
\alias{CDORemapper}
\title{CDO Remap Data Transformation for 'startR'}
\usage{
CDORemapper(data_array, variables, file_selectors = NULL, ...)
CDORemapper(
data_array,
variables,
file_selectors = NULL,
crop_domain = NULL,
...
)
}
\arguments{
\item{data_array}{A data array to be transformed. See details in the
......@@ -18,6 +24,9 @@ parameter 'transform' of the function Start().}
the file parameter 'data_array' comes from. See details in the documentation of
the parameter 'transform' of the function Start(). The default value is NULL.}
\item{crop_domain}{A list of the transformed domain of each transform
variable, automatically provided by Start().}
\item{\dots}{A list of additional parameters to adjust the transform process,
as provided in the parameter 'transform_params' in a Start() call. See details
in the documentation of the parameter 'transform' of the function Start().}
......@@ -53,8 +62,7 @@ perform the interpolation, hence CDO is required to be installed.
longitude_reorder = CircularSort(-180, 180),
transform = CDORemapper,
transform_params = list(grid = 'r360x181',
method = 'conservative',
crop = c(-120, 120, -60, 60)),
method = 'conservative'),
transform_vars = c('latitude', 'longitude'),
return_vars = list(latitude = 'dat',
longitude = 'dat',
......
......@@ -269,8 +269,7 @@ exp <- Start(dat = path,
transform = CDORemapper,
transform_extra_cells = 8,
transform_params = list(grid = 'r100x50',
method = 'conservative',
crop = c(0, 22, -90, -60)),
method = 'conservative'),
transform_vars = c('lat','lon'),
synonims = list(lon = c('lon', 'longitude'), lat = c('lat', 'latitude')),
return_vars = list(lat = 'dat', lon = 'dat', time = 'sdate'),
......@@ -304,27 +303,17 @@ res3$output1
expect_equal(
drop(res$output1)[, 1],
c(241.5952, 243.0271, 247.6998, 246.7727, 248.7175, 267.7744, 273.2705),
c(241.4042, 242.5804, 246.8507, 245.8008, 246.4318, 267.0983),
tolerance = 0.001
)
expect_equal(
drop(res$output1)[, 2],
c(241.4042, 242.5804, 246.8507, 245.8008, 246.4318, 267.0983, 272.9651),
c(241.2223, 242.2564, 245.9863, 244.5377, 244.8937, 266.5749),
tolerance = 0.001
)
expect_equal(
drop(res$output1)[, 3],
c(241.2223, 242.2564, 245.9863, 244.5377, 244.8937, 266.5749, 272.5154),
tolerance = 0.001
)
expect_equal(
drop(res$output1)[, 4],
c(241.0894, 242.1896, 245.3183, 243.1169, 243.9446, 266.4386, 272.4731),
tolerance = 0.001
)
expect_equal(
drop(res$output1)[, 5],
c(241.0217, 242.3326, 244.6789, 241.6538, 244.3845, 266.6960, 272.4390),
c(241.0895, 242.1896, 245.3183, 243.1169, 243.9446, 266.4386),
tolerance = 0.001
)
......@@ -482,8 +471,7 @@ exp <- Start(dat = path,
lon_reorder = CircularSort(0, 360),
transform = CDORemapper,
transform_extra_cells = 8,
transform_params = list(grid = 'r100x50', method = 'conservative',
crop = c(0, 18, -90, -67)),
transform_params = list(grid = 'r100x50', method = 'conservative'),
transform_vars = c('lat','lon'),
synonims = list(lon = c('lon', 'longitude'), lat = c('lat', 'latitude')),
return_vars = list(lat = 'dat', lon = 'dat', time = 'sdate'),
......@@ -539,79 +527,23 @@ drop(res1$output1)[, 5],
c(241.0894, 242.1896, 245.3183, 243.1169, 243.9446, 266.4386),
tolerance = 0.001
)
expect_equal(
drop(res1$output1)[, 6],
c(241.0217, 242.3326, 244.6789, 241.6538, 244.3845, 266.6960),
tolerance = 0.001
)
#------------------------------------------------------
# crop = FALSE
suppressWarnings(
exp <- Start(dat = path,
var = 'tas',
sdate = '20000101',
ensemble = indices(1),
time = indices(1),
lat = indices(1:80), # 1:80 = -89.78488:-67.58778
lon = indices(1:65),# 1:65 = 0.00000:17.7777778
lat_reorder = Sort(),
lon_reorder = CircularSort(0, 360),
transform = CDORemapper,
transform_extra_cells = 8,
transform_params = list(grid = 'r100x50', method = 'conservative',
crop = F),
transform_vars = c('lat','lon'),
synonims = list(lon = c('lon', 'longitude'), lat = c('lat', 'latitude')),
return_vars = list(lat = 'dat', lon = 'dat', time = 'sdate'),
retrieve = F)
)
func <- function(x) {
return(x)
}
step <- Step(func, target_dims = 'time', output_dims = 'time')
wf <- AddStep(exp, step)
#---------------------------------
# lat indices is reversed
suppressWarnings(
res_crop_F_1 <- Compute(wf, chunks = list(lon = 2))
)
suppressWarnings(
res_crop_F_2 <- Compute(wf, chunks = list(ensemble = 1))
)
suppressWarnings(
res_crop_F_3 <- Compute(wf, chunks = list(lon = 3))
)
expect_equal(
as.vector(res1$output1),
as.vector(drop(res_crop_F_1$output1)[1:6, ])
)
expect_equal(
res_crop_F_1$output1,
res_crop_F_2$output1
)
expect_equal(
res_crop_F_1$output1,
res_crop_F_3$output1
)
#----------------------------------------------
# crop = TRUE
suppressWarnings(
exp <- Start(dat = path,
var = 'tas',
sdate = '20000101',
ensemble = indices(1),
time = indices(1),
lat = indices(1:80), # 1:80 = -89.78488:-67.58778
lat = indices(80:1), # 1:80 = -89.78488:-67.58778
lon = indices(1:65),# 1:65 = 0.00000:17.7777778
lat_reorder = Sort(),
lon_reorder = CircularSort(0, 360),
transform = CDORemapper,
transform_extra_cells = 8,
transform_params = list(grid = 'r100x50', method = 'conservative',
crop = T),
transform_params = list(grid = 'r100x50', method = 'conservative'),
transform_vars = c('lat','lon'),
synonims = list(lon = c('lon', 'longitude'), lat = c('lat', 'latitude')),
return_vars = list(lat = 'dat', lon = 'dat', time = 'sdate'),
......@@ -625,26 +557,122 @@ step <- Step(func, target_dims = 'time', output_dims = 'time')
wf <- AddStep(exp, step)
suppressWarnings(
res_crop_T_1 <- Compute(wf, chunks = list(lon = 2))
res4 <- Compute(wf, chunks = list(lon = 2))
)
suppressWarnings(
res_crop_T_2 <- Compute(wf, chunks = list(ensemble = 1))
)
suppressWarnings(
res_crop_T_3 <- Compute(wf, chunks = list(lon = 3))
res5 <- Compute(wf, chunks = list(lat = 2))
)
expect_equal(
res_crop_F_1$output1,
res_crop_T_1$output1
)
expect_equal(
res_crop_T_1$output1,
res_crop_T_2$output1
res4$output1,
res5$output1
)
expect_equal(
res_crop_T_1$output1,
res_crop_T_3$output1
as.vector(drop(res1$output1)[6:1, ]),
as.vector(drop(res4$output1))
)
#------------------------------------------------------
#NOTE_19/01/2022: crop is deprecated
## crop = FALSE
#suppressWarnings(
#exp <- Start(dat = path,
# var = 'tas',
# sdate = '20000101',
# ensemble = indices(1),
# time = indices(1),
# lat = indices(1:80), # 1:80 = -89.78488:-67.58778
# lon = indices(1:65),# 1:65 = 0.00000:17.7777778
# lat_reorder = Sort(),
# lon_reorder = CircularSort(0, 360),
# transform = CDORemapper,
# transform_extra_cells = 8,
# transform_params = list(grid = 'r100x50', method = 'conservative',
# crop = F),
# transform_vars = c('lat','lon'),
# synonims = list(lon = c('lon', 'longitude'), lat = c('lat', 'latitude')),
# return_vars = list(lat = 'dat', lon = 'dat', time = 'sdate'),
# retrieve = F)
#)
#
#func <- function(x) {
# return(x)
#}
#step <- Step(func, target_dims = 'time', output_dims = 'time')
#wf <- AddStep(exp, step)
#
#suppressWarnings(
#res_crop_F_1 <- Compute(wf, chunks = list(lon = 2))