Skip to content

Commit da316e2

Browse files
Feb 05 2021 release (#32)
* Update readme. * Set release version number. * Update units file * Update UNFCCC emissions and scaling mapping for GHGs * Add non-comb emission inventory default assumptions, largely for Annex I CO2 * Update MEIC 2018 scaling methods * Fix usa energy user input sector mapping * Eliminate soil emissions discontinuity in idn N2O and pak NOx * Update SKorea inventory input files and mappings * Add NH3 to S Korea inventory. * Improve match to off road inventory estimates by assuming usa and can commercial sector diesel fuel is off-road mobile * Default user and system combustion EF and non-combustion emission files now explicitly sorted for consistency * Update to most recent satellite data for SO2 refinery/fugitive emissions. Use refinery throughput for extrapolation * Update to consistently represent China iron smelting SO2 * Fix China BC/OC Coke emissions * Add BC/OC controls for recent years in China * Add usa can rail EF trends * Add USA off-road IEA energy data corrections * Overwrite Ethiopia and Nigeria residential biomass consumption with valued based no UN data instead of IEA. * Add BC/OC for fossil-fuel fires. * Remove 2004 discontinuity in USA inventory data MISC sector * Scale BC/OC road transportation to country inventory PM2.5 * Added maximum road BC/OC EF pathway * Fix outlier values in GAINS default EF generation * remove iso's in edgar scaling that are scaled by country inventories * update Australia inventory with 2018/2019 year, add NH3, updated mapping file * Removed Australia soil-emissions from scaling - these emissions not included in AUS inventory * Remove AgriOther from EMEP scaling which includes AWB, which is not included in CEDS * Updated SPEW process (coke oven) BC and OC emissions with aggregate countries (e.g FSU) are not included for earlier years * Add oil production driver for emissions extension * Remove outdated figure generation scripts
1 parent 504e834 commit da316e2

File tree

225 files changed

+69263
-164189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+69263
-164189
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ CH4_IO_documentation.csv
2121

2222
#Proprietary Data
2323
input/energy/OECD_and_NonOECD_E_Stat.csv
24+
input/energy/OECD_and_NonOECD_Conversion_Factors.csv
2425
input/energy/OECD_and_NonOECD_Conversion_Factors_Full.csv
2526

2627
.Rproj.user

Makefile

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ endif
110110
# Note that this is an inefficient method of creating data for multiple species
111111
# If a multi-processor machine is available, CEDS should be instead run in parallel for multiple species
112112
all: SO2-emissions BC-emissions OC-emissions NOx-emissions CO-emissions NMVOC-emissions CO2-emissions NH3-emissions CH4-emissions N2O-emissions
113-
part1: SO2-emissions NOx-emissions NH3-emissions
113+
part1: NOx-emissions SO2-emissions NH3-emissions
114114
part2: BC-emissions OC-emissions CO2-emissions N2O-emissions
115115
part3: CO-emissions NMVOC-emissions CH4-emissions
116116

@@ -122,7 +122,7 @@ clean-all: \
122122
clean-modD clean-modE clean-modF clean-modH clean-gridding clean-user_defined_energy
123123

124124
clean-user_defined_energy:
125-
# Deletes all CSVs in the directory except for:
125+
# Deletes all CSVs in the directory except for:
126126
# 1) CEDS user-defined energy inputs, metadata, and instructions (U.*.csv)
127127
# 2) Relevant mapping and instructions files for user-defined energy input which require pre-processing for use in CEDS (A.*-instructions.csv, A.*_sector_map.csv, A.*-mapping.xlsx)
128128
find $(USER_EN_IN) -name "*.csv" ! -name "U.*.csv" ! -name "A.*-instructions.csv" ! -name "A.*_sector_map.csv" -delete
@@ -468,6 +468,7 @@ $(MED_OUT)/A.NC_activity_db.csv: \
468468
$(MOD_A)/A5.2.add_NC_activity_gdp.R \
469469
$(MOD_A)/A5.2.add_NC_activity_population.R \
470470
$(MOD_A)/A5.2.add_NC_activity_energy.R \
471+
$(MOD_A)/A5.2.add_NC_activity_fossil_fuel_production.R \
471472
$(PARAMS)/common_data.R \
472473
$(PARAMS)/global_settings.R \
473474
$(PARAMS)/IO_functions.R \
@@ -477,18 +478,23 @@ $(MED_OUT)/A.NC_activity_db.csv: \
477478
$(PARAMS)/process_db_functions.R \
478479
$(MAPPINGS)/activity_input_mapping.csv \
479480
$(MED_OUT)/A.other_IEA_energy_values.csv \
481+
$(MED_OUT)/A.en_stat_sector_fuel.csv \
480482
$(MAPPINGS)/NC_EDGAR_sector_mapping.csv \
481483
$(MAPPINGS)/2011_NC_SO2_ctry.csv \
484+
$(MAPPINGS)/Master_Country_List.csv \
482485
$(ACTIV)/Smelter-Feedstock-Sulfur.xlsx \
483486
$(ACTIV)/Wood_Pulp_Consumption.xlsx \
484-
$(ACTIV)/GDP.xlsx
487+
$(ACTIV)/GDP.xlsx \
488+
$(ENERGY_DATA)/Hyde_oil_1800-1975.xls
485489
Rscript $< $(EM) --nosave --no-restore
486490
Rscript $(word 2,$^) $(EM) --nosave --no-restore
487491
Rscript $(word 3,$^) $(EM) --nosave --no-restore
488492
Rscript $(word 4,$^) $(EM) --nosave --no-restore
489493
Rscript $(word 5,$^) $(EM) --nosave --no-restore
490494
Rscript $(word 6,$^) $(EM) --nosave --no-restore
491495
Rscript $(word 7,$^) $(EM) --nosave --no-restore
496+
Rscript $(word 8,$^) $(EM) --nosave --no-restore
497+
Rscript $(word 9,$^) $(EM) --nosave --no-restore
492498

493499
$(MED_OUT)/A.pulp_paper_consumption_full.csv: \
494500
$(MED_OUT)/A.NC_activity_db.csv
@@ -567,9 +573,11 @@ $(MED_OUT)/A.NC_activity_extended_db.csv: \
567573
$(MOD_A)/A7.2.add_activity_CDIAC.R \
568574
$(MOD_A)/A7.2.add_activity_population.R \
569575
$(MOD_A)/A7.2.add_activity_pulp_paper_consumption.R \
576+
$(MOD_A)/A7.2.add_activity_fossil_fuel_production.R \
570577
$(MED_OUT)/E.CO2_CDIAC_inventory.csv \
571578
$(MED_OUT)/A.pulp_paper_consumption_full.csv \
572579
$(MED_OUT)/A.NC_activity.csv \
580+
$(MED_OUT)/A.crude_oil_production_data.csv \
573581
$(EXT_IN)/CEDS_historical_extension_drivers_activity.csv
574582
Rscript $< $(EM) --nosave --no-restore
575583
Rscript $(word 2,$^) $(EM) --nosave --no-restore
@@ -728,9 +736,10 @@ $(MED_OUT)/C.$(EM)_NC_emissions.csv: \
728736
$(MED_OUT)/E.$(EM)_EMEP_NFR09_inventory.csv \
729737
$(MED_OUT)/E.$(EM)_EMEP_NFR14_inventory.csv \
730738
$(MED_OUT)/E.$(EM)_Japan_inventory.csv \
739+
$(MED_OUT)/E.$(EM)_KOR2017_inventory.csv \
731740
$(MED_OUT)/E.$(EM)_REAS_inventory.csv \
732741
$(MED_OUT)/E.$(EM)_UNFCCC_inventory.csv \
733-
$(MED_OUT)/E.$(EM)_UNFCCC_inventory_update.csv \
742+
$(MED_OUT)/E.$(EM)_UNFCCC_update_inventory.csv \
734743
$(MED_OUT)/E.$(EM)_US_inventory.csv \
735744
$(MED_OUT)/E.$(EM)_US-EPA_inventory.csv \
736745
$(MED_OUT)/E.$(EM)_US_GHG_inventory.csv \
@@ -782,7 +791,7 @@ $(MED_OUT)/E.$(EM)_UNFCCC_inventory.csv: \
782791
Rscript $< $(EM) --nosave --no-restore
783792

784793
# ee1-2
785-
$(MED_OUT)/E.$(EM)_UNFCCC_inventory_update.csv: \
794+
$(MED_OUT)/E.$(EM)_UNFCCC_update_inventory.csv: \
786795
$(MOD_E)/E.UNFCCC_emissions_update.R
787796
Rscript $< $(EM) --nosave --no-restore
788797

@@ -801,7 +810,7 @@ $(MED_OUT)/E.CO2_CDIAC_inventory.csv: \
801810
$(MOD_E)/E.CDIAC_emissions.R \
802811
$(MED_OUT)/A.UN_pop_master.csv
803812
Rscript $< $(EM) --nosave --no-restore
804-
813+
805814
# ee1-2
806815
$(MED_OUT)/E.CO2_Andrew_Cement.csv: \
807816
$(MOD_E)/E.Andrew_emissions.R \
@@ -848,6 +857,11 @@ $(MED_OUT)/E.$(EM)_Japan_inventory.csv: \
848857
$(MOD_E)/E.Japan_emissions.R
849858
Rscript $< $(EM) --nosave --no-restore
850859

860+
# ee1-2
861+
$(MED_OUT)/E.$(EM)_KOR2017_inventory.csv: \
862+
$(MOD_E)/E.SKorea_emissions_2017.R
863+
Rscript $< $(EM) --nosave --no-restore
864+
851865
# ee1-2
852866
$(MED_OUT)/E.$(EM)_US_inventory.csv: \
853867
$(MOD_E)/E.US_emissions.R
@@ -859,13 +873,13 @@ $(MED_OUT)/E.$(EM)_US-EPA_inventory.csv: \
859873
Rscript $< $(EM) --nosave --no-restore
860874

861875
# ee1-2
862-
$(MED_OUT)/E.$(EM)_US_GHG_inventory.csv : \
876+
$(MED_OUT)/E.$(EM)_US_GHG_inventory.csv: \
863877
$(MOD_E)/E.US-GHG_emissions.R
864878
Rscript $< $(EM) --nosave --no-restore
865879

866880
# ee1-2
867881
$(MED_OUT)/E.$(EM)_AUS_inventory.csv: \
868-
$(MOD_E)/E.Australia_emissions.R
882+
$(MOD_E)/E.Australia_emissions_2018Update.R
869883
Rscript $< $(EM) --nosave --no-restore
870884

871885
# ee1-2
@@ -888,7 +902,7 @@ $(MED_OUT)/F.$(EM)_scaled_emissions.csv: \
888902
$(MOD_F)/F1.1.EMEP_NFR14_scaling.R \
889903
$(MOD_F)/F1.1.Japan_scaling.R \
890904
$(MOD_F)/F1.1.REAS_scaling.R \
891-
$(MOD_F)/F1.1.South_korea_scaling.R \
905+
$(MOD_F)/F1.1.South_korea_scaling_2017.R \
892906
$(MOD_F)/F1.1.UNFCCC_scaling.R \
893907
$(MOD_F)/F1.1.US_scaling.R \
894908
$(MOD_F)/F1.1.US-EPA_scaling.R \
@@ -905,6 +919,7 @@ $(MED_OUT)/F.$(EM)_scaled_emissions.csv: \
905919
$(MED_OUT)/E.$(EM)_EMEP_NFR09_inventory.csv \
906920
$(MED_OUT)/E.$(EM)_EMEP_NFR14_inventory.csv \
907921
$(MED_OUT)/E.$(EM)_Japan_inventory.csv \
922+
$(MED_OUT)/E.$(EM)_KOR2017_inventory.csv \
908923
$(MED_OUT)/E.$(EM)_REAS_inventory.csv \
909924
$(MED_OUT)/E.$(EM)_UNFCCC_inventory.csv \
910925
$(MED_OUT)/E.$(EM)_US_inventory.csv \
@@ -936,12 +951,12 @@ $(MED_OUT)/F.$(EM)_scaled_emissions.csv: \
936951
$(SC_MAPPINGS)/S_Korea_scaling_mapping.csv \
937952
$(SC_MAPPINGS)/UNFCCC_scaling_mapping.csv \
938953
$(SC_MAPPINGS)/UNFCCC_scaling_year.csv \
939-
$(SC_MAPPINGS)/UNFCCC_CH4_scaling_mapping.csv \
940-
$(SC_MAPPINGS)/UNFCCC_CH4_scaling_year.csv \
954+
$(SC_MAPPINGS)/UNFCCC_GHG_scaling_mapping.csv \
941955
$(SC_MAPPINGS)/US_scaling_mapping.csv \
942956
$(SC_MAPPINGS)/US-EPA_scaling_mapping.csv \
943957
$(SC_MAPPINGS)/US-GHG_scaling_mapping.csv \
944958
$(SC_MAPPINGS)/Australia_scaling_mapping.csv \
959+
$(SC_MAPPINGS)/Australia_NOx_scaling_mapping.csv \
945960
$(SC_MAPPINGS)/Taiwan_scaling_mapping.csv \
946961
$(SC_MAPPINGS)/Taiwan_scaling_method.csv \
947962
$(MED_OUT)/D.$(EM)_default_total_EF.csv \
@@ -1013,7 +1028,7 @@ $(MED_OUT)/gridded-emissions/CEDS_$(EM)_anthro_%.csv: \
10131028
$(PARAMS)/nc_generation_functions.R \
10141029
$(FINAL_OUT)/current-versions/CEDS_$(EM)_emissions_by_country_CEDS_sector_*.csv
10151030
Rscript $< $(EM) --nosave --no-restore
1016-
1031+
10171032
ifeq ($(EM),NMVOC)
10181033
Rscript $(MOD_G)/G1.2.grid_subVOC_emissions.R VOC01 --nosave --no-restore
10191034
Rscript $(MOD_G)/G1.2.grid_subVOC_emissions.R VOC02 --nosave --no-restore

README.md

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,49 @@
11
# CEDS
22
The Community Emissions Data System (CEDS) produces consistent estimates of global air emissions species over the industrial era (1750 - present). The system is written in R and uses open-source data (with the exception of the IEA energy statistics which must be purchased from IEA). CEDS is publicly available through an [Open Source License](#license-section).
33

4-
***
5-
**Code Update:** December 28, 2020. This code update adds N2O emissions and updates CH4 and CO2 data. See the [release notes](https://github.com/JGCRI/CEDS/wiki/Release-Notes) for further details. Emissions data will be included in the upcoming full release.
64

7-
**Pre-Release:** September 11, 2020. The current code and data in this repository is associated with a pre-release set of data for review and assessment.
5+
**Feb 2021 Release:** February 05, 2021 (v\_2021\_02\_05)
6+
7+
This data and code release extends the emissions time series to 2019 and updates driver and emissions data throughout. This version builds on the extension of the CEDS system to 2017 described in [McDuffie et al. 2020](https://essd.copernicus.org/preprints/essd-2020-103/). Major features:
88

9-
This pre-release extends the emissions time series to 2019 and updates driver and emissions data throughout. This version builds on the extension of the CEDS system to 2017 described in [McDuffie et al. 2020](https://essd.copernicus.org/preprints/essd-2020-103/). This pre-release focuses on aerosol and ozone precursor emissions.
9+
* Emissions estimates to 2019
10+
* Updated default data from GAINS and EDGAR
11+
* Updates to country inventories used for scaling
12+
* Improved BC/OC emission time series
13+
* Improved consistency over time
14+
* Updated code and driver data
1015

1116
For details on this release see:
1217

13-
* See the [release notes](https://github.com/JGCRI/CEDS/wiki/Release-Notes) for a summary of changes and notes on **known issues** with this dataset that are currently being addressed.
14-
* [Graphs of emission differences](./documentation/Version_comparison_figures_v_2020_09_11_vs_v_2019_12_23.pdf) between this version and the previous December 2019 CEDS data release.
15-
* [Graphs of emission differences](./documentation/Version_comparison_figures_v_2020_09_11_vs_v_2016_07_16(CMIP6).pdf) between this version and the CEDS CMIP6 data release documented in Hoesly et al (2018a).
16-
* Emissions by country and sector, archived [here](https://zenodo.org/record/4025316).
18+
* See the [release notes](https://github.com/JGCRI/CEDS/wiki/Release-Notes) for a summary of changes.
19+
* [Graphs of emission differences](./documentation/Version_comparison_figures_v_2021_02_05_vs_v_2016_07_16(CMIP6).pdf) between this version and the CEDS CMIP6 data release documented in Hoesly et al (2018a).
20+
* [Graphs of emission differences](./documentation/Version_comparison_figures_v_2021_02_05_vs_v_2019_12_23.pdf) between this version and the previous December 2019 CEDS data release.
21+
* Emissions by country and sector, archived [here](http://doi.org/10.5281/zenodo.4509372).
22+
23+
We encourage comments on this data. The best way to comment on the data is through the [CEDS Issues](https://github.com/JGCRI/CEDS/issues) page.
24+
25+
_Gridded data corresponding to this release is in production and will be released shortly._
1726

18-
We encourage assessment of and comments on this pre-release data. The best way to comment on the data is through the [CEDS Issues](https://github.com/JGCRI/CEDS/issues) page. A full release is in progress for fall 2020 and will incorporate as many comments as possible.
27+
_A journal paper describing this dataset is in preparation. A notice will be updated here and sent to the CEDS listserv when this is available._
1928

20-
We do not anticipate substantial changes to the CEDS system structure prior to the fall 2020 full release.
2129
***
2230

2331
Documentation of CEDS assumptions and system operation, including a user guide, are available at the [CEDS project wiki](https://github.com/JGCRI/CEDS/wiki) and in the journal papers noted below.
2432

25-
Current issues with the data or system are documented in the [CEDS Issues](https://github.com/JGCRI/CEDS/issues) system in this GitHub repository. Users can submit issues using this system. These can include anomalies found in either the aggregate or gridded emissions data. Please use an appropriate tag for any submitted issues. Note that by default only unresolved issues are shown. All issues, including resolved issues, can be viewed by removing the "is:open" filter. *Issues relevant for CMIP6 data releases are tagged with a “CMIP6” label (note that issues will be closed when resolved in subsequent CEDS data releases.)*
33+
Current issues with the data or system are documented in the [CEDS Issues](https://github.com/JGCRI/CEDS/issues) system in this GitHub repository. Users can submit issues using this system. These can include anomalies found in either the aggregate or gridded emissions data. Please use an appropriate tag for any submitted issues. Note that by default only unresolved issues are shown. All issues, including resolved issues, can be viewed by removing the "is:open" filter. *Issues relevant for CMIP6 data releases are tagged with a “CMIP6” label (note that issues will be closed when resolved in subsequent CEDS data releases, but are still available for viewing.)*
2634

27-
Further information can also be found at the [project web site](http://www.globalchange.umd.edu/ceds/), including a [CMIP6 page](http://www.globalchange.umd.edu/ceds/ceds-cmip6-data/) that provides details for obtaining gridded emission datasets produced by this project for use in CMIP6.
35+
Further information can also be found at the [project web site](http://www.globalchange.umd.edu/ceds/), including a [CMIP6 page](http://www.globalchange.umd.edu/ceds/ceds-cmip6-data/) that provides details for obtaining gridded emission datasets produced by this project for use in CMIP6. You can also sign up for data release announcements from the CEDSinfo listserv following the instructions on the [project web site](http://www.globalchange.umd.edu/ceds/).
2836

2937
If you plan to use the CEDS data system for a research project you are encouraged to contact [Steve Smith](mailto:ssmith@pnnl.gov) so that we can coordinate with any on-going work on the CEDS system and make sure we are not duplicating effort. CEDS is research software, and we will be happy to help and make sure that you are able to make the best possible use of this system.
3038

31-
Users should use the most recent version of this repository, which will include maintenance updates to address documentation or usability issues. Major changes that alter emission estimates or system structure and use ill be noted in the [release notes](https://github.com/JGCRI/CEDS/wiki/Release-Notes).
39+
Users should use the most recent version of this repository, which will include maintenance updates to address documentation or usability issues. Major changes that alter emission estimates or system structure and use will be noted in the [release notes](https://github.com/JGCRI/CEDS/wiki/Release-Notes).
3240

33-
CEDS has only been possible through the participation of many collaborators. Our **collaboration policy** is that collaborators who contribute data used in CEDS updates will be included as co-authors on the journal paper that describes the next CEDS major release. We particularly encourage contributions of updated emission information from countries or sectors not well represented in the data currently used in CEDS.
41+
CEDS has only been possible through the participation of many collaborators. Our **collaboration policy** is that collaborators who contribute unpublished data used in CEDS updates will be included as co-authors on the journal paper that describes the next CEDS major release. We particularly encourage contributions of updated emission information from countries or sectors not well represented in the data currently used in CEDS.
3442

3543
# Data Reference
3644

3745
Reference for [this data version](https://github.com/JGCRI/CEDS/wiki/Release-Notes):
38-
O'Rourke, Patrick R, Smith, Steven J., McDuffie, Erin E., Crippa, Monica, Klimont, Zbigniew, Mott, Andrea, Wang, Shuxiao, Nicholson, Matthew B, Feng, Leyang, and Hoesly, Rachel M. (2020, September 11). CEDS v-2020-09-11 Pre-Release Emission Data 1975-2019 (Version Sept-11-2020). [Zenodo. http://doi.org/10.5281/zenodo.4025316](http://doi.org/10.5281/zenodo.4025316).
46+
O'Rourke, P. R, Smith, S. J., Mott, A., Ahsan, H., McDuffie, E. E., Crippa, M., Klimont, S., McDonald, B., Z., Wang, Nicholson, M. B, Feng, L., and Hoesly, R. M. (2021, February 05). CEDS v-2021-02-05 Emission Data 1975-2019 (Version Feb-05-2021). [Zenodo. http://doi.org/10.5281/zenodo.4509372](http://doi.org/10.5281/zenodo.4509372).
3947

4048
# Journal Papers
4149
[Hoesly et al, Historical (1750–2014) anthropogenic emissions of reactive gases and aerosols from the Community Emissions Data System (CEDS). ](https://www.geosci-model-dev.net/11/369/2018/gmd-11-369-2018.html) _Geosci. Model Dev._ 11, 369-408, 2018a.

code/diagnostic/Compare_to_RCP.R

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ initialize( script_name, log_msg, headers )
3535

3636
args_from_makefile <- commandArgs( TRUE )
3737
em <- args_from_makefile[ 1 ]
38-
if ( is.na( em ) ) em <- "CH4"
38+
if ( is.na( em ) ) em <- "N2O"
3939

40-
# Run for all ems besides N2O
41-
if (em != "N2O"){
40+
# Run for all ems (RCP for N2O and CO2 is blank, but we want graphs for CEDS values anyway)
41+
if (em != "N2Ox"){
4242

4343
# Load Packages
4444

@@ -54,7 +54,8 @@ library('gridExtra')
5454
rcp_start_year <- 1850
5555
rcp_end_year <- 2000
5656
CEDS_start_year <- 1850
57-
if ( em == 'CH4') CEDS_start_year <- 1970
57+
# If not doing for publication, look at all years.
58+
#if ( em == 'CH4') CEDS_start_year <- 1970
5859
CEDS_end_year <- end_year
5960

6061
rcp_years <- seq(from=rcp_start_year,to=rcp_end_year,by=10)
@@ -109,7 +110,8 @@ ceds_remove_sectors <- c("1A3ai_International-aviation",
109110
# if current em does not have ship emissions
110111
# for the RCP shipping emissions data Historicalshipemissions_IPCC_FINAL_Jan09_updated_1850.xlsx
111112
# it doesn't contain data for NH3
112-
has_ship <- em != "NH3"
113+
has_ship <- TRUE
114+
if( em %in% c( 'NH3', 'N2O', 'CO2' ) ) has_ship <- FALSE
113115

114116
if ( has_ship ) {
115117
ceds_remove_sectors_global <- c("1A3ai_International-aviation",
@@ -126,21 +128,25 @@ if ( has_ship ) {
126128

127129
}
128130

131+
RCP_em <- em
132+
133+
# Process RCP CH4 emissions then zero out so can draw graphs
134+
if ( em %in% c( 'N2O', 'CO2' ) ) RCP_em <- "CH4"
129135

130136
# ---------------------------------------------------------------------------
131137
# 2. Load and process RCP files
132138
rcp_dir <- './emissions-inventories/RCP/'
133139

134140
# create temporary folder to extract zipped files
135-
zipfile_path <- paste0(rcp_dir, em, '.zip')
136-
dir.name <- paste0(rcp_dir, em, '_RCP_temp_folder')
141+
zipfile_path <- paste0(rcp_dir, RCP_em, '.zip')
142+
dir.name <- paste0(rcp_dir, RCP_em, '_RCP_temp_folder')
137143
dir.create(dir.name)
138144
# unzip files to temp folder
139145
unzip(zipfile_path, exdir = dir.name)
140146

141147
# list files in the folder
142-
files <- list.files(paste0(dir.name,'/',em) ,pattern = '.dat')
143-
files <- paste0(dir.name,'/',em,'/',files)
148+
files <- list.files(paste0(dir.name,'/',RCP_em) ,pattern = '.dat')
149+
files <- paste0(dir.name,'/',RCP_em,'/',files)
144150

145151
rcp_files <- list()
146152
for (i in seq_along(rcp_years)){
@@ -204,6 +210,13 @@ rcp_ship_emissions$units <- "kt"
204210
rcp_ship_emissions$SO2 <- rcp_ship_emissions$SO2 * 2 #Convert from S to SO2 for SO2
205211
rcp_ship_emissions$NOx <- rcp_ship_emissions$NOx * 3.285 # Convert from N to NO2 for NOx
206212

213+
if ( em %in% c( 'CO2', 'N2O' ) ) {
214+
# Rill RCP dataset with zeros
215+
RCP <- RCP %>%
216+
dplyr::mutate_if( is.numeric, function(x) ifelse(is.numeric(x), 0, x ) )
217+
rcp_ship_emissions$em <- rcp_ship_emissions$NOx * 0.0
218+
}
219+
207220
# ---------------------------------------------------------------------------
208221
# 4. Process CEDS Emissions Data
209222
x_years<-paste('X',CEDS_start_year:CEDS_end_year,sep="")
@@ -481,6 +494,14 @@ writeData( region_sector_both,'DIAG_OUT', paste0('RCP_',em,'_region_sector_Compa
481494

482495
}
483496

497+
# Write out total by country with region tag for diagnostics
498+
#add region to ceds data
499+
country_ceds <- aggregate(ceds_comparable[x_years],
500+
by = list(iso = ceds_comparable$iso ),FUN=sum )
501+
country_ceds$Region <- complete_region_map[match(country_ceds$iso,tolower(complete_region_map$Code)),'Region']
502+
country_ceds[which(is.na(country_ceds$Region)),'Region']<- 'Not Mapped'
503+
writeData( country_ceds,'DIAG_OUT', paste0(em,'_CEDS_comparable_country_total'),domain_extension = 'ceds-comparisons/',meta=F)
504+
484505
# ---------------------------------------------------------------------------
485506
# 10. End
486507

0 commit comments

Comments
 (0)