第 2 章 CMIP5或CMIP6数据处理

2.1 数据下载

R包CMIP6tools集成了一套完整的CMIP6/5数据下载,和数据处理的函数。

library(CMIP6tools) # v0.1.5.9001
# Dongdong Kong, 2020-01-09
## evspsbl, Evaporation

dir_runner  <- "E:/CMIP6_data/runner" # 请核对自己的runner路径
aria2c_path <- paste0(dir_runner, "/aria2c.bat") 
ESGF_user   <- "kongdd"  # your openid username, e.g. how_ll, fengshy

set_aria2c(aria2c_path)
Sys.setenv(ESGF_HOME = paste0(dirname(aria2c_path), "/.auth/", ESGF_user))

# evspsblveg: Evaporation from Canopy, the canopy evaporation+sublimation (if present in model)
# evspsblsoi: Water Evaporation from Soil, includes sublimation
# tran: transpiration
# evspsbl and tran
options_et <- list(
    variables = c("evspsbl", "tran", "evspsblveg", "evspsblsoi"),
    # variables = c("hfls", "hfss", "hurs", "hurs2", "pr", "rlds", "sfcWind", "tas", "tasmax", "tasmin")[-4]
    frequency = "mon", # day, mon 仅限两种可选
    scenarios = c("hist-GHG", "hist-nat", "hist-aer", "historical"),
    cmip = "cmip6",          # cmip5 or cmip6
    OUTPUT = "E:/CMIP6_data" # 数据存储路径,确保有充足的存储空间,cmip6 daily单变量2T左右
)

options_tas <- list(
    variables   = c("tasmax", "tasmin"),
    # variables = c("hfls", "hfss", "hurs", "hurs2", "pr", "rlds", "sfcWind", "tas", "tasmax", "tasmin")[-4]
    frequency   = "day", # day, mon 仅限两种可选
    scenarios   = NULL,
    cmip        = "cmip6",
    OUTPUT      = "J:/CMIP6_data"
)

options_hus <- list(
    variables   = c("hurs", "huss"),
    # variables = c("hfls", "hfss", "hurs", "hurs2", "pr", "rlds", "sfcWind", "tas", "tasmax", "tasmin")[-4]
    frequency   = "day", # day, mon 仅限两种可选
    scenarios   = NULL,
    cmip        = "cmip6",
    OUTPUT      = "G:/CMIP6_data"
)

## main ------------------------------------------------------------
# options  <- options_tas
options <- options_hus
options$OUTPUT %<>% Ipaper::path.mnt() # automatically change to wsl path

