Running 'generate_tasmax.R' [157s]
  Running 'generate_wrfg_cgcm3_tasmax.R' [160s]
  Running 'test-all.R' [15s]
Running the tests in 'tests/generate_tasmax.R' failed.
Complete output:
  > # library(ncdf4)
  > #
  > # tasmax_array = function(a, cuts) {
  > #   aperm(apply(a, 1:2, function(x) tapply(x, cuts, max)), c(2:3, 1))
  > # }
  > #
  > # timecuts = function(x) {
  > #   cut(x, floor(min(x)):ceiling(max(x)))
  > # }
  > #
  > # setwd("~/Dropbox")
  > #
  > # nc68 = nc_open("tas_ECP2_gfdl_1968010103.nc")
  > # lon_ecp2 = ncvar_get(nc68, "lon") - 360
  > # lat_ecp2 = ncvar_get(nc68, "lat")
  > # alt_ecp2 = ncvar_get(nc68, "level")
  > # nc_close(nc68)
  > #
  > # nc71 = nc_open("tas_ECP2_gfdl_1971010103.nc")
  > # tas71 = ncvar_get(nc71, "tas")
  > # t71 = ncvar_get(nc71, "time")
  > # nc_close(nc71)
  > # tasmax71 = tasmax_array(tas71, timecuts(t71))
  > # rm(tas71)
  > #
  > # nc76 = nc_open("tas_ECP2_gfdl_1976010103.nc")
  > # tas76 = ncvar_get(nc76, "tas")
  > # t76 = ncvar_get(nc76, "time")
  > # nc_close(nc76)
  > # tasmax76 = tasmax_array(tas76, timecuts(t76))
  > # rm(tas76)
  > #
  > # nc81 = nc_open("tas_ECP2_gfdl_1981010103.nc")
  > # tas81 = ncvar_get(nc81, "tas")
  > # t81 = ncvar_get(nc81, "time")
  > # nc_close(nc81)
  > # tasmax81 = tasmax_array(tas81, timecuts(t81))
  > # rm(tas81)
  > #
  > # nc86 = nc_open("tas_ECP2_gfdl_1986010103.nc")
  > # tas86 = ncvar_get(nc86, "tas")
  > # t86 = ncvar_get(nc86, "time")
  > # nc_close(nc86)
  > # tasmax86 = tasmax_array(tas86, timecuts(t86))
  > # rm(tas86)
  > #
  > # nc91 = nc_open("tas_ECP2_gfdl_1991010103.nc")
  > # tas91 = ncvar_get(nc91, "tas")
  > # t91 = ncvar_get(nc91, "time")
  > # nc_close(nc91)
  > # tasmax91 = tasmax_array(tas91, timecuts(t91))
  > # rm(tas91)
  > #
  > # nc96 = nc_open("tas_ECP2_gfdl_1996010103.nc")
  > # tas96 = ncvar_get(nc96, "tas")
  > # t96 = ncvar_get(nc96, "time")
  > # nc_close(nc96)
  > # tasmax96 = tasmax_array(tas96, timecuts(t96))
  > # rm(tas96)
  > #
  > # tasmax_ecp2_gfdl_1971_2000 = abind::abind(tasmax71, tasmax76,
  > #                                 tasmax81, tasmax86,
  > #                                 tasmax91, tasmax96) - 273.14
  > #
  > # save(lon_ecp2, lat_ecp2, alt_ecp2, file = "ecp2_covar.rda",
  > #      compress = "xz")
  > #
  > # save(tasmax_ecp2_gfdl_1971_2000,
  > #      file = "tasmax_ecp2_gfdil_1971_2000.rda",
  > #      compress = "bzip2")
  > #
  > # lon = lon_ecp2
  > # lat = lat_ecp2
  > # tasmax = tasmax_ecp2_gfdl_1971_2000[,,1:30]
  > # save(lon, lat, tasmax, file = "tasmax.rda", compress = "xz")
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.18    0.06    0.23 
Running the tests in 'tests/generate_wrfg_cgcm3_tasmax.R' failed.
Complete output:
  > # library(ncdf4)
  > #
  > # setwd("~/Dropbox/UCD_Files/Research/In Progress/tasmax_WRFG_cgcm3")
  > # wrfg_covar = nc_open("orog_WRFG.nc") #open covariates file
  > # wrfg_lon <- ncvar_get(wrfg_covar, "lon") #longitude
  > # wrfg_lat <- ncvar_get(wrfg_covar, "lat") #latitude
  > # wrfg_alt <- ncvar_get(wrfg_covar, "orog") #altitude
  > # nc_close(wrfg_covar)
  > #
  > # wrfg_covar2 = nc_open("sftlf_WRFG.nc") #open covariates file
  > # wrfg_sftlf <- ncvar_get(wrfg_covar2, "sftlf") #altitude
  > # nc_close(wrfg_covar2)
  > #
  > # mydim = dim(wrfg_lon)
  > #
  > # # Get tasmax from 2038 file
  > # wrfg_cgcm3_2038 = nc_open("tasmax_WRFG_cgcm3_2038010106.nc")
  > # tasmax_2038 <- ncvar_get(wrfg_cgcm3_2038, varid = "tasmax")
  > # time_bnds_2038 <- ncvar_get(wrfg_cgcm3_2038, varid = "time_bnds")
  > # nc_close(wrfg_cgcm3_2038)
  > #
  > # # Get tasmax from 2041 file
  > # wrfg_cgcm3_2041 = nc_open("tasmax_WRFG_cgcm3_2041010106.nc")
  > # tasmax_2041 <- ncvar_get(wrfg_cgcm3_2041, varid = "tasmax")
  > # time_bnds_2041 <- ncvar_get(wrfg_cgcm3_2041, varid = "time_bnds")
  > # nc_close(wrfg_cgcm3_2041)
  > #
  > # # Get tasmax from 2046 file
  > # wrfg_cgcm3_2046 = nc_open("tasmax_WRFG_cgcm3_2046010106.nc")
  > # tasmax_2046 <- ncvar_get(wrfg_cgcm3_2046, varid = "tasmax")
  > # time_bnds_2046 <- ncvar_get(wrfg_cgcm3_2046, varid = "time_bnds")
  > # nc_close(wrfg_cgcm3_2046)
  > #
  > # # Get tasmax from 2051 file
  > # wrfg_cgcm3_2051 = nc_open("tasmax_WRFG_cgcm3_2051010106.nc")
  > # tasmax_2051 <- ncvar_get(wrfg_cgcm3_2051, varid = "tasmax")
  > # time_bnds_2051 <- ncvar_get(wrfg_cgcm3_2051, varid = "time_bnds")
  > # nc_close(wrfg_cgcm3_2051)
  > #
  > # # Get tasmax from 2056 file
  > # wrfg_cgcm3_2056 = nc_open("tasmax_WRFG_cgcm3_2056010106.nc")
  > # tasmax_2056 <- ncvar_get(wrfg_cgcm3_2056, varid = "tasmax")
  > # time_bnds_2056 <- ncvar_get(wrfg_cgcm3_2056, varid = "time_bnds")
  > # nc_close(wrfg_cgcm3_2056)
  > #
  > # # Get tasmax from 2061 file
  > # wrfg_cgcm3_2061 = nc_open("tasmax_WRFG_cgcm3_2061010106.nc")
  > # tasmax_2061 <- ncvar_get(wrfg_cgcm3_2061, varid = "tasmax")
  > # time_bnds_2061 <- ncvar_get(wrfg_cgcm3_2061, varid = "time_bnds")
  > # nc_close(wrfg_cgcm3_2061)
  > #
  > # # Get tasmax from 2066 file
  > # wrfg_cgcm3_2066 = nc_open("tasmax_WRFG_cgcm3_2066010106.nc")
  > # tasmax_2066 <- ncvar_get(wrfg_cgcm3_2066, varid = "tasmax")
  > # time_bnds_2066 <- ncvar_get(wrfg_cgcm3_2066, varid = "time_bnds")
  > # nc_close(wrfg_cgcm3_2066)
  > #
  > # wrfg_cgcm3_tasmax = abind::abind(tasmax_2041,
  > #                                  tasmax_2046,
  > #                                  tasmax_2051,
  > #                                  tasmax_2056,
  > #                                  tasmax_2061,
  > #                                  tasmax_2066)
  > # wrfg_lon = wrfg_lon - 360
  > # wrfg_cgcm3_tasmax = wrfg_cgcm3_tasmax - 273.15
  > #
  > # usapoly = maps::map("usa")
  > # p1 = list(x = usapoly$x[1:533], y = usapoly$y[1:533])
  > # plot(p1, type = "l")
  > #
  > # wrfg_lonv = c(wrfg_lon)
  > # wrfg_latv = c(wrfg_lat)
  > # wrfg_cgcm3_tasmaxm = matrix(c(wrfg_cgcm3_tasmax[,,1:365]), ncol = 365)
  > #
  > # pip = sp::point.in.polygon(wrfg_lonv, wrfg_latv, p1$x, p1$y)
  > # w = which(pip == 1)
  > # usa_sp = sp::SpatialPointsDataFrame(coords = cbind(wrfg_lonv, wrfg_latv)[w, ],
  > #                                     data = as.data.frame(wrfg_cgcm3_tasmaxm[w, ]))
  > # plot(p1, type = "l")
  > # points(wrfg_lonv, wrfg_latv)
  > # spplot(usa_sp, c("V1", "V2"))
  > # autoimage::autoimage(wrfg_lonv, wrfg_latv, wrfg_cgcm3_tasmaxm[,1:4])
  > #
  > # usa_sppoly = sp::Polygon(cbind(p1$x, p1$y), hole = FALSE)
  > # usa_sppoly = sp::Polygons(list(usa_sppoly), "usa_main")
  > # usa_sppoly = sp::SpatialPolygons(list(usa_sppoly))
  > #
  > # usa_coords = cbind(wrfg_lonv, wrfg_latv)[w, ]
  > # usa_tasmax = wrfg_cgcm3_tasmaxm[w, ]
  > # save(usa_sppoly, usa_coords, usa_tasmax, file = "usa_tasmax.rda", compress = "xz")
  > #
  > # for (i in 1:nrow(wrfg_sftlf)) {
  > #   for (j in 1:ncol(wrfg_sftlf)) {
  > #     if (wrfg_sftlf[i, j] < 1) {
  > #       wrfg_sftlf[i, j] = NA
  > #     }
  > #   }
  > # }
  > #
  > # # $x
  > # [1] 273.7302 303.5238 304.7276
  > #
  > # $y
  > # [1] 24.35004 70.04290 57.66775
  > #
  > # u1 = which(wrfg_lon > 273 & wrfg_lat < 24.35, arr.ind = TRUE)
  > # u2 = which(wrfg_lon > 303.5 & wrfg_lat > 57 & wrfg_lat < 70, arr.ind = TRUE)
  > # wrfg_sftlf[u1] = NA
  > # wrfg_sftlf[u2] = NA
  > #
  > # nonna = which(!is.na(c(wrfg_sftlf)))
  > #
  > #
  > # image(wrfg_sftlf)
  > #
  > # for (i in seq_len(dim(wrfg_cgcm3_tasmax)[3])) {
  > #   wrfg_cgcm3_tasmax[,,i] = wrfg_cgcm3_tasmax[,,i] * wrfg_sftlf
  > # }
  > #
  > # wrfg_cgcm3_tasmax = wrfg_cgcm3_tasmax[,,1:30]
  > # save(wrfg_lon, wrfg_lat, wrfg_cgcm3_tasmax, file = "wrfg_cgcm3_tasmax.rda", compress = "xz")
  > 
  > proc.time()
     user  system elapsed 
     0.17    0.04    0.20