Skip to content

Commit

Permalink
Merge branch 'calibtests' of github.com:vartika271987/magpie into f_f…
Browse files Browse the repository at this point in the history
…secCHA

 Inclusion of AQUASTAT calibration factors for yields magpiemodel#457
  • Loading branch information
xwangatpik committed Oct 13, 2022
2 parents 2359d77 + 5ef50bd commit 2977d0b
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 58 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### changed
- **scripts** fix in start_functions for the calibration setting `ifneeded`
- **config** best_calib set to FALSE in default
- **42_water_demand** account for multiple cropping in water requirements
- **config** new switches `s36_minimum_wage`, `s36_scale_productivity_with_wage`, and `s38_fix_capital_need`
- **38_factor_costs** included labor cost scaling in case of wage scenario
- **70_livestock** included labor cost scaling in case of wage scenario
Expand Down Expand Up @@ -50,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **scripts** added output scripts for FSEC FSDP runs
- **15_food** added new realization with country level exogenous diets, product-specific intake estimates, new scenarios for exogenous BMI and decomposition switches for EAT Lancet diets. Simplified code and improved iteration procedure.
- **57_maccs** added new Marginal Abatement Cost Curve (MACCs) data set from PBL (PBL2022)
- **14_yields** added input file containing AQUASTAT yield calibration factors and switch `s14_calib_ir2rf` in default.cfg to activate this yield calibration

### removed
- **38_factor_costs** removed `mixed_reg_feb17` realization
Expand Down
56 changes: 29 additions & 27 deletions config/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,11 @@ cfg$input <- c(regional = "rev4.77_h12_magpie.tgz",
cellular = "rev4.77_h12_fd712c0b_cellularmagpie_c200_MRI-ESM2-0-ssp370_lpjml-8e6c5eb1.tgz",
validation = "rev4.77_h12_validation.tgz",
additional = "additional_data_rev4.30.tgz",
calibration = "calibration_H12_per_ton_fao_may22_28May22.tgz")
calibration = "calibration_H12+ir2rf_05Oct22.tgz")

# Options for calibration tgz files for different factor costs realizations, with default settings and rev4.73:
# * (mixed_reg_feb17, global fac req) "calibration_H12_mixed_reg_feb17_28May22.tgz"
# * (mixed_reg_feb17, regional fac req) "calibration_H12_mixed_reg_feb17_reg_13Jun22.tgz"
# * (per_ton_fao_may22, global fac req) "calibration_H12_per_ton_fao_may22_28May22.tgz"
# * (per_ton_fao_may22, regional fac req) "calibration_H12_per_ton_fao_may22_reg_13Jun22.tgz"
# * (sticky_feb18, global fac req) "calibration_H12_sticky_feb18_28May22.tgz"
# * (sticky_feb18, regional fac req) "calibration_H12_sticky_feb18_reg_13Jun22.tgz"
# * (sticky_labor, global fac req) "calibration_H12_sticky_feb18_28May22.tgz"
# * (sticky_labor, regional fac req) "calibration_H12_sticky_feb18_reg_13Jun22.tgz"

# Calibration factors for 31_past (pasture management module)
# * (grasslands_mar22) "calibration_H12_grassland_mar22.tgz"
# NOTE: It is recommended to recalibrate the model when changing cellular input data
# as well as for any other setting that would affect initial values in the model,
# e.g. changes in costs structure, NPI policies, etc.

#a list of repositories (please pay attention to the list format!) in which the
#files should be searched for. Files will be searched in all repositories until
Expand All @@ -54,7 +45,8 @@ cfg$input <- c(regional = "rev4.77_h12_magpie.tgz",
#below it will get merged into cfg$repositories

cfg$repositories <- append(list("https://rse.pik-potsdam.de/data/magpie/public"=NULL),
getOption("magpie_repos"))
getOption("magpie_repos"))



# Should input data be downloaded from source even if cfg$input did not change?
Expand Down Expand Up @@ -82,7 +74,7 @@ cfg$crop_calib_max <- 1.5 # def= 1.5
# Selection type of calibration factors.
# If FALSE, calibration factors from the last iteration are used.
# If TRUE, calibration factors from the iteration with the lowest standard deviation are used.
cfg$best_calib <- TRUE
cfg$best_calib <- FALSE # def = FALSE

