Introduction#

%load_ext watermark
%watermark -u -i
Last updated: 2024-08-29T08:10:47.663664+00:00

These pages are generated from notebooks.

They are run on an hourly schedule and you can retrieve previous runs at the following URLs:

Hide code cell source
import datetime as dt

now = dt.datetime.now()
timestamps = [(now - dt.timedelta(hours=x)).strftime("%Y-%m-%d-h%H") for x in range(24)]
root = "https://{}--swarm-quicklooks.netlify.app"
for url in [root.format(t) for t in timestamps]:
    print(url)
https://2024-08-29-h08--swarm-quicklooks.netlify.app
https://2024-08-29-h07--swarm-quicklooks.netlify.app
https://2024-08-29-h06--swarm-quicklooks.netlify.app
https://2024-08-29-h05--swarm-quicklooks.netlify.app
https://2024-08-29-h04--swarm-quicklooks.netlify.app
https://2024-08-29-h03--swarm-quicklooks.netlify.app
https://2024-08-29-h02--swarm-quicklooks.netlify.app
https://2024-08-29-h01--swarm-quicklooks.netlify.app
https://2024-08-29-h00--swarm-quicklooks.netlify.app
https://2024-08-28-h23--swarm-quicklooks.netlify.app
https://2024-08-28-h22--swarm-quicklooks.netlify.app
https://2024-08-28-h21--swarm-quicklooks.netlify.app
https://2024-08-28-h20--swarm-quicklooks.netlify.app
https://2024-08-28-h19--swarm-quicklooks.netlify.app
https://2024-08-28-h18--swarm-quicklooks.netlify.app
https://2024-08-28-h17--swarm-quicklooks.netlify.app
https://2024-08-28-h16--swarm-quicklooks.netlify.app
https://2024-08-28-h15--swarm-quicklooks.netlify.app
https://2024-08-28-h14--swarm-quicklooks.netlify.app
https://2024-08-28-h13--swarm-quicklooks.netlify.app
https://2024-08-28-h12--swarm-quicklooks.netlify.app
https://2024-08-28-h11--swarm-quicklooks.netlify.app
https://2024-08-28-h10--swarm-quicklooks.netlify.app
https://2024-08-28-h09--swarm-quicklooks.netlify.app

Tricks with notebook cells#

See https://jupyterbook.org/en/stable/interactive/hiding.html for more

Cells can be hidden (both input and output):

Hide code cell content
!mamba run -n swarmpal-runner pip install hapiplot
Collecting hapiplot
  Downloading hapiplot-0.2.2.tar.gz (35 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: matplotlib in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from hapiplot) (3.8.0)
Requirement already satisfied: hapiclient>0.1.7 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from hapiplot) (0.2.5)
Requirement already satisfied: isodate>=0.6.0 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from hapiclient>0.1.7->hapiplot) (0.6.1)
Requirement already satisfied: urllib3 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from hapiclient>0.1.7->hapiplot) (2.0.7)
Requirement already satisfied: joblib in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from hapiclient>0.1.7->hapiplot) (1.3.2)
Requirement already satisfied: pandas>=0.23 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from hapiclient>0.1.7->hapiplot) (2.1.1)
Requirement already satisfied: numpy>=1.14.3 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from hapiclient>0.1.7->hapiplot) (1.26.0)
Requirement already satisfied: contourpy>=1.0.1 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from matplotlib->hapiplot) (1.1.1)
Requirement already satisfied: cycler>=0.10 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from matplotlib->hapiplot) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from matplotlib->hapiplot) (4.43.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from matplotlib->hapiplot) (1.4.5)
Requirement already satisfied: packaging>=20.0 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from matplotlib->hapiplot) (23.2)
Requirement already satisfied: pillow>=6.2.0 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from matplotlib->hapiplot) (10.1.0)
Requirement already satisfied: pyparsing>=2.3.1 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from matplotlib->hapiplot) (3.1.1)
Requirement already satisfied: python-dateutil>=2.7 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from matplotlib->hapiplot) (2.8.2)
Requirement already satisfied: six in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from isodate>=0.6.0->hapiclient>0.1.7->hapiplot) (1.16.0)
Requirement already satisfied: pytz>=2020.1 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from pandas>=0.23->hapiclient>0.1.7->hapiplot) (2023.3.post1)
Requirement already satisfied: tzdata>=2022.1 in /opt/conda/envs/swarmpal-runner/lib/python3.11/site-packages (from pandas>=0.23->hapiclient>0.1.7->hapiplot) (2023.3)
Building wheels for collected packages: hapiplot
  Building wheel for hapiplot (setup.py): started
  Building wheel for hapiplot (setup.py): finished with status 'done'
  Created wheel for hapiplot: filename=hapiplot-0.2.2-py3-none-any.whl size=37943 sha256=dcf30cab61328631540da7384385bf436a7c3015c017e1a89a3b92f52bcbba7e
  Stored in directory: /home/jovyan/.cache/pip/wheels/f5/96/9f/01fe1cc0af99e9712eea51c925e5b93c32d613440fcd97200f
Successfully built hapiplot
Installing collected packages: hapiplot
Successfully installed hapiplot-0.2.2

(In the hidden cell above, we installed hapiplot because it was missing. This will be moved into the docker image directly.)

We can display some of the main software versions used:

%watermark -v -p swarmpal,viresclient,hapiclient,hapiplot,cdflib,pandas,xarray,matplotlib,cartopy
Python implementation: CPython
Python version       : 3.11.6
IPython version      : 8.16.1

swarmpal   : 0.1.0
viresclient: 0.11.3
hapiclient : 0.2.5
hapiplot   : 0.2.2
cdflib     : 1.2.3
pandas     : 2.1.1
xarray     : 2023.10.1
matplotlib : 3.8.0
cartopy    : 0.22.0

We can run some code (hiding the input, but showing the output):

Hide code cell source
import datetime as dt
from hapiclient import hapi

from hapiplot import hapiplot

# # Current time, rounded to nearest minute
# now = dt.datetime.now()
# now = now - dt.timedelta(seconds=now.second, microseconds=now.microsecond)
# # 24 hours earlier
# past = now - dt.timedelta(hours=240)

server     = 'https://vires.services/hapi'
dataset    = 'SW_OPER_MAGA_LR_1B'
parameters = 'B_NEC_res_Model'

meta = hapi(server, dataset)
latest_available = dt.datetime.fromisoformat(meta["stopDate"])
one_day_prior = latest_available - dt.timedelta(hours=24)

start = one_day_prior.strftime("%Y-%m-%dT%H:%M:%S")
stop = latest_available.strftime("%Y-%m-%dT%H:%M:%S")

data, meta = hapi(server, dataset, parameters, start, stop)

hapiplot(data, meta);
../_images/5d47101cc2daadd0189827009cffd291a812c8db078b3ea3e17ce41d249508e3.png