# !/usr/bin/Rscript
library(SpatioTemporalCluster)
library(foreach)
library(iterators)
library(glue)
library(Ipaper)
library(lubridate)
library(nctools)
library(ncdf4)
file_nc = "data-raw/CN05.1_Tmax_1961_2018_daily_025x025.nc"
fid <- nc_open(file_nc)
dates = seq(as.Date("1961-01-01"), as.Date("2018-12-31"), by = "day")
lat = ncread(file_nc, "lat")
lon = ncread(file_nc, "lon")
## How to kill R process
# pkill -f R
# kill -9 pid
InitCluster(kill = TRUE)
?InitCluster
load("/mnt/n/Research/cmip5/heatwave/OUTPUT/HW13.rda")
any(is.na(HW13))
setwd('/mnt/n/Research/cmip5/heatwave/')
foreach(i = c(1:13), icount()) %do% {
outfile = glue("OUTPUT/clusterId/nonHI/HW{i}.nc")
if (!file.exists(outfile)) {
infile <- glue("OUTPUT/HW_indexes/nonHI/HW{i}.rda")
load(infile)
print(infile)
cmd = glue("HW <- HW{i}")
eval(parse(text = cmd))
clusterId <- HW_cluster(HW, 8)
dims = ncdim_def_lonlat(lon, lat, dates)
ncwrite(list(clusterId = clusterId), outfile, dims = dims, compression = 2)
# saveRDS(clusterId, outfile)
}
}
# 0.25*0.25
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.