Skip to content

Commit 43a3280

Browse files
authored
Update to VRE 1.0.8 (#4)
* Update to VRE 1.0.8 * Use Netlify action instead of CLI * Maintenance updates * minor fixes
1 parent d4fa14f commit 43a3280

File tree

6 files changed

+44
-41
lines changed

6 files changed

+44
-41
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- main
88

99
env:
10-
DOCKER_IMAGE: 'registry.gitlab.eox.at/esa/vires_vre_ops/vre-swarm-notebook:0.10.11'
10+
DOCKER_IMAGE: 'registry.gitlab.eox.at/esa/vires_vre_ops/vre-swarm-notebook:1.0.8'
1111

1212
jobs:
1313
run:
@@ -18,7 +18,7 @@ jobs:
1818
run: |
1919
echo ${{ secrets.EOX_REGISTRY_PASSWORD }} | docker login -u ${{ secrets.EOX_REGISTRY_USER }} --password-stdin registry.gitlab.eox.at
2020
docker pull ${{ env.DOCKER_IMAGE }}
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v4
2222
- name: Execute notebooks and build book
2323
run: |
2424
docker run -v $GITHUB_WORKSPACE:/home/jovyan -u root \
@@ -31,5 +31,16 @@ jobs:
3131
pip install 'jupyter-book==0.15.1' && \
3232
jupyter-book build --verbose .
3333
'
34-
- name: Deploy preview with netlify
35-
run: netlify deploy --dir=_build/html --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} --site=${{ secrets.NETLIFY_SITE_API_ID }}
34+
- name: Deploy preview to Netlify
35+
if: always()
36+
uses: nwtgck/actions-netlify@v3.0
37+
with:
38+
publish-dir: './_build/html'
39+
production-deploy: false
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
enable-pull-request-comment: true
42+
enable-commit-comment: false
43+
overwrites-pull-request-comment: true
44+
env:
45+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
46+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_API_ID }}

