4 "cell_type": "markdown",
5 "id": "b1100419-e2ec-46b6-89d3-327421288025",
8 "## Find Data Availability for Stations\n",
10 "Find which RAWS stations in Colorado have data availability for variables of interest to fuel moisture model."
15 "execution_count": null,
16 "id": "edb47918-af48-4002-8a66-7e78c7d10c77",
20 "!pip install MesoPy\n",
21 "from MesoPy import Meso\n",
22 "import os.path as osp\n",
26 "# bounding_box = \"-115, 38, -110, 40\"\n",
27 "meso_token=\"4192c18707b848299783d59a9317c6e1\"\n",
33 "execution_count": null,
34 "id": "37683794-406d-4524-99d3-2c167ff444ea",
38 "time_start = \"201806010800\" # June 1 2018 08:00 in format yyyymmddHHMM\n",
39 "time_s2 = \"201806010900\" # June 1 2018 09:00 in format yyyymmddHHMM \n",
40 "time_end = \"201907200900\" # June 20 2018 09:00 in format yyyymmddHHMM\n",
42 "vars='air_temp,relative_humidity,precip_accum,fuel_moisture'"
47 "execution_count": null,
48 "id": "7dfb0387-6535-4976-9e9a-62e3cf9a69cd",
52 "meso_obss = m.timeseries(time_start, time_s2, state=\"CO\", \n",
53 " showemptystations = '0', vars=vars)"
58 "execution_count": null,
59 "id": "2255f323-2685-47b1-b862-f86eca6a3991",
63 "import pandas as pd\n",
64 "import numpy as np\n",
66 "station_df = pd.DataFrame(columns=['STID', 'air_temp', 'relative_humidity', 'precip_accum', 'fuel_moisture'],\n",
67 " index=range(0, len(meso_obss[\"STATION\"])))"
72 "execution_count": null,
73 "id": "6f4fbe0d-dd16-4c1c-950e-97e23e5a1918",
77 "for i in range(0, station_df.shape[0]):\n",
78 " station_df[\"STID\"][i] = meso_obss[\"STATION\"][i][\"STID\"]\n",
79 " station_df[\"air_temp\"][i] = int(\"air_temp\" in meso_obss[\"STATION\"][i][\"SENSOR_VARIABLES\"].keys())\n",
80 " station_df[\"relative_humidity\"][i] = int(\"relative_humidity\" in meso_obss[\"STATION\"][i][\"SENSOR_VARIABLES\"].keys())\n",
81 " station_df[\"precip_accum\"][i] = int(\"precip_accum\" in meso_obss[\"STATION\"][i][\"SENSOR_VARIABLES\"].keys())\n",
82 " station_df[\"fuel_moisture\"][i] = int(\"fuel_moisture\" in meso_obss[\"STATION\"][i][\"SENSOR_VARIABLES\"].keys())"
87 "execution_count": null,
88 "id": "de8ec8c9-4af7-4bdc-9dbc-1b361d011654",
92 "station_df[station_df[\"fuel_moisture\"]==1].head()"
97 "execution_count": null,
98 "id": "99dde77e-5f6f-4e45-babf-f7599e8fca14",
103 "station_df.to_csv(osp.join(outpath, 'station_df_co.csv'), index=False)"
107 "cell_type": "markdown",
108 "id": "8f63bc34-6deb-48bd-9aa9-c2f5a4cc293e",
111 "## Plot Timeseries for a Station\n",
113 "Visualize the available data."
118 "execution_count": null,
119 "id": "d45d76e5-ccb1-45b6-a187-25d0d1f91b8e",
123 "meso_ts = m.timeseries(time_start, time_end, stid=\"CPTC2\", showemptystations = '0', vars=vars) # ask the object for data"
128 "execution_count": null,
129 "id": "05e37b54-e014-44e8-b0f4-e3d53b5dbf86",
133 "from datetime import datetime, timedelta, time\n",
134 "import numpy as np\n",
135 "import matplotlib.pyplot as plt\n",
137 "station = meso_ts['STATION'][0]\n",
138 "time_str = station['OBSERVATIONS']['date_time']\n",
139 "obs_time = [datetime.strptime(t, '%Y-%m-%dT%H:%M:%SZ').replace(tzinfo=pytz.UTC) for t in time_str]\n",
140 "start_time = obs_time[0].replace(minute=0) # remember obs_time and start_time for later\n",
141 "end_time = obs_time[-1]\n",
142 "obs_data = np.array(station['OBSERVATIONS'][\"fuel_moisture_set_1\"])\n",
145 "%matplotlib inline\n",
146 "plt.figure(figsize=(16,4))\n",
147 "plt.plot(obs_data,linestyle='-',c='k',label='10-h fuel data')\n",
148 "plt.title(station['STID'] + ' 10 h fuel moisture data')\n",
149 "plt.xlabel('Time (hours)') \n",
150 "plt.ylabel('Fuel moisture content (%)')\n",
156 "execution_count": null,
157 "id": "d58d9cb6-f87f-47a2-8845-97c6d6c15358",
161 "obs_data = np.array(station['OBSERVATIONS'][\"relative_humidity_set_1\"])\n",
164 "%matplotlib inline\n",
165 "plt.figure(figsize=(16,4))\n",
166 "plt.plot(obs_data,linestyle='-',c='k')\n",
167 "plt.title(station['STID'] + ' relative humidity data')\n",
168 "plt.xlabel('Time (hours)') \n",
169 "plt.ylabel('Relative Humidity (%)')"
174 "execution_count": null,
175 "id": "20176db9-997d-4a46-8d73-f2e7a08ee9d4",
179 "obs_data = np.array(station['OBSERVATIONS'][\"precip_accum_set_1\"])\n",
182 "%matplotlib inline\n",
183 "plt.figure(figsize=(16,4))\n",
184 "plt.plot(obs_data,linestyle='-',c='k')\n",
185 "plt.title(station['STID'] + ' precip accum data')\n",
186 "plt.xlabel('Time (hours)') \n",
187 "plt.ylabel('Precipitation Accumulated (mm)')"
192 "execution_count": null,
193 "id": "2cf93527-578c-4ce2-b4f6-1508b9dbfa7c",
197 "obs_data = np.array(station['OBSERVATIONS'][\"air_temp_set_1\"])\n",
200 "%matplotlib inline\n",
201 "plt.figure(figsize=(16,4))\n",
202 "plt.plot(obs_data,linestyle='-',c='k')\n",
203 "plt.title(station['STID'] + ' air temp data')\n",
204 "plt.xlabel('Time (hours)') \n",
205 "plt.ylabel('Air Temp (C)')"
210 "execution_count": null,
211 "id": "45264085-d516-4803-bcc6-d0a64cc7e1c9",
218 "execution_count": null,
219 "id": "0730d61b-6d71-407a-a31b-8b16494f1921",
227 "display_name": "Python 3 (ipykernel)",
228 "language": "python",
236 "file_extension": ".py",
237 "mimetype": "text/x-python",
239 "nbconvert_exporter": "python",
240 "pygments_lexer": "ipython3",