Skip to content

Commit

Permalink
Merge pull request #614 from alexkoberle/develop
Browse files Browse the repository at this point in the history
Bugfix in grasslands_apr22 pasture realization.
  • Loading branch information
alexkoberle authored Nov 27, 2023
2 parents 9d96aee + 8f829ad commit 96c23d4
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 81 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **14_yields_and_config** The new default is to not use yield calibration factors from a calibration run. The switch s14_use_yield_calib can optionally reenable the use of yield calibration factors.
- **scripts** LUH2_disaggregation output script was modified. Specifically, flooded area was made compatible with the LUH definition, cropland and grazing land were added to the states.nc file, and specific naming/details (datatype, zname, xname, and yname) were added when creating the .nc files.
- **scripts** For the emulator scripts select a different bioenergy demand variable that excludes bioenergy sources other than second generation bioenergy crops. Set the minimal bioenergy demand to zero. Both avoid artificial clustering of data points and allow for better fits.
- **31_past** in grasslands_apr22 realization: changed structure of f31_pastr_suitability to align with ssp-rcp specific input data formulation. Changed input filename from cs3 to cs2. Added `cc`, `nocc` and `nocc_hist` options for `i31_manpast_suit` and changed input gams code from table to parameter. Climate scenario assignment moved from preloop.gms to input.gms. Removed pastSuit set in sets.gms as not needed anymore. Adjusted not_used.txt in both grasslands_apr22 and static realizations.
- **36_employment** regression between hourly labor regression and GDP pc changed from linear to log-log

### added
Expand All @@ -21,7 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **32_forestry** new interface `vm_land_forestry`

### removed
-
- **default.cfg** Removed description of cfg$gms$c31_past_suit_scen since no longer needed due to changes in 31_past described below. Its function is now done by cfg$gms$c31_grassl_yld_scenario.

### fixed
- **inputdata** There was another bug (terra default na.rm changed) in the inputdata that was fixed with rev4.93
Expand Down
6 changes: 6 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ authors:
affiliation: "Potsdam Institute for Climate Impact Research"
email: [email protected]

- family-names: Köberle
given-names: Alexandre
orcid: https://orcid.org/0000-0003-0328-4750
affiliation: "Potsdam Institute for Climate Impact Research"
email: [email protected]

- family-names: Lotze-Campen
given-names: Hermann
orcid: https://orcid.org/0000-0002-0003-5508
Expand Down
15 changes: 4 additions & 11 deletions config/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ cfg$model <- "main.gms" #def = "main.gms"
#### input settings ####

