{ "cells": [ { "cell_type": "markdown", "metadata": { "papermill": { "duration": 0.0094, "end_time": "2020-06-25T19:22:54.824135", "exception": false, "start_time": "2020-06-25T19:22:54.814735", "status": "completed" }, "tags": [] }, "source": [ "\n", "\n", "# Animated polar plot with oceanographic data\n", "\n", "**Original Notebook**:\n", "https://matplotlib.org/matplotblog/posts/animated-polar-plot/\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2020-06-25T19:22:54.847044Z", "iopub.status.busy": "2020-06-25T19:22:54.846462Z", "iopub.status.idle": "2020-06-25T19:22:56.768239Z", "shell.execute_reply": "2020-06-25T19:22:56.767820Z" }, "papermill": { "duration": 1.934521, "end_time": "2020-06-25T19:22:56.768317", "exception": false, "start_time": "2020-06-25T19:22:54.833796", "status": "completed" }, "tags": [ "hide-input", "hide_input" ] }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "\n", "from argopy import DataFetcher as ArgoDataFetcher\n", "\n", "argo_loader = ArgoDataFetcher(cache=True)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2020-06-25T19:22:56.785652Z", "iopub.status.busy": "2020-06-25T19:22:56.785206Z", "iopub.status.idle": "2020-06-25T19:23:00.439925Z", "shell.execute_reply": "2020-06-25T19:23:00.440268Z" }, "papermill": { "duration": 3.66531, "end_time": "2020-06-25T19:23:00.440370", "exception": false, "start_time": "2020-06-25T19:22:56.775060", "status": "completed" }, "tags": [ "hide-input", "hide_input" ] }, "outputs": [], "source": [ "# Query surface and 1000m temp in Med sea with argopy\n", "\n", "df1 = argo_loader.region(\n", " [-1.2, 29.0, 28.0, 46.0, 0, 10.0, \"2009-12\", \"2020-01\"]\n", ").to_xarray()\n", "df2 = argo_loader.region(\n", " [-1.2, 29.0, 28.0, 46.0, 975.0, 1025.0, \"2009-12\", \"2020-01\"]\n", ").to_xarray()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2020-06-25T19:23:00.457053Z", "iopub.status.busy": "2020-06-25T19:23:00.456614Z", "iopub.status.idle": "2020-06-25T19:23:00.458729Z", "shell.execute_reply": "2020-06-25T19:23:00.458241Z" }, "papermill": { "duration": 0.011654, "end_time": "2020-06-25T19:23:00.458819", "exception": false, "start_time": "2020-06-25T19:23:00.447165", "status": "completed" }, "tags": [ "parameters", "hide-input", "hide_input" ] }, "outputs": [], "source": [ "start_date = \"2010-01-04\"\n", "end_date = \"2020-01-07\"" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2020-06-25T19:23:00.475867Z", "iopub.status.busy": "2020-06-25T19:23:00.475401Z", "iopub.status.idle": "2020-06-25T19:23:00.477850Z", "shell.execute_reply": "2020-06-25T19:23:00.477317Z" }, "papermill": { "duration": 0.012077, "end_time": "2020-06-25T19:23:00.477940", "exception": false, "start_time": "2020-06-25T19:23:00.465863", "status": "completed" }, "tags": [ "injected-parameters" ] }, "outputs": [], "source": [ "# Parameters\n", "start_date = \"2016-01-01\"\n", "end_date = \"2020-01-03\"\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "execution": { "iopub.execute_input": "2020-06-25T19:23:00.497282Z", "iopub.status.busy": "2020-06-25T19:23:00.496829Z", "iopub.status.idle": "2020-06-25T19:23:00.498592Z", "shell.execute_reply": "2020-06-25T19:23:00.498954Z" }, "papermill": { "duration": 0.01382, "end_time": "2020-06-25T19:23:00.499058", "exception": false, "start_time": "2020-06-25T19:23:00.485238", "status": "completed" }, "tags": [ "hide-input", "hide_input" ] }, "outputs": [], "source": [ "# Weekly date array\n", "\n", "daterange = np.arange(start_date, end_date, dtype=\"datetime64[7D]\")\n", "dayoftheyear = pd.DatetimeIndex(\n", " np.array(daterange, dtype=\"datetime64[D]\") + 3\n", ").dayofyear # middle of the week\n", "\n", "activeyear = pd.DatetimeIndex(\n", " np.array(daterange, dtype=\"datetime64[D]\") + 3\n", ").year # extract year" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "execution": { "iopub.execute_input": "2020-06-25T19:23:00.518075Z", "iopub.status.busy": "2020-06-25T19:23:00.517629Z", "iopub.status.idle": "2020-06-25T19:23:00.519479Z", "shell.execute_reply": "2020-06-25T19:23:00.519874Z" }, "papermill": { "duration": 0.013536, "end_time": "2020-06-25T19:23:00.519980", "exception": false, "start_time": "2020-06-25T19:23:00.506444", "status": "completed" }, "tags": [ "hide-input", "hide_input" ] }, "outputs": [], "source": [ "# Init final arrays\n", "\n", "tsurf = np.zeros(len(daterange))\n", "t1000 = np.zeros(len(daterange))" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "execution": { "iopub.execute_input": "2020-06-25T19:23:00.542014Z", "iopub.status.busy": "2020-06-25T19:23:00.541472Z", "iopub.status.idle": "2020-06-25T19:23:08.091372Z", "shell.execute_reply": "2020-06-25T19:23:08.090817Z" }, "papermill": { "duration": 7.563813, "end_time": "2020-06-25T19:23:08.091473", "exception": false, "start_time": "2020-06-25T19:23:00.527660", "status": "completed" }, "tags": [ "hide-input", "hide_input" ] }, "outputs": [], "source": [ "# Filling arrays\n", "\n", "for i in range(len(daterange)):\n", " i1 = (df1[\"TIME\"] >= daterange[i]) & (df1[\"TIME\"] < daterange[i] + 7)\n", " i2 = (df2[\"TIME\"] >= daterange[i]) & (df2[\"TIME\"] < daterange[i] + 7)\n", " tsurf[i] = df1.where(i1, drop=True)[\"TEMP\"].mean().values\n", " t1000[i] = df2.where(i2, drop=True)[\"TEMP\"].mean().values" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "execution": { "iopub.execute_input": "2020-06-25T19:23:08.119382Z", "iopub.status.busy": "2020-06-25T19:23:08.118716Z", "iopub.status.idle": "2020-06-25T19:23:08.124891Z", "shell.execute_reply": "2020-06-25T19:23:08.124377Z" }, "papermill": { "duration": 0.024567, "end_time": "2020-06-25T19:23:08.124982", "exception": false, "start_time": "2020-06-25T19:23:08.100415", "status": "completed" }, "tags": [ "hide-input", "hide_input" ] }, "outputs": [ { "data": { "text/html": [ "
\n", " | date | \n", "tsurf | \n", "t1000 | \n", "
---|---|---|---|
0 | \n", "2015-12-31 | \n", "16.008982 | \n", "13.473844 | \n", "
1 | \n", "2016-01-07 | \n", "15.808208 | \n", "13.474958 | \n", "
2 | \n", "2016-01-14 | \n", "15.696154 | \n", "13.482945 | \n", "
3 | \n", "2016-01-21 | \n", "15.573696 | \n", "13.489998 | \n", "
4 | \n", "2016-01-28 | \n", "15.446599 | \n", "13.481531 | \n", "