其他分享
首页 > 其他分享> > GCAM | GCAM-v5.1.3 构建输入文件数据系统(the GCAM data system)

GCAM | GCAM-v5.1.3 构建输入文件数据系统(the GCAM data system)

作者:互联网

 
全球变化分析模型(Global Change Analysis Model,GCAM),一种用于探索全球变化后果和应对措施的综合评估工具。
Github:https://github.com/JGCRI/gcam-core
Github下载:https://github.com/JGCRI/gcam-core/releases
官方文档:http://jgcri.github.io/gcam-doc/index.html
GCAM 大量的 XML 输入文件是通过构建输入文件数据系统(the GCAM data system)来生成的。这项工作在 GCAM Release Package 中已预先完成,但若要更换输入数据则可能需要重新进行。

GCAM data system 的构建:https://github.com/JGCRI/gcamdata/wiki/Getting-Started
GCAM-v5.1.3 data system 的构建,步骤如下:
 

文章目录

一、准备

1.1 准备软件

1、R 语言与 RStudio
https://www.r-project.org/
https://www.rstudio.com/products/rstudio/download/
此为构建输入文件数据系统的环境。
注:R 版本过新,则构建时可能会发生错误,我的 R 版本为 3.5.3。

2、GitHub Desktop(可选)
https://desktop.github.com/
用于对输入文件数据系统进行版本管理。

1.2 准备 R Package

在 RStudio 中的 Console 上输入下列代码安装所需的 R Package:

install.packages("devtools")

# 控制 R Package 的版本,已安装的 R Package 若版本不兼容则可能需要 remove.packages() 再重新安装
require(devtools)
install_version("tibble", version = "2.1.1")
install_version("dplyr", version = "0.8.3")
install_version("tidyr", version = "0.8.3")
install_version("readr", version = "1.3.1")
install_version("assertthat", version = "0.2.1")
install_version("roxygen2", version = "7.1.1")
install_version("data.table", version = "1.12.0")

devtools::install_github("krlmlr/mockr")

注:安装 R Package 时注意依赖 Package 的安装是否成功。
·

二、构建 the GCAM data system

2.1 构建流程

打开 GCAM\input\gcamdata 目录或者克隆(下载)的 gcamdata 目录,使用 RStudio 打开 gcamdata.Rproj :
在这里插入图片描述
点击 build --> install and restart
在这里插入图片描述
输入下列代码进行构建:

driver(write_output=FALSE, write_xml=TRUE)

在这里插入图片描述
构建成功后,XML 输入文件将会保存在 GCAM\input\gcamdata\xml 下
·

2.2 可能错误

构建 the GCAM data system 时遇到的错误,大都由于 R Package 版本不兼容而导致。Google 可能会有解决方案,但最好在 Github 官方上寻求答案:
https://github.com/JGCRI/gcamdata/issues

下面列举几个我遇到的问题:

# 1、R 版本:R 4+ 可能出现此问题,切换到 R 3.5.3 解决
Error in mutate_impl(.data, dots, caller_env()) :  attempt to bind a variable to R_UnboundValue

# 2、dplyr 版本:dplyr 1.0 可能出现此问题,切换到 dplyr 0.8.3 解决(tidyr 要求 dplyr 不太旧)
Error: L100.Land_type_area_ha is being returned grouped. This is not allowed; please ungroup()

# 3、tidyr 版本:tidyr 1.0 可能出现此问题,切换到 tidyr 0.8.3 解决
Error in left_join_error_no_match(., L162.defaultYieldRate, by = c("year", "GCAM_commodity"))
left_join_no_match: NA values in new data columns

# 4、readr 版本:readr 2.0 可能出现此问题,切换到 readr 1.3.1 解决
Error in load_csv_files(unfound_chunk$input, unfound_chunk$optional, quiet = TRUE):
Error or warning while reading A_ff_RegionalSubsector.csv

# 5、tibble 版本:tibble 3.0 可能出现此问题,切换到 tibble 2.1.1 解决
Error: Assigned data min(MODEL_BASE_YEARS) must be compatible with existing data.
i Error occurred for column logit.year.fillout.

# 6、tidyselect 版本:tidyselect 1.0 可能出现此问题,切换到 tidyselect 0.2.5 解决
Error: Names must be unique.
Run rlang::last_error() to see where the error occurred.

参考:
https://github.com/JGCRI/gcamdata/issues/1153
https://github.com/JGCRI/gcamdata/issues/1138
https://github.com/JGCRI/gcamdata/issues/1177
https://github.com/JGCRI/gcamdata/issues/1172
https://github.com/JGCRI/gcamdata/issues/1155


有问题欢迎下方评论或者私信我。

标签:GCAM,github,system,version,v5.1,https,gcamdata,data
来源: https://blog.csdn.net/Sh1Y1/article/details/123020420