點贊發Nature
關注中Science
GCAM計算結果我們可以用model interface直接檢視,在model interface中直接複制結果即可。但有時我們需要批量導出結果,此時,我們可以利用python的
gcam_reader
包。
gcam_reader
包并不在
PyPI
中,需要從JGCRI下載下傳擷取。
pip install https://github.com/JGCRI/gcamreader
gcam_reader
将database讀取為
DataFrame
:
import gcam_reader
import os
os.chdir(
r"file/path/to/gcam_directory"
)
dbpath = "output" # set output file
dbfile = "database_basexdb" # database name
conn = gcam_reader.LocalDBConn(dbpath, dbfile)
# Examplary outputs:
# Database scenarios: Reference, 4p5, GCAM_SSP4, GCAM_SSP5, GCAM_SSP1, GCAM_SSP2, GCAM_SSP1
# set a query file - query database results, gcam gives an example query file as "Main_queries.xml"
queries = gcam_reader.parse_batch_query(os.path.join(dbpath, "queries.xml"))
[q.title for q in queries] # show the titles of queries
# get a query dataframe
query_df = conn.runQuery(queries, ["GCAM_SSP1"])
————————
我是仁荷大學的博士生(我的google scholar, 我的Github),關注能源轉型過程中的環境、經濟問題。
專注于分享利用python科研的技巧,歡迎一起交流、學習、合作。
關于我的部落格内容、其他相關的研究問題,有問題可以下方👇評論、或私信我~