# ESMValTool
# recipe_ecs.yml
---
documentation:
  title: >
    Equilibrium Climate Sensitivity (ECS)

  description: >
    Calculate Equilibrium Climate Sensitivity (ECS) using linear regression
    following Gregory et al. (2004).

  authors:
    - schlund_manuel

  maintainer:
    - schlund_manuel

  references:
    - gregory04grl

  projects:
    - crescendo


preprocessors:

  spatial_mean:
    area_statistics:
      operator: mean


CMIP5_RTNT: &cmip5_rtnt
  # Models with missing data (on all ESGF nodes)
  # EC-EARTH (no rsut)
  - {dataset: ACCESS1-0,     exp: piControl,   start_year:  300, end_year:  449}
  - {dataset: ACCESS1-0,     exp: abrupt4xCO2, start_year:  300, end_year:  449}
  - {dataset: ACCESS1-3,     exp: piControl,   start_year:  250, end_year:  399}
  - {dataset: ACCESS1-3,     exp: abrupt4xCO2, start_year:  250, end_year:  399}
  - {dataset: bcc-csm1-1,    exp: piControl,   start_year:  160, end_year:  309}
  - {dataset: bcc-csm1-1,    exp: abrupt4xCO2, start_year:  160, end_year:  309}
  - {dataset: bcc-csm1-1-m,  exp: piControl,   start_year:  240, end_year:  389}
  - {dataset: bcc-csm1-1-m,  exp: abrupt4xCO2, start_year:  240, end_year:  389}
  - {dataset: BNU-ESM,       exp: piControl,   start_year: 1850, end_year: 1999}
  - {dataset: BNU-ESM,       exp: abrupt4xCO2, start_year: 1850, end_year: 1999}
  - {dataset: CanESM2,       exp: piControl,   start_year: 2321, end_year: 2470}
  - {dataset: CanESM2,       exp: abrupt4xCO2, start_year: 1850, end_year: 1999}
  # Wrong start year for piControl? (branch_time = 2.)
  - {dataset: CCSM4,         exp: piControl,   start_year:  250, end_year:  399}
  - {dataset: CCSM4,         exp: abrupt4xCO2, start_year: 1850, end_year: 1999}
  - {dataset: CNRM-CM5,      exp: piControl,   start_year: 1850, end_year: 1999}
  - {dataset: CNRM-CM5,      exp: abrupt4xCO2, start_year: 1850, end_year: 1999}
  # Only 140 years available
  - {dataset: CNRM-CM5-2,    exp: piControl,   start_year: 1850, end_year: 1989}
  - {dataset: CNRM-CM5-2,    exp: abrupt4xCO2, start_year: 1850, end_year: 1989}
  - {dataset: CSIRO-Mk3-6-0, exp: piControl,   start_year:  104, end_year:  253}
  - {dataset: CSIRO-Mk3-6-0, exp: abrupt4xCO2, start_year:    1, end_year:  150}
  - {dataset: FGOALS-g2,     exp: piControl,   start_year:  490, end_year:  639}
  - {dataset: FGOALS-g2,     exp: abrupt4xCO2, start_year:  490, end_year:  639}
  - {dataset: GFDL-CM3,      exp: piControl,   start_year:    1, end_year:  150}
  - {dataset: GFDL-CM3,      exp: abrupt4xCO2, start_year:    1, end_year:  150}
  - {dataset: GFDL-ESM2G,    exp: piControl,   start_year:    1, end_year:  150}
  - {dataset: GFDL-ESM2G,    exp: abrupt4xCO2, start_year:    1, end_year:  150}
  - {dataset: GFDL-ESM2M,    exp: piControl,   start_year:    1, end_year:  150}
  - {dataset: GFDL-ESM2M,    exp: abrupt4xCO2, start_year:    1, end_year:  150}
  - {dataset: GISS-E2-H,     exp: piControl,   start_year: 2660, end_year: 2809}
  - {dataset: GISS-E2-H,     exp: abrupt4xCO2, start_year: 1850, end_year: 1999}
  - {dataset: GISS-E2-R,     exp: piControl,   start_year: 4200, end_year: 4349}
  - {dataset: GISS-E2-R,     exp: abrupt4xCO2, start_year: 1850, end_year: 1999}
  # Experiments start at 1859-12-01
  - {dataset: HadGEM2-ES,    exp: piControl,   start_year: 1860, end_year: 2009}
  - {dataset: HadGEM2-ES,    exp: abrupt4xCO2, start_year: 1860, end_year: 2009}
  - {dataset: inmcm4,        exp: piControl,   start_year: 2090, end_year: 2239}
  - {dataset: inmcm4,        exp: abrupt4xCO2, start_year: 2090, end_year: 2239}
  # Only 140 years available
  - {dataset: IPSL-CM5A-MR,  exp: piControl,   start_year: 1850, end_year: 1989}
  - {dataset: IPSL-CM5A-MR,  exp: abrupt4xCO2, start_year: 1850, end_year: 1989}
  - {dataset: IPSL-CM5B-LR,  exp: piControl,   start_year: 1850, end_year: 1999}
  - {dataset: IPSL-CM5B-LR,  exp: abrupt4xCO2, start_year: 1850, end_year: 1999}
  - {dataset: MIROC5,        exp: piControl,   start_year: 2100, end_year: 2249}
  - {dataset: MIROC5,        exp: abrupt4xCO2, start_year: 2100, end_year: 2249}
  - {dataset: MIROC-ESM,     exp: piControl,   start_year: 1880, end_year: 2029}
  - {dataset: MIROC-ESM,     exp: abrupt4xCO2, start_year:    1, end_year:  150}
  - {dataset: MPI-ESM-LR,    exp: piControl,   start_year: 1880, end_year: 2029}
  - {dataset: MPI-ESM-LR,    exp: abrupt4xCO2, start_year: 1850, end_year: 1999}
  - {dataset: MPI-ESM-MR,    exp: piControl,   start_year: 1850, end_year: 1999}
  - {dataset: MPI-ESM-MR,    exp: abrupt4xCO2, start_year: 1850, end_year: 1999}
  - {dataset: MPI-ESM-P,     exp: piControl,   start_year: 1866, end_year: 2015}
  - {dataset: MPI-ESM-P,     exp: abrupt4xCO2, start_year: 1850, end_year: 1999}
  - {dataset: MRI-CGCM3,     exp: piControl,   start_year: 1891, end_year: 2040}
  - {dataset: MRI-CGCM3,     exp: abrupt4xCO2, start_year: 1851, end_year: 2000}
  - {dataset: NorESM1-M,     exp: piControl,   start_year:  700, end_year:  849}
  - {dataset: NorESM1-M,     exp: abrupt4xCO2, start_year:    1, end_year:  150}