# Settings for land conversion cost calibration (cropland)
# The calibration routine derives regional calibration factors for
Expand Down Expand Up @@ -308,6 +300,11 @@ cfg$gms$s14_yld_past_switch <- 0.25 # def = 0.25
# * 0 (pure relative calibration)
cfg$gms$s14_limit_calib <- 1 # def = 1

# * Switch on scaling of irrigated yields to AQUASTAT irrigated-to-rainfed yield
# * ratio on regional scale
# NOTE: It is recommended to recalibrate the model when changing this setting!
cfg$gms$s14_calib_ir2rf <- 1 # def = 1

# ***--------------------- 15_food ---------------------------------------
# * (anthropometrics_jan18): estimates food using scenario dependent regression
# * and demography drivers
Expand Down Expand Up @@ -597,6 +594,7 @@ cfg$gms$ageclass <- "feb21" # def = feb21
# * (endo_apr21): Hard rotational constraints. Dynamic cropland and detailed cropland availability data at grid cell level.
# * (rotation_apr22): hard rotational constraints and fallow constraints with the option of different future scenarios. Dynamic cropland and detailed cropland availability data at grid cell level.
# * (penalty_apr222): rotational and fallow constraints are incentivized via penalty payments. Dynamic cropland and detailed cropland availability data at grid cell level.
# NOTE: It is recommended to recalibrate the model when changing this setting!
cfg$gms$crop <- "endo_apr21" # def = endo_apr21
# * (c30_bioen_type): switch for type of bioenergy crops; options: begr, betr, all
cfg$gms$c30_bioen_type <- "all" # def = "all"
Expand Down Expand Up @@ -651,6 +649,7 @@ cfg$gms$policy_countries30 <- all_iso_countries
# * (static): static pasture
# * (endo_jun13): dynamic pasture
# * (grasslands_apr22): Grassland management separating managed pastures from rangelands
# NOTE: It is recommended to recalibrate the model when changing this setting!
cfg$gms$past <- "endo_jun13" # def = endo_jun13

# * Factor requirements (USD04 per ton DM)
Expand Down Expand Up @@ -862,12 +861,12 @@ cfg$gms$employment <- "exo_may22" # default = "exo_may22"
# * global minimum wage in USDMER05 per hour that needs to be reached in all countries by 2050
cfg$gms$s36_minimum_wage <- 0 # default = 0 (no minimum wage)

# * A scenario that increases wages can either be fully related to productivity increase
# * A scenario that increases wages can either be fully related to productivity increase
# * (leading to lower employment for the same total labor costs), or keep productivity
# * constant (leading to the same employment for higher total labor costs), or to a
# * mixture between productivity increase an total labor cost increase.
# * The scalar `s36_scale_productivity_with_wage` describes how high the labor productivity
# * gain should be relative to the increase in hourly labor costs. If set to 0,
# * constant (leading to the same employment for higher total labor costs), or to a
# * mixture between productivity increase an total labor cost increase.
# * The scalar `s36_scale_productivity_with_wage` describes how high the labor productivity
# * gain should be relative to the increase in hourly labor costs. If set to 0,
# * productivity stays constant, if set to 1 productivity scales proportional to hourly
# * labor costs. Other positive values lead to a mixture of productivity gain and increase
# * in total costs.
Expand Down Expand Up @@ -899,16 +898,19 @@ cfg$gms$c37_labor_uncertainty <- "ensmean" # default = "ensmean"
# * (per_ton_fao_may22) factor costs fixed per ton
# * (sticky_feb18) factor costs including investments in capital
# * (sticky_labor) based on sticky_feb18 + labor productivity factor included
# NOTE: It is recommended to recalibrate the model when changing this setting!
# NOTE: It is recommended to use best_calib only for sticky factor cost realizations!
cfg$gms$factor_costs <- "per_ton_fao_may22" # default = per_ton_fao_may22

