Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 16 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/SSP370-LOWNTCF-AERCHEMMIP_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/PICONTROL_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/SSP370_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/configs/magicc-ar7-fast-track-drawnset-v0-3-0.json filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/SSP245_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/SSP370-LOWNTCF-GIDDEN_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/bin/magicc filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/HISTRCP_VOLCANIC_RF.MON filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/SSP534-OVER_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/SSP245_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/SSP119_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/SSP585_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/SSP126_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/SSP460_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/HIST_VOLCANIC_RF.MON filter=lfs diff=lfs merge=lfs -text
tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/run/rcmip/SSP434_EMMS.SCEN7 filter=lfs diff=lfs merge=lfs -text
5 changes: 5 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
lfs: true
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
Expand Down Expand Up @@ -91,6 +93,9 @@ jobs:
# feel free to update.
shell: bash
steps:
- name: Support longpaths on Windows
if: runner.os == 'Windows'
run: git config --global core.longpaths true
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
Expand Down
71 changes: 45 additions & 26 deletions docs/how-to-guides/how-to-run-the-cmip7-scenariomip-workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
# ## Imports

# %% editable=true slideshow={"slide_type": ""}
import multiprocessing
import os
import platform
from functools import partial
from pathlib import Path

Expand All @@ -47,6 +50,7 @@
)
from gcages.cmip7_scenariomip.infilling import CMIP7ScenarioMIPInfiller
from gcages.cmip7_scenariomip.pre_processing import CMIP7ScenarioMIPPreProcessor
from gcages.cmip7_scenariomip.scm_running import CMIP7_SCENARIOMIP_SCMRunner
from gcages.index_manipulation import split_sectors

# %%
Expand Down Expand Up @@ -563,43 +567,58 @@

# %%
# combine to create complete timeseries using sum of gridded
# and the global harmonised timeseries
# and the global harmonised timeseries or provide both as input
# complete_scenarios = pd.concat([harmonised, infilled])
# complete_scenarios

# %%
# MAGICC_EXE_PATH = Path("tests/regression/ar6/ar6-workflow-inputs/magicc-v7.5.3/bin")
# MAGICC_AR6_PROBABILISTIC_CONFIG_FILE = Path(
# "tests/regression/ar6/ar6-workflow-inputs/magicc-ar6-0fd0f62-f023edb-drawnset/0fd0f62-derived-metrics-id-f023edb-drawnset.json" # noqa: E501
# )
MAGICC_EXE_PATH = Path(
"tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/bin"
)
MAGICC_CMIP7_SCENARIOMIP_PROBABILISTIC_CONFIG_FILE = Path(
"tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs/magicc-v7.6.0a3/configs/magicc-ar7-fast-track-drawnset-v0-3-0.json"
)

# %% editable=true slideshow={"slide_type": ""} tags=["remove_input"]
if not MAGICC_EXE_PATH.exists():
MAGICC_EXE_PATH = Path("../..") / MAGICC_EXE_PATH
if not MAGICC_EXE_PATH.exists():
raise AssertionError

if not MAGICC_CMIP7_SCENARIOMIP_PROBABILISTIC_CONFIG_FILE.exists():
MAGICC_CMIP7_SCENARIOMIP_PROBABILISTIC_CONFIG_FILE = (
Path("../..")
/ "tests/regression/cmip7-scenariomip/cmip7-scenariomip-workflow-inputs"
/ "magicc-v7.6.0a3/configs/magicc-ar7-fast-track-drawnset-v0-3-0.json"
)
if not MAGICC_CMIP7_SCENARIOMIP_PROBABILISTIC_CONFIG_FILE.exists():
raise AssertionError

# %%
# if platform.system() == "Darwin":
# if platform.processor() == "arm":
# MAGICC_EXE = MAGICC_EXE_PATH / "magicc-darwin-arm64"
# os.environ["DYLD_LIBRARY_PATH"] = "/opt/homebrew/opt/gfortran/lib/gcc/current/" # noqa: E501
if platform.system() == "Darwin":
if platform.processor() == "arm":
MAGICC_EXE = MAGICC_EXE_PATH / "magicc-darwin-arm64"
os.environ["DYLD_LIBRARY_PATH"] = "/opt/homebrew/opt/gfortran/lib/gcc/current/"

# elif platform.system() == "Linux":
# MAGICC_EXE = MAGICC_EXE_PATH / "magicc"
elif platform.system() == "Linux":
MAGICC_EXE = MAGICC_EXE_PATH / "magicc"

# elif platform.system() == "Windows":
# MAGICC_EXE = MAGICC_EXE_PATH / "magicc.exe"
elif platform.system() == "Windows":
MAGICC_EXE = MAGICC_EXE_PATH / "magicc.exe"

# %% [markdown]
# With the set up done, we can initialise our SCM runner.

# %%
# scm_runner = AR6SCMRunner.from_ar6_config(
# # Generally, you want to run SCMs in parallel
# n_processes=multiprocessing.cpu_count(),
# magicc_exe_path=MAGICC_EXE,
# magicc_prob_distribution_path=MAGICC_AR6_PROBABILISTIC_CONFIG_FILE,
# historical_emissions=get_ar6_full_historical_emissions(
# AR6_INFILLING_DB_CFCS_FILE),
# harmonisation_year=2015,
# output_variables=("Surface Air Temperature Change",
# "Effective Radiative Forcing"),
# )
scm_runner = CMIP7_SCENARIOMIP_SCMRunner.from_cmip7_scenariomip_config(
# Generally, you want to run SCMs in parallel
n_processes=multiprocessing.cpu_count(),
magicc_exe_path=MAGICC_EXE,
magicc_prob_distribution_path=MAGICC_CMIP7_SCENARIOMIP_PROBABILISTIC_CONFIG_FILE,
historical_emissions_path=CMIP7_SCENARIOMIP_GLOBAL_HISTORICAL_EMISSIONS_FILE,
output_variables=("Surface Air Temperature Change", "Effective Radiative Forcing"),
batch_size_scenarios=15,
)

# %% [markdown]
# If you're reading this on RtD,
Expand All @@ -616,8 +635,8 @@
# And then run

# %%
# scm_results = scm_runner(complete_scenarios)
# scm_results
scm_results = scm_runner(infilled)
scm_results

# %% [markdown]
# With these outputs, we can look at raw (i.e. before pre-processing) variables.
Expand Down
4 changes: 4 additions & 0 deletions src/gcages/cmip7_scenariomip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
ReaggregatorBasic,
ReaggregatorLike,
)
from gcages.cmip7_scenariomip.scm_running import (
CMIP7_SCENARIOMIP_SCMRunner,
)

__all__ = [
"CMIP7ScenarioMIPInfiller",
"CMIP7ScenarioMIPPreProcessingResult",
"CMIP7ScenarioMIPPreProcessor",
"CMIP7_SCENARIOMIP_SCMRunner",
"ReaggregatorBasic",
"ReaggregatorLike",
"create_cmip7_scenariomip_global_harmoniser",
Expand Down
Loading
Loading