{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# TECxTMS_2F (Total electron content)\n", "\n", "> Abstract: Access to the total electric contents (level 2 product)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load_ext watermark\n", "%watermark -i -v -p viresclient,pandas,xarray,matplotlib" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from viresclient import SwarmRequest\n", "import datetime as dt\n", "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "\n", "request = SwarmRequest()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## TECxTMS_2F product information\n", "\n", "Derived total electron content (TEC) \n", "\n", "Documentation:\n", "- https://earth.esa.int/web/guest/missions/esa-eo-missions/swarm/data-handbook/level-2-product-definitions#TECxTMS_2F" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Check what \"TEC\" data variables are available" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request.available_collections(\"IPD\", details=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request.available_measurements(\"TEC\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fetch one day of TEC data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request.set_collection(\"SW_OPER_TECATMS_2F\")\n", "request.set_products(measurements=request.available_measurements(\"TEC\"))\n", "data = request.get_between(dt.datetime(2014,1,1),\n", " dt.datetime(2014,1,2))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Loading as pandas" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = data.as_dataframe()\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "NB: The time interval is not always the same:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "times = df.index\n", "np.unique(np.sort(np.diff(times.to_pydatetime())))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "len(df), 60*60*24" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading and plotting as xarray" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds = data.as_xarray()\n", "ds" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(15,5), sharex=True)\n", "ds[\"Absolute_VTEC\"].plot.line(x=\"Timestamp\", ax=axes[0])\n", "ds[\"Absolute_STEC\"].plot.line(x=\"Timestamp\", ax=axes[1]);\n", "fig.subplots_adjust(hspace=0)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }