Help using startR to run Climpact script
Hello @aho,
I am very new to startR
and I would really appreciate any help.
I sould like to use startR
to run, in the most efficient way, on Nord3v2 a Climpact function from the climdex.pcic.ncdf
R package.
Here below my script so far, which however is not yet correct. I am using only two models for one SSP scenario and I would like to compute all the climpact indices available on original models' grids.
library(startR)
###1 Load data (does not return error but I am not sure if original horizontal resolution is kept)
data_load<- Start(dat = "/esarchive/scratch/pdeluca/landmarc/def/tasmax_tasmin_pr_$model$_ssp126_1949_2100.nc",
var = c('tasmax', 'tasmin', 'pr'),
model = c('CanESM5', 'INM-CM4-8'),
#ssp = 'all',
lat = 'all',
lon = 'all',
transform = NULL,
synonims = list(lon = c('lon', 'longitude'),
lat = c('lat', 'latitude')),
return_vars = list(time = NULL,
lat = 'dat',
lon = 'dat'),
retrieve = FALSE)
###2 Define function (to adjust)
library(climdex.pcic.ncdf)
library(stringr)
setwd("/esarchive/scratch/pdeluca/scripts/climpact-master")
create.indices.from.files(input.files= !!these are the datasets loaded in the previous step!!,
out.dir="/esarchive/scratch/pdeluca/landmarc/out/",
output.filename.template=paste("all_daily_cmip6_ssp126_",
!!here the models names in loaded in the previous step!!, "_1949-2100.nc", sep = ""),
author.data=list(institution="My University", institution_id="MU"),
climdex.vars.subset = NULL,
climdex.time.resolution = "all",
variable.name.map = c(tmax = "tasmax",
tmin = "tasmin",
prec = "pr"),
axis.to.split.on = "Y",
fclimdex.compatible = FALSE,
base.range = c(1981,2010),
parallel = 16,
verbose = TRUE,
thresholds.files = NULL,
thresholds.name.map = c(
tx05thresh= "tx05thresh",
tx10thresh ="tx10thresh",
tx50thresh = "tx50thresh",
tn05thresh = "tn05thresh",
tn10thresh = "tn10thresh",
tn50thresh = "tn50thresh",
tx90thresh = "tx90thresh",
tx95thresh = "tx95thresh",
tn90thresh = "tn90thresh",
tn95thresh = "tn95thresh",
tx90thresh_15days = "tx90thresh_15days",
tn90thresh_15days = "tn90thresh_15days",
tavg90thresh_15days = "tavg90thresh_15days",
tavg05thresh = "tavg05thresh",
tavg95thresh = "tavg95thresh",
r95thresh = "r95thresh",
r99thresh = "r99thresh",
txraw = "txraw",
tnraw = "tnraw",
precraw = "precraw"),
max.vals.millions = 30, cluster.type = "SOCK")
###3 Define the workflow (to adjust)
step <- Step(fun = climdex_ind,
target_dims = list(tx = c('lat', 'time'),
tn = c('lat', 'time'),
pr = c('lat', 'time')),
output_dims = list(fd = c('lat', 'time'),
cdd = c('lat','time')))
wf <- AddStep(inputs = list(hist_tx, hist_tn, hist_pr), step,
times = time, lats = lat)
###4 Define user and submit jobs (to adjust)
queue_host = 'nord3' #your own host name for power9
temp_dir = '/gpfs/scratch/bsc32/bsc32339/startR_hpc/'
ecflow_suite_dir = '/home/Earth/nperez/startR_local/'
res <- Compute(wf$fd,
chunks = list(lon = 2),
threads_load = 1,
threads_compute = 4,
cluster = list(queue_host = queue_host,
queue_type = 'lsf',
extra_queue_params = list('#BSUB -q bsc_es'),
cores_per_job = 4,
temp_dir = temp_dir,
polling_period = 10,
job_wallclock = '01:00',
max_jobs = 2,
bidirectional = FALSE),
ecflow_suite_dir = ecflow_suite_dir,
wait = TRUE)
Thanks
paolo