{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# MAGxHR_1B (Magnetic field 50Hz)\n", "\n", "> Abstract: Access to the high rate (50Hz) magnetic data (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 numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request = SwarmRequest()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Product information\n", "\n", "The 50Hz measurements of the magnetic field vector (`B_NEC`) and total intensity (`F`).\n", "\n", "Documentation:\n", "- https://earth.esa.int/web/guest/missions/esa-eo-missions/swarm/data-handbook/level-1b-product-definitions#MAGX_HR_1B_Product\n", "\n", "Measurements are available through VirES as part of collections with names containing `MAGx_HR`, for each Swarm spacecraft:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request.available_collections(\"MAG_HR\", details=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The measurements can be used together with geomagnetic model evaluations as shall be shown below." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Check what \"MAG_HR\" data variables are available" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request.available_measurements(\"MAG_HR\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fetch and load data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "request = SwarmRequest()\n", "request.set_collection(\"SW_OPER_MAGA_HR_1B\")\n", "request.set_products(\n", " measurements=[\"B_NEC\"],\n", ")\n", "data = request.get_between(\n", " start_time=\"2015-06-21T12:00:00Z\", \n", " end_time=\"2015-06-21T12:01:00Z\",\n", " asynchronous=False\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data.sources" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds = data.as_xarray()\n", "ds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualisation of data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, axes = plt.subplots(figsize=(20, 3), ncols=3, sharex=True)\n", "for i in range(3):\n", " axes[i].plot(ds[\"Timestamp\"], ds[\"B_NEC\"][:, i])\n", " axes[i].set_ylabel(\"NEC\"[i])\n", " axes[i].set_xlabel(\"Time\")\n", "fig.suptitle(\"B_NEC components [nT]\");" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(20, 3))\n", "dBdt = np.diff(ds[\"B_NEC\"], axis=0) * (1/50)\n", "ax.plot(ds[\"Timestamp\"][1:], dBdt[:, 2])\n", "ax.set_ylabel(\"nT / s\")\n", "ax.set_xlabel(\"Time\")\n", "ax.set_title(\"Vertical component (C) first differences\");" ] } ], "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 }