Skip to content

Commit

Permalink
nominally working v1.2 percentile emission generation
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyFyke committed Jun 7, 2021
1 parent cd7dbac commit 8c1db40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
9 changes: 8 additions & 1 deletion generate_projection_output.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,18 @@
for en=1:c.ensemble_size
emis_arr(en,1:length(so(en).burn_rate))=so(en).burn_rate;
end
save('output/emissions_standalone.mat','emis_arr')
plev=[5,10,25,50,75,90,95];
percentiles=prctile(emis_arr,plev,1);%p is npercentiles by nyears
%percentiles=median(emis_arr,1)

%TODO: scale percentiles by 2012 CMIP6 global annual average CO2 emissions value so they are entirely consistent with CMIP6 at this point.
percentiles(1,1)

%Scale all data by 2012 CMIP6 global annual average CO2 emissions value so they are entirely consistent with CMIP6 at this point.
CMIP6_emissions_2012=0.0092; %from scale-calculator.sh
CEPM_emissions_2012=percentiles(1,1); %from first year of CEPM output
scale_factor=CMIP6_emissions_2012/CEPM_emissions_2012
percentiles=percentiles.*scale_factor;

for n=1:length(plev)
p=percentiles(n,:);
Expand Down
19 changes: 8 additions & 11 deletions scale-calculator.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/bin/bash

cdo yearmean -cat '../CO2-em-anthro*.nc' tmp1.nc
cdo fldsum -mul tmp1.nc -gridarea tmp1.nc tmp2.nc
ncap2 -O -s 'emissions = CO2_em_anthro.total($sector)' tmp2.nc tmp3.nc
ncap2 -O -s 'emissions_scaled=emissions*31557600.' tmp3.nc tmp3.nc #seconds to years
ncap2 -O -s 'emissions_scaled=emissions/44.*12.' tmp3.nc tmp3.nc #CO2 to C
ncap2 -O -s 'emissions_scaled=emissions/1.e3' tmp3.nc tmp3.nc #kg to t
ncap2 -O -s 'emissions_scaled=emissions/1.e12' tmp3.nc tmp3.nc #t to Tt

fin=../CO2-em-anthro_input4MIPs_emissions_CMIP_CEDS-2017-05-18_gn_200001-201412.nc

#seconds to years
#CO2 to C
#kg to teratons
cdo -O yearmean $fin tmp1.nc
cdo -O fldsum -mul tmp1.nc -gridarea tmp1.nc tmp2.nc
ncap2 -O -s 'emissions = CO2_em_anthro.total($sector)' tmp2.nc tmp3.nc
ncap2 -O -s 'emissions=emissions*31557600.' tmp3.nc tmp3.nc #seconds to years
ncap2 -O -s 'emissions=emissions/44.*12.' tmp3.nc tmp3.nc #CO2 to C
ncap2 -O -s 'emissions=emissions/1.e3' tmp3.nc tmp3.nc #kg to t
ncap2 -O -s 'emissions=emissions/1.e12' tmp3.nc CMIP6_emissions.nc #t to Tt

0 comments on commit 8c1db40

Please sign in to comment.