geomag-obs-models/01a_Visualising-Geomagnetic-Observatory-Data.ipynb

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,13 @@
3232
},
3333
"outputs": [],
3434
"source": [
35-
"## Uncomment here to autoreload local modules as you edit them\n",
36-
"# %load_ext autoreload\n",
37-
"# %autoreload 2\n",
38-
"\n",
3935
"import datetime as dt\n",
4036
"import numpy as np\n",
4137
"import pandas as pd\n",
4238
"import matplotlib.pyplot as plt\n",
4339
"import ipywidgets as widgets\n",
4440
"from viresclient import SwarmRequest\n",
4541
"\n",
46-
"## Use to make interactive matplotlib plots\n",
47-
"## - doesn't work smoothly\n",
48-
"## - investigating using plotly/bokeh instead\n",
49-
"# %matplotlib widget\n",
50-
"\n",
5142
"%load_ext watermark\n",
5243
"%watermark -i -v -p numpy,pandas,xarray,matplotlib,ipywidgets,viresclient"
5344
]
@@ -116,11 +107,10 @@
116107
" **kwargs\n",
117108
" )\n",
118109
" if use_xarray:\n",
119-
" ds = data.as_xarray().drop(\"Spacecraft\")\n",
120-
" return ds\n",
110+
" return data.as_xarray()\n",
121111
" else:\n",
122112
" # Load data in Pandas Dataframe with X, Y, Z columns\n",
123-
" df = data.as_dataframe(expand=True).drop(columns=\"Spacecraft\")\n",
113+
" df = data.as_dataframe(expand=True)\n",
124114
" df = df.rename(columns={f\"B_NEC_{i}\": j for i, j in zip(\"NEC\", \"XYZ\")})\n",
125115
" return df\n",
126116
"\n",
@@ -178,20 +168,22 @@
178168
" Returns:\n",
179169
" Figure\n",
180170
" \"\"\"\n",
171+
" observatory = df[\"IAGA_code\"].iloc[0]\n",
172+
" # Restrict to only the XYZ values so that resampling will work\n",
173+
" df = df[[\"X\", \"Y\", \"Z\"]].copy()\n",
181174
" # Evaluate annual means to use later,\n",
182175
" # reindexed with the ending index points for each year\n",
183-
" annual_mean = df.resample(\"1y\").mean()\n",
176+
" annual_mean = df.resample(\"Y\").mean()\n",
184177
" annual_mean.index = [df.loc[str(year)].index[-1] for year in df.index.year.unique()]\n",
185178
" # Subset dataframe to selection\n",
186179
" df = df.loc[start_date:end_date]\n",
187180
" # Cut the annual mean (and reindex) to match df\n",
188181
" # so we can use it directly in ax.fill_between\n",
189182
" annual_mean = annual_mean.loc[str(start_date.year):str(end_date.year)]\n",
190183
" annual_mean = annual_mean.reindex(index=df.index, method=\"backfill\")\n",
191-
" observatory = df[\"IAGA_code\"][0]\n",
192184
" title = f\"Minute data from {observatory}\"\n",
193185
" if hourly_mean:\n",
194-
" df = df.resample(\"1h\").mean()\n",
186+
" df = df.resample(\"h\").mean()\n",
195187
" annual_mean = annual_mean.reindex(index=df.index)\n",
196188
" title += \": averaged over each hour\"\n",
197189
" if show_annual_mean:\n",
@@ -322,7 +314,11 @@
322314
"outputs": [],
323315
"source": [
324316
"def monthly_means(df=obs_hourly):\n",
325-
" \"\"\"Return MultIndex DataFrame of monthly means over each hourly interval\"\"\"\n",
317+
" \"\"\"Return MultiIndex DataFrame of monthly means over each hourly interval\"\"\"\n",
318+
" # Restrict to only the XYZ values so that resampling will work\n",
319+
" df = df[[\"X\", \"Y\", \"Z\"]].copy()\n",
320+
" # Append Declination\n",
321+
" df[\"D\"] = np.rad2deg(np.arctan2(df[\"Y\"], df[\"X\"]))\n",
326322
" # Append hour of day, and approx fractional year, to use for plotting\n",
327323
" df[\"t_hour\"] = df.index.map(lambda x: x.hour + x.minute/60)\n",
328324
" epoch = pd.to_datetime(0, unit='s').to_julian_date()\n",
@@ -337,8 +333,6 @@
337333
" monthly[\"D_variation\"] = monthly['D'].values - monthly_all['D'].values.repeat(24)\n",
338334
" return monthly\n",
339335
"\n",
340-
"\n",
341-
"obs_hourly[\"D\"] = np.rad2deg(np.arctan2(obs_hourly[\"Y\"], obs_hourly[\"X\"]))\n",
342336
"obs_monthly = monthly_means(obs_hourly)\n",
343337
"obs_monthly"
344338
]
@@ -462,7 +456,7 @@
462456
" df = df.copy()\n",
463457
"\n",
464458
" # Evaluate the annual means\n",
465-
" annual_means = df[[\"X\", \"Y\", \"Z\"]].resample(\"1y\").mean()\n",
459+
" annual_means = df[[\"X\", \"Y\", \"Z\"]].resample(\"Y\").mean()\n",
466460
" annual_means = annual_means.rename(columns={\"X\": \"X_mean\", \"Y\": \"Y_mean\", \"Z\": \"Z_mean\"})\n",
467461
" # Identify the year-end index times\n",
468462
" year_ends = [df.loc[str(year)].index[-1] for year in df.index.year.unique()]\n",
@@ -524,7 +518,7 @@
524518
" (df[\"time\"].dt.day == 1) & (df[\"time\"].dt.hour == 0)\n",
525519
" ).dropna()\n",
526520
" if bartrot in month_starts.keys():\n",
527-
" bartrotday = float(month_starts.loc[bartrot].index.values)\n",
521+
" bartrotday = float(month_starts.loc[bartrot].index.values[0])\n",
528522
" month = month_starts.loc[bartrot].dt.strftime(\"%b\").values[0]\n",
529523
" ax.text(bartrotday, y0.iloc[0] - 85, month, verticalalignment=\"top\")\n",
530524
"\n",
@@ -592,14 +586,15 @@
592586
" asynchronous=False,\n",
593587
" show_progress=False,\n",
594588
" )\n",
595-
" df = df.resample(\"1y\").mean()\n",
589+
" df = df[[\"X\", \"Y\", \"Z\"]].resample(\"Y\").mean()\n",
596590
" df.index = df.index.year\n",
597591
" df.index.name = \"Year\"\n",
598592
" annual_means[obs] = df\n",
599593
" return annual_means\n",
600594
"\n",
601595
"\n",
602-
"observatories = [\"ESK\", \"NGK\", \"CLF\"]\n",
596+
"# observatories = [\"ESK\", \"NGK\", \"CLF\"] # Why aren't NGK and CLF working?\n",
597+
"observatories = [\"ESK\"]\n",
603598
"annual_means = fetch_annual_means(observatories)"
604599
]
605600
},
@@ -709,7 +704,7 @@
709704
"name": "python",
710705
"nbconvert_exporter": "python",
711706
"pygments_lexer": "ipython3",
712-
"version": "3.10.6"
707+
"version": "3.11.6"
713708
},
714709
"toc-autonumbering": true,
715710
"toc-showcode": false,

geomag-obs-models/02a_K-Index-Calculation.ipynb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@
152152
" dt.datetime(2003, 1, 1),\n",
153153
" dt.datetime(2004, 1, 1),\n",
154154
" )\n",
155-
" df = data.as_dataframe(expand=True).drop(\n",
156-
" columns=[\"Spacecraft\"]\n",
157-
" )\n",
155+
" df = data.as_dataframe(expand=True)\n",
158156
" df = df.rename(columns={f\"B_NEC_{i}\": j for i, j in zip(\"NEC\", \"XYZ\")})\n",
159157
" return df"
160158
]
@@ -552,7 +550,7 @@
552550
"name": "python",
553551
"nbconvert_exporter": "python",
554552
"pygments_lexer": "ipython3",
555-
"version": "3.10.6"
553+
"version": "3.11.6"
556554
}
557555
},
558556
"nbformat": 4,

