{ "cells": [ { "cell_type": "markdown", "metadata": { "papermill": { "duration": 0.01072, "end_time": "2020-06-25T19:22:10.142657", "exception": false, "start_time": "2020-06-25T19:22:10.131937", "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:10.164961Z", "iopub.status.busy": "2020-06-25T19:22:10.164366Z", "iopub.status.idle": "2020-06-25T19:22:12.604873Z", "shell.execute_reply": "2020-06-25T19:22:12.605225Z" }, "papermill": { "duration": 2.453614, "end_time": "2020-06-25T19:22:12.605357", "exception": false, "start_time": "2020-06-25T19:22:10.151743", "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:12.622983Z", "iopub.status.busy": "2020-06-25T19:22:12.622573Z", "iopub.status.idle": "2020-06-25T19:22:16.757236Z", "shell.execute_reply": "2020-06-25T19:22:16.756238Z" }, "papermill": { "duration": 4.144164, "end_time": "2020-06-25T19:22:16.757371", "exception": false, "start_time": "2020-06-25T19:22:12.613207", "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:22:16.789444Z", "iopub.status.busy": "2020-06-25T19:22:16.788655Z", "iopub.status.idle": "2020-06-25T19:22:16.790897Z", "shell.execute_reply": "2020-06-25T19:22:16.791390Z" }, "papermill": { "duration": 0.016357, "end_time": "2020-06-25T19:22:16.791519", "exception": false, "start_time": "2020-06-25T19:22:16.775162", "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:22:16.814232Z", "iopub.status.busy": "2020-06-25T19:22:16.813642Z", "iopub.status.idle": "2020-06-25T19:22:16.815741Z", "shell.execute_reply": "2020-06-25T19:22:16.815206Z" }, "papermill": { "duration": 0.014733, "end_time": "2020-06-25T19:22:16.815846", "exception": false, "start_time": "2020-06-25T19:22:16.801113", "status": "completed" }, "tags": [ "injected-parameters" ] }, "outputs": [], "source": [ "# Parameters\n", "start_date = \"2010-01-01\"\n", "end_date = \"2015-01-03\"\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "execution": { "iopub.execute_input": "2020-06-25T19:22:16.839143Z", "iopub.status.busy": "2020-06-25T19:22:16.838617Z", "iopub.status.idle": "2020-06-25T19:22:16.840896Z", "shell.execute_reply": "2020-06-25T19:22:16.841314Z" }, "papermill": { "duration": 0.017058, "end_time": "2020-06-25T19:22:16.841428", "exception": false, "start_time": "2020-06-25T19:22:16.824370", "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:22:16.864126Z", "iopub.status.busy": "2020-06-25T19:22:16.863560Z", "iopub.status.idle": "2020-06-25T19:22:16.866159Z", "shell.execute_reply": "2020-06-25T19:22:16.865667Z" }, "papermill": { "duration": 0.015322, "end_time": "2020-06-25T19:22:16.866261", "exception": false, "start_time": "2020-06-25T19:22:16.850939", "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:22:16.890589Z", "iopub.status.busy": "2020-06-25T19:22:16.890083Z", "iopub.status.idle": "2020-06-25T19:22:25.343005Z", "shell.execute_reply": "2020-06-25T19:22:25.342357Z" }, "papermill": { "duration": 8.468353, "end_time": "2020-06-25T19:22:25.343134", "exception": false, "start_time": "2020-06-25T19:22:16.874781", "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:22:25.372453Z", "iopub.status.busy": "2020-06-25T19:22:25.371919Z", "iopub.status.idle": "2020-06-25T19:22:25.379182Z", "shell.execute_reply": "2020-06-25T19:22:25.379674Z" }, "papermill": { "duration": 0.027522, "end_time": "2020-06-25T19:22:25.379800", "exception": false, "start_time": "2020-06-25T19:22:25.352278", "status": "completed" }, "tags": [ "hide-input", "hide_input" ] }, "outputs": [ { "data": { "text/html": [ "
\n", " | date | \n", "tsurf | \n", "t1000 | \n", "
---|---|---|---|
0 | \n", "2009-12-31 | \n", "15.724999 | \n", "13.306132 | \n", "
1 | \n", "2010-01-07 | \n", "15.530416 | \n", "13.315657 | \n", "
2 | \n", "2010-01-14 | \n", "15.307376 | \n", "13.300347 | \n", "
3 | \n", "2010-01-21 | \n", "14.954196 | \n", "13.300646 | \n", "
4 | \n", "2010-01-28 | \n", "14.708815 | \n", "13.300274 | \n", "