CMIP6_RTNT: &cmip6_rtnt
  - {dataset: ACCESS-CM2,      exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:  950, end_year: 1099, institute: CSIRO-ARCCSS}
  - {dataset: ACCESS-CM2,      exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year:  950, end_year: 1099, institute: CSIRO-ARCCSS}
  - {dataset: ACCESS-ESM1-5,   exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:  101, end_year:  250}
  - {dataset: ACCESS-ESM1-5,   exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year:  101, end_year:  250}
  - {dataset: AWI-CM-1-1-MR,   exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 2650, end_year: 2799}
  - {dataset: AWI-CM-1-1-MR,   exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: BCC-CSM2-MR,     exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: BCC-CSM2-MR,     exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: BCC-ESM1,        exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: BCC-ESM1,        exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: CAMS-CSM1-0,     exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 3030, end_year: 3179}
  - {dataset: CAMS-CSM1-0,     exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 3030, end_year: 3179}
  - {dataset: CanESM5,         exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 5201, end_year: 5350}
  - {dataset: CanESM5,         exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: CESM2,           exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:    1, end_year:  150}
  - {dataset: CESM2,           exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year:    1, end_year:  150}
  - {dataset: CESM2-FV2,       exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:  321, end_year:  470, institute: NCAR}
  - {dataset: CESM2-FV2,       exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year:    1, end_year:  150, institute: NCAR}
  - {dataset: CESM2-WACCM,     exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:    1, end_year:  150, institute: NCAR}
  - {dataset: CESM2-WACCM,     exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year:    1, end_year:  150, institute: NCAR}
  - {dataset: CESM2-WACCM-FV2, exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:  301, end_year:  450, institute: NCAR}
  - {dataset: CESM2-WACCM-FV2, exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year:    1, end_year:  150, institute: NCAR}
  - {dataset: CMCC-CM2-SR5,    exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: CMCC-CM2-SR5,    exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: CNRM-CM6-1,      exp: piControl,    ensemble: r1i1p1f2, grid: gr,  start_year: 1850, end_year: 1999}
  - {dataset: CNRM-CM6-1,      exp: abrupt-4xCO2, ensemble: r1i1p1f2, grid: gr,  start_year: 1850, end_year: 1999}
  - {dataset: CNRM-CM6-1-HR,   exp: piControl,    ensemble: r1i1p1f2, grid: gr,  start_year: 1850, end_year: 1999}
  - {dataset: CNRM-CM6-1-HR,   exp: abrupt-4xCO2, ensemble: r1i1p1f2, grid: gr,  start_year: 1850, end_year: 1999}
  - {dataset: CNRM-ESM2-1,     exp: piControl,    ensemble: r1i1p1f2, grid: gr,  start_year: 1850, end_year: 1999}
  - {dataset: CNRM-ESM2-1,     exp: abrupt-4xCO2, ensemble: r1i1p1f2, grid: gr,  start_year: 1850, end_year: 1999}
  - {dataset: E3SM-1-0,        exp: piControl,    ensemble: r1i1p1f1, grid: gr,  start_year:  101, end_year:  250}
  - {dataset: E3SM-1-0,        exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gr,  start_year:    1, end_year:  150}
  - {dataset: EC-Earth3-Veg,   exp: piControl,    ensemble: r1i1p1f1, grid: gr,  start_year: 1850, end_year: 1999}
  - {dataset: EC-Earth3-Veg,   exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gr,  start_year: 1850, end_year: 1999}
  # parent_time_units messed up
  - {dataset: FGOALS-f3-L,     exp: piControl,    ensemble: r1i1p1f1, grid: gr,  start_year:  600, end_year:  749}
  - {dataset: FGOALS-f3-L,     exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gr,  start_year: 1850, end_year: 1999}
  - {dataset: FGOALS-g3,       exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:  463, end_year:  612}
  - {dataset: FGOALS-g3,       exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year:  463, end_year:  612}
  - {dataset: GISS-E2-1-G,     exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 4150, end_year: 4299}
  - {dataset: GISS-E2-1-G,     exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: GISS-E2-1-H,     exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 3180, end_year: 3329}
  - {dataset: GISS-E2-1-H,     exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: HadGEM3-GC31-LL, exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: HadGEM3-GC31-LL, exp: abrupt-4xCO2, ensemble: r1i1p1f3, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: HadGEM3-GC31-MM, exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: HadGEM3-GC31-MM, exp: abrupt-4xCO2, ensemble: r1i1p1f3, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: INM-CM5-0,       exp: piControl,    ensemble: r1i1p1f1, grid: gr1, start_year: 2099, end_year: 2248}
  - {dataset: INM-CM5-0,       exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gr1, start_year: 1850, end_year: 1999}
  - {dataset: INM-CM4-8,       exp: piControl,    ensemble: r1i1p1f1, grid: gr1, start_year: 1947, end_year: 2096}
  - {dataset: INM-CM4-8,       exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gr1, start_year: 1850, end_year: 1999}
  - {dataset: IPSL-CM6A-LR,    exp: piControl,    ensemble: r1i1p1f1, grid: gr,  start_year: 1870, end_year: 2019}
  - {dataset: IPSL-CM6A-LR,    exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gr,  start_year: 1850, end_year: 1999}
  - {dataset: KACE-1-0-G,      exp: piControl,    ensemble: r1i1p1f1, grid: gr,  start_year: 2150, end_year: 2299}
  - {dataset: KACE-1-0-G,      exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gr,  start_year: 1850, end_year: 1999}
  - {dataset: MIROC6,          exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 3200, end_year: 3349}
  - {dataset: MIROC6,          exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 3200, end_year: 3349}
  - {dataset: MIROC-ES2L,      exp: piControl,    ensemble: r1i1p1f2, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: MIROC-ES2L,      exp: abrupt-4xCO2, ensemble: r1i1p1f2, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: MPI-ESM-1-2-HAM, exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 1950, end_year: 2099}
  - {dataset: MPI-ESM-1-2-HAM, exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: MPI-ESM1-2-HR,   exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: MPI-ESM1-2-HR,   exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: MPI-ESM1-2-LR,   exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: MPI-ESM1-2-LR,   exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: MRI-ESM2-0,      exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: MRI-ESM2-0,      exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  # parent_time_units not correct
  - {dataset: NESM3,           exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:  550, end_year:  699}
  - {dataset: NESM3,           exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  - {dataset: NorCPM1,         exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:  251, end_year:  400, institute: NCC}
  - {dataset: NorCPM1,         exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year:    1, end_year:  150, institute: NCC}
  - {dataset: NorESM2-MM,      exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year: 1201, end_year: 1350}
  - {dataset: NorESM2-MM,      exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year:    1, end_year:  150}
  # Issue #286 (manual copying was necessary)
  - {dataset: SAM0-UNICON,     exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:  274, end_year:  423}
  - {dataset: SAM0-UNICON,     exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year: 1850, end_year: 1999}
  # Wrong start year for piControl (must be 1201)
  - {dataset: TaiESM1,         exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:  201, end_year:  350}
  - {dataset: TaiESM1,         exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year:    1, end_year:  150}

CMIP6_RTMT: &cmip6_rtmt
  # branch_time_in_child weird
  - {dataset: MCM-UA-1-0,      exp: piControl,    ensemble: r1i1p1f1, grid: gn,  start_year:    1, end_year:  150}
  - {dataset: MCM-UA-1-0,      exp: abrupt-4xCO2, ensemble: r1i1p1f1, grid: gn,  start_year:    1, end_year:  150}

ECS_SCRIPT: &ecs_script
  script: climate_metrics/ecs.py
  calculate_mmm: false
SCATTERPLOT: &scatterplot_script
  script: climate_metrics/create_scatterplot.py
  pattern: 'ecs.nc'
  seaborn_settings:
    style: ticks
  y_range: [0.0, 6.0]


diagnostics:

  cmip5:
    description: Calculate ECS for all available CMIP5 models.
    variables:
      tas_rtnt: &variable_settings_cmip5
        short_name: tas
        preprocessor: spatial_mean
        project: CMIP5
        ensemble: r1i1p1
        mip: Amon
        additional_datasets: *cmip5_rtnt
      rtnt:
        <<: *variable_settings_cmip5
        short_name: rtnt
        derive: true
        additional_datasets: *cmip5_rtnt
    scripts:
      ecs:
        <<: *ecs_script
      scatterplot:
        <<: *scatterplot_script
        ancestors: ['cmip5/ecs']
        dataset_style: cmip5

  cmip6:
    description: Calculate ECS for all available CMIP6 models.
    variables:
      tas_rtnt: &variable_settings_cmip6
        short_name: tas
        preprocessor: spatial_mean
        project: CMIP6
        mip: Amon
        additional_datasets: *cmip6_rtnt
      tas_rtmt:
        <<: *variable_settings_cmip6
        additional_datasets: *cmip6_rtmt
      rtnt:
        <<: *variable_settings_cmip6
        short_name: rtnt
        derive: true
        additional_datasets: *cmip6_rtnt
      rtmt:
        <<: *variable_settings_cmip6
        short_name: rtmt
        additional_datasets: *cmip6_rtmt
    scripts:
      ecs:
        <<: *ecs_script
      scatterplot:
        <<: *scatterplot_script
        ancestors: ['cmip6/ecs']
        dataset_style: cmip6

  barplot:
    description: Create barplot of ECS.
    scripts:
      barplot:
        script: climate_metrics/create_barplot.py
        ancestors: ['*/ecs']
        add_mean: true
        label_attribute: project
        order: ['CMIP5', 'CMIP6']
        patterns: ['ecs.nc']
        sort_descending: true
        value_labels: true
        y_range: [0.0, 6.0]
