5 "execution_count": null,
6 "id": "dd71eb39-f938-440e-99a8-3dc02ee55102",
10 "from utils import read_pkl\n",
11 "from data_funcs import combine_nested\n",
12 "import pandas as pd\n",
13 "import matplotlib.pyplot as plt\n",
14 "import plotly.express as px\n",
15 "import plotly.graph_objects as go\n",
16 "import numpy as np\n",
17 "from mpl_toolkits.basemap import Basemap\n",
18 "from matplotlib.patches import Polygon\n",
19 "import os.path as osp"
24 "execution_count": null,
25 "id": "f8ac5c75-a590-4dae-8a5f-737c8833af1e",
32 "execution_count": null,
33 "id": "4197b2ae-d8e3-4878-b87b-795f7622c753",
37 "# dat = read_pkl(\"train.pkl\")\n",
38 "dat = read_pkl(\"data/fmda_rocky_202403-05_f05.pkl\")"
43 "execution_count": null,
44 "id": "28dcf75e-2fad-4fc5-8deb-354f1e31a472",
48 "dat['CPTC2_202403'].keys()"
53 "execution_count": null,
54 "id": "d28d3760-92ad-4e14-90fd-69020c2c4b56",
59 "bbox = [37, -111, 46, -95]"
64 "execution_count": null,
65 "id": "189ab08a-06f5-4758-8d9f-ee95e5cafa70",
71 " loc_data = dat[key]['loc']\n",
72 " data.append([loc_data['STID'], loc_data['lat'], loc_data['lon']])\n",
74 "df = pd.DataFrame(data, columns=['STID', 'lat', 'lon'])\n",
80 "execution_count": null,
81 "id": "4c04a46d-7096-4fad-8c20-807e409f8f80",
85 "def make_st_map_interactive(df):\n",
86 " fig = go.Figure(go.Scattermapbox(\n",
90 " marker=go.scattermapbox.Marker(\n",
94 " text=df['STID'],\n",
96 " showlegend=False # Turn off legend\n",
100 " center_lon=df['lon'].median()\n",
101 " center_lat=df['lat'].median()\n",
102 " fig.update_layout(\n",
103 " mapbox_style=\"open-street-map\",\n",
104 " mapbox_center=dict(lat=center_lat, lon=center_lon)\n",
106 " # Add Lines for Bounding Box\n",
108 " fig.add_trace(go.Scattermapbox(\n",
109 " mode=\"lines\",\n",
110 " lon=[df['lon'].min(), df['lon'].min(), df['lon'].max(), df['lon'].max(), df['lon'].min()],\n",
111 " lat=[df['lat'].min(), df['lat'].max(), df['lat'].max(), df['lat'].min(), df['lat'].min()],\n",
112 " marker=dict(size=5, color=\"black\"),\n",
113 " line=dict(width=1.5, color=\"black\"),\n",
114 " showlegend=False\n",
117 " fig.update_layout(\n",
118 " margin={\"r\":0,\"t\":0,\"l\":0,\"b\":0},\n",
119 " mapbox_zoom =5,\n",
120 " mapbox_center={\"lat\": np.median(df.lat), \"lon\": np.median(df.lon)}, # Center the map on desired location\n",
129 "execution_count": null,
130 "id": "1fd6cfd9-8ce5-44a8-a618-fc06ba898666",
134 "make_st_map_interactive(df)"
139 "execution_count": null,
140 "id": "39374ba7-e4fb-4a7d-a9b0-7bca76e2f950",
144 "st = \"TGSK1_202403\""
149 "execution_count": null,
150 "id": "62053cfb-d882-4044-90c5-38165572596e",
154 "fig, ax = plt.subplots()\n",
155 "plt.title(f\"RAWS Station {st}\")\n",
156 "ax.plot(dat[st]['RAWS']['fm'][0:500], linestyle='-',c='#468a29',label='FMC Observed')\n",
157 "plt.legend(loc='upper right')\n",
158 "ax.set_ylabel(\"Fuel Moisture Content (%)\")\n",
159 "ax.set_xlabel(\"Hour\")\n",
160 "plt.savefig(\"outputs/fmc_plot2.png\")\n",
161 "# Increase the thickness of the axis borders\n",
162 "ax.spines['top'].set_linewidth(1.5)\n",
163 "ax.spines['bottom'].set_linewidth(1.5)\n",
164 "ax.spines['left'].set_linewidth(1.5)\n",
165 "ax.spines['right'].set_linewidth(1.5)\n",
167 "# plt.savefig(\"outputs/fmc_plot2.png\")"
171 "cell_type": "markdown",
172 "id": "d9aba79a-70b0-4fdb-aeaf-bc593daa0bda",
175 "## Plot Tif Files Remotely"
180 "execution_count": null,
181 "id": "6e5ce074-d1c6-4521-857e-d31aec07f88b",
185 "url = \"https://demo.openwfm.org/web/data/fmda/tif/20210428/\"\n",
186 "tif_files = [\"hrrr.t00z.wrfprsf00.629.tif\", \"hrrr.t00z.wrfprsf01.629.tif\",\n",
187 " \"hrrr.t00z.wrfprsf03.629.tif\", \"hrrr.t00z.wrfprsf06.629.tif\"]"
192 "execution_count": null,
193 "id": "0d5d84da-39ce-46b6-ade1-5afb774e9159",
198 "from rasterio.plot import show\n",
199 "import matplotlib.pyplot as plt"
204 "execution_count": null,
205 "id": "08d8d690-fdaa-479f-a597-77f2fa4aace9",
209 "with rasterio.open(osp.join(url, tif_files[0])) as dataset:\n",
210 " # Plot the dataset\n",
211 " fig, ax = plt.subplots()\n",
212 " show(dataset, ax=ax)\n",
218 "execution_count": null,
219 "id": "7cfd568d-30d9-4a0a-b83a-9b500fced3b4",
223 "with rasterio.open(osp.join(url, tif_files[2])) as dataset:\n",
224 " # Plot the dataset\n",
225 " fig, ax = plt.subplots()\n",
226 " show(dataset, ax=ax)\n",
232 "execution_count": null,
233 "id": "1ca98402-5fa4-4383-8798-969db67f7352",
240 "execution_count": null,
241 "id": "86d94b91-fbb4-47fb-bba0-e41551f361b5",
249 "display_name": "Python 3 (ipykernel)",
250 "language": "python",
258 "file_extension": ".py",
259 "mimetype": "text/x-python",
261 "nbconvert_exporter": "python",
262 "pygments_lexer": "ipython3",