From e72a5653b379e0a9812b14b5659f092ba5b54ff8 Mon Sep 17 00:00:00 2001 From: Daniel Kennedy Date: Fri, 11 Feb 2022 14:46:41 -0700 Subject: [PATCH] sp working --- analysis/sp.ipynb | 208 ++++++++++++++++++++++++++++++++++++++++++ ppe_tools/analysis.py | 11 +-- 2 files changed, 213 insertions(+), 6 deletions(-) create mode 100644 analysis/sp.ipynb diff --git a/analysis/sp.ipynb b/analysis/sp.ipynb new file mode 100644 index 0000000..6aaf64b --- /dev/null +++ b/analysis/sp.ipynb @@ -0,0 +1,208 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "d5d1eacf-f4ab-473a-a132-26ccf39aec6e", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import pandas as pd\n", + "import xarray as xr\n", + "import glob\n", + "import matplotlib\n", + "import matplotlib.pyplot as plt" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "ade99a07-1ae3-4ac7-9e52-ef87ec1b3263", + "metadata": {}, + "outputs": [], + "source": [ + "### import some analysis functions we wrote for this project\n", + "import sys ; sys.path.append(\"..\")\n", + "from ppe_analysis.analysis import *" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "ad533cbe-be7a-41db-b814-d835936a8c08", + "metadata": {}, + "outputs": [], + "source": [ + "# Setup your PBSCluster\n", + "import dask\n", + "from dask_jobqueue import PBSCluster\n", + "from dask.distributed import Client\n", + "ncores=1\n", + "nmem='25GB'\n", + "cluster = PBSCluster(\n", + " cores=ncores, # The number of cores you want\n", + " memory=nmem, # Amount of memory\n", + " processes=1, # How many processes\n", + " queue='casper', # The type of queue to utilize (/glade/u/apps/dav/opt/usr/bin/execcasper)\n", + " local_directory='$TMPDIR', # Use your local directory\n", + " resource_spec='select=1:ncpus='+str(ncores)+':mem='+nmem, # Specify resources\n", + " project='P93300641', # Input your project ID here\n", + " walltime='02:00:00', # Amount of wall time\n", + " interface='ib0', # Interface to use\n", + ")\n", + "\n", + "# Scale up\n", + "cluster.scale(30)\n", + "\n", + "# Setup your client\n", + "client = Client(cluster)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "4d16b0dd-5cd1-43ee-8d6f-a6b41e3ce466", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "d74970786cac4550b5b6dd3ac69c33f3", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Tab(children=(HTML(value='
]" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEGCAYAAAB1iW6ZAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAczUlEQVR4nO3dfZAd1Xnn8e9zZ0YEgkpWhHiTNBLCmI1FYpDGRi52bWzj18QhxqZw4qXiVIjiKrxlap0qO+xG6/XWbsXrDWunQsIqkLVdkQHHyIZ1rR0TFgLElkCjEuhtkRWBxEQKSPIAcmA1mrnP/nFf6OnpO7fva3ef+/tUqTRz75l7T58+/fTpp093m7sjIiLFV8q6AiIi0h0K6CIigVBAFxEJhAK6iEggFNBFRAIxnNUXn3POOb5q1aqsvl5EpJDGx8ePu/vSpPcyC+irVq1i+/btWX29iEghmdmhRu8p5SIiEggFdBGRQCigi4gEQgFdRCQQCugiIoFQQBcRCYQCuoh0ZPzQJLc/fIDxQ5NZV2XgZTYPXUSKb/zQJJ+4cytT02UWDJfYfNN61q1cnHW1BpZG6CLStq0HTzA1XabscHq6zNaDJ7Ku0kBTQBeRtq1fvYQFwyWGDEaGS6xfvSTrKg00pVxEpG3rVi5m803r2XrwBOtXL1G6JWMK6CLSkXUrFyuQ54RSLiIigVBAFxEJhAK6iEggFNBFRAKhgC4iEggFdBGRQCigi4gEQgFdRCQQCugiIoFQQBcRCYQCuohIIBTQ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+d99jZt8C9gLTwM3uPpNJxXukQXtcbWaXU0kfPAf8HgxEe1wF3AjsMrOd1dduZUD6hy79FxEJRNFSLiIi0oACuohIIBTQRUQCoYAuIhIIBXQRkUAooIuIBEIBXUQkEAroMpDM7F+b2RPVe4X/DzMbMrOfmdl/NrOnzGyrmZ1XLXu9me2uvv5o1nUXaUQBXQaOmf0icAOVm5xdDswAnwB+Htjq7m8BHgV+t/onG4H3V1//tf7XWCSdQl36L9Il7wHWAU9Wb6FwJpWbNU0B36uWGQfeW/3574GvVS8R34JITimgyyAy4Ovu/gezXjT7fX/9XhgzVLcPd/+UmV0J/Aqw08wud/cTfa2xSApKucggegj4mJmdC/XnTa5sVNjMLnb3be6+ETjO7NutiuSGRugycNx9r5n9eypPfSoBp4Gb5/mTL5vZJVRG9g9ReQalSO7obosiIoFQykVEJBAK6CIigVBAFxEJhAK6iEggFNBFRAKhgC4iEggFdBGRQPx/urc0OQac07MAAAAASUVORK5CYII=\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "x.plot.line('.')" + ] + }, + { + "cell_type": "markdown", + "id": "7f661375-f821-436f-8006-741dc70bef20", + "metadata": {}, + "source": [ + "### via calc_mean" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "a2f9149e-090f-4f25-8d2e-ce7697f1e5d5", + "metadata": {}, + "outputs": [], + "source": [ + "da,iav = calc_mean('CTL2010SP','FPSN',csv=csv)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5f8918bc-63f6-45d0-809e-cab5e0bd57c4", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python [conda env:miniconda3-ppe-py]", + "language": "python", + "name": "conda-env-miniconda3-ppe-py-py" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/ppe_tools/analysis.py b/ppe_tools/analysis.py index 5db0168..699dc05 100644 --- a/ppe_tools/analysis.py +++ b/ppe_tools/analysis.py @@ -9,14 +9,12 @@ #define the directory structure to find files def get_files(name,htape,keys): - - topdir = '/glade/campaign/asp/djk2120/PPEn11/hist/' + topdir = '/glade/scratch/djk2120/PPEn11/hist/' thisdir = topdir+name+'/' files = [glob.glob(thisdir+'*'+key+'*'+htape+'*.nc')[0] for key in keys] return files def ppe_init(csv='/glade/scratch/djk2120/PPEn11/surv.csv'): - paramkey = pd.read_csv(csv) keys = paramkey.key @@ -191,17 +189,18 @@ def get_cfs(attrs,datavar,ds,la): units = 'tbd' return cf1,cf2,units -def calc_mean(ens_name,datavar,domain='global',overwrite=False): +def calc_mean(ens_name,datavar,domain='global',overwrite=False, + csv='/glade/scratch/djk2120/PPEn11/surv.csv'): ''' Calculate the annual mean for given datavar across the ensemble. - ens_name, one of CTL2010,CTL2010SP,AF1855,AF2095,C285,C867,NDEP + ens_name, one of CTL2010,AF1855,AF2095,C285,C867,NDEP datavar, e.g. GPP domain, one of global,biome,pft overwrite, option to rewrite existing saved data returns xmean,xiav ''' - ds0,la,attrs,paramkey,keys = ppe_init() + ds0,la,attrs,paramkey,keys = ppe_init(csv=csv) preload = ('/glade/u/home/djk2120/clm5ppe/pyth/data/'+ ens_name+'_'+datavar+'_'+domain+'.nc')