# which input data sets should be used?
cfg$input <- c(regional = "rev4.94_h12_magpie.tgz",
cellular = "rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz",
validation = "rev4.94_h12_validation.tgz",
cfg$input <- c(regional = "rev4.95_h12_magpie.tgz",
cellular = "rev4.95_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz",
validation = "rev4.95_h12_validation.tgz",
additional = "additional_data_rev4.46.tgz",
calibration = "calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz")

Expand Down Expand Up @@ -718,19 +718,12 @@ cfg$gms$s31_fac_req_past <- 1 # def = 1
# * reflecting that not all pasture area is grazed.
cfg$gms$s31_unequal <- 1 # def = 1

# * Scenario for grassland and pasture yields (only take effect for realization grasslands_apr22)
# * Scenario for grassland, pasture suitability areas and pasture yields (only take effect for realization grasslands_apr22)
# * options: cc (climate change)
# * nocc (no climate change)
# * nocc_hist (no climate change after year defined by sm_fix_cc)
cfg$gms$c31_grassl_yld_scenario <- "cc" # def = "cc"


# * SSP scenario switch for pasture suitability areas (only take effect for realization grasslands_apr22)
# * options: ssp126, ssp245, ssp370, ssp460, ssp585
# * nocc (fixed to values from 1995),
# * nocc_hist (ssp245 until year defined in sm_fix_cc, fixed thereafter)
cfg$gms$c31_past_suit_scen <- "ssp370" # def = "ssp370"

# * Switch that allows selecting how yield calibration factors will be calculated.
# * If 0, grassland yield calibration will be calculated as multiplicative relative values.
# * If 1, calibration values will be limited to additive absolute values when modeled yields strongly
Expand Down
44 changes: 22 additions & 22 deletions core/sets.gms
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,31 @@ sets
VEN, VGB, VIR, VNM, VUT, WLF, WSM, YEM, ZAF, ZMB, ZWE /

j number of LPJ cells
/ CAZ_1*CAZ_6,
CHA_7*CHA_23,
EUR_24*EUR_32,
IND_33*IND_40,
JPN_41*JPN_41,
LAM_42*LAM_85,
MEA_86*MEA_111,
NEU_112*NEU_118,
OAS_119*OAS_128,
REF_129*REF_141,
SSA_142*SSA_179,
/ CAZ_1*CAZ_5,
CHA_6*CHA_21,
EUR_22*EUR_29,
IND_30*IND_36,
JPN_37*JPN_38,
LAM_39*LAM_79,
MEA_80*MEA_109,
NEU_110*NEU_117,
OAS_118*OAS_128,
REF_129*REF_140,
SSA_141*SSA_179,
USA_180*USA_200 /

cell(i,j) number of LPJ cells per region i
/ CAZ . (CAZ_1*CAZ_6)
CHA . (CHA_7*CHA_23)
EUR . (EUR_24*EUR_32)
IND . (IND_33*IND_40)
JPN . (JPN_41*JPN_41)
LAM . (LAM_42*LAM_85)
MEA . (MEA_86*MEA_111)
NEU . (NEU_112*NEU_118)
OAS . (OAS_119*OAS_128)
REF . (REF_129*REF_141)
SSA . (SSA_142*SSA_179)
/ CAZ . (CAZ_1*CAZ_5)
CHA . (CHA_6*CHA_21)
EUR . (EUR_22*EUR_29)
IND . (IND_30*IND_36)
JPN . (JPN_37*JPN_38)
LAM . (LAM_39*LAM_79)
MEA . (MEA_80*MEA_109)
NEU . (NEU_110*NEU_117)
OAS . (OAS_118*OAS_128)
REF . (REF_129*REF_140)
SSA . (SSA_141*SSA_179)
USA . (USA_180*USA_200) /

i_to_iso(i,iso) mapping regions to iso countries
Expand Down
38 changes: 19 additions & 19 deletions main.gms
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,25 @@ $title magpie

*##################### R SECTION START (VERSION INFO) ##########################
*
* Used data set: rev4.88_h12_magpie.tgz
* md5sum: 740da40ceda04850eb374df215837c1b
* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public
* Used data set: rev4.94_h12_magpie.tgz
* md5sum: 25623b5ad3e8b72bd3008da9b69adfe0
* Repository: /p/projects/rd3mod/inputdata/output
*
* Used data set: rev4.88_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz
* md5sum: 9edbcc62e75b663eada84524402bccbf
* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public
* Used data set: rev4.94_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz
* md5sum: d7800a0ffe271483116a8f00a939a89a
* Repository: /p/projects/rd3mod/inputdata/output
*
* Used data set: rev4.88_h12_validation.tgz
* md5sum: d42abd58de683506a807b411d7fe87cb
* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public
* Used data set: rev4.94_h12_validation.tgz
* md5sum: 4b4128910822cf45603cab46f45ccf78
* Repository: /p/projects/rd3mod/inputdata/output
*
* Used data set: additional_data_rev4.45.tgz
* md5sum: bb51c8c8608b8b9363582eb4aa220754
* Repository: /p/projects/landuse/data/input/archive
* Used data set: additional_data_rev4.46.tgz
* md5sum: NA
* Repository: https://rse.pik-potsdam.de/data/magpie/public
*
* Used data set: calibration_H12_per_ton_fao_may22_glo_08Aug23.tgz
* md5sum: 5d34e4b54112db10f330f1e59dd60cc9
* Repository: /p/projects/rd3mod/mirror/rse.pik-potsdam.de/data/magpie/public
* md5sum: NA
* Repository: https://rse.pik-potsdam.de/data/magpie/public
*
* Low resolution: c200
* High resolution: 0.5
Expand All @@ -175,27 +175,27 @@ $title magpie
*
* Number of cells per region:
* CAZ CHA EUR IND JPN LAM MEA NEU OAS REF SSA USA
* 6 17 9 8 1 44 26 7 10 13 38 21
* 5 16 8 7 2 41 30 8 11 12 39 21
*
* Regionscode: 62eff8f7
*
* Regions data revision: 4.88
* Regions data revision: 4.94
*
* lpj2magpie settings:
* * LPJmL data: MRI-ESM2-0:ssp370
* * Revision: 4.88
* * Revision: 4.94
*
* aggregation settings:
* * Input resolution: 0.5
* * Output resolution: c200
* * Regionscode: 62eff8f7
* * Number of clusters per region:
* CAZ CHA EUR IND JPN LAM MEA NEU OAS REF SSA USA
* 6 17 9 8 1 44 26 7 10 13 38 21
* 5 16 8 7 2 41 30 8 11 12 39 21
* * Call: withCallingHandlers(expr, message = messageHandler, warning = warningHandler, error = errorHandler)
*
*
* Last modification (input data): Fri Sep 22 15:20:24 2023
* Last modification (input data): Fri Nov 17 19:42:06 2023
*
*###################### R SECTION END (VERSION INFO) ###########################

Expand Down
1 change: 0 additions & 1 deletion modules/31_past/endo_jun13/not_used.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ name,type,reason
pcm_land, input, not needed
vm_tau,input,questionnaire
fm_pastr_tau_hist,input,questionnaire
sm_fix_SSP2, input, not needed
sm_fix_cc, input, not needed
33 changes: 20 additions & 13 deletions modules/31_past/grasslands_apr22/input.gms
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ scalars
s31_cost_grass_prod Grasslands factor costs (USD05MER per tDM) / 1 /
;

$setglobal c31_past_suit_scen ssp370
$setglobal c31_grassl_yld_scenario cc
* options: cc (climate change)
* nocc (no climate change)
* nocc_hist (no climate change after year defined by sm_fix_cc)

table f31_pastr_suitability(t_all,j,ssp_past) Areas suitable for pasture management (mio. ha)
parameter f31_pastr_suitability(t_all,j) Areas suitable for pasture management (mio. ha)
/
$ondelim
$include "./modules/31_past/input/f31_pastr_suitability.cs3"
$include "./modules/31_past/input/f31_pastr_suitability.cs2"
$offdelim
;
/;

i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j)
* set values to 1995 if nocc scenario is used, or to sm_fix_cc after sm_fix_cc if nocc_hist is used
$if "%c31_grassl_yld_scenario%" == "nocc" i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j);
$if "%c31_grassl_yld_scenario%" == "nocc_hist" i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = i31_manpast_suit(t_all,j)$(m_year(t_all) = sm_fix_cc);

