This function connects to a gcamdatabase and uses a query file to out results into a table ready for plotting.

readgcam(
  gcamdatabase = NULL,
  gcamdata_folder = NULL,
  queryFile = NULL,
  dataProjFile = "dataProj.proj",
  maxMemory = "4g",
  scenOrigNames = "All",
  scenNewNames = NULL,
  reReadData = T,
  regionsSelect = NULL,
  regionsAggregate = NULL,
  regionsAggregateNames = NULL,
  paramsSelect = "diagnostic",
  folder = getwd(),
  nameAppend = "",
  saveData = T
)

Arguments

gcamdatabase

Default = NULL. Full path to GCAM database folder.

gcamdata_folder

(OPTIONAL) Default=NULL. Full path to gcamdata folder. Required for some params.

queryFile

Defualt = NULL. When NULL gcamextractor loads pre-saved xml file gcamextractor::queries_xml

dataProjFile

Default = NULL. Optional. A default 'dataProj.proj' is produced if no .Proj file is specified.

maxMemory

Default = "4g". Set the maxMemory. Sometimes need to increase this for very large data.

scenOrigNames

Default = "All". Original Scenarios names in GCAM database in a string vector. For example c('scenario1','scenario2).

scenNewNames

New Names which may be shorter and more useful for figures etc. Default will use Original Names. For example c('scenario1','scenario2)

reReadData

If TRUE will read the GCAM data base and create a queryData.proj file in the same folder as the GCAM database. If FALSE will load a '.proj' file if a file with full path is provided otherwise it will search for a dataProj.proj file in the existing folder which may have been created from an old run.

regionsSelect

Default = NULL. The regions to analyze in a vector. Example c('Colombia','Argentina'). Full list: USA, Africa_Eastern, Africa_Northern, Africa_Southern, Africa_Western, Australia_NZ, Brazil, Canada Central America and Caribbean, Central Asia, China, EU-12, EU-15, Europe_Eastern, Europe_Non_EU, European Free Trade Association, India, Indonesia, Japan, Mexico, Middle East, Pakistan, Russia, South Africa, South America_Northern, South America_Southern, South Asia, South Korea, Southeast Asia,

regionsAggregate

Default = NULL. Vector or list of vectors containing regions to aggregate into a new region. Example c('South America_Northern', 'South America_Southern') will add one aggregated region while list(c('South America_Northern', 'South America_Southern'), c('USA', 'Canada', 'Mexico')) will add two aggregated regions.

regionsAggregateNames

Default = NULL. Vector of names for aggregated regions. Length must be 1 if regionsAggregate is a vector or match the length of the list given by regionsAggregate. Example: c('South America', 'North America')

paramsSelect

Default = "diagnostic".

Choose "All" or paramSet from "energy", "electricity", "transport", "water" , "socioecon" ,"ag" , "livestock" ,"land" ,"emissions".

Or pick an individual param from the list:

# energy "energyPrimaryByFuelEJ","energyPrimaryRefLiqProdEJ", "energyFinalConsumBySecEJ","energyFinalByFuelEJ","energyFinalSubsecByFuelTranspEJ", "energyFinalSubsecByFuelBuildEJ", "energyFinalSubsecByFuelIndusEJ","energyFinalSubsecBySectorBuildEJ", "energyPrimaryByFuelMTOE","energyPrimaryRefLiqProdMTOE", "energyFinalConsumBySecMTOE","energyFinalbyFuelMTOE","energyFinalSubsecByFuelTranspMTOE", "energyFinalSubsecByFuelBuildMTOE", "energyFinalSubsecByFuelIndusMTOE","energyFinalSubsecBySectorBuildMTOE", "energyPrimaryByFuelTWh","energyPrimaryRefLiqProdTWh", "energyFinalConsumBySecTWh","energyFinalbyFuelTWh","energyFinalSubsecByFuelTranspTWh", "energyFinalSubsecByFuelBuildTWh", "energyFinalSubsecByFuelIndusTWh","energyFinalSubsecBySectorBuildTWh",

# electricity "elecByTechTWh","elecCapByFuel","elecFinalBySecTWh","elecFinalByFuelTWh", "elecConsumByDemandSector", "elecNewCapCost","elecNewCapGW","elecAnnualRetPrematureCost","elecAnnualRetPrematureGW","elecCumCapCost","elecCumCapGW","elecCumRetPrematureCost","elecCumRetPrematureGW",

# transport "transportPassengerVMTByMode", "transportFreightVMTByMode", "transportPassengerVMTByFuel", "transportFreightVMTByFuel",

# buildings "serviceOutputByTechBuildings", "buildingFloorspace",

# water "watConsumBySec", "watWithdrawBySec", "watWithdrawByCrop", "watBioPhysCons", "watIrrWithdrawBasin","watIrrConsBasin",

# socioecon "gdpPerCapita", "gdp", "gdpGrowthRate", "pop",

# ag "agProdbyIrrRfd", "agProdBiomass", "agProdForest","agProdByCrop",

# livestock "livestock_MeatDairybyTechMixed","livestock_MeatDairybyTechPastoral","livestock_MeatDairybyTechImports", "livestock_MeatDairybySubsector",

# land "landIrrRfd", "landIrrCrop","landRfdCrop", "landAlloc","landAllocByCrop",

# emissions "emissLUC", "emissGHGBySectorGWPAR5","emissGHGBySectorGTPAR5", "emissNonCO2ByResProdGWPAR5", "emissBySectorGWPAR5FFI","emissMethaneBySourceGWPAR5", "emissByGasGWPAR5FFI", "emissByGasGWPAR5LUC", "emissBySectorGWPAR5LUC", "emissNonCO2ByResProdGTPAR5", "emissBySectorGTPAR5FFI","emissMethaneBySourceGTPAR5", "emissByGasGTPAR5FFI", "emissByGasGTPAR5LUC","emissBySectorGTPAR5LUC", "emissCO2BySectorNoBio",

# hydrogen

folder

Default = getwd(). Path to directory for outputs

nameAppend

Default="". Name to append to saved files.

saveData

Default = "T". Set to F if do not want to save any data to file.

Value

A list with the scenarios in the gcam database, queries in the queryxml file and a tibble with gcam data formatted for gcamextractor charts aggregated to different categories. These include data, dataAggParam, dataAggClass1, dataAggClass2.