geomag-obs-models/04b_SHA2.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"# Import notebook dependencies\n",
1717
"import sys\n",
1818
"import matplotlib.pyplot as plt\n",
19-
"plt.style.use('seaborn-white')\n",
2019
"import numpy as np\n",
2120
"import pandas as pd \n",
2221
"\n",
@@ -602,7 +601,7 @@
602601
"name": "python",
603602
"nbconvert_exporter": "python",
604603
"pygments_lexer": "ipython3",
605-
"version": "3.10.6"
604+
"version": "3.11.6"
606605
}
607606
},
608607
"nbformat": 4,

geomag-obs-models/04c_GroundObs-to-Model.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
" _ds = df.to_xarray()\n",
110110
" _ds[\"Latitude\"] = 90 - _ds[\"Colat\"]\n",
111111
" _ds[\"Longitude\"] = (_ds[\"Long\"] % 360 + 540) % 360 - 180\n",
112-
" _ds = _ds.drop(\"index\")\n",
112+
" _ds = _ds.drop_vars(\"index\")\n",
113113
" return _ds\n",
114114
"\n",
115115
"input_data = load_data(year=2000.5)\n",
@@ -393,7 +393,7 @@
393393
"name": "python",
394394
"nbconvert_exporter": "python",
395395
"pygments_lexer": "ipython3",
396-
"version": "3.10.6"
396+
"version": "3.11.6"
397397
}
398398
},
399399
"nbformat": 4,

geomag-obs-models/05a_Swarm-Measurements.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"metadata": {},
8383
"outputs": [],
8484
"source": [
85-
"_ds = ds.drop(\"Timestamp\").sel(NEC=\"C\")\n",
85+
"_ds = ds.drop_vars(\"Timestamp\").sel(NEC=\"C\")\n",
8686
"_ds.hvplot.scatter(\n",
8787
" x=\"Longitude\", y=\"Latitude\", color=\"B_NEC\",\n",
8888
" rasterize=True, colorbar=True, cmap=\"coolwarm\", clabel=\"Vertical (downwards) magnetic field (nT)\"\n",
@@ -229,7 +229,7 @@
229229
"ds = append_model_evaluations(ds, model_coeffs)\n",
230230
"\n",
231231
"# Plot the \n",
232-
"_ds = ds.drop(\"Timestamp\").sel(NEC=\"C\")\n",
232+
"_ds = ds.drop_vars(\"Timestamp\").sel(NEC=\"C\")\n",
233233
"_ds.hvplot.scatter(\n",
234234
" x=\"Longitude\", y=\"Latitude\", color=\"B_NEC_res_model\",\n",
235235
" rasterize=True, colorbar=True, cmap=\"coolwarm\", clim=(-40, 40), clabel=\"Vertical (B_C) data-model residuals (nT)\",\n",
@@ -251,7 +251,7 @@
251251
"metadata": {},
252252
"outputs": [],
253253
"source": [
254-
"_ds = ds.drop(\"Timestamp\").sel(NEC=\"E\")\n",
254+
"_ds = ds.drop_vars(\"Timestamp\").sel(NEC=\"E\")\n",
255255
"_ds.hvplot.scatter(\n",
256256
" x=\"Longitude\", y=\"Latitude\", color=\"B_NEC_res_model\",\n",
257257
" rasterize=True, colorbar=True, cmap=\"coolwarm\", clim=(-40, 40), clabel=\"Eastward (B_E) data-model residuals (nT)\",\n",
@@ -275,7 +275,7 @@
275275
"metadata": {},
276276
"outputs": [],
277277
"source": [
278-
"_ds = ds.drop(\"Timestamp\").sel(NEC=\"E\")\n",
278+
"_ds = ds.drop_vars(\"Timestamp\").sel(NEC=\"E\")\n",
279279
"_ds.hvplot.scatter(\n",
280280
" x=\"MLT\", y=\"Latitude\", color=\"B_NEC_res_model\",\n",
281281
" rasterize=True, colorbar=True, cmap=\"coolwarm\", clim=(-40, 40), clabel=\"Eastward (B_E) data-model residuals (nT)\",\n",
@@ -289,7 +289,7 @@
289289
"metadata": {},
290290
"outputs": [],
291291
"source": [
292-
"ds.drop(\"Timestamp\").hvplot.scatter(x=\"Latitude\", y=\"B_NEC_res_model\", col=\"NEC\", rasterize=True, colorbar=False, cmap=\"bwr\")"
292+
"ds.drop_vars(\"Timestamp\").hvplot.scatter(x=\"Latitude\", y=\"B_NEC_res_model\", col=\"NEC\", rasterize=True, colorbar=False, cmap=\"bwr\")"
293293
]
294294
},
295295
{
@@ -350,7 +350,7 @@
350350
"name": "python",
351351
"nbconvert_exporter": "python",
352352
"pygments_lexer": "ipython3",
353-
"version": "3.10.6"
353+
"version": "3.11.6"
354354
}
355355
},
356356
"nbformat": 4,

0 commit comments

Comments
 (0)