-
Notifications
You must be signed in to change notification settings - Fork 30
Trouble shooting
First thing if you have a problem, try to run the function with verbose
set to TRUE
, if there is a verbose
argument. E.g.
normal.period <- subset(Oslo,it=c(1961,1990),verbose=TRUE)
The messages produced may give you a clue about the problem. Also try the examples provided in the manual, if you can find it (e.g. type ?subset
). Try to do the analysis with the data provided in esd
. The problem may be that the data structure is not quite right, that some attributes are missing, etc. Often the problem can be fixed re-setting the attributes.
The esd
package comes with some sample data like Oslo
, Ferder
, bjornholt
, NACD
(station(src='nacd')
) and large-scale filtered versions of some reanalyses (see eg ?t2m.NCEP
). If you have troubles, then you can try to repeat the analysis with data objects provided in esd
to see if the problem is related to the structure of the data objects - sometimes a mis-specified attribute may cause the the analysis to halt.
Another general approach to debug the code is to use trace()
and traceback()
to identify the function causing the computation to stop. E.g.
data(Oslo)
trace(PCA(Oslo))
traceback()
One solution is to read in the data 'manually':
## Sea surface temperature data from http://www.esrl.noaa.gov/psd/data/gridded/data.noaa.oisst.v2.html
## Get sea surface temperatures from NOAA
## Read the data 'manually'
ncid <- nc_open('/disk1/sst.mnmean.nc')
x <- ncvar_get(ncid,'sst')
lon <- ncvar_get(ncid,'lon')
lat <- ncvar_get(ncid,'lat')
tim <- ncvar_get(ncid,'time')
nc_close(ncid)
## Read the land-sea mask
ncid <- nc_open('/disk1/lsmask.nc')
lsm <- ncvar_get(ncid)
nc_close(ncid)
## Prepare the data
d <- dim(x)
dim(x) <- c(d[1]*d[2],d[3])
x[c(lsm)==0,] <- NA # Set land-points to NA
X <- zoo(t(x),order.by=as.Date(tim + julian(as.Date('1800-1-1'))))
sst <- as.field(X,lon=lon,lat=lat,param='sst',unit='deg C',
longname='Sea surface Temperature',ref='Reynolds OI SST',
src='NOAA Optimum Interpolation (OI) Sea Surface Temperature (SST) V2',
url='http://www.esrl.noaa.gov/psd/data/gridded/data.noaa.oisst.v2.html')
## Estimate annual mean SST:
SST <- annual(sst)
SST <- subset(SST,it=c(start(SST),2014)) # Remove the incomplete 2015
save(file='/disk1/SST.rda',SST,sst)
There have been some problems for some windows platforms which may be due to different language set-ups in R and in Windows:
install_local('../Downloads/esd-master.zip')
Installing esd
"C:/Program Files/R/R-3.2.0/bin/x64/R" --no-site-file --no-environ --no-save \
--no-restore CMD INSTALL \
"C:/Users/mja/AppData/Local/Temp/RtmpqIAipE/devtools2ce473df32e8/esd-master" \
--library="C:/Users/mja/Documents/R/win-library/3.2" --install-tests
C:\Program gjenkjennes ikke som en intern eller ekstern kommando,
kj›rbart program eller satsvis fil.
Error: Command failed (1)
A possible fix may be to either install R directly under 'C:/' or create a symbolic link called 'Program Files' on 'C:' that points to the correct directory holding the folder 'R'.
*** caught segfault ***
address 0x58, cause 'memory not mapped'
Happens when reading netCDF files (retrieve). Check ifd you have the latest version of ncdf. Also try ncdf4.
In order to investigate if the calculations are correct and check all the details that are outputted in the R environment, one could use the function sink
which drives the R output into an external connection such as outputR.txt
then it becomes much easier to follow and double check all the R outputs.
# As an example, to check all the CMIP6 files that are available from ESGF, one can use the function `meta.ESGF`.
# To save all the outputs into a file, one can do the following
# Create and open the connection as
sink("outputR.txt")
# Set verbose = TRUE, to display details of the calculations
meta.test <- meta.ESGF(verbose = TRUE)
# Close the connection as
sink()
Copyright of MET Norway 2022