# * Regional (reg) or global (glo) factor requirements (applicable for per_ton_fao_may22,
# * sticky_feb18, sticky_labor). The regional version keeps factor requirements constant
# * after 2010, the global version uses values from 2005 for all years. Typically, the
# * same version (glo or reg) should be chosen for c70_fac_req_regr for consistency.
# NOTE: It is recommended to recalibrate the model when changing this setting!
cfg$gms$c38_fac_req <- "glo" # default "glo"

# * Only relevant for sticky_labor implementation: scalar to determine until which year
# * the capital need (per unit of output) should be fixed to start value (i.e. not
# * the capital need (per unit of output) should be fixed to start value (i.e. not
# * allowing for subsititution between labor and capital).

cfg$gms$s38_fix_capital_need <- 2020 # default 2020
Expand Down Expand Up @@ -1567,15 +1569,15 @@ cfg$gms$c60_bioenergy_subsidy <- 300 # def = 300
cfg$gms$material <- "exo_flexreg_apr16"

# * Biomass demand for bioplastics is based on a logistic curve projecting
# * bioplastic demand, which matches the historic demand in 2020, and is
# * bioplastic demand, which matches the historic demand in 2020, and is
# * defined by the maximum demand for bioplastics s62_max_dem_bioplastics
# * (in mio. tonnes) and the midpoint s62_midpoint_dem_bioplastics (i.e.
# * (in mio. tonnes) and the midpoint s62_midpoint_dem_bioplastics (i.e.
# * where bioplastic demand is half of the maximum demand).
# * If maximum demand is 0, biomass demand for bioplastic production is not included.
# * Projected total plastic use in the "Global Ambiton" scneario of the OECD is
# * about 600 mio. tonnes in 2050 -> E.g. 200 mio. tonnes in 2050 could be a
# * reasonable (but ambitious) bioplastic scenario. With midpoint 2050 this
# * would mean s62_max_dem_bioplastic = 400.
# * Projected total plastic use in the "Global Ambiton" scneario of the OECD is
# * about 600 mio. tonnes in 2050 -> E.g. 200 mio. tonnes in 2050 could be a
# * reasonable (but ambitious) bioplastic scenario. With midpoint 2050 this
# * would mean s62_max_dem_bioplastic = 400.
cfg$gms$s62_max_dem_bioplastic <- 0 # def = 0
cfg$gms$s62_midpoint_dem_bioplastic <- 2050 # def = 2050

Expand Down
8 changes: 8 additions & 0 deletions literature.bib
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,14 @@ @article{siebert_FAO_2007
year = {2007},
}

@book{fao_aquastat_2016,
address = {Rome},
title = {{AQUASTAT} main database},
publisher = {Food and Agriculture Organization of the United Nations (FAO)},
author = {{FAO}},
year = {2016},
}

@techreport{worldbank_irrigation_1995,
title = {World Bank and Irrigation},
institution = {World Bank},
Expand Down
4 changes: 4 additions & 0 deletions modules/14_yields/managementcalib_aug19/declarations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ parameters
p14_growing_stock_initial(j,ac,forest_land,forest_type) Initial Forest growing stock (tDM per ha per yr)
pm_timber_yield_initial(j,ac,forest_land) Initial Forest yield (tDM per ha per yr)
pm_yields_semi_calib(j,kve,w) Potential yields calibrated to FAO regional levels (tDM per ha per yr)
i14_calib_yields_hist(i,w) Calibrated yields average over region and crop type at the historical reference year (tDM per ha per yr)
i14_calib_yields_ratio(i) Irrigated to rainfed yield ratio for calibrated yields (1)
i14_target_ratio(i) Target irrigated to rainfed ratio as upper bound (1)
i14_modeled_yields_hist2(i,knbe14) Calibrated yields average over region and water supply type at the historical reference year (tDM per ha per yr)
;

positive variables
Expand Down
10 changes: 10 additions & 0 deletions modules/14_yields/managementcalib_aug19/input.gms
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ $setglobal c14_yields_scenario cc

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

scalar s14_calib_ir2rf Switch to calibrate rainfed to irrigated yield ratios (1=calib 0=not calib) / 0 /;

scalars
s14_yld_past_switch Spillover parameter for translating technological change in the crop sector into pasture yield increases (1) / 0.25 /
;
Expand Down Expand Up @@ -54,6 +56,14 @@ $offdelim
;
m_fillmissingyears(f14_fao_yields_hist,"i,kcr");

parameter f14_ir2rf_ratio(i) AQUASTAT ratio of irrigated to rainfed yields per region (1)
/
$ondelim
$include "./modules/14_yields/managementcalib_aug19/input/f14_ir2rf_ratio.cs4"
$offdelim
/
;

table f14_ipcc_bce(clcl,forest_type) IPCC Biomass Conversion and Expansion factors (1)
$ondelim
$include "./modules/14_yields/input/f14_ipcc_bce.cs3"
Expand Down
1 change: 1 addition & 0 deletions modules/14_yields/managementcalib_aug19/input/files
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* list of files that are required here
f14_region_yields.cs3
f14_ir2rf_ratio.cs4
f14_ipcc_bce.cs3
f14_aboveground_fraction.csv
32 changes: 31 additions & 1 deletion modules/14_yields/managementcalib_aug19/preloop.gms
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ loop(t,
);
);