# `ensemble_pattern`控制选取的realizations
urls_fetch(options, overwrite_sh = FALSE, overwrite_txt = FALSE, ensemble_pattern = "r1i1p1f1")
## [1] "hist-GHG"
## [1] "hist-nat"
## [1] "hist-aer"
## [1] "historical"
## [1] "piControl"
## [1] "ssp126"
## [1] "ssp245"
## [1] "ssp370"
## [1] "ssp460"
## [1] "ssp585"
## [1] "hist-GHG"
## [1] "hist-nat"
## [1] "hist-aer"
## [1] "historical"
## [1] "piControl"
## [1] "ssp126"
## [1] "ssp245"
## [1] "ssp370"
## [1] "ssp460"
## [1] "ssp585"
links_all <- retrieve_links(options)  # all links
## [ok] hurs_hist-GHG   :  249 finished,    0 left
## [ok] hurs_hist-nat   :  267 finished,    0 left
## [ok] hurs_hist-aer   :  249 finished,    0 left
## [ok] hurs_historical : 1089 finished,    0 left
## [ok] hurs_piControl  : 2918 finished,    0 left
## [ok] hurs_ssp126     :  401 finished,    0 left
## [ok] hurs_ssp245     :  487 finished,    0 left
## [ok] hurs_ssp370     :  487 finished,    0 left
## [ok] hurs_ssp460     :   99 finished,    0 left
## [ok] hurs_ssp585     :  487 finished,    0 left
## [ok] huss_hist-GHG   :  255 finished,    0 left
## [ok] huss_hist-nat   :  273 finished,    0 left
## [ok] huss_hist-aer   :  255 finished,    0 left
## [ok] huss_historical : 1106 finished,    0 left
## [ok] huss_piControl  : 2443 finished,  580 left
## [ok] huss_ssp126     :  392 finished,   13 left
## [ok] huss_ssp245     :  392 finished,   99 left
## [ok] huss_ssp370     :  478 finished,   13 left
## [ok] huss_ssp460     :   89 finished,    0 left
## [ok] huss_ssp585     :  492 finished,   90 left
## =======================================
## G:/CMIP6_data/cmip6_hurs_day-url
## | hurs_hist-aer.txt         ALL:  249
## | hurs_hist-GHG.txt         ALL:  249
## | hurs_hist-nat.txt         ALL:  267
## | hurs_historical.txt       ALL: 1089
## | hurs_piControl.txt        ALL: 2918
## | hurs_ssp126.txt           ALL:  401
## | hurs_ssp245.txt           ALL:  487
## | hurs_ssp370.txt           ALL:  487
## | hurs_ssp460.txt           ALL:   99
## | hurs_ssp585.txt           ALL:  487
## =======================================
## G:/CMIP6_data/cmip6_huss_day-url
## | huss_hist-aer.txt         ALL:  255
## | huss_hist-GHG.txt         ALL:  255
## | huss_hist-nat.txt         ALL:  273
## | huss_historical.txt       ALL: 1106
## | huss_piControl.txt        ALL: 3023
## | huss_ssp126.txt           ALL:  405
## | huss_ssp245.txt           ALL:  491
## | huss_ssp370.txt           ALL:  491
## | huss_ssp460.txt           ALL:   89
## | huss_ssp585.txt           ALL:  582
links_left <- check_download(options) # undownload links
## [ok] hurs_hist-GHG   :  249 finished,    0 left
## [ok] hurs_hist-nat   :  267 finished,    0 left
## [ok] hurs_hist-aer   :  249 finished,    0 left
## [ok] hurs_historical : 1089 finished,    0 left
## [ok] hurs_piControl  : 2918 finished,    0 left
## [ok] hurs_ssp126     :  401 finished,    0 left
## [ok] hurs_ssp245     :  487 finished,    0 left
## [ok] hurs_ssp370     :  487 finished,    0 left
## [ok] hurs_ssp460     :   99 finished,    0 left
## [ok] hurs_ssp585     :  487 finished,    0 left
## [ok] huss_hist-GHG   :  255 finished,    0 left
## [ok] huss_hist-nat   :  273 finished,    0 left
## [ok] huss_hist-aer   :  255 finished,    0 left
## [ok] huss_historical : 1106 finished,    0 left
## [ok] huss_piControl  : 2443 finished,  580 left
## [ok] huss_ssp126     :  392 finished,   13 left
## [ok] huss_ssp245     :  392 finished,   99 left
## [ok] huss_ssp370     :  478 finished,   13 left
## [ok] huss_ssp460     :   89 finished,    0 left
## [ok] huss_ssp585     :  492 finished,   90 left
## [1] "G:/CMIP6_data/cmip6_hurs_day-url" "G:/CMIP6_data/cmip6_huss_day-url"
## =======================================
## G:/CMIP6_data/cmip6_hurs_day-url
## [1] cmip6_hurs_day-url left: 0  
## =======================================
## G:/CMIP6_data/cmip6_huss_day-url
## | huss_piControl_rem.txt    left: 580
## | huss_ssp126_rem.txt       left: 13 
## | huss_ssp245_rem.txt       left: 99 
## | huss_ssp370_rem.txt       left: 13 
## | huss_ssp585_rem.txt       left: 90 
## [2] cmip6_huss_day-url left: 795
## ======================================
## IN ALL left: [795]
# runner(options_et, x = 4, j = 4)      # uncomment this line to download data

