New function CST_ChangeDimNames(): Rename dimensions in an s2dv_cube
Hi @erifarov
I developed this method to rename the dimensions of the data in an s2dv_cube and renaming `dims, coords` and `attrs` accordingly. I might have missed something that needs changing so if you see anything, please let me know!
Here is some code to test the function:
library(CSTools)
source("https://earth.bsc.es/gitlab/external/cstools/-/raw/develop-CST_ChangeDimNames/R/CST_ChangeDimNames.R")
# Check original dimensions and coordinates
lonlat_temp$exp$dims
names(lonlat_temp$exp$coords)
dim(lonlat_temp$exp$attrs$Dates)
# Change 'dataset' to 'dat' and 'ftime' to 'time'
exp <- CST_ChangeDimNames(lonlat_temp$exp,
original_names = c("dataset", "ftime"),
new_names = c("dat", "time"))
# Check new dimensions and coordinates
exp$dims
names(exp$coords)
dim(exp$attrs$Dates)
Cheers,
Victòria