|
209 | 209 | " print(f\"Getting data from {urls[key]}\")\n", |
210 | 210 | "\n", |
211 | 211 | " ds = xr.open_dataset(urls[key])\n", |
212 | | - " \n", |
| 212 | + "\n", |
213 | 213 | " data = (\n", |
214 | 214 | " ds.filter_by_attrs(abbreviation=\"HTSGW\")\n", |
215 | 215 | " .sel(lat=lat, lon=lon360, method=\"nearest\")\n", |
|
592 | 592 | "import matplotlib.dates as dates\n", |
593 | 593 | "import pytz\n", |
594 | 594 | "\n", |
595 | | - "\n", |
596 | 595 | "kw = {\n", |
597 | 596 | " \"marker\": \"o\",\n", |
598 | 597 | " \"linestyle\": \"none\",\n", |
599 | 598 | "}\n", |
600 | | - " \n", |
| 599 | + "\n", |
| 600 | + "\n", |
601 | 601 | "def station_scatter(df, station, ax):\n", |
602 | 602 | " df.plot(\n", |
603 | 603 | " ax=ax[0],\n", |
604 | 604 | " x=\"time (UTC)\",\n", |
605 | 605 | " y=\"sea_surface_wave_significant_height (m)\",\n", |
606 | 606 | " label=station,\n", |
607 | 607 | " **kw,\n", |
608 | | - "\n", |
609 | 608 | " )\n", |
610 | 609 | "\n", |
611 | 610 | " df.plot(\n", |
|
658 | 657 | ], |
659 | 658 | "source": [ |
660 | 659 | "import datetime\n", |
661 | | - "import pytz\n", |
662 | 660 | "\n", |
| 661 | + "import pytz\n", |
663 | 662 | "\n", |
664 | 663 | "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", |
666 | 670 | "].copy()\n", |
667 | 671 | "\n", |
668 | 672 | "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", |
670 | 679 | "].copy()\n", |
671 | 680 | "\n", |
672 | 681 | "dfs[\"gdfs\"].rename(\n", |
|
733 | 742 | "tools = \"pan,box_zoom,reset\"\n", |
734 | 743 | "width, height = 750, 250\n", |
735 | 744 | "\n", |
| 745 | + "\n", |
736 | 746 | "def make_plot(series, station):\n", |
737 | 747 | " p = figure(\n", |
738 | 748 | " toolbar_location=\"above\",\n", |
|
751 | 761 | " )\n", |
752 | 762 | " return p, line\n", |
753 | 763 | "\n", |
| 764 | + "\n", |
754 | 765 | "def make_marker(p, location, fname):\n", |
755 | 766 | " html = file_html(p, CDN, fname)\n", |
756 | 767 | " iframe = IFrame(html, width=width + 45, height=height + 80)\n", |
|
1077 | 1088 | "import folium\n", |
1078 | 1089 | "import folium.plugins\n", |
1079 | 1090 | "\n", |
1080 | | - "\n", |
1081 | 1091 | "m = folium.Map()\n", |
1082 | 1092 | "folium.plugins.Fullscreen().add_to(m)\n", |
1083 | 1093 | "\n", |
|
1086 | 1096 | " lat = df[\"latitude (degrees_north)\"].dropna().unique().squeeze()\n", |
1087 | 1097 | " cols = [\"time (UTC)\", \"sea_surface_wave_significant_height (m)\"]\n", |
1088 | 1098 | " df = df[cols].set_index(\"time (UTC)\").squeeze()\n", |
1089 | | - " \n", |
| 1099 | + "\n", |
1090 | 1100 | " df.index = df.index.tz_localize(None)\n", |
1091 | | - " \n", |
| 1101 | + "\n", |
1092 | 1102 | " p, _ = make_plot(df, station=station)\n", |
1093 | 1103 | " marker = make_marker(p, location=(lat, lon), fname=station)\n", |
1094 | 1104 | " marker.add_to(m)\n", |
|
0 commit comments