table f31_LUH2v2(t_all,j,f31_luh) Different land type areas (mio. ha)
$ondelim
$include "./modules/31_past/input/f31_LUH2v2.cs3"
$offdelim
;

scalar s31_limit_calib Relative managament calibration switch (1=limited 0=pure relative) / 1 /;

$setglobal c31_grassl_yld_scenario cc
* options: cc (climate change)
* nocc (no climate change)
* nocc_hist (no climate change after year defined by sm_fix_cc)

table f31_grassl_yld(t_all,j,grassland,w) LPJmL potential yields per cell (rainfed only) (tDM per ha)
$ondelim
Expand All @@ -46,3 +46,10 @@ table f31_grass_bio(t_all,i, grassland) Estimated regional grass biomass consump
$ondelim
$include "./modules/31_past/input/f31_grass_bio_hist.cs3"
$offdelim;



table f31_LUH2v2(t_all,j, f31_luh) LUH2v2 land classes separating rangelands from managed pastures
$ondelim
$include "./modules/31_past/input/f31_LUH2v2.cs3"
$offdelim;
9 changes: 0 additions & 9 deletions modules/31_past/grasslands_apr22/preloop.gms
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: [email protected]

$ifthen "%c31_past_suit_scen%" == "nocc"
i31_manpast_suit(t_all,j) = f31_pastr_suitability("y1995",j,"ssp245");
$elseif "%c31_past_suit_scen%" == "nocc_hist"
i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"ssp245");
i31_manpast_suit(t_all,j)$(m_year(t_all) > sm_fix_cc) = f31_pastr_suitability(t_all,j,"ssp245")$(m_year(t_all) = sm_fix_cc);
$else
i31_manpast_suit(t_all,j) = f31_pastr_suitability(t_all,j,"%c31_past_suit_scen%");
i31_manpast_suit(t_all,j)$(m_year(t_all) <= sm_fix_SSP2) = f31_pastr_suitability(t_all,j,"ssp245");
$endif

pc31_grass(j,grassland) = f31_LUH2v2("y1995",j,grassland);

Expand Down
3 changes: 0 additions & 3 deletions modules/31_past/grasslands_apr22/sets.gms
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,4 @@ sets
grass_from31(grassland) pasture management options
/ pastr,range /

ssp_past SSP scenarios for pasture suitability areas
/ ssp126, ssp245, ssp370, ssp460, ssp585 /

;
2 changes: 1 addition & 1 deletion modules/31_past/input/files
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
* list of files that are required here
f31_pastr_suitability.cs3
f31_pastr_suitability.cs2
f31_LUH2v2.cs3
f31_grassl_yld.cs3
f31_grass_bio_hist.cs3
1 change: 0 additions & 1 deletion modules/31_past/static/not_used.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ vm_yld, input, not needed
pm_land_conservation,input,questionnaire
vm_tau,input,questionnaire
fm_pastr_tau_hist,input,questionnaire
sm_fix_SSP2, input, not needed
sm_fix_cc, input, not needed

0 comments on commit 96c23d4

Please sign in to comment.