*' The calibrated cellular yield 'i14_yields_calib' is calculated for each time step depending
*' on the constant values 'i14_modeled_yields_hist', 'i14_fao_yields_hist', 'i14_lambda_yields'
*' and the uncalibrated, cellular yield 'f14_yields' following the idea of eq. (9) in @Heinke.2013:
Expand All @@ -108,6 +107,37 @@ i14_yields_calib(t,j,knbe14,w) = i14_managementcalib(t,j,knbe14,w) * f14_yiel
pm_yields_semi_calib(j,knbe14,w) = i14_yields_calib("y1995",j,knbe14,w);

*' Note that the calculation is split into two parts for better readability.

*' Irrigated yields can be optionally calibrated to meet the country-level
*' ratio between irrigated and rainfed yields reported by Aquastat
*' by activating the switch `s14_calib_ir2rf`.
if ((s14_calib_ir2rf = 1),

* Weighted yields
i14_calib_yields_hist(i,w)
= sum((cell(i,j), knbe14), fm_croparea("y1995",j,"irrigated",knbe14) * i14_yields_calib("y1995",j,knbe14,w)) /
sum((cell(i,j), knbe14), fm_croparea("y1995",j,"irrigated",knbe14));

* Use irrigated-rainfed ratio of Aquastat if larger than our calculated ratio
i14_calib_yields_ratio(i) = i14_calib_yields_hist(i,"irrigated") / i14_calib_yields_hist(i,"rainfed");
i14_target_ratio(i) = max(i14_calib_yields_ratio(i), f14_ir2rf_ratio(i));
i14_yields_calib(t,j,knbe14,"irrigated") = sum((cell(i,j)), i14_target_ratio(i) / i14_calib_yields_ratio(i)) *
i14_yields_calib(t,j,knbe14,"irrigated");

* Calibrate newly calibrated yields to FAO yields
i14_modeled_yields_hist2(i,knbe14)
= (sum((cell(i,j),w), fm_croparea("y1995",j,w,knbe14) * i14_yields_calib("y1995",j,knbe14,w)) /
sum((cell(i,j),w), fm_croparea("y1995",j,w,knbe14)))$(sum((cell(i,j),w), fm_croparea("y1995",j,w,knbe14))>0)
+ (sum((cell(i,j),w), i14_croparea_total("y1995",w,j) * f14_yields("y1995",j,knbe14,w)) /
sum((cell(i,j),w), i14_croparea_total("y1995",w,j)))$(sum((cell(i,j),w), fm_croparea("y1995",j,w,knbe14))=0);

i14_yields_calib(t,j,knbe14,w) = sum((cell(i,j)), i14_fao_yields_hist("y1995",i,knbe14) /
i14_modeled_yields_hist2(i,knbe14)) *
i14_yields_calib(t,j,knbe14,w);

pm_yields_semi_calib(j,knbe14,w) = i14_yields_calib("y1995",j,knbe14,w);
);

*' @stop


