Skip to content

Commit

Permalink
Merge pull request #49 from wwieder/land-example
Browse files Browse the repository at this point in the history
point to shared directory, no dask
  • Loading branch information
mnlevy1981 authored Jan 19, 2024
2 parents 83d4e5f + e838cd4 commit 164ac42
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 73 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ $ cupid-build config.yml # Will build HTML from Jupyter Book
After the last step is finished, you can use Jupyter to view generated notebooks in `${CUPID_ROOT}/examples/coupled-model/computed_notebooks/quick-run`
or you can copy the entire `${CUPID_ROOT}/examples/coupled-model/computed_notebooks/quick-run/_build/html`
directory to your local machine and look at `index.html` in a web browser.

For users running on the NCAR super computers (derecho or casper), you can visualize the web page in a browser with the following steps:
1. open a new browser window that points to https://fastx.ucar.edu:3300/session/
1. open a default desktop icon
1. select the browser client
1. type `xterm` and hit enter to open a terminal
1. In the terminal, run `cd ${CUPID_ROOT}/examples/coupled_model/computed_notebooks/quick-run/_build/html` to enter the `html` directory
1. From the updated directory, run `firefox index.html &` to open a web browser pointed at the generated web page
81 changes: 8 additions & 73 deletions examples/nblibrary/land_comparision.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
"metadata": {},
"source": [
"## Simple example comparing land variables from two simulations\n",
"- Created by [email protected]\n",
"- Jan 2024\n",
"Created by [email protected], Jan 2024\n",
"\n",
"- paths are harded coded for now\n",
"- quickly (and inaccurately) calcultes 20 year mean from raw, .h0., files \n",
"- quickly (and inaccurately) calculates 5 year mean from raw, .h0., files.\n",
"- plots global means and differences which also not very nice to look at, especially since this points to a 4x5 grid."
]
},
Expand Down Expand Up @@ -64,55 +63,6 @@
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e0d67916-85c5-4590-b03f-c00753e88df4",
"metadata": {},
"outputs": [],
"source": [
"# Updated for PBS scheduler\n",
"# this could go into utils.\n",
"# By default gets 1 core w/ 25 GB memory\n",
"def get_ClusterClient(ncores=1, nmem='25GB'):\n",
" import dask\n",
" from dask_jobqueue import PBSCluster\n",
" from dask.distributed import Client\n",
" ncores=ncores\n",
" nmem = nmem\n",
"\n",
" cluster = PBSCluster(\n",
" cores=ncores, # The number of cores you want\n",
" memory=nmem, # Amount of memory\n",
" processes=ncores, # How many processes\n",
" queue='casper', # The type of queue to utilize (/glade/u/apps/dav/opt/usr/bin/execcasper)\n",
" resource_spec='select=1:ncpus='+str(ncores)+':mem='+nmem, # Specify resources\n",
" project='P93300641', # Input your project ID here\n",
" walltime='2:00:00', # Amount of wall time\n",
" interface='ext', # Interface to use 'lo' provided a cluster window, below.\n",
" )\n",
"\n",
" dask.config.set({\n",
" 'distributed.dashboard.link':\n",
" 'https://jupyterhub.hpc.ucar.edu/stable/user/{USER}/proxy/{port}/status'\n",
" })\n",
"\n",
" client = Client(cluster)\n",
" return cluster, client"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "590d68d1-7bf3-4164-911c-c6593d010246",
"metadata": {},
"outputs": [],
"source": [
"cluster, client = get_ClusterClient(nmem='1GB')\n",
"cluster.scale(10) \n",
"cluster"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -123,8 +73,8 @@
"# -- read only these variables from the whole netcdf files\n",
"# average over time\n",
"def preprocess (ds):\n",
" variables = ['GPP', 'TOTECOSYSC', 'TOTVEGC','ELAI','TOTSOMC',\n",
" 'SOM_PAS_C_vr','SOM_SLO_C_vr','ALT']\n",
" variables = ['TOTECOSYSC', 'TOTVEGC','TOTSOMC',\n",
" 'SOM_PAS_C_vr']\n",
"\n",
" ds_new= ds[variables]\n",
" return ds_new\n",
Expand Down Expand Up @@ -154,10 +104,11 @@
"for c in range(len(cases)):\n",
"\n",
" sim_files =[]\n",
" sim_path = \"/glade/derecho/scratch/slevis/archive/\"+cases[c]+\"/lnd/hist/\"\n",
" sim_path = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing/\"\n",
" sim_path = sim_path+cases[c]+\"/lnd/hist/\"\n",
" sim_files.extend(sorted(glob(join(sim_path+cases[c]+\".clm2.h0.*.nc\"))))\n",
" # subset last 20 years of data \n",
" sim_files = sim_files[-240:None]\n",
" # subset last 5 years of data \n",
" sim_files = sim_files[-60:None]\n",
" print(\"All simulation files for \"+cases[c]+\": [\", len(sim_files), \"files]\")\n",
"\n",
" temp = xr.open_mfdataset(sim_files, decode_times=True, combine='by_coords',\n",
Expand Down Expand Up @@ -261,22 +212,6 @@
"plt.ylabel(None)\n",
"#plt.ylim(6,0)"
]
},
{
"cell_type": "markdown",
"id": "b3f729af-05b4-4540-b4b5-567cc1cbe8f2",
"metadata": {},
"source": [
"### Big blob of passive C with depth in pAD"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c10babf2-4530-4ca9-b304-4db7fb6a965d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 164ac42

Please sign in to comment.