{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EEFxTMS_2F (Equatorial electric field)\n", "\n", "> Abstract: Access to the equatorial electric field (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 matplotlib.pyplot as plt\n", "\n", "request = SwarmRequest()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## EEFxTMS_2F product information\n", "\n", "Dayside equatorial electric field, sampled at every dayside equator crossing +- 20mins\n", "\n", "\n", "Documentation:\n", "- https://earth.esa.int/web/guest/missions/esa-eo-missions/swarm/data-handbook/level-2-product-definitions#EEFxTMS_2F" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Check what \"EEF\" data variables are available" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request.available_collections(\"EEF\", details=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request.available_measurements(\"EEF\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fetch all the EEF and EEJ values from Bravo during 2016" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request.set_collection(\"SW_OPER_EEFBTMS_2F\")\n", "request.set_products(measurements=[\"EEF\", \"EEJ\", \"Flags\"])\n", "data = request.get_between(\n", " dt.datetime(2016,1,1),\n", " dt.datetime(2017,1,1)\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# The first three and last three source (daily) files\n", "data.sources[:3], data.sources[-3:]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = data.as_dataframe()\n", "df.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ax = df.plot(y=\"EEF\", figsize=(20,10))\n", "ax.set_ylim((-2, 2));\n", "ax.set_ylabel(\"EEF [mV/m]\");" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Take a look at the time jumps between entries... Nominally the product should produce one measurement \"every dayside equator crossing ±20 minutes\"" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "times = df.index\n", "delta_t_minutes = [t.seconds/60 for t in np.diff(times.to_pydatetime())]\n", "print(\"Range of time gaps (in minutes) between successive measurements:\")\n", "np.unique(np.sort(delta_t_minutes))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Access the EEJ estimate via xarray instead of pandas\n", "\n", "Since the EEJ estimate has both time and latitude dimensions, it is not suited to pandas. Here we load the data as a `xarray.Dataset` which better handles n-dimensional data." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds = data.as_xarray()\n", "ds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's select a subset (one month) and visualise it:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "_ds = ds.sel({\"Timestamp\": \"2016-01\"})\n", "\n", "fig, ax1 = plt.subplots(nrows=1, figsize=(15,3), sharex=True)\n", "_ds.plot.scatter(x=\"Timestamp\", y=\"EEJ_QDLat\", hue=\"EEJ\", vmax=10, s=1, linewidths=0, ax=ax1)" ] } ], "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 }