{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import netCDF4 as nc\n", "from matplotlib import pyplot as plt\n", "import numpy as np\n", "import glob\n", "import pickle\n", "from salishsea_tools import evaltools as et\n", "import datetime as dt\n", "import os\n", "import re\n", "import cmocean\n", "import matplotlib as mpl\n", "mpl.rc('xtick', labelsize=8)\n", "mpl.rc('ytick', labelsize=8)\n", "mpl.rc('legend', fontsize=8)\n", "mpl.rc('axes', titlesize=8)\n", "mpl.rc('axes', labelsize=8)\n", "mpl.rc('figure', titlesize=8)\n", "mpl.rc('font', size=8)\n", "mpl.rc('text', usetex=True)\n", "mpl.rc('text.latex', preamble = r'''\n", " \\usepackage{txfonts}\n", " \\usepackage{lmodern}\n", " ''')\n", "mpl.rc('font', family='sans-serif', weight='normal', style='normal')\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "with nc.Dataset('/ocean/eolson/MEOPAR/NEMO-forcing/grid/mesh_mask201702_noLPE.nc') as mesh:\n", " tmask=mesh.variables['tmask'][0,:,:,:]\n", " e1t=np.expand_dims(mesh.variables['e1t'][:,:,:],1)\n", " e2t=np.expand_dims(mesh.variables['e2t'][:,:,:],1)\n", "SOGtmaskPath='/ocean/eolson/MEOPAR/northernNO3PaperCalcs/save/SOGtmask.pkl'\n", "(tmaskSOG,_,_,_,_)=pickle.load(open(SOGtmaskPath,'rb'))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "idir='/data/sallen/results/MEOPAR/fluxes_elise_2/'\n", "ts=dt.datetime(2015,1,1)\n", "te=dt.datetime(2015,12,31)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "ftype='dian_T'\n", "paths=glob.glob(os.path.join(idir,'*','*'+ftype+'*'))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "fPlist=et.index_model_files_flex(idir,'dian_T','1d','nowcast',ts,te)\n", "fDlist=et.index_model_files_flex(idir,'dia1_T','1d','nowcast',ts,te)\n", "fD2list=et.index_model_files_flex(idir,'dia2_T','1d','nowcast',ts,te)\n", "fSlist=et.index_model_files_flex(idir,'snp_T','1d','nowcast',ts,te)\n", "fRlist=et.index_model_files_flex(idir,'rad_T','1d','nowcast',ts,te)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "ATFNO3Sum=list(); ATFNH4Sum=list(); ATFDONSum=list(); ATFPONSum=list(); ATFLIVSum=list();\n", "BFXPONSum=list(); BFXDIATSum=list();\n", "for i,r in fDlist.iterrows():\n", " with nc.Dataset(r['paths']) as f:\n", " ATFNO3Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['ATF_NO3'][:,:,:,:],3),2),1))\n", " ATFNH4Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['ATF_NH4'][:,:,:,:],3),2),1))\n", " ATFDONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['ATF_DON'][:,:,:,:],3),2),1))\n", " ATFPONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['ATF_PON'][:,:,:,:],3),2),1))\n", " ATFLIVSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['ATF_LIV'][:,:,:,:],3),2),1))\n", " BFXPONSum.append(np.sum(np.sum(tmaskSOG[:,0,:,:]*e1t[:,0,:,:]*e2t[:,0,:,:]*f.variables['BFX_PON'][:,:,:],2),1))\n", " BFXDIATSum.append(np.sum(np.sum(tmaskSOG[:,0,:,:]*e1t[:,0,:,:]*e2t[:,0,:,:]*f.variables['BFX_DIAT'][:,:,:],2),1))\n", "ATFNO3Sum=np.concatenate(ATFNO3Sum,axis=0)\n", "ATFNH4Sum=np.concatenate(ATFNH4Sum,axis=0)\n", "ATFDONSum=np.concatenate(ATFDONSum,axis=0)\n", "ATFPONSum=np.concatenate(ATFPONSum,axis=0)\n", "ATFLIVSum=np.concatenate(ATFLIVSum,axis=0)\n", "BFXPONSum=np.concatenate(BFXPONSum,axis=0)\n", "BFXDIATSum=np.concatenate(BFXDIATSum,axis=0)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "PHSNO3Sum=list(); PHSNH4Sum=list(); PHSDONSum=list(); PHSPONSum=list(); PHSLIVSum=list();\n", "SMSNO3Sum=list(); SMSNH4Sum=list(); SMSDONSum=list(); SMSPONSum=list(); SMSLIVSum=list();\n", "for i,r in fD2list.iterrows():\n", " with nc.Dataset(r['paths']) as f:\n", " SMSNO3Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['SMS_NO3'][:,:,:,:],3),2),1))\n", " SMSNH4Sum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['SMS_NH4'][:,:,:,:],3),2),1))\n", " SMSDONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['SMS_DON'][:,:,:,:],3),2),1))\n", " SMSPONSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['SMS_PON'][:,:,:,:],3),2),1))\n", " SMSLIVSum.append(np.sum(np.sum(np.sum(tmaskSOG*f.variables['SMS_LIV'][:,:,:,:],3),2),1))\n", "SMSNO3Sum=np.concatenate(SMSNO3Sum,axis=0)\n", "SMSNH4Sum=np.concatenate(SMSNH4Sum,axis=0)\n", "SMSDONSum=np.concatenate(SMSDONSum,axis=0)\n", "SMSPONSum=np.concatenate(SMSPONSum,axis=0)\n", "SMSLIVSum=np.concatenate(SMSLIVSum,axis=0)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAALMAAACVCAYAAAAT4cvYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAQkklEQVR4nO2dXWwUV5bH/6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gCmVTu7B7HanwAQVwPSTcYATKh957Pe56RHzsc859Wsc2YzoWyz+tlewsrPdqUU+5uUev915N24qRvRdji/GU1UcIyMzbCL+gle/ull5oGyB/kEFSmIUy+ojudI1jhse8eJmO2hfGBTwLdqFC2oCDIqRvUEaTa2XaqxXcQshIZI3QAK4UbELIQGEbMQGkTMQmgQMQuhQcQshIb/B9Tia5l72/g4AAAAAElFTkSuQmCC\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "fig,ax=plt.subplots(1,1,figsize=(2.5,2))\n", "ax.set_position((.3,.2,.65,.75))\n", "ax.plot(SMSNO3Sum,ATFNO3Sum,'k.')\n", "ax.plot(SMSNH4Sum,ATFNH4Sum,'k.')\n", "ax.plot(SMSDONSum,ATFDONSum,'k.')\n", "ax.plot(SMSPONSum+BFXPONSum,ATFPONSum,'k.')\n", "ax.plot(SMSLIVSum+BFXDIATSum,ATFLIVSum,'k.')\n", "ax.plot(np.arange(-2e6,3e6,1e6),0.1111*np.arange(-2e6,3e6,1e6),'c-',label='y = 0.11 x')\n", "ax.set_xlabel('Biological Trend (mmol N s$^{-1}$)')\n", "ax.set_ylabel('Filter Trend (mmol N s$^{-1}$)')\n", "ax.set_xlim(-1.8e6,1.2e6)\n", "ax.set_ylim(-2e5,1.4e5)\n", "ax.set_aspect(9)\n", "fig.savefig('ATFvsBioPlot.eps',dpi=200)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python (py38)", "language": "python", "name": "py38" }, "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.8.1" } }, "nbformat": 4, "nbformat_minor": 2 }