cmip6历史情景一般模拟到2014或2020年。此外,需要注意不同情景model的个数可能不同。

2.2 数据处理

l_files <- get_files(links_all, options) # convert url links to file path

作为示例,这里仅对hurs进行处理。

# only hurs used here
# 详情请查看`CMIP5Files_info`的说明文档
info <- purrr::map(l_files$hurs, CMIP5Files_info)
str(info, 2)
## List of 10
##  $ hist-aer  :Classes 'data.table' and 'data.frame': 249 obs. of  12 variables:
##   ..$ Id        : int [1:249] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ model     : chr [1:249] "ACCESS-CM2" "ACCESS-CM2" "ACCESS-CM2" "ACCESS-CM2" ...
##   ..$ ensemble  : chr [1:249] "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" ...
##   ..$ freq      : chr [1:249] "day" "day" "day" "day" ...
##   ..$ start     : Date[1:249], format: "1850-01-01" "1900-01-01" ...
##   ..$ end       : Date[1:249], format: "1899-12-31" "1949-12-31" ...
##   ..$ start_adj : Date[1:249], format: "1850-01-01" "1900-01-01" ...
##   ..$ end_adj   : Date[1:249], format: "1899-12-31" "1949-12-31" ...
##   ..$ year_start: int [1:249] 1850 1900 1950 2000 1850 1900 1950 2000 1850 1860 ...
##   ..$ year_end  : int [1:249] 1899 1949 1999 2020 1899 1949 1999 2020 1859 1869 ...
##   ..$ len       : num [1:249] 50 50 50 21 50 50 50 21 10 10 ...
##   ..$ file      : chr [1:249] "G:/CMIP6_data/hist-aer/hurs_day_ACCESS-CM2_hist-aer_r1i1p1f1_gn_18500101-18991231.nc" "G:/CMIP6_data/hist-aer/hurs_day_ACCESS-CM2_hist-aer_r1i1p1f1_gn_19000101-19491231.nc" "G:/CMIP6_data/hist-aer/hurs_day_ACCESS-CM2_hist-aer_r1i1p1f1_gn_19500101-19991231.nc" "G:/CMIP6_data/hist-aer/hurs_day_ACCESS-CM2_hist-aer_r1i1p1f1_gn_20000101-20201231.nc" ...
##   ..- attr(*, ".internal.selfref")=<externalptr> 
##  $ hist-GHG  :Classes 'data.table' and 'data.frame': 249 obs. of  12 variables:
##   ..$ Id        : int [1:249] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ model     : chr [1:249] "ACCESS-CM2" "ACCESS-CM2" "ACCESS-CM2" "ACCESS-CM2" ...
##   ..$ ensemble  : chr [1:249] "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" ...
##   ..$ freq      : chr [1:249] "day" "day" "day" "day" ...
##   ..$ start     : Date[1:249], format: "1850-01-01" "1900-01-01" ...
##   ..$ end       : Date[1:249], format: "1899-12-31" "1949-12-31" ...
##   ..$ start_adj : Date[1:249], format: "1850-01-01" "1900-01-01" ...
##   ..$ end_adj   : Date[1:249], format: "1899-12-31" "1949-12-31" ...
##   ..$ year_start: int [1:249] 1850 1900 1950 2000 1850 1900 1950 2000 1850 1860 ...
##   ..$ year_end  : int [1:249] 1899 1949 1999 2020 1899 1949 1999 2020 1859 1869 ...
##   ..$ len       : num [1:249] 50 50 50 21 50 50 50 21 10 10 ...
##   ..$ file      : chr [1:249] "G:/CMIP6_data/hist-GHG/hurs_day_ACCESS-CM2_hist-GHG_r1i1p1f1_gn_18500101-18991231.nc" "G:/CMIP6_data/hist-GHG/hurs_day_ACCESS-CM2_hist-GHG_r1i1p1f1_gn_19000101-19491231.nc" "G:/CMIP6_data/hist-GHG/hurs_day_ACCESS-CM2_hist-GHG_r1i1p1f1_gn_19500101-19991231.nc" "G:/CMIP6_data/hist-GHG/hurs_day_ACCESS-CM2_hist-GHG_r1i1p1f1_gn_20000101-20201231.nc" ...
##   ..- attr(*, ".internal.selfref")=<externalptr> 
##  $ hist-nat  :Classes 'data.table' and 'data.frame': 267 obs. of  12 variables:
##   ..$ Id        : int [1:267] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ model     : chr [1:267] "ACCESS-CM2" "ACCESS-CM2" "ACCESS-CM2" "ACCESS-CM2" ...
##   ..$ ensemble  : chr [1:267] "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" ...
##   ..$ freq      : chr [1:267] "day" "day" "day" "day" ...
##   ..$ start     : Date[1:267], format: "1850-01-01" "1900-01-01" ...
##   ..$ end       : Date[1:267], format: "1899-12-31" "1949-12-31" ...
##   ..$ start_adj : Date[1:267], format: "1850-01-01" "1900-01-01" ...
##   ..$ end_adj   : Date[1:267], format: "1899-12-31" "1949-12-31" ...
##   ..$ year_start: int [1:267] 1850 1900 1950 2000 1850 1900 1950 2000 1850 1860 ...
##   ..$ year_end  : int [1:267] 1899 1949 1999 2020 1899 1949 1999 2020 1859 1869 ...
##   ..$ len       : num [1:267] 50 50 50 21 50 50 50 21 10 10 ...
##   ..$ file      : chr [1:267] "G:/CMIP6_data/hist-nat/hurs_day_ACCESS-CM2_hist-nat_r1i1p1f1_gn_18500101-18991231.nc" "G:/CMIP6_data/hist-nat/hurs_day_ACCESS-CM2_hist-nat_r1i1p1f1_gn_19000101-19491231.nc" "G:/CMIP6_data/hist-nat/hurs_day_ACCESS-CM2_hist-nat_r1i1p1f1_gn_19500101-19991231.nc" "G:/CMIP6_data/hist-nat/hurs_day_ACCESS-CM2_hist-nat_r1i1p1f1_gn_20000101-20201231.nc" ...
##   ..- attr(*, ".internal.selfref")=<externalptr> 
##  $ historical:Classes 'data.table' and 'data.frame': 1089 obs. of  12 variables:
##   ..$ Id        : int [1:1089] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ model     : chr [1:1089] "ACCESS-CM2" "ACCESS-CM2" "ACCESS-CM2" "ACCESS-CM2" ...
##   ..$ ensemble  : chr [1:1089] "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" ...
##   ..$ freq      : chr [1:1089] "day" "day" "day" "day" ...
##   ..$ start     : Date[1:1089], format: "1850-01-01" "1900-01-01" ...
##   ..$ end       : Date[1:1089], format: "1899-12-31" "1949-12-31" ...
##   ..$ start_adj : Date[1:1089], format: "1850-01-01" "1900-01-01" ...
##   ..$ end_adj   : Date[1:1089], format: "1899-12-31" "1949-12-31" ...
##   ..$ year_start: int [1:1089] 1850 1900 1950 2000 1850 1900 1950 2000 1850 1851 ...
##   ..$ year_end  : int [1:1089] 1899 1949 1999 2014 1899 1949 1999 2014 1850 1851 ...
##   ..$ len       : num [1:1089] 50 50 50 15 50 50 50 15 1 1 ...
##   ..$ file      : chr [1:1089] "G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_18500101-18991231.nc" "G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_19000101-19491231.nc" "G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_19500101-19991231.nc" "G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_20000101-20141231.nc" ...
##   ..- attr(*, ".internal.selfref")=<externalptr> 
##  $ piControl :Classes 'data.table' and 'data.frame': 2918 obs. of  12 variables:
##   ..$ Id        : int [1:2918] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ model     : chr [1:2918] "ACCESS-CM2" "ACCESS-CM2" "ACCESS-CM2" "ACCESS-CM2" ...
##   ..$ ensemble  : chr [1:2918] "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" ...
##   ..$ freq      : chr [1:2918] "day" "day" "day" "day" ...
##   ..$ start     : Date[1:2918], format: "0950-01-01" "1000-01-01" ...
##   ..$ end       : Date[1:2918], format: "0999-12-31" "1049-12-31" ...
##   ..$ start_adj : Date[1:2918], format: "0950-01-01" "1000-01-01" ...
##   ..$ end_adj   : Date[1:2918], format: "0999-12-31" "1049-12-31" ...
##   ..$ year_start: int [1:2918] 950 1000 1050 1100 1150 1200 1250 1300 1350 1400 ...
##   ..$ year_end  : int [1:2918] 999 1049 1099 1149 1199 1249 1299 1349 1399 1449 ...
##   ..$ len       : num [1:2918] 50 50 50 50 50 50 50 50 50 50 ...
##   ..$ file      : chr [1:2918] "G:/CMIP6_data/piControl/hurs_day_ACCESS-CM2_piControl_r1i1p1f1_gn_09500101-09991231.nc" "G:/CMIP6_data/piControl/hurs_day_ACCESS-CM2_piControl_r1i1p1f1_gn_10000101-10491231.nc" "G:/CMIP6_data/piControl/hurs_day_ACCESS-CM2_piControl_r1i1p1f1_gn_10500101-10991231.nc" "G:/CMIP6_data/piControl/hurs_day_ACCESS-CM2_piControl_r1i1p1f1_gn_11000101-11491231.nc" ...
##   ..- attr(*, ".internal.selfref")=<externalptr> 
##  $ ssp126    :Classes 'data.table' and 'data.frame': 401 obs. of  12 variables:
##   ..$ Id        : int [1:401] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ model     : chr [1:401] "ACCESS-CM2" "ACCESS-CM2" "ACCESS-ESM1-5" "ACCESS-ESM1-5" ...
##   ..$ ensemble  : chr [1:401] "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" ...
##   ..$ freq      : chr [1:401] "day" "day" "day" "day" ...
##   ..$ start     : Date[1:401], format: "2015-01-01" "2065-01-01" ...
##   ..$ end       : Date[1:401], format: "2064-12-31" "2100-12-31" ...
##   ..$ start_adj : Date[1:401], format: "2015-01-01" "2065-01-01" ...
##   ..$ end_adj   : Date[1:401], format: "2064-12-31" "2100-12-31" ...
##   ..$ year_start: int [1:401] 2015 2065 2015 2065 2015 2016 2017 2018 2019 2020 ...
##   ..$ year_end  : int [1:401] 2064 2100 2064 2100 2015 2016 2017 2018 2019 2020 ...
##   ..$ len       : num [1:401] 50 36 50 36 1 1 1 1 1 1 ...
##   ..$ file      : chr [1:401] "G:/CMIP6_data/ssp126/hurs_day_ACCESS-CM2_ssp126_r1i1p1f1_gn_20150101-20641231.nc" "G:/CMIP6_data/ssp126/hurs_day_ACCESS-CM2_ssp126_r1i1p1f1_gn_20650101-21001231.nc" "G:/CMIP6_data/ssp126/hurs_day_ACCESS-ESM1-5_ssp126_r1i1p1f1_gn_20150101-20641231.nc" "G:/CMIP6_data/ssp126/hurs_day_ACCESS-ESM1-5_ssp126_r1i1p1f1_gn_20650101-21001231.nc" ...
##   ..- attr(*, ".internal.selfref")=<externalptr> 
##  $ ssp245    :Classes 'data.table' and 'data.frame': 487 obs. of  12 variables:
##   ..$ Id        : int [1:487] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ model     : chr [1:487] "ACCESS-CM2" "ACCESS-CM2" "ACCESS-ESM1-5" "ACCESS-ESM1-5" ...
##   ..$ ensemble  : chr [1:487] "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" ...
##   ..$ freq      : chr [1:487] "day" "day" "day" "day" ...
##   ..$ start     : Date[1:487], format: "2015-01-01" "2065-01-01" ...
##   ..$ end       : Date[1:487], format: "2064-12-31" "2100-12-31" ...
##   ..$ start_adj : Date[1:487], format: "2015-01-01" "2065-01-01" ...
##   ..$ end_adj   : Date[1:487], format: "2064-12-31" "2100-12-31" ...
##   ..$ year_start: int [1:487] 2015 2065 2015 2065 2015 2016 2017 2018 2019 2020 ...
##   ..$ year_end  : int [1:487] 2064 2100 2064 2100 2015 2016 2017 2018 2019 2020 ...
##   ..$ len       : num [1:487] 50 36 50 36 1 1 1 1 1 1 ...
##   ..$ file      : chr [1:487] "G:/CMIP6_data/ssp245/hurs_day_ACCESS-CM2_ssp245_r1i1p1f1_gn_20150101-20641231.nc" "G:/CMIP6_data/ssp245/hurs_day_ACCESS-CM2_ssp245_r1i1p1f1_gn_20650101-21001231.nc" "G:/CMIP6_data/ssp245/hurs_day_ACCESS-ESM1-5_ssp245_r1i1p1f1_gn_20150101-20641231.nc" "G:/CMIP6_data/ssp245/hurs_day_ACCESS-ESM1-5_ssp245_r1i1p1f1_gn_20650101-21001231.nc" ...
##   ..- attr(*, ".internal.selfref")=<externalptr> 
##  $ ssp370    :Classes 'data.table' and 'data.frame': 487 obs. of  12 variables:
##   ..$ Id        : int [1:487] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ model     : chr [1:487] "ACCESS-CM2" "ACCESS-CM2" "ACCESS-ESM1-5" "ACCESS-ESM1-5" ...
##   ..$ ensemble  : chr [1:487] "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" ...
##   ..$ freq      : chr [1:487] "day" "day" "day" "day" ...
##   ..$ start     : Date[1:487], format: "2015-01-01" "2065-01-01" ...
##   ..$ end       : Date[1:487], format: "2064-12-31" "2100-12-31" ...
##   ..$ start_adj : Date[1:487], format: "2015-01-01" "2065-01-01" ...
##   ..$ end_adj   : Date[1:487], format: "2064-12-31" "2100-12-31" ...
##   ..$ year_start: int [1:487] 2015 2065 2015 2065 2015 2016 2017 2018 2019 2020 ...
##   ..$ year_end  : int [1:487] 2064 2100 2064 2100 2015 2016 2017 2018 2019 2020 ...
##   ..$ len       : num [1:487] 50 36 50 36 1 1 1 1 1 1 ...
##   ..$ file      : chr [1:487] "G:/CMIP6_data/ssp370/hurs_day_ACCESS-CM2_ssp370_r1i1p1f1_gn_20150101-20641231.nc" "G:/CMIP6_data/ssp370/hurs_day_ACCESS-CM2_ssp370_r1i1p1f1_gn_20650101-21001231.nc" "G:/CMIP6_data/ssp370/hurs_day_ACCESS-ESM1-5_ssp370_r1i1p1f1_gn_20150101-20641231.nc" "G:/CMIP6_data/ssp370/hurs_day_ACCESS-ESM1-5_ssp370_r1i1p1f1_gn_20650101-21001231.nc" ...
##   ..- attr(*, ".internal.selfref")=<externalptr> 
##  $ ssp460    :Classes 'data.table' and 'data.frame': 99 obs. of  12 variables:
##   ..$ Id        : int [1:99] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ model     : chr [1:99] "CanESM5" "FGOALS-g3" "FGOALS-g3" "FGOALS-g3" ...
##   ..$ ensemble  : chr [1:99] "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" ...
##   ..$ freq      : chr [1:99] "day" "day" "day" "day" ...
##   ..$ start     : Date[1:99], format: "2015-01-01" "2015-01-01" ...
##   ..$ end       : Date[1:99], format: "2100-12-31" "2015-12-31" ...
##   ..$ start_adj : Date[1:99], format: "2015-01-01" "2015-01-01" ...
##   ..$ end_adj   : Date[1:99], format: "2100-12-31" "2015-12-31" ...
##   ..$ year_start: int [1:99] 2015 2015 2016 2017 2018 2019 2020 2021 2022 2023 ...
##   ..$ year_end  : int [1:99] 2100 2015 2016 2017 2018 2019 2020 2021 2022 2023 ...
##   ..$ len       : num [1:99] 86 1 1 1 1 1 1 1 1 1 ...
##   ..$ file      : chr [1:99] "G:/CMIP6_data/ssp460/hurs_day_CanESM5_ssp460_r1i1p1f1_gn_20150101-21001231.nc" "G:/CMIP6_data/ssp460/hurs_day_FGOALS-g3_ssp460_r1i1p1f1_gn_20150101-20151231.nc" "G:/CMIP6_data/ssp460/hurs_day_FGOALS-g3_ssp460_r1i1p1f1_gn_20160101-20161231.nc" "G:/CMIP6_data/ssp460/hurs_day_FGOALS-g3_ssp460_r1i1p1f1_gn_20170101-20171231.nc" ...
##   ..- attr(*, ".internal.selfref")=<externalptr> 
##  $ ssp585    :Classes 'data.table' and 'data.frame': 487 obs. of  12 variables:
##   ..$ Id        : int [1:487] 1 2 3 4 5 6 7 8 9 10 ...
##   ..$ model     : chr [1:487] "ACCESS-CM2" "ACCESS-CM2" "ACCESS-ESM1-5" "ACCESS-ESM1-5" ...
##   ..$ ensemble  : chr [1:487] "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" "r1i1p1f1_gn" ...
##   ..$ freq      : chr [1:487] "day" "day" "day" "day" ...
##   ..$ start     : Date[1:487], format: "2015-01-01" "2065-01-01" ...
##   ..$ end       : Date[1:487], format: "2064-12-31" "2100-12-31" ...
##   ..$ start_adj : Date[1:487], format: "2015-01-01" "2065-01-01" ...
##   ..$ end_adj   : Date[1:487], format: "2064-12-31" "2100-12-31" ...
##   ..$ year_start: int [1:487] 2015 2065 2015 2065 2015 2016 2017 2018 2019 2020 ...
##   ..$ year_end  : int [1:487] 2064 2100 2064 2100 2015 2016 2017 2018 2019 2020 ...
##   ..$ len       : num [1:487] 50 36 50 36 1 1 1 1 1 1 ...
##   ..$ file      : chr [1:487] "G:/CMIP6_data/ssp585/hurs_day_ACCESS-CM2_ssp585_r1i1p1f1_gn_20150101-20641231.nc" "G:/CMIP6_data/ssp585/hurs_day_ACCESS-CM2_ssp585_r1i1p1f1_gn_20650101-21001231.nc" "G:/CMIP6_data/ssp585/hurs_day_ACCESS-ESM1-5_ssp585_r1i1p1f1_gn_20150101-20641231.nc" "G:/CMIP6_data/ssp585/hurs_day_ACCESS-ESM1-5_ssp585_r1i1p1f1_gn_20650101-21001231.nc" ...
##   ..- attr(*, ".internal.selfref")=<externalptr>

