{ "cells": [ { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from salishsea_tools import evaltools as et, viz_tools\n", "import cmocean as cmo\n", "import datetime as dt\n", "import netCDF4 as nc\n", "import matplotlib.dates as mdates\n", "import matplotlib as mpl\n", "import matplotlib.gridspec as gridspec\n", "from matplotlib.colors import LogNorm\n", "import cmocean\n", "import pandas as pd\n", "\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### definitions for matching model output" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# path to model files:\n", "PATH= '/results/SalishSea/nowcast-green.201812/'\n", "\n", "# start and end dates for analysis:\n", "start_date = dt.datetime(2015,1,1)\n", "end_date = dt.datetime(2016,1,1)\n", "\n", "# number of days per model file:\n", "flen=1\n", "\n", "# dictionary mapping desired model variables to the file types where they are found\n", "filemap={'nitrate':'ptrc_T','silicon':'ptrc_T','ammonium':'ptrc_T','diatoms':'ptrc_T','ciliates':'ptrc_T',\n", " 'flagellates':'ptrc_T','vosaline':'grid_T','votemper':'grid_T'}\n", "\n", "# dictionary mapping model file types to their time resolution in hours (1 is hourly files, 24 is daily)\n", "fdict={'ptrc_T':1,'grid_T':1}\n", "\n", "# results format\n", "# -- nowcast: files like 01jan15/SalishSea_1h_20150101_20150101_ptrc_T.nc\n", "# -- long: files like SalishSea_1h_20150206_20150804_ptrc_T_20150427-20150506.nc, all in one directory\n", "namfmt='nowcast'\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### load PSF data and create csv file" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "# load PSF bottle data (returns pandas dataframe)\n", "# NO23 is nitrate+nitrate, Si is Silicate; Chl is chlorophyll; Z is depth (m); dtUTC is datetime in UTC\n", "# SA is reference salinity (g/kg), CT is Conservative Temperature (deg C)\n", "df1=et.loadPSF(loadCTD=True)\n", "df1.drop(columns=['pLat','pLon','tdiffH'])\n", "print(len(df1))\n", "df1.head()" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "df1.to_csv('/data/eolson/results/MEOPAR/oldDBs/PSFBotChl.csv',index=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### load csv file" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3558\n" ] }, { "data": { "text/html": [ "
\n", " | Lat | \n", "Lon | \n", "NO23 | \n", "PO4 | \n", "Si | \n", "Station | \n", "Z | \n", "dtUTC | \n", "Chl | \n", "Depth_m | \n", "Phaeo | \n", "SA | \n", "CT | \n", "pLat | \n", "pLon | \n", "tdiffH | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "49.608333 | \n", "-124.866667 | \n", "18.65 | \n", "1.459 | \n", "68.43 | \n", "BS1 | \n", "2.0 | \n", "2015-02-18 23:07:00 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "24.3455 | \n", "8.986387 | \n", "49.603803 | \n", "-124.867129 | \n", "0.059306 | \n", "
1 | \n", "49.608333 | \n", "-124.866667 | \n", "26.62 | \n", "2.175 | \n", "55.73 | \n", "BS1 | \n", "20.0 | \n", "2015-02-18 23:07:00 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "28.0035 | \n", "8.810689 | \n", "49.603803 | \n", "-124.867129 | \n", "0.059306 | \n", "
2 | \n", "49.608333 | \n", "-124.866667 | \n", "16.25 | \n", "1.809 | \n", "39.14 | \n", "BS1 | \n", "2.0 | \n", "2015-03-21 22:55:00 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "26.9730 | \n", "9.675332 | \n", "49.608083 | \n", "-124.865769 | \n", "0.060139 | \n", "
3 | \n", "49.608333 | \n", "-124.866667 | \n", "16.83 | \n", "2.069 | \n", "39.11 | \n", "BS1 | \n", "20.0 | \n", "2015-03-21 22:55:00 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "28.3310 | \n", "9.113702 | \n", "49.608083 | \n", "-124.865769 | \n", "0.060139 | \n", "
4 | \n", "49.608333 | \n", "-124.866667 | \n", "24.27 | \n", "0.551 | \n", "49.90 | \n", "BS1 | \n", "20.0 | \n", "2015-04-05 23:10:00 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "28.6415 | \n", "9.296229 | \n", "49.607844 | \n", "-124.867736 | \n", "0.029306 | \n", "