{ "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": [ "import datetime as dt\n", "\n", "import matplotlib.pyplot as plt\n", "from viresclient import SwarmRequest\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", "- [Swarm Handbook: EFIx_LP_1B](https://swarmhandbook.earth.esa.int/catalogue/SW_EFIx_LP_1B)\n", "- [Product specification](https://earth.esa.int/eogateway/documents/20142/37627/swarm-level-1b-product-definition-specification.pdf)" ] }, { "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=[\n", " \"U_orbit\",\n", " \"N_ion\",\n", " \"dN_ion\",\n", " \"T_elec\",\n", " \"dT_elec\",\n", " \"Vs\",\n", " \"Vs_error\",\n", " \"Flags_N_ion\",\n", " \"Flags_T_elec\",\n", " \"Flags_Vs\",\n", " ]\n", ")\n", "data = request.get_between(dt.datetime(2016, 1, 1), dt.datetime(2016, 1, 2))" ] }, { "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=[\"N_ion\", \"T_elec\", \"Vs\"], subplots=True, figsize=(20,5));" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df.plot(x=\"Latitude\", y=\"N_ion\");" ] }, { "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((\"N_ion\", \"T_elec\"), (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 }