Expand Down
2 changes: 2 additions & 0 deletions modules/14_yields/managementcalib_aug19/realization.gms
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*' yields achieved under the highest currently observed value of the $\tau$ factor
*' representing agricultural land-use intensity. Secondly, pasture yields are calculated
*' based on pasture demand to account for in- and extensification of managed grasslands.
*' Thirdly, irrigated yields are scaled to meet the irrigated-to-rainfed yield
*' ratio as provided by AQUASTAT [@fao_aquastat_2016].
*' Finally, crop yields are calibrated to FAO [@FAOSTAT] regional yield levels of the
*' initial time step. An additional feature of this realization is to allow crop yields
*' technological change from the precedent times step to spillover to pasture areas. This
Expand Down
2 changes: 2 additions & 0 deletions modules/14_yields/module.gms
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*' [@FAOSTAT]. For the simulation of the temporal development of agricultural
*' yields, the module receives information about the agricultural land use
*' intensity represented by the $\tau$ factor coming from the module [13_tc].
*' Irrigated yields can optionally be calibrated to meet irrigated-rainfed
*' country-level yield ratios as reported by Aquastat [@fao_aquastat_2016].
*'
*' The module returns yields for all crops and for pasture, which is then used
*' by the modules [30_crop] and [31_past].
Expand Down
2 changes: 1 addition & 1 deletion modules/18_residues/flexreg_apr16/equations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
q18_prod_res_ag_reg(i2,kcr,attributes) ..
vm_res_biomass_ag(i2,kcr,attributes)
=e=
(sum((cell(i2,j2),w), vm_area(j2,kcr,w)) * sum(ct,f18_multicropping(ct,i2)) * f18_cgf("intercept",kcr)
(sum((cell(i2,j2),w), vm_area(j2,kcr,w)) * sum(ct,fm_multicropping(ct,i2)) * f18_cgf("intercept",kcr)
+ vm_prod_reg(i2,kcr)*f18_cgf("slope",kcr))
* f18_attributes_residue_ag(attributes,kcr);

Expand Down
2 changes: 1 addition & 1 deletion modules/18_residues/flexreg_apr16/input.gms
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
$setglobal c18_burn_scen phaseout
* options: phaseout,constant

table f18_multicropping(t_all,i) Multicropping indicator as ratio of area harvested by physical area (1)
table fm_multicropping(t_all,i) Multicropping indicator as ratio of area harvested by physical area (1)
$ondelim
$include "./modules/18_residues/input/f18_multicropping.csv"
$offdelim;
Expand Down
13 changes: 13 additions & 0 deletions modules/18_residues/off/input.gms
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*** | (C) 2008-2021 Potsdam Institute for Climate Impact Research (PIK)
*** | authors, and contributors see CITATION.cff file. This file is part
*** | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of
*** | AGPL-3.0, you are granted additional permissions described in the
*** | MAgPIE License Exception, version 1.0 (see LICENSE file).
*** | Contact: magpie@pik-potsdam.de

table fm_multicropping(t_all,i) Multicropping indicator as ratio of area harvested by physical area (1)
$ondelim
$include "./modules/18_residues/input/f18_multicropping.csv"
$offdelim;

*** EOF input.gms ***
2 changes: 1 addition & 1 deletion modules/36_employment/exo_may22/declarations.gms
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ positive variables
;

parameters
p36_hourly_costs_iso(t,iso, wage_scen) Hourly labor costs in agriculture on iso level before and after including wage scenario (USDMER05 per hour)
p36_hourly_costs_iso(t_all,iso, wage_scen) Hourly labor costs in agriculture on iso level before and after including wage scenario (USDMER05 per hour)
p36_hourly_costs_increase(iso) Difference between minimum hourly labor costs and actual hourly labor costs in 2050 (USDMER05 per hour)
pm_hourly_costs(t,i, wage_scen) Hourly labor costs in agriculture on regional level before and after including wage scenario (USDMER05 per hour)
pm_productivity_gain_from_wages(t,i) Multiplicative factor describing productivity gain related to higher wages (1)
Expand Down
Loading

0 comments on commit 2977d0b

Please sign in to comment.