-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from wwieder/land-example
point to shared directory, no dask
- Loading branch information
Showing
2 changed files
with
16 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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." | ||
] | ||
}, | ||
|
@@ -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, | ||
|
@@ -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", | ||
|
@@ -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", | ||
|
@@ -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": { | ||
|