返回的infol_files$hurs等长,为10个情景(scenario)。取historical作为示例:

d = info$historical
print(d)
##         Id         model    ensemble freq      start        end  start_adj
##    1:    1    ACCESS-CM2 r1i1p1f1_gn  day 1850-01-01 1899-12-31 1850-01-01
##    2:    2    ACCESS-CM2 r1i1p1f1_gn  day 1900-01-01 1949-12-31 1900-01-01
##    3:    3    ACCESS-CM2 r1i1p1f1_gn  day 1950-01-01 1999-12-31 1950-01-01
##    4:    4    ACCESS-CM2 r1i1p1f1_gn  day 2000-01-01 2014-12-31 2000-01-01
##    5:    5 ACCESS-ESM1-5 r1i1p1f1_gn  day 1850-01-01 1899-12-31 1850-01-01
##   ---                                                                     
## 1085: 1085       TaiESM1 r1i1p1f1_gn  day 1970-01-01 1979-12-31 1970-01-01
## 1086: 1086       TaiESM1 r1i1p1f1_gn  day 1980-01-01 1989-12-31 1980-01-01
## 1087: 1087       TaiESM1 r1i1p1f1_gn  day 1990-01-01 1999-12-31 1990-01-01
## 1088: 1088       TaiESM1 r1i1p1f1_gn  day 2000-01-01 2009-12-31 2000-01-01
## 1089: 1089       TaiESM1 r1i1p1f1_gn  day 2010-01-01 2014-12-31 2010-01-01
##          end_adj year_start year_end len
##    1: 1899-12-31       1850     1899  50
##    2: 1949-12-31       1900     1949  50
##    3: 1999-12-31       1950     1999  50
##    4: 2014-12-31       2000     2014  15
##    5: 1899-12-31       1850     1899  50
##   ---                                   
## 1085: 1979-12-31       1970     1979  10
## 1086: 1989-12-31       1980     1989  10
## 1087: 1999-12-31       1990     1999  10
## 1088: 2009-12-31       2000     2009  10
## 1089: 2014-12-31       2010     2014   5
##                                                                                              file
##    1:    G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_18500101-18991231.nc
##    2:    G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_19000101-19491231.nc
##    3:    G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_19500101-19991231.nc
##    4:    G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_20000101-20141231.nc
##    5: G:/CMIP6_data/historical/hurs_day_ACCESS-ESM1-5_historical_r1i1p1f1_gn_18500101-18991231.nc
##   ---                                                                                            
## 1085:       G:/CMIP6_data/historical/hurs_day_TaiESM1_historical_r1i1p1f1_gn_19700101-19791231.nc
## 1086:       G:/CMIP6_data/historical/hurs_day_TaiESM1_historical_r1i1p1f1_gn_19800101-19891231.nc
## 1087:       G:/CMIP6_data/historical/hurs_day_TaiESM1_historical_r1i1p1f1_gn_19900101-19991231.nc
## 1088:       G:/CMIP6_data/historical/hurs_day_TaiESM1_historical_r1i1p1f1_gn_20000101-20091231.nc
## 1089:       G:/CMIP6_data/historical/hurs_day_TaiESM1_historical_r1i1p1f1_gn_20100101-20141231.nc
# 把相同的model划分到一起
l <- split(d[, -2], d$model)
# file为文件路径,接下来对每个model采用cdo进行预处理
# 取出其中一个model的数据
l$`ACCESS-CM2`
##    Id    ensemble freq      start        end  start_adj    end_adj year_start
## 1:  1 r1i1p1f1_gn  day 1850-01-01 1899-12-31 1850-01-01 1899-12-31       1850
## 2:  2 r1i1p1f1_gn  day 1900-01-01 1949-12-31 1900-01-01 1949-12-31       1900
## 3:  3 r1i1p1f1_gn  day 1950-01-01 1999-12-31 1950-01-01 1999-12-31       1950
## 4:  4 r1i1p1f1_gn  day 2000-01-01 2014-12-31 2000-01-01 2014-12-31       2000
##    year_end len
## 1:     1899  50
## 2:     1949  50
## 3:     1999  50
## 4:     2014  15
##                                                                                        file
## 1: G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_18500101-18991231.nc
## 2: G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_19000101-19491231.nc
## 3: G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_19500101-19991231.nc
## 4: G:/CMIP6_data/historical/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_20000101-20141231.nc

2.2.1 cdo 数据预处理

# d %>% group_by(model) %>%