{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EFIx_LP_1B (Langmuir probe 2Hz)\n", "\n", "> Abstract: Access to the electric field instrument langmuir probe data (2Hz) (level 1b 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 matplotlib.pyplot as plt\n", "\n", "request = SwarmRequest()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## EFIx_LP_1B product information\n", "\n", "Measurements from the Langmuir Probe (LP) of the Electric Field Instrument (EFI) at 2Hz, for each Swarm spacecraft.\n", "\n", "Documentation:\n", "- https://earth.esa.int/web/guest/missions/esa-eo-missions/swarm/data-handbook/level-1b-product-definitions#EFIX_LP_1B_Product" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Check what \"EFI\" data variables are available" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request.available_collections(\"EFI\", details=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request.available_measurements(\"EFI\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fetch one day of EFI data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request.set_collection(\"SW_OPER_EFIA_LP_1B\")\n", "request.set_products(\n", " measurements=['U_orbit',\n", " 'Ne',\n", " 'Ne_error',\n", " 'Te',\n", " 'Te_error',\n", " 'Vs',\n", " 'Vs_error',\n", " 'Flags_LP',\n", " 'Flags_Ne',\n", " 'Flags_Te',\n", " 'Flags_Vs']\n", ")\n", "data = request.get_between(\n", " dt.datetime(2016,1,1),\n", " dt.datetime(2016,1,2)\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data.sources" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load and plot using pandas/matplotlib" ] }, { "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": [ "df.plot(y=[\"Ne\", \"Te\", \"Vs\"], subplots=True, figsize=(20,5));" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df.plot(x=\"Latitude\", y=\"Ne\");" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load 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, (ax1, ax2) = plt.subplots(figsize=(10, 5), nrows=2, sharex=True)\n", "def subplot(_ax, da):\n", " \"\"\"Plot a given DataArray on a given axes\"\"\"\n", " _ax.plot(da)\n", " _ax.set_ylabel(f\"{da.name} [{da.units}]\")\n", "for var, ax in zip((\"Ne\", \"Te\"), (ax1, ax2)):\n", " subplot(ax, ds[var])" ] } ], "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 }