I am trying to calculate climate indices from a netcdf file by creating a ClimIndVis object using the ClimIndVis package.
your text
Using the data from https://github.com/ARCCSS-extremes/climpact2/blob/master/sample_data/climpact2.sampledata.gridded.1991-2010.nc i tried :
`library(Climindvis)
library(ncdf4)
nc_file <- "climpact2-master/sample_data/climpact2.sampledata.gridded.1991-2010.nc"
nc_data <- nc_open(nc_file)
# create ClimIndiVis object using make_object()
my_climindivis_obj <- make_object(
data = nc_data,
variable = "nc_data$var$precip$name",
time_dim = "nc_data$dim$time$vals",
lat_dim = "nc_data$dim$lat$vals",
lon_dim = "nc_data$dim$lon$vals",
missing_value = -9999
)
i get the following error: Error in make_object(data = nc_data, variable = "nc_data$var$precip$name", : argument 1 matches multiple formal arguments
I also noticed that the time dimension was not similar to the example shown with the package :
data(data_grid)
data_grid$time
So i tried the above using the terra package :
pp = terra::rast(nc_file)
# create ClimIndiVis object using make_object()
my_climindivis_obj <- make_object(
data = pp,
variable = "terra::varnames(pp)[3]",
time_dim = "terra::time(pp)",
lat_dim = "terra::crds(pp)[,1]",
lon_dim = "terra::crds(pp)[,2]",
missing_value = -9999)
and recieve a similar error: Error in make_object(data = pp, variable = "terra::varnames(pp)[3]", time_dim = "terra::time(pp)", : argument 1 matches multiple formal arguments
I would appreciate any help on getting this to work. Thanks