{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import arrow as arw\n", "import datetime\n", "from erddapy import ERDDAP\n", "import gsw\n", "import matplotlib.pyplot as plt\n", "import netCDF4 as nc\n", "import numpy as np\n", "import pandas as pd\n", "import xarray as xr\n", "import seaborn as sns\n", "\n", "from salishsea_tools import places, teos_tools\n", "\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Get Observations" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "server = \"https://salishsea.eos.ubc.ca/erddap\"\n", "protocol = 'tabledap'\n", "dataset_ids = [\"ubcONCSCVIPCTD15mV1\", \"ubcONCSEVIPCTD15mV1\", \"ubcONCLSBBLCTD15mV1\", \"ubcONCUSDDLCTD15mV1\"]\n", "nodes = [\"Central node\", \"Delta BBL node\", \"Delta DDL node\", \"East node\"]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "variables = [\n", " \"latitude\",\n", " \"longitude\",\n", " \"temperature\",\n", " \"salinity\",\n", " \"time\",\n", " \"depth\",\n", " ]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "start_date = '2015-01-01T00:00:00Z'\n", "end_date = '2018-12-31T23:30:00Z'\n", "\n", "constraints = {\n", " \"time>=\": start_date,\n", " \"time<=\": end_date,\n", " }\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "obs = ERDDAP(server=server, protocol=protocol)\n", "obs.dataset_id = dataset_ids[0]\n", "obs.variables = variables\n", "obs.constraints = constraints\n", "sal_obs = obs.to_pandas(index_col=\"time (UTC)\", parse_dates=True,).dropna()\n", "sal_obs['conservative temperature (oC)'] = gsw.CT_from_pt(sal_obs['salinity (g/kg)'], sal_obs['temperature (degrees_Celcius)'] )\n", "sal_obs['dtUTC'] = sal_obs.index.tz_localize(None)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | latitude (degrees_north) | \n", "longitude (degrees_east) | \n", "temperature (degrees_Celcius) | \n", "salinity (g/kg) | \n", "depth (m) | \n", "conservative temperature (oC) | \n", "dtUTC | \n", "
---|---|---|---|---|---|---|---|
time (UTC) | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
2015-01-01 00:00:00+00:00 | \n", "49.040067 | \n", "-123.425825 | \n", "9.382127 | \n", "31.281386 | \n", "294 | \n", "9.439521 | \n", "2015-01-01 00:00:00 | \n", "
2015-01-01 00:15:00+00:00 | \n", "49.040067 | \n", "-123.425825 | \n", "9.380800 | \n", "31.282002 | \n", "294 | \n", "9.438177 | \n", "2015-01-01 00:15:00 | \n", "
2015-01-01 00:30:00+00:00 | \n", "49.040067 | \n", "-123.425825 | \n", "9.376987 | \n", "31.283275 | \n", "294 | \n", "9.434324 | \n", "2015-01-01 00:30:00 | \n", "
2015-01-01 00:45:00+00:00 | \n", "49.040067 | \n", "-123.425825 | \n", "9.370100 | \n", "31.285338 | \n", "294 | \n", "9.427370 | \n", "2015-01-01 00:45:00 | \n", "
2015-01-01 01:00:00+00:00 | \n", "49.040067 | \n", "-123.425825 | \n", "9.365593 | \n", "31.286671 | \n", "294 | \n", "9.422819 | \n", "2015-01-01 01:00:00 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2018-12-31 22:30:00+00:00 | \n", "49.040067 | \n", "-123.425825 | \n", "9.773498 | \n", "31.397133 | \n", "294 | \n", "9.830717 | \n", "2018-12-31 22:30:00 | \n", "
2018-12-31 22:45:00+00:00 | \n", "49.040067 | \n", "-123.425825 | \n", "9.773646 | \n", "31.397576 | \n", "294 | \n", "9.830857 | \n", "2018-12-31 22:45:00 | \n", "
2018-12-31 23:00:00+00:00 | \n", "49.040067 | \n", "-123.425825 | \n", "9.773969 | \n", "31.399504 | \n", "294 | \n", "9.831148 | \n", "2018-12-31 23:00:00 | \n", "
2018-12-31 23:15:00+00:00 | \n", "49.040067 | \n", "-123.425825 | \n", "9.774080 | \n", "31.400561 | \n", "294 | \n", "9.831241 | \n", "2018-12-31 23:15:00 | \n", "
2018-12-31 23:30:00+00:00 | \n", "49.040067 | \n", "-123.425825 | \n", "9.774178 | \n", "31.401886 | \n", "294 | \n", "9.831316 | \n", "2018-12-31 23:30:00 | \n", "
99780 rows × 7 columns
\n", "