{ "cells": [ { "cell_type": "markdown", "id": "d88a8f2e-7cc7-4664-88b8-aaf7d1a0a555", "metadata": { "tags": [] }, "source": [ "# ADF in Jupyter\n", "\n", "Now that we have seen how to run the ADF via terminal, let's take a look at how to run the ADF through Jupyter.\n", "\n", "### Why Jupyter?\n", "\n", "If you are looking to use the ADF in a more developmental or interactive way, using Jupyter will offer a lot more flexibility than running through the terminal.\n", "\n", "One major advantage of this way of running the ADF will allow the user to immediately have access to output data in a Jupyter notebook which can allow for further development or use of diagnostics that aren't in the ADF by defualt.\n", "\n", "One scenario to highlight this flexibility could be for tuning specific parameters of your model run that need a specific diagnostics set of tools that maybe only good for this tune. Now the user can build custom diagnostics code within the same Jupyter notebook that the ADF was run in!\n", "\n", "If you need help with navigating Jupyter Nobeooks or NCAR's JupyterHub, please see the reference section of this tutorial." ] }, { "cell_type": "markdown", "id": "a50566c5-005a-45f2-afa1-b00d1a20defb", "metadata": {}, "source": [ "### Step 1: Run ADF\n", "\n", "This will simulate running the ADF in the terminal, so nothing will be different here. In order to run the ADF, any of the NPL conda environments will suffice in Jupyter. NCAR has a couple to choose from (as of this tutorial):\n", "\n", " NPL 2023a\n", " NPL 2023b" ] }, { "cell_type": "markdown", "id": "91f6ab33-f72c-4e07-9c73-608f9064b687", "metadata": {}, "source": [ "If you are not up tp date or familiar with JupyterHub/Jupyter Notebooks, to change the kernel (environment) from the default Python3 (or None) to a different kerenel, at the top right of the notebook is an option to switch kernels:\n", "\n", "\n", "\n", "Click on the kernel and it will bring up a dropdown box with available kernels:\n", "\n", "\n", "\n", "Find one of the NPL environments and select that:\n", "\n", "NOTE: your available kernels may not be same as the ones displayed here.\n", "\n", "" ] }, { "cell_type": "raw", "id": "053799ae-8b20-4b9e-b6ca-63f257f60791", "metadata": {}, "source": [ "\n", "
\n", "Click the below button to download this Jupyter Notebook
\n", " \n", " \n", " \n", "Output:
" ] }, { "cell_type": "markdown", "id": "b9e3adc6-eb24-4de0-bda8-1464e090a191", "metadata": {}, "source": [ " Generating Diagnostics webpages...\n", " ...Webpages have been generated successfully." ] }, { "cell_type": "markdown", "id": "447a17a3-89af-4fb5-8b59-615562fd5e82", "metadata": {}, "source": [ "---" ] }, { "cell_type": "markdown", "id": "789a3fe1-b94d-48ec-80bf-da543c2742d3", "metadata": {}, "source": [ "### Step 2: Analyze ADF Output\n", "\n", "Once the ADF has completed (either here in Jupyter or previously from terminal run) we can use the `adf` object to gain access to everything available in the ADF. This could be very useful if you want to develop diagsnostics separate from the ADF in a Jupyter Notebook" ] }, { "cell_type": "raw", "id": "77fc2bde-f29a-4a56-be77-4f59fcf7a8bb", "metadata": {}, "source": [ " config_cam_baseline_example.yaml
"
]
},
{
"cell_type": "markdown",
"id": "73a7385a-8a41-4b2d-bdd2-cef633109509",
"metadata": {},
"source": [
"The `adf` object can be searched for any quantity of interest. Using the dot, `.` and tab function in Jupyter, we can get a list of all the available instances, classes, functions, etc:\n",
"\n",
"\n",
"\n",
"Or calling the dir
command on the ADF object will print a list of all available objects:"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "e6136e1a-3bac-4093-a249-aef4fcf568d0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['_AdfBase__debug_log',\n",
" '_AdfConfig__config_dict',\n",
" '_AdfConfig__create_search_dict',\n",
" '_AdfConfig__expand_yaml_var_ref',\n",
" '_AdfConfig__kword_pattern',\n",
" '_AdfConfig__search_dict',\n",
" '_AdfDiag__analysis_scripts',\n",
" '_AdfDiag__cvdp_info',\n",
" '_AdfDiag__diag_scripts_caller',\n",
" '_AdfDiag__function_caller',\n",
" '_AdfDiag__plotting_scripts',\n",
" '_AdfDiag__regridding_scripts',\n",
" '_AdfDiag__time_averaging_scripts',\n",
" '_AdfInfo__base_nickname',\n",
" '_AdfInfo__basic_info',\n",
" '_AdfInfo__cam_bl_climo_info',\n",
" '_AdfInfo__cam_climo_info',\n",
" '_AdfInfo__compare_obs',\n",
" '_AdfInfo__diag_var_list',\n",
" '_AdfInfo__eyear_baseline',\n",
" '_AdfInfo__eyears',\n",
" '_AdfInfo__num_cases',\n",
" '_AdfInfo__num_procs',\n",
" '_AdfInfo__plot_location',\n",
" '_AdfInfo__syear_baseline',\n",
" '_AdfInfo__syears',\n",
" '_AdfInfo__test_nicknames',\n",
" '_AdfObs__var_obs_dict',\n",
" '_AdfObs__variable_defaults',\n",
" '_AdfWeb__case_web_paths',\n",
" '_AdfWeb__plot_type_multi',\n",
" '_AdfWeb__plot_type_order',\n",
" '_AdfWeb__website_data',\n",
" '__class__',\n",
" '__delattr__',\n",
" '__dict__',\n",
" '__dir__',\n",
" '__doc__',\n",
" '__eq__',\n",
" '__format__',\n",
" '__ge__',\n",
" '__getattribute__',\n",
" '__gt__',\n",
" '__hash__',\n",
" '__init__',\n",
" '__init_subclass__',\n",
" '__le__',\n",
" '__lt__',\n",
" '__module__',\n",
" '__ne__',\n",
" '__new__',\n",
" '__reduce__',\n",
" '__reduce_ex__',\n",
" '__repr__',\n",
" '__setattr__',\n",
" '__sizeof__',\n",
" '__str__',\n",
" '__subclasshook__',\n",
" '__weakref__',\n",
" 'add_diag_var',\n",
" 'add_website_data',\n",
" 'baseline_climo_dict',\n",
" 'basic_info_dict',\n",
" 'cam_climo_dict',\n",
" 'case_nicknames',\n",
" 'climo_yrs',\n",
" 'compare_obs',\n",
" 'create_climo',\n",
" 'create_html',\n",
" 'create_plots',\n",
" 'create_time_series',\n",
" 'create_website',\n",
" 'debug_log',\n",
" 'diag_var_list',\n",
" 'end_diag_fail',\n",
" 'expand_references',\n",
" 'get_baseline_info',\n",
" 'get_basic_info',\n",
" 'get_cam_info',\n",
" 'get_cvdp_info',\n",
" 'num_cases',\n",
" 'num_procs',\n",
" 'perform_analyses',\n",
" 'plot_location',\n",
" 'plotting_scripts',\n",
" 'read_config_var',\n",
" 'regrid_climo',\n",
" 'setup_run_cvdp',\n",
" 'var_obs_dict',\n",
" 'variable_defaults']"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dir(adf)"
]
},
{
"cell_type": "markdown",
"id": "37c73012-17e5-4468-8fb9-76e474321760",
"metadata": {},
"source": [
"