Skip to content

Commit 44a275b

Browse files
committed
add map
1 parent c369c41 commit 44a275b

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

jupyterbook/content/code_gallery/data_access_notebooks/2022-11-25-plan_surf_trip_EDS.ipynb

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
" print(f\"Getting data from {urls[key]}\")\n",
210210
"\n",
211211
" ds = xr.open_dataset(urls[key])\n",
212-
" \n",
212+
"\n",
213213
" data = (\n",
214214
" ds.filter_by_attrs(abbreviation=\"HTSGW\")\n",
215215
" .sel(lat=lat, lon=lon360, method=\"nearest\")\n",
@@ -592,20 +592,19 @@
592592
"import matplotlib.dates as dates\n",
593593
"import pytz\n",
594594
"\n",
595-
"\n",
596595
"kw = {\n",
597596
" \"marker\": \"o\",\n",
598597
" \"linestyle\": \"none\",\n",
599598
"}\n",
600-
" \n",
599+
"\n",
600+
"\n",
601601
"def station_scatter(df, station, ax):\n",
602602
" df.plot(\n",
603603
" ax=ax[0],\n",
604604
" x=\"time (UTC)\",\n",
605605
" y=\"sea_surface_wave_significant_height (m)\",\n",
606606
" label=station,\n",
607607
" **kw,\n",
608-
"\n",
609608
" )\n",
610609
"\n",
611610
" df.plot(\n",
@@ -658,15 +657,25 @@
658657
],
659658
"source": [
660659
"import datetime\n",
661-
"import pytz\n",
662660
"\n",
661+
"import pytz\n",
663662
"\n",
664663
"dfs[\"gdfs\"] = df_out[\n",
665-
" [\"time\", \"Significant_height_of_combined_wind_waves_and_swell_surface_gfs\", \"lat_gfs\", \"lon_gfs\"]\n",
664+
" [\n",
665+
" \"time\",\n",
666+
" \"Significant_height_of_combined_wind_waves_and_swell_surface_gfs\",\n",
667+
" \"lat_gfs\",\n",
668+
" \"lon_gfs\",\n",
669+
" ]\n",
666670
"].copy()\n",
667671
"\n",
668672
"dfs[\"nwps\"] = df_out[\n",
669-
" [\"time\", \"Significant_height_of_combined_wind_waves_and_swell_surface_nwps\", 'lat_nwps', 'lon_nwps']\n",
673+
" [\n",
674+
" \"time\",\n",
675+
" \"Significant_height_of_combined_wind_waves_and_swell_surface_nwps\",\n",
676+
" \"lat_nwps\",\n",
677+
" \"lon_nwps\",\n",
678+
" ]\n",
670679
"].copy()\n",
671680
"\n",
672681
"dfs[\"gdfs\"].rename(\n",
@@ -733,6 +742,7 @@
733742
"tools = \"pan,box_zoom,reset\"\n",
734743
"width, height = 750, 250\n",
735744
"\n",
745+
"\n",
736746
"def make_plot(series, station):\n",
737747
" p = figure(\n",
738748
" toolbar_location=\"above\",\n",
@@ -751,6 +761,7 @@
751761
" )\n",
752762
" return p, line\n",
753763
"\n",
764+
"\n",
754765
"def make_marker(p, location, fname):\n",
755766
" html = file_html(p, CDN, fname)\n",
756767
" iframe = IFrame(html, width=width + 45, height=height + 80)\n",
@@ -1077,7 +1088,6 @@
10771088
"import folium\n",
10781089
"import folium.plugins\n",
10791090
"\n",
1080-
"\n",
10811091
"m = folium.Map()\n",
10821092
"folium.plugins.Fullscreen().add_to(m)\n",
10831093
"\n",
@@ -1086,9 +1096,9 @@
10861096
" lat = df[\"latitude (degrees_north)\"].dropna().unique().squeeze()\n",
10871097
" cols = [\"time (UTC)\", \"sea_surface_wave_significant_height (m)\"]\n",
10881098
" df = df[cols].set_index(\"time (UTC)\").squeeze()\n",
1089-
" \n",
1099+
"\n",
10901100
" df.index = df.index.tz_localize(None)\n",
1091-
" \n",
1101+
"\n",
10921102
" p, _ = make_plot(df, station=station)\n",
10931103
" marker = make_marker(p, location=(lat, lon), fname=station)\n",
10941104
" marker.add_to(m)\n",

0 commit comments

Comments
 (0)