Skip to content

Commit

Permalink
Merge pull request #141 from mnlevy1981/link_ADF_webpage
Browse files Browse the repository at this point in the history
Create a new example that will run full ADF package (not from notebook)
  • Loading branch information
TeaganKing authored Nov 20, 2024
2 parents 2dda82f + 5e4e0be commit 33e9705
Show file tree
Hide file tree
Showing 5 changed files with 427 additions and 15 deletions.
18 changes: 18 additions & 0 deletions cupid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""
from __future__ import annotations

import shutil
import subprocess

import click
Expand Down Expand Up @@ -45,6 +46,19 @@ def build(config_path):
subprocess.run(
["jupyter-book", "build", f"{run_dir}/computed_notebooks/{sname}", "--all"],
)
for component in control["compute_notebooks"]:
for notebook in control["compute_notebooks"][component]:
if "external_tool" in control["compute_notebooks"][component][notebook]:
if (
control["compute_notebooks"][component][notebook][
"external_tool"
].get("tool_name")
== "ADF"
):
shutil.copytree(
f"{run_dir}/ADF_output",
f"{run_dir}/computed_notebooks/{sname}/_build/html/ADF",
)

# Originally used this code to copy jupyter book HTML to a location to host it online

Expand All @@ -59,3 +73,7 @@ def build(config_path):
# f"{user}@{remote_mach}:{remote_dir}"])

return None


if __name__ == "__main__":
build()
225 changes: 225 additions & 0 deletions examples/external_diag_packages/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
################## SETUP ##################

################
# Data Sources #
################
data_sources:
# sname is any string used as a nickname for this configuration. It will be
### used as the name of the folder your computed notebooks are put in
sname: external_diag_packages

# run_dir is the path to the folder you want
### all the files associated with this configuration
### to be created in
run_dir: .

# nb_path_root is the path to the folder that cupid will
### look for your template notebooks in. It doesn't have to
### be inside run_dir, or be specific to this project, as
### long as the notebooks are there
nb_path_root: ../nblibrary

######################
# Computation Config #
######################

computation_config:

# default_kernel_name is the name of the environment that
### the notebooks in this configuration will be run in by default.
### It must already be installed on your machine. You can also
### specify a different environment than the default for any
### notebook in NOTEBOOK CONFIG
default_kernel_name: cupid-analysis

# log level sets the level of how verbose logging will be.
# options include: debug, info, warning, error
log_level: 'info'

############# NOTEBOOK CONFIG #############

############################
# Notebooks and Parameters #
############################

# All parameters under global_params get passed to all the notebooks

global_params:
case_name: 'b.e30_beta02.BLT1850.ne30_t232.104'
base_case_name: 'f.e23_alpha17f.FLTHIST_ne30.roughtopo.099'
CESM_output_dir: /glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing
start_date: '0001-01-01'
end_date: '0101-01-01'
lc_kwargs:
threads_per_worker: 1

timeseries:
num_procs: 8
ts_done: [False, False]
overwrite_ts: [False, False]
case_name: ['b.e30_beta02.BLT1850.ne30_t232.104', 'f.e23_alpha17f.FLTHIST_ne30.roughtopo.099']

atm:
vars: ['PSL']
derive_vars: []
hist_str: 'h0a'
start_years: [1,1]
end_years: [100,100]
level: 'lev'

lnd:
vars: []
derive_vars: []
hist_str: 'h0'
start_years: [1,1]
end_years: [100,100]
level: 'lev'

ocn:
vars: []
derive_vars: []
hist_str: 'h.z'
start_years: [1,1]
end_years: [100,100]
level: 'lev'

ice:
vars: []
derive_vars: []
hist_str: 'h'
start_years: [1,1]
end_years: [100,100]
level: 'lev'

glc:
vars: []
derive_vars: []
hist_str: 'initial_hist'
start_years: [1,1]
end_years: [100,100]
level: 'lev'

compute_notebooks:

# This is where all the notebooks you want run and their
# parameters are specified. Several examples of different
# types of notebooks are provided.

# The first key (here infrastructure) is the name of the
# notebook from nb_path_root, minus the .ipynb

infrastructure:
index:
parameter_groups:
none: {}

atm:
link_to_ADF:
kernel_name: cupid-dev
parameter_groups:
none:
adf_root: ../../external_diag_packages/ADF/
case_year_range: "1_100"
base_case_year_range: "1995_2006"
external_tool:
tool_name: 'ADF'
vars: ['PRECT', 'SST']
plotting_scripts: ["global_latlon_map", "global_latlon_vect_map"]

# glc:
# LIWG_SMB_diagnostic:
# parameter_groups:
# none:
# obs_path: '/glade/u/home/gunterl/obs_diagnostic_cesm/'
# obs_name: 'GrIS_MARv3.12_climo_1960_1999.nc'
# climo_nyears: 40

# ice:
# seaice:
# parameter_groups:
# none:
# cases:
# - g.e23_a16g.GJRAv4.TL319_t232_hycom1_N75.2024.005
# - g.e23_a16g.GJRAv4.TL319_t232_zstar_N65.2024.004
# begyr1: 245
# endyr1: 305
# begyr2: 245
# endyr2: 305
# nyears: 25

# lnd:
# land_comparison:
# parameter_groups:
# none:
# cases:
# - ctsm51d159_f45_GSWP3_bgccrop_1850pAD
# - ctsm51d159_f45_GSWP3_bgccrop_1850pSASU
# type:
# - 1850pAD
# - 1850pSASU

# ocn:
# ocean_surface:
# parameter_groups:
# none:
# Case: b.e23_alpha16b.BLT1850.ne30_t232.054
# savefigs: False
# mom6_tools_config:
# start_date: '0091-01-01'
# end_date: '0101-01-01'
# Fnames:
# native: 'mom6.h.native.????-??.nc'
# static: 'mom6.h.static.nc'
# oce_cat: /glade/u/home/gmarques/libs/oce-catalogs/reference-datasets.yml

########### JUPYTER BOOK CONFIG ###########

##################################
# Jupyter Book Table of Contents #
##################################
book_toc:

# See https://jupyterbook.org/en/stable/structure/configure.html for
# complete documentation of Jupyter book construction options

format: jb-book

# All filenames are notebook filename without the .ipynb, similar to above

root: infrastructure/index # root is the notebook that will be the homepage for the book
parts:

# Parts group notebooks into different sections in the Jupyter book
# table of contents, so you can organize different parts of your project.
# Each chapter is the name of one of the notebooks that you executed
# in compute_notebooks above, also without .ipynb

- caption: Atmosphere
chapters:
- file: atm/link_to_ADF

# - caption: Ocean
# chapters:
# - file: ocn/ocean_surface

# - caption: Land
# chapters:
# - file: lnd/land_comparison

# - caption: Sea Ice
# chapters:
# - file: ice/seaice

# - caption: Land Ice
# chapters:
# - file: glc/LIWG_SMB_diagnostic

#####################################
# Keys for Jupyter Book _config.yml #
#####################################
book_config_keys:

title: External Diagnostic Packages # Title of your jupyter book

# Other keys can be added here, see https://jupyterbook.org/en/stable/customize/config.html
### for many more options
Loading

0 comments on commit 33e9705

Please sign in to comment.