Calibration() doesn't show warnings in atomic function when multiple cores are used
Hi @erifarov,
Summary
In CST_Calibration.R, the inner function .cal() that is used by Apply() has warning. But the warning cannot be printed if ncores > 1
& the data is bigger than the essential dimensions*. I guess it is due to the parallel packages used by Apply(), but I need to check more. But if it is not easy to improve on Apply() side, it would be better to see if there is another way to return this warning by Calibration().
*The "essential dimension" means the minimal dimensions required. In Calibration(), it is [sdate, member].
NOTE1: warning() cannot be returned, but print() can.
NOTE2: The mechanism in the functions to print the warning only once (using warning_shown
) works as expected when ncores = 1; but when multiple cores are used, the message is returned by each core so it is printed multiple times still. I realized this by adding print() in .cal().
Example
#NOTE: If remove time = 2, the warning shows always
exp <- array(1:24, dim = c(time = 2, member = 4, sdate = 3))
obs <- array(1:6, dim = c(time = 2, member = 1, sdate = 3))
res <- Calibration(exp, obs, cal.method = "mse_min")
Warning message:
In (new("functionWithTrace", .Data = function (exp, obs, exp_cor = NULL, :
Some forecast data could not be corrected due to data lack and is replaced with NA values.
res <- Calibration(exp, obs, cal.method = "mse_min", ncores = 2)
# Nothing returns
Best,
An-Chi