{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## DFO Nutrient Comparison" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import os\n", "import pandas as pd\n", "import netCDF4 as nc\n", "import datetime as dt\n", "from salishsea_tools import evaltools as et, viz_tools\n", "import gsw\n", "import matplotlib.gridspec as gridspec\n", "import matplotlib as mpl\n", "import matplotlib.dates as mdates\n", "import cmocean as cmo\n", "import scipy.interpolate as sinterp\n", "import pickle\n", "import cmocean\n", "from matplotlib.colors import LogNorm\n", "\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", "\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "PATH= '/results2/SalishSea/nowcast-green.201905/'\n", "modver='HC1905'\n", "start_date = dt.datetime(2013,1,1)\n", "end_date = dt.datetime(2017,1,1)\n", "flen=1\n", "namfmt='nowcast'\n", "#varmap={'N':'nitrate','Si':'silicon','Ammonium':'ammonium'}\n", "filemap={'vosaline':'grid_T','votemper':'grid_T'}\n", "#gridmap={'nitrate':'tmask','silicon':'tmask','ammonium':'tmask'}\n", "fdict={'ptrc_T':1,'grid_T':1}\n", "rematch=True\n", "if rematch==True:\n", " df1=et.loadDFOCTD()\n", " df1.head()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(Lat,Lon)= 48.95583333333333 -125.10966666666667 not matched to domain\n", "(Lat,Lon)= 48.963 -125.115 not matched to domain\n", "(Lat,Lon)= 48.96383333333333 -125.1145 not matched to domain\n", "(Lat,Lon)= 48.964666666666666 -125.12581666666667 not matched to domain\n", "(Lat,Lon)= 49.01083333333333 -125.17 not matched to domain\n", "(Lat,Lon)= 49.011 -125.17083333333333 not matched to domain\n", "(Lat,Lon)= 49.01116666666667 -125.17 not matched to domain\n", "(Lat,Lon)= 49.01133333333333 -125.17033333333333 not matched to domain\n", "(Lat,Lon)= 49.01133333333333 -125.17 not matched to domain\n", "(Lat,Lon)= 49.020833333333336 -125.1565 not matched to domain\n", "(Lat,Lon)= 49.021 -125.157 not matched to domain\n", "(Lat,Lon)= 49.021 -125.15666666666667 not matched to domain\n", "(Lat,Lon)= 49.021 -125.1565 not matched to domain\n", "(Lat,Lon)= 49.021 -125.15616666666666 not matched to domain\n", "(Lat,Lon)= 49.029333333333334 -125.15333333333334 not matched to domain\n", "(Lat,Lon)= 49.0295 -125.15266666666666 not matched to domain\n", "(Lat,Lon)= 49.029666666666664 -125.15333333333334 not matched to domain\n", "(Lat,Lon)= 49.029666666666664 -125.153 not matched to domain\n", "(Lat,Lon)= 49.029666666666664 -125.1525 not matched to domain\n", "(Lat,Lon)= 49.03033333333333 -125.15333333333334 not matched to domain\n", "(Lat,Lon)= 49.04233333333333 -125.15283333333333 not matched to domain\n", "(Lat,Lon)= 49.0425 -125.1525 not matched to domain\n", "(Lat,Lon)= 49.0425 -125.152 not matched to domain\n", "(Lat,Lon)= 49.0425 -125.1515 not matched to domain\n", "(Lat,Lon)= 49.04266666666667 -125.15216666666667 not matched to domain\n", "(Lat,Lon)= 49.042833333333334 -125.15266666666666 not matched to domain\n", "(Lat,Lon)= 49.052 -125.14283333333333 not matched to domain\n", "(Lat,Lon)= 49.052 -125.1425 not matched to domain\n", "(Lat,Lon)= 49.0525 -125.14316666666667 not matched to domain\n", "(Lat,Lon)= 49.0525 -125.143 not matched to domain\n", "(Lat,Lon)= 49.0525 -125.14266666666667 not matched to domain\n", "(Lat,Lon)= 49.053 -125.14316666666667 not matched to domain\n", "(Lat,Lon)= 49.07083333333333 -125.157 not matched to domain\n", "(Lat,Lon)= 49.07083333333333 -125.15666666666667 not matched to domain\n", "(Lat,Lon)= 49.071333333333335 -125.15716666666667 not matched to domain\n", "(Lat,Lon)= 49.071333333333335 -125.15683333333334 not matched to domain\n", "(Lat,Lon)= 49.071666666666665 -125.157 not matched to domain\n", "(Lat,Lon)= 49.083 -125.17183333333334 not matched to domain\n", "(Lat,Lon)= 49.08316666666666 -125.17166666666667 not matched to domain\n", "(Lat,Lon)= 49.083333333333336 -125.17183333333334 not matched to domain\n", "(Lat,Lon)= 49.08383333333333 -125.17233333333333 not matched to domain\n", "(Lat,Lon)= 49.08416666666667 -125.173 not matched to domain\n", "(Lat,Lon)= 49.09166666666667 -125.19466666666666 not matched to domain\n", "(Lat,Lon)= 49.091833333333334 -125.19416666666666 not matched to domain\n", "(Lat,Lon)= 49.29533333333333 -122.9685 not matched to domain\n", "(Lat,Lon)= 49.29966666666667 -123.09016666666666 not matched to domain\n", "(Lat,Lon)= 49.315666666666665 -122.9375 not matched to domain\n", "(Lat,Lon)= 49.969833333333334 -124.68516666666666 not matched to domain\n", "(Lat,Lon)= 49.97 -124.68516666666666 not matched to domain\n", "(Lat,Lon)= 49.97083333333333 -124.68266666666666 not matched to domain\n", "(Lat,Lon)= 49.97083333333333 -124.6825 not matched to domain\n", "(Lat,Lon)= 49.9725 -124.68716666666667 not matched to domain\n", "(Lat,Lon)= 49.97266666666667 -124.686 not matched to domain\n", "(Lat,Lon)= 49.972833333333334 -124.686 not matched to domain\n", "(Lat,Lon)= 49.9745 -124.68083333333334 not matched to domain\n", "(Lat,Lon)= 49.974666666666664 -124.68133333333333 not matched to domain\n", "(Lat,Lon)= 49.9785 -124.691 not matched to domain\n", "(Lat,Lon)= 49.978833333333334 -124.68883333333333 not matched to domain\n", "(Lat,Lon)= 49.979 -124.68883333333333 not matched to domain\n", "(Lat,Lon)= 49.979 -124.68833333333333 not matched to domain\n", "(Lat,Lon)= 49.98 -124.68666666666667 not matched to domain\n", "(Lat,Lon)= 49.98016666666667 -124.68666666666667 not matched to domain\n", "(Lat,Lon)= 49.982 -124.69716666666666 not matched to domain\n", "(Lat,Lon)= 49.982 -124.6925 not matched to domain\n", "(Lat,Lon)= 49.983333333333334 -124.69383333333333 not matched to domain\n", "(Lat,Lon)= 49.98433333333333 -124.68966666666667 not matched to domain\n", "(Lat,Lon)= 49.98466666666667 -124.68883333333333 not matched to domain\n", "(Lat,Lon)= 49.98833333333333 -124.70416666666667 not matched to domain\n", "(Lat,Lon)= 49.9885 -124.70416666666667 not matched to domain\n", "(Lat,Lon)= 49.98866666666667 -124.6995 not matched to domain\n", "(Lat,Lon)= 49.98866666666667 -124.69916666666667 not matched to domain\n", "(Lat,Lon)= 49.9915 -124.6955 not matched to domain\n", "(Lat,Lon)= 49.993 -124.712 not matched to domain\n", "(Lat,Lon)= 49.99333333333333 -124.71183333333333 not matched to domain\n", "(Lat,Lon)= 49.99483333333333 -124.709 not matched to domain\n", "(Lat,Lon)= 49.995333333333335 -124.70866666666667 not matched to domain\n", "(Lat,Lon)= 49.99633333333333 -124.70466666666667 not matched to domain\n", "(Lat,Lon)= 49.9965 -124.70483333333334 not matched to domain\n", "(Lat,Lon)= 50.00416666666667 -124.71883333333334 not matched to domain\n", "(Lat,Lon)= 50.004333333333335 -124.71866666666666 not matched to domain\n", "(Lat,Lon)= 50.004666666666665 -124.71333333333334 not matched to domain\n", "(Lat,Lon)= 50.00516666666667 -124.7145 not matched to domain\n", "(Lat,Lon)= 50.00633333333333 -124.70683333333334 not matched to domain\n", "(Lat,Lon)= 50.00683333333333 -124.70616666666666 not matched to domain\n", "(Lat,Lon)= 50.01683333333333 -124.72416666666666 not matched to domain\n", "(Lat,Lon)= 50.01733333333333 -124.7245 not matched to domain\n", "(Lat,Lon)= 50.01766666666666 -124.72116666666666 not matched to domain\n", "(Lat,Lon)= 50.01766666666666 -124.72083333333333 not matched to domain\n", "(Lat,Lon)= 50.0195 -124.71433333333333 not matched to domain\n", "(Lat,Lon)= 50.019666666666666 -124.71483333333333 not matched to domain\n", "(Lat,Lon)= 50.02 -124.7385 not matched to domain\n", "(Lat,Lon)= 50.02016666666667 -124.73866666666666 not matched to domain\n", "(Lat,Lon)= 50.0225 -124.741 not matched to domain\n", "(Lat,Lon)= 50.022666666666666 -124.741 not matched to domain\n", "(Lat,Lon)= 50.025 -124.74383333333333 not matched to domain\n", "(Lat,Lon)= 50.025333333333336 -124.74433333333333 not matched to domain\n", "(Lat,Lon)= 50.027 -124.74683333333333 not matched to domain\n", "(Lat,Lon)= 50.02883333333333 -124.7325 not matched to domain\n", "(Lat,Lon)= 50.02916666666667 -124.7395 not matched to domain\n", "(Lat,Lon)= 50.02916666666667 -124.7385 not matched to domain\n", "(Lat,Lon)= 50.032333333333334 -124.72933333333333 not matched to domain\n", "(Lat,Lon)= 50.032833333333336 -124.72966666666667 not matched to domain\n", "(Lat,Lon)= 50.034666666666666 -124.74383333333333 not matched to domain\n", "(Lat,Lon)= 50.03616666666667 -124.72116666666666 not matched to domain\n", "(Lat,Lon)= 50.0365 -124.72 not matched to domain\n", "(Lat,Lon)= 50.040333333333336 -124.71616666666667 not matched to domain\n", "(Lat,Lon)= 50.04183333333334 -124.71916666666667 not matched to domain\n", "(Lat,Lon)= 50.04366666666667 -124.72283333333333 not matched to domain\n", "(Lat,Lon)= 50.05 -124.7225 not matched to domain\n", "(Lat,Lon)= 50.050333333333334 -124.71683333333333 not matched to domain\n", "(Lat,Lon)= 50.05166666666667 -124.713 not matched to domain\n", "(Lat,Lon)= 50.057 -124.71816666666666 not matched to domain\n", "(Lat,Lon)= 50.05766666666667 -124.70983333333334 not matched to domain\n", "(Lat,Lon)= 50.058 -124.72283333333333 not matched to domain\n", "(Lat,Lon)= 50.058 -124.717 not matched to domain\n", "(Lat,Lon)= 50.0655 -124.70916666666666 not matched to domain\n", "(Lat,Lon)= 50.066 -124.71333333333334 not matched to domain\n", "(Lat,Lon)= 50.06733333333333 -124.72016666666667 not matched to domain\n", "(Lat,Lon)= 50.0795 -124.718 not matched to domain\n", "(Lat,Lon)= 50.07966666666667 -124.71166666666667 not matched to domain\n", "(Lat,Lon)= 50.07983333333333 -124.71416666666667 not matched to domain\n", "(Lat,Lon)= 50.17333333333333 -125.34011666666666 not matched to domain\n", "(Lat,Lon)= 50.40533333333333 -125.76346666666667 not matched to domain\n", "(Lat,Lon)= 50.45666666666666 -126.1651 not matched to domain\n", "(Lat,Lon)= 50.45666666666666 -126.1639 not matched to domain\n", "(Lat,Lon)= 50.45666666666666 -126.16348333333333 not matched to domain\n", "(Lat,Lon)= 50.45713333333333 -126.16475 not matched to domain\n", "(Lat,Lon)= 50.45718333333333 -126.16443333333333 not matched to domain\n", "(Lat,Lon)= 50.45726666666667 -126.16365 not matched to domain\n", "(Lat,Lon)= 50.45745 -126.16433333333333 not matched to domain\n", "(Lat,Lon)= 50.458016666666666 -126.15373333333334 not matched to domain\n", "(Lat,Lon)= 50.471666666666664 -126.1591 not matched to domain\n", "(Lat,Lon)= 50.4735 -126.16683333333333 not matched to domain\n", "(Lat,Lon)= 50.48016666666667 -126.19516666666667 not matched to domain\n", "(Lat,Lon)= 50.48016666666667 -126.1615 not matched to domain\n", "(Lat,Lon)= 50.48383333333334 -126.18633333333334 not matched to domain\n", "(Lat,Lon)= 50.4845 -126.26616666666666 not matched to domain\n", "(Lat,Lon)= 50.48453333333333 -126.39215 not matched to domain\n", "(Lat,Lon)= 50.48683333333334 -126.23916666666666 not matched to domain\n", "(Lat,Lon)= 50.487 -126.24116666666667 not matched to domain\n", "(Lat,Lon)= 50.48883333333333 -126.35466666666667 not matched to domain\n", "(Lat,Lon)= 50.48883333333333 -126.33266666666667 not matched to domain\n", "(Lat,Lon)= 50.49166666666667 -126.37233333333333 not matched to domain\n", "(Lat,Lon)= 50.49166666666667 -126.2175 not matched to domain\n", "(Lat,Lon)= 50.49366666666667 -126.241 not matched to domain\n", "(Lat,Lon)= 50.49733333333333 -126.349 not matched to domain\n", "(Lat,Lon)= 50.4975 -126.347 not matched to domain\n", "(Lat,Lon)= 50.4985 -126.272 not matched to domain\n", "(Lat,Lon)= 50.504333333333335 -126.4035 not matched to domain\n", "(Lat,Lon)= 50.50528333333333 -126.25658333333334 not matched to domain\n", "(Lat,Lon)= 50.60106666666667 -126.35993333333333 not matched to domain\n", "(Lat,Lon)= 50.6117 -126.2906 not matched to domain\n", "(Lat,Lon)= 50.629933333333334 -126.39663333333333 not matched to domain\n", "(Lat,Lon)= 50.638666666666666 -126.30083333333333 not matched to domain\n", "(Lat,Lon)= 50.66675 -126.44075 not matched to domain\n", "(Lat,Lon)= 50.7607 -126.5075 not matched to domain\n", "(Lat,Lon)= 50.77965 -126.62056666666666 not matched to domain\n", "(Lat,Lon)= 50.8272 -126.5612 not matched to domain\n", "(Lat,Lon)= 50.83016666666666 -126.26748333333333 not matched to domain\n", "(Lat,Lon)= 50.83936666666666 -126.26266666666666 not matched to domain\n", "(Lat,Lon)= 50.84276666666667 -126.47793333333334 not matched to domain\n", "(Lat,Lon)= 50.87348333333333 -126.72328333333333 not matched to domain\n", "(Lat,Lon)= 50.88633333333333 -126.59383333333334 not matched to domain\n", "(Lat,Lon)= 51.67483333333333 -127.28466666666667 not matched to domain\n", "(Lat,Lon)= 51.67483333333333 -127.2845 not matched to domain\n", "(Lat,Lon)= 51.675333333333334 -127.28516666666667 not matched to domain\n", "(Lat,Lon)= 51.67583333333333 -127.28483333333334 not matched to domain\n", "(Lat,Lon)= 51.676833333333335 -127.29916666666666 not matched to domain\n", "(Lat,Lon)= 51.67733333333334 -127.33316666666667 not matched to domain\n", "(Lat,Lon)= 51.678 -127.334 not matched to domain\n", "(Lat,Lon)= 51.67816666666667 -127.334 not matched to domain\n", "(Lat,Lon)= 51.678666666666665 -127.33216666666667 not matched to domain\n", "progress: 0.0%\n", "progress: 0.979274631694811%\n", "progress: 1.958549263389622%\n", "progress: 2.937823895084433%\n", "progress: 3.917098526779244%\n", "progress: 4.896373158474055%\n", "progress: 5.875647790168866%\n", "progress: 6.854922421863677%\n", "progress: 7.834197053558488%\n", "progress: 8.8134716852533%\n", "progress: 9.79274631694811%\n", "progress: 10.772020948642922%\n", "progress: 11.751295580337732%\n", "progress: 12.730570212032543%\n", "progress: 13.709844843727353%\n", "progress: 14.689119475422165%\n", "progress: 15.668394107116976%\n", "progress: 16.647668738811788%\n", "progress: 17.6269433705066%\n", "progress: 18.60621800220141%\n", "progress: 19.58549263389622%\n", "progress: 20.56476726559103%\n", "progress: 21.544041897285844%\n", "progress: 22.52331652898065%\n", "progress: 23.502591160675465%\n", "progress: 24.481865792370275%\n", "progress: 25.461140424065086%\n", "progress: 26.440415055759896%\n", "progress: 27.419689687454706%\n", "progress: 28.39896431914952%\n", "progress: 29.37823895084433%\n", "progress: 30.35751358253914%\n", "progress: 31.336788214233952%\n", "progress: 32.31606284592876%\n", "progress: 33.295337477623576%\n", "progress: 34.27461210931838%\n", "progress: 35.2538867410132%\n", "progress: 36.233161372708004%\n", "progress: 37.21243600440282%\n", "progress: 38.19171063609763%\n", "progress: 39.17098526779244%\n", "progress: 40.15025989948725%\n", "progress: 41.12953453118206%\n", "progress: 42.108809162876874%\n", "progress: 43.08808379457169%\n", "progress: 44.067358426266495%\n", "progress: 45.0466330579613%\n", "progress: 46.02590768965612%\n", "progress: 47.00518232135093%\n", "progress: 47.984456953045736%\n", "progress: 48.96373158474055%\n", "progress: 49.94300621643536%\n", "progress: 50.92228084813017%\n", "progress: 51.90155547982498%\n", "progress: 52.88083011151979%\n", "progress: 53.860104743214606%\n", "progress: 54.83937937490941%\n", "progress: 55.81865400660423%\n", "progress: 56.79792863829904%\n", "progress: 57.77720326999385%\n", "progress: 58.75647790168866%\n", "progress: 59.73575253338347%\n", "progress: 60.71502716507828%\n", "progress: 61.6943017967731%\n", "progress: 62.673576428467904%\n", "progress: 63.65285106016272%\n", "progress: 64.63212569185752%\n", "progress: 65.61140032355233%\n", "progress: 66.59067495524715%\n", "progress: 67.56994958694196%\n", "progress: 68.54922421863677%\n", "progress: 69.52849885033157%\n", "progress: 70.5077734820264%\n", "progress: 71.4870481137212%\n", "progress: 72.46632274541601%\n", "progress: 73.44559737711083%\n", "progress: 74.42487200880564%\n", "progress: 75.40414664050044%\n", "progress: 76.38342127219526%\n", "progress: 77.36269590389007%\n", "progress: 78.34197053558488%\n", "progress: 79.3212451672797%\n", "progress: 80.3005197989745%\n", "progress: 81.27979443066931%\n", "progress: 82.25906906236412%\n", "progress: 83.23834369405894%\n", "progress: 84.21761832575375%\n", "progress: 85.19689295744855%\n", "progress: 86.17616758914338%\n", "progress: 87.15544222083818%\n", "progress: 88.13471685253299%\n", "progress: 89.11399148422781%\n", "progress: 90.0932661159226%\n", "progress: 91.07254074761742%\n", "progress: 92.05181537931225%\n", "progress: 93.03109001100705%\n", "progress: 94.01036464270186%\n", "progress: 94.98963927439667%\n", "progress: 95.96891390609147%\n", "progress: 96.9481885377863%\n", "progress: 97.9274631694811%\n", "progress: 98.90673780117592%\n", "progress: 99.88601243287071%\n" ] } ], "source": [ "\n", "saveloc='/data/eolson/MEOPAR/SS36runs/calcFiles/evalMatches/'\n", "fname=f'data_DFOCTD_{modver}_{start_date.strftime(\"%Y%m%d\")}_{end_date.strftime(\"%Y%m%d\")}'\n", "if rematch==True:\n", " data=et.matchData(df1,filemap, fdict, start_date, end_date, namfmt, PATH, flen)\n", " pickle.dump(data,open(os.path.join(saveloc,fname)+'.pkl','wb'))\n", "else:\n", " data=pickle.load(open(os.path.join(saveloc,fname)+'.pkl','rb'))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | Year | \n", "Month | \n", "Day | \n", "Hour | \n", "Lat | \n", "Lon | \n", "Z | \n", "SA | \n", "CT | \n", "Fluor | \n", "dtUTC | \n", "j | \n", "i | \n", "mod_vosaline | \n", "mod_votemper | \n", "k | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "2013.0 | \n", "1.0 | \n", "10.0 | \n", "17.118056 | \n", "49.329667 | \n", "-124.081 | \n", "0.892338 | \n", "27.814801 | \n", "6.753649 | \n", "NaN | \n", "2013-01-10 17:07:05 | \n", "526 | \n", "206 | \n", "28.452301 | \n", "7.408990 | \n", "0 | \n", "
| 1 | \n", "2013.0 | \n", "1.0 | \n", "10.0 | \n", "17.118056 | \n", "49.329667 | \n", "-124.081 | \n", "1.883821 | \n", "27.826002 | \n", "6.762110 | \n", "NaN | \n", "2013-01-10 17:07:05 | \n", "526 | \n", "206 | \n", "28.452488 | \n", "7.410102 | \n", "1 | \n", "
| 2 | \n", "2013.0 | \n", "1.0 | \n", "10.0 | \n", "17.118056 | \n", "49.329667 | \n", "-124.081 | \n", "2.974446 | \n", "27.842222 | \n", "6.764341 | \n", "NaN | \n", "2013-01-10 17:07:05 | \n", "526 | \n", "206 | \n", "28.452883 | \n", "7.411254 | \n", "2 | \n", "
| 3 | \n", "2013.0 | \n", "1.0 | \n", "10.0 | \n", "17.118056 | \n", "49.329667 | \n", "-124.081 | \n", "4.065065 | \n", "27.901148 | \n", "6.812357 | \n", "NaN | \n", "2013-01-10 17:07:05 | \n", "526 | \n", "206 | \n", "28.454327 | \n", "7.413784 | \n", "4 | \n", "
| 4 | \n", "2013.0 | \n", "1.0 | \n", "10.0 | \n", "17.118056 | \n", "49.329667 | \n", "-124.081 | \n", "4.957386 | \n", "28.036150 | \n", "6.874438 | \n", "NaN | \n", "2013-01-10 17:07:05 | \n", "526 | \n", "206 | \n", "28.454327 | \n", "7.413784 | \n", "4 | \n", "