diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index 80dd356..fbddc43 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: env: - DOCKER_IMAGE: 'registry.gitlab.eox.at/esa/vires_vre_ops/vre-swarm-notebook:0.10.17' + DOCKER_IMAGE: 'registry.gitlab.eox.at/esa/vires_vre_ops/vre-swarm-notebook:1.0.1' jobs: pre-commit: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f01f286..f5b9bc5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: env: - DOCKER_IMAGE: 'registry.gitlab.eox.at/esa/vires_vre_ops/vre-swarm-notebook:0.10.17' + DOCKER_IMAGE: 'registry.gitlab.eox.at/esa/vires_vre_ops/vre-swarm-notebook:1.0.1' jobs: pre-commit: diff --git a/notebooks/01b1_Pandas-and-Plots.ipynb b/notebooks/01b1_Pandas-and-Plots.ipynb index 52f0e9e..1e3236c 100644 --- a/notebooks/01b1_Pandas-and-Plots.ipynb +++ b/notebooks/01b1_Pandas-and-Plots.ipynb @@ -196,7 +196,7 @@ "outputs": [], "source": [ "# Generate some sample times at hourly intervals over a month\n", - "df[\"time\"] = pd.date_range(\"2020-01-01\", \"2020-02-01\", periods=745, closed=\"left\")\n", + "df[\"time\"] = pd.date_range(\"2020-01-01\", \"2020-02-01\", periods=745, inclusive=\"left\")\n", "df = df.set_index(\"time\")\n", "df" ] diff --git a/notebooks/03e1_Demo-FACxTMS_2F.ipynb b/notebooks/03e1_Demo-FACxTMS_2F.ipynb index d2376eb..8e0e94e 100644 --- a/notebooks/03e1_Demo-FACxTMS_2F.ipynb +++ b/notebooks/03e1_Demo-FACxTMS_2F.ipynb @@ -235,7 +235,7 @@ " # Extract times from the lower x axis\n", " # Use them to find the nearest Lat values in the dataframe\n", " xtick_times = [dt.datetime.strptime(ts.get_text(), datetime_format) for ts in ax.get_xticklabels()]\n", - " ilocs = [df.index.get_loc(t, method=\"nearest\") for t in xtick_times]\n", + " ilocs = [df.index.get_indexer([t], method=\"nearest\")[0] for t in xtick_times]\n", " lats = df.iloc[ilocs][\"Latitude\"]\n", " lat_labels = [\"{}°\".format(s) for s in np.round(lats.values, decimals=1)]\n", " ax2.set_xticklabels(lat_labels)\n", diff --git a/notebooks/03i1_Demo-VOBS.ipynb b/notebooks/03i1_Demo-VOBS.ipynb index 4bc9f30..d938205 100644 --- a/notebooks/03i1_Demo-VOBS.ipynb +++ b/notebooks/03i1_Demo-VOBS.ipynb @@ -336,9 +336,8 @@ " _ds[var] = _ds[var].roll({\"NEC\": 1}, roll_coords=False)\n", " _ds[var].attrs = ds[var].attrs\n", " # Rename NEC dims & coords to RTP\n", - " _ds = _ds.assign_coords({\"NEC\": [\"Radial\", \"Theta\", \"Phi\"]})\n", - " _ds = _ds.rename_dims({\"NEC\": \"RTP\"}).rename({\"NEC\": \"RTP\"})\n", - " _ds = _ds.set_index({\"RTP\": \"RTP\"}).set_coords(\"RTP\")\n", + " _ds = _ds.rename({\"NEC\": \"RTP\"})\n", + " _ds = _ds.assign_coords({\"RTP\": [\"Radial\", \"Theta\", \"Phi\"]})\n", " _ds[\"RTP\"].attrs = {\n", " \"units\": \"\",\n", " \"description\": \"RTP frame - Radial, Theta, Phi [R,T,P] = [-C,-N,E]\"\n", @@ -359,7 +358,7 @@ " )\n", " data = request.get_between(\n", " dt.datetime(1999, 1, 1),\n", - " dt.datetime.now(),\n", + " dt.datetime(2024, 1, 1),\n", " asynchronous=False, show_progress=False\n", " )\n", " ds = data.as_xarray(reshape=reshape)\n", @@ -423,7 +422,7 @@ "source": [ "rad = {}\n", "for mission in (\"Orsted\", \"CHAMP\", \"Cryosat\", \"Swarm\", \"Composite\"):\n", - " rad[mission] = int(ALL_VOBS[f\"{mission}_4M\"][\"Radius\"].values[0]/1e3)\n", + " rad[mission] = int(ALL_VOBS[f\"{mission}_4M\"][\"Radius\"][0]/1e3)\n", "\n", "plt.figure(figsize=(10,3))\n", "for mission in (\"Orsted\", \"CHAMP\", \"Cryosat\", \"Swarm\", \"Composite\"):\n", @@ -463,34 +462,34 @@ " _ds_1m = ds_1m.sel(RTP=rtp)\n", " # Observed field\n", " axes[i, 0].errorbar(\n", - " _ds_1m[\"Timestamp\"].values, _ds_1m[\"B_OB\"].values, _ds_1m[\"sigma_OB\"].values,\n", + " _ds_1m[\"Timestamp\"].values, _ds_1m[\"B_OB\"].values, np.abs(_ds_1m[\"sigma_OB\"].values),\n", " fmt=\".\", label=\"1M\"\n", " )\n", " # Core field\n", " axes[i, 1].errorbar(\n", - " _ds_1m[\"Timestamp\"].values, _ds_1m[\"B_CF\"].values, _ds_1m[\"sigma_CF\"].values,\n", + " _ds_1m[\"Timestamp\"].values, _ds_1m[\"B_CF\"].values, np.abs(_ds_1m[\"sigma_CF\"].values),\n", " fmt=\".\",\n", " )\n", " # Secular variation (of core field)\n", " axes[i, 2].errorbar(\n", - " _ds_1m[\"Timestamp_SV\"].values, _ds_1m[\"B_SV\"].values, _ds_1m[\"sigma_SV\"].values,\n", + " _ds_1m[\"Timestamp_SV\"].values, _ds_1m[\"B_SV\"].values, np.abs(_ds_1m[\"sigma_SV\"].values),\n", " fmt=\".\",\n", " )\n", " _ds_4m = ds_4m.sel(RTP=rtp)\n", " # Observed field\n", " axes[i, 0].errorbar(\n", - " _ds_4m[\"Timestamp\"].values, _ds_4m[\"B_OB\"].values, _ds_4m[\"sigma_OB\"].values,\n", + " _ds_4m[\"Timestamp\"].values, _ds_4m[\"B_OB\"].values, np.abs(_ds_4m[\"sigma_OB\"].values),\n", " fmt=\".\", label=\"4M\"\n", " )\n", " # Core field\n", " axes[i, 1].errorbar(\n", - " _ds_4m[\"Timestamp\"].values, _ds_4m[\"B_CF\"].values, _ds_4m[\"sigma_CF\"].values,\n", + " _ds_4m[\"Timestamp\"].values, _ds_4m[\"B_CF\"].values, np.abs(_ds_4m[\"sigma_CF\"].values),\n", " fmt=\".\",\n", " )\n", " axes[i, 1].set_ylim(axes[i, 0].get_ylim())\n", " # Secular variation (of core field)\n", " axes[i, 2].errorbar(\n", - " _ds_4m[\"Timestamp_SV\"].values, _ds_4m[\"B_SV\"].values, _ds_4m[\"sigma_SV\"].values,\n", + " _ds_4m[\"Timestamp_SV\"].values, _ds_4m[\"B_SV\"].values, np.abs(_ds_4m[\"sigma_SV\"].values),\n", " fmt=\".\",\n", " )\n", " axes[0, 0].set_ylabel(\"Radial\\n[nT]\")\n", diff --git a/notebooks/03z1_External-Data.ipynb b/notebooks/03z1_External-Data.ipynb index 0b012ba..8e2179a 100644 --- a/notebooks/03z1_External-Data.ipynb +++ b/notebooks/03z1_External-Data.ipynb @@ -100,43 +100,28 @@ "metadata": {}, "outputs": [], "source": [ - "!pip install \"hapiplot==0.2.0\" --quiet\n", + "!pip install \"git+https://github.com/hapi-server/plot-python@f95ce860d456dd9278a62897d6f83d416c988273\" --quiet\n", "\n", "from hapiplot import hapiplot" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "4aeea673", - "metadata": {}, - "outputs": [], - "source": [ - "hapiplot(data, meta);" - ] - }, { "cell_type": "markdown", - "id": "0e2e6ec5", + "id": "1119a42c-1733-49be-beb4-2370637fe0b0", "metadata": {}, "source": [ - "## Other packages (TODO)\n", - "\n", - "- pysat\n", - "- spacepy\n", - "- mangopy\n", - "- madrigalweb\n", - "- pyaurorax\n", - "- ??? (any suggestions? contact ashley.smith@ed.ac.uk)" + "(NB: We are using a more recent development version of hapiplot, rather than what is on PyPI)" ] }, { "cell_type": "code", "execution_count": null, - "id": "e60071a3", + "id": "4aeea673", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "hapiplot(data, meta);" + ] } ], "metadata": { diff --git a/notebooks/07a1_SW-chaosmagpy.ipynb b/notebooks/07a1_SW-chaosmagpy.ipynb index 1f677bf..b335a7c 100644 --- a/notebooks/07a1_SW-chaosmagpy.ipynb +++ b/notebooks/07a1_SW-chaosmagpy.ipynb @@ -24,6 +24,16 @@ "Finlay, C.C., Kloss, C., Olsen, N., Hammer, M. Toeffner-Clausen, L., Grayver, A and Kuvshinov, A. (2020), The CHAOS-7 geomagnetic field model and observed changes in the South Atlantic Anomaly, Earth Planets and Space 72, doi:10.1186/s40623-020-01252-9" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%load_ext watermark\n", + "%watermark -i -v -p chaosmagpy,numpy,matplotlib" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -149,5 +159,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/notebooks/07b1_SW-pyamps.ipynb b/notebooks/07b1_SW-pyamps.ipynb index 93d9929..d8b41c0 100644 --- a/notebooks/07b1_SW-pyamps.ipynb +++ b/notebooks/07b1_SW-pyamps.ipynb @@ -24,6 +24,16 @@ "Laundal, K. M., Finlay, C. C., Olsen, N. & Reistad, J. P. (2018), Solar wind and seasonal influence on ionospheric currents from Swarm and CHAMP measurements, Journal of Geophysical Research - Space Physics. doi:10.1029/2018JA025387" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%load_ext watermark\n", + "%watermark -i -v -p pyamps,numpy,matplotlib" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -77,5 +87,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/notebooks/07c1_SW-pyswipe.ipynb b/notebooks/07c1_SW-pyswipe.ipynb index 318e936..947e0d4 100644 --- a/notebooks/07c1_SW-pyswipe.ipynb +++ b/notebooks/07c1_SW-pyswipe.ipynb @@ -21,6 +21,26 @@ "[Code](https://github.com/Dartspacephysiker/pyswipe) " ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Temporarily patch in fixed version\n", + "!pip install --quiet git+https://github.com/smithara/pyswipe/@hotfix-numpy-1.25" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%load_ext watermark\n", + "%watermark -i -v -p pyswipe,numpy,matplotlib" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -537,5 +557,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/notebooks/07e1_SW-swarmface.ipynb b/notebooks/07e1_SW-swarmface.ipynb index 14c6445..8cf5e9f 100644 --- a/notebooks/07e1_SW-swarmface.ipynb +++ b/notebooks/07e1_SW-swarmface.ipynb @@ -27,6 +27,16 @@ "Blagau A and Vogt J (2023) SwarmFACE: A Python package for field-aligned currents exploration with Swarm. Front. Astron. Space Sci. 9:1077845. doi: 10.3389/fspas.2022.1077845" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%load_ext watermark\n", + "%watermark -i -v -p SwarmFACE,viresclient,numpy,pandas,matplotlib" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -48,79 +58,30 @@ ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ + "The package is currently awaiting updates to make it work here.\n", + "\n", + "Example usage:\n", + "\n", + "```python\n", "# Settings\n", "dtime_beg = '2014-05-04T17:48:00'\n", "dtime_end = '2014-05-04T17:54:00'\n", "sat = ['C']\n", "res = 'LR'\n", "N3d=[0.2276, 0.6924, 0.6847]\n", - "tincl = ['2014-05-04 17:49:50', '2014-05-04 17:52:44']" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ + "tincl = ['2014-05-04 17:49:50', '2014-05-04 17:52:44']\n", + "\n", "# Fetch data and apply algorithm using above settings\n", "j_df, input_df, param = j1sat(\n", " dtime_beg, dtime_end, sat, res=res,\n", " N3d=N3d, tincl=tincl\n", - ")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The inputs are stored within `input_df`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "input_df" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "... and the newly calculated FAC current in `j_df`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "j_df" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "... with some extra metadata in `param`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "param" + ")\n", + "```\n", + "\n", + "The inputs are stored within `input_df`, and the newly calculated FAC current in `j_df` with some extra metadata in `param`." ] } ], @@ -148,5 +109,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }