Skip to content

Commit 5b02c50

Browse files
authored
Request NDBC Station Metadata (#239)
Addresses #76 by adding a function get_buoy_metadata to the ndbc submodule. This PR adds needed tests and updates the PACWAVE example to show how to call the metadata.
1 parent c2d2b0e commit 5b02c50

File tree

6 files changed

+564
-411
lines changed

6 files changed

+564
-411
lines changed

examples/PacWave_resource_characterization_example.ipynb

Lines changed: 112 additions & 68 deletions
Large diffs are not rendered by default.

examples/metocean_example.ipynb

Lines changed: 54 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
"source": [
3030
"from mhkit.wave.io import ndbc\n",
3131
"from mhkit.wave.io.hindcast import wind_toolkit\n",
32+
"from mhkit.tidal.graphics import plot_rose\n",
33+
"from mhkit.tidal.graphics import plot_joint_probability_distribution\n",
3234
"import pandas as pd\n",
3335
"import numpy as np\n",
3436
"import matplotlib.pyplot as plt"
@@ -85,139 +87,139 @@
8587
" </thead>\n",
8688
" <tbody>\n",
8789
" <tr>\n",
88-
" <th>1211</th>\n",
90+
" <th>1214</th>\n",
8991
" <td>46022</td>\n",
9092
" <td>1996</td>\n",
9193
" <td>46022c1996.txt.gz</td>\n",
9294
" </tr>\n",
9395
" <tr>\n",
94-
" <th>1212</th>\n",
96+
" <th>1215</th>\n",
9597
" <td>46022</td>\n",
9698
" <td>1997</td>\n",
9799
" <td>46022c1997.txt.gz</td>\n",
98100
" </tr>\n",
99101
" <tr>\n",
100-
" <th>1213</th>\n",
102+
" <th>1216</th>\n",
101103
" <td>46022</td>\n",
102104
" <td>1998</td>\n",
103105
" <td>46022c1998.txt.gz</td>\n",
104106
" </tr>\n",
105107
" <tr>\n",
106-
" <th>1214</th>\n",
108+
" <th>1217</th>\n",
107109
" <td>46022</td>\n",
108110
" <td>1999</td>\n",
109111
" <td>46022c1999.txt.gz</td>\n",
110112
" </tr>\n",
111113
" <tr>\n",
112-
" <th>1215</th>\n",
114+
" <th>1218</th>\n",
113115
" <td>46022</td>\n",
114116
" <td>2000</td>\n",
115117
" <td>46022c2000.txt.gz</td>\n",
116118
" </tr>\n",
117119
" <tr>\n",
118-
" <th>1216</th>\n",
120+
" <th>1219</th>\n",
119121
" <td>46022</td>\n",
120122
" <td>2001</td>\n",
121123
" <td>46022c2001.txt.gz</td>\n",
122124
" </tr>\n",
123125
" <tr>\n",
124-
" <th>1217</th>\n",
126+
" <th>1220</th>\n",
125127
" <td>46022</td>\n",
126128
" <td>2002</td>\n",
127129
" <td>46022c2002.txt.gz</td>\n",
128130
" </tr>\n",
129131
" <tr>\n",
130-
" <th>1218</th>\n",
132+
" <th>1221</th>\n",
131133
" <td>46022</td>\n",
132134
" <td>2003</td>\n",
133135
" <td>46022c2003.txt.gz</td>\n",
134136
" </tr>\n",
135137
" <tr>\n",
136-
" <th>1219</th>\n",
138+
" <th>1222</th>\n",
137139
" <td>46022</td>\n",
138140
" <td>2004</td>\n",
139141
" <td>46022c2004.txt.gz</td>\n",
140142
" </tr>\n",
141143
" <tr>\n",
142-
" <th>1220</th>\n",
144+
" <th>1223</th>\n",
143145
" <td>46022</td>\n",
144146
" <td>2005</td>\n",
145147
" <td>46022c2005.txt.gz</td>\n",
146148
" </tr>\n",
147149
" <tr>\n",
148-
" <th>1221</th>\n",
150+
" <th>1224</th>\n",
149151
" <td>46022</td>\n",
150152
" <td>2006</td>\n",
151153
" <td>46022c2006.txt.gz</td>\n",
152154
" </tr>\n",
153155
" <tr>\n",
154-
" <th>1222</th>\n",
156+
" <th>1225</th>\n",
155157
" <td>46022</td>\n",
156158
" <td>2007</td>\n",
157159
" <td>46022c2007.txt.gz</td>\n",
158160
" </tr>\n",
159161
" <tr>\n",
160-
" <th>1223</th>\n",
162+
" <th>1226</th>\n",
161163
" <td>46022</td>\n",
162164
" <td>2008</td>\n",
163165
" <td>46022c2008.txt.gz</td>\n",
164166
" </tr>\n",
165167
" <tr>\n",
166-
" <th>1224</th>\n",
168+
" <th>1227</th>\n",
167169
" <td>46022</td>\n",
168170
" <td>2009</td>\n",
169171
" <td>46022c2009.txt.gz</td>\n",
170172
" </tr>\n",
171173
" <tr>\n",
172-
" <th>1225</th>\n",
174+
" <th>1228</th>\n",
173175
" <td>46022</td>\n",
174176
" <td>2010</td>\n",
175177
" <td>46022c2010.txt.gz</td>\n",
176178
" </tr>\n",
177179
" <tr>\n",
178-
" <th>1226</th>\n",
180+
" <th>1229</th>\n",
179181
" <td>46022</td>\n",
180182
" <td>2011</td>\n",
181183
" <td>46022c2011.txt.gz</td>\n",
182184
" </tr>\n",
183185
" <tr>\n",
184-
" <th>1227</th>\n",
186+
" <th>1230</th>\n",
185187
" <td>46022</td>\n",
186188
" <td>2012</td>\n",
187189
" <td>46022c2012.txt.gz</td>\n",
188190
" </tr>\n",
189191
" <tr>\n",
190-
" <th>1228</th>\n",
192+
" <th>1231</th>\n",
191193
" <td>46022</td>\n",
192194
" <td>2013</td>\n",
193195
" <td>46022c2013.txt.gz</td>\n",
194196
" </tr>\n",
195197
" <tr>\n",
196-
" <th>1229</th>\n",
198+
" <th>1232</th>\n",
197199
" <td>46022</td>\n",
198200
" <td>2014</td>\n",
199201
" <td>46022c2014.txt.gz</td>\n",
200202
" </tr>\n",
201203
" <tr>\n",
202-
" <th>1230</th>\n",
204+
" <th>1233</th>\n",
203205
" <td>46022</td>\n",
204206
" <td>2015</td>\n",
205207
" <td>46022c2015.txt.gz</td>\n",
206208
" </tr>\n",
207209
" <tr>\n",
208-
" <th>1231</th>\n",
210+
" <th>1234</th>\n",
209211
" <td>46022</td>\n",
210212
" <td>2016</td>\n",
211213
" <td>46022c2016.txt.gz</td>\n",
212214
" </tr>\n",
213215
" <tr>\n",
214-
" <th>1232</th>\n",
216+
" <th>1235</th>\n",
215217
" <td>46022</td>\n",
216218
" <td>2017</td>\n",
217219
" <td>46022c2017.txt.gz</td>\n",
218220
" </tr>\n",
219221
" <tr>\n",
220-
" <th>1233</th>\n",
222+
" <th>1236</th>\n",
221223
" <td>46022</td>\n",
222224
" <td>2018</td>\n",
223225
" <td>46022c2018.txt.gz</td>\n",
@@ -228,29 +230,29 @@
228230
],
229231
"text/plain": [
230232
" id year filename\n",
231-
"1211 46022 1996 46022c1996.txt.gz\n",
232-
"1212 46022 1997 46022c1997.txt.gz\n",
233-
"1213 46022 1998 46022c1998.txt.gz\n",
234-
"1214 46022 1999 46022c1999.txt.gz\n",
235-
"1215 46022 2000 46022c2000.txt.gz\n",
236-
"1216 46022 2001 46022c2001.txt.gz\n",
237-
"1217 46022 2002 46022c2002.txt.gz\n",
238-
"1218 46022 2003 46022c2003.txt.gz\n",
239-
"1219 46022 2004 46022c2004.txt.gz\n",
240-
"1220 46022 2005 46022c2005.txt.gz\n",
241-
"1221 46022 2006 46022c2006.txt.gz\n",
242-
"1222 46022 2007 46022c2007.txt.gz\n",
243-
"1223 46022 2008 46022c2008.txt.gz\n",
244-
"1224 46022 2009 46022c2009.txt.gz\n",
245-
"1225 46022 2010 46022c2010.txt.gz\n",
246-
"1226 46022 2011 46022c2011.txt.gz\n",
247-
"1227 46022 2012 46022c2012.txt.gz\n",
248-
"1228 46022 2013 46022c2013.txt.gz\n",
249-
"1229 46022 2014 46022c2014.txt.gz\n",
250-
"1230 46022 2015 46022c2015.txt.gz\n",
251-
"1231 46022 2016 46022c2016.txt.gz\n",
252-
"1232 46022 2017 46022c2017.txt.gz\n",
253-
"1233 46022 2018 46022c2018.txt.gz"
233+
"1214 46022 1996 46022c1996.txt.gz\n",
234+
"1215 46022 1997 46022c1997.txt.gz\n",
235+
"1216 46022 1998 46022c1998.txt.gz\n",
236+
"1217 46022 1999 46022c1999.txt.gz\n",
237+
"1218 46022 2000 46022c2000.txt.gz\n",
238+
"1219 46022 2001 46022c2001.txt.gz\n",
239+
"1220 46022 2002 46022c2002.txt.gz\n",
240+
"1221 46022 2003 46022c2003.txt.gz\n",
241+
"1222 46022 2004 46022c2004.txt.gz\n",
242+
"1223 46022 2005 46022c2005.txt.gz\n",
243+
"1224 46022 2006 46022c2006.txt.gz\n",
244+
"1225 46022 2007 46022c2007.txt.gz\n",
245+
"1226 46022 2008 46022c2008.txt.gz\n",
246+
"1227 46022 2009 46022c2009.txt.gz\n",
247+
"1228 46022 2010 46022c2010.txt.gz\n",
248+
"1229 46022 2011 46022c2011.txt.gz\n",
249+
"1230 46022 2012 46022c2012.txt.gz\n",
250+
"1231 46022 2013 46022c2013.txt.gz\n",
251+
"1232 46022 2014 46022c2014.txt.gz\n",
252+
"1233 46022 2015 46022c2015.txt.gz\n",
253+
"1234 46022 2016 46022c2016.txt.gz\n",
254+
"1235 46022 2017 46022c2017.txt.gz\n",
255+
"1236 46022 2018 46022c2018.txt.gz"
254256
]
255257
},
256258
"execution_count": 2,
@@ -309,7 +311,7 @@
309311
" </thead>\n",
310312
" <tbody>\n",
311313
" <tr>\n",
312-
" <th>1233</th>\n",
314+
" <th>1236</th>\n",
313315
" <td>46022</td>\n",
314316
" <td>2018</td>\n",
315317
" <td>46022c2018.txt.gz</td>\n",
@@ -320,7 +322,7 @@
320322
],
321323
"text/plain": [
322324
" id year filename\n",
323-
"1233 46022 2018 46022c2018.txt.gz"
325+
"1236 46022 2018 46022c2018.txt.gz"
324326
]
325327
},
326328
"execution_count": 3,
@@ -884,7 +886,7 @@
884886
{
885887
"data": {
886888
"text/plain": [
887-
"<matplotlib.legend.Legend at 0x1d0b8c6d370>"
889+
"<matplotlib.legend.Legend at 0x29b2f3eeeb0>"
888890
]
889891
},
890892
"execution_count": 11,
@@ -957,7 +959,7 @@
957959
"width_velocity = 1 # in m/s\n",
958960
"\n",
959961
"# Plot the wind rose\n",
960-
"ax = ndbc.plot_rose(ndbc_hourly_data['WDIR'],ndbc_hourly_data['WSPD'],\n",
962+
"ax = plot_rose(ndbc_hourly_data['WDIR'],ndbc_hourly_data['WSPD'],\n",
961963
" width_direction,width_velocity)\n"
962964
]
963965
},
@@ -982,7 +984,7 @@
982984
}
983985
],
984986
"source": [
985-
"ax2 = ndbc.plot_rose(wtk_hourly_wind['winddirection_10m_0'],wtk_hourly_wind['windspeed_10m_0'],\n",
987+
"ax2 = plot_rose(wtk_hourly_wind['winddirection_10m_0'],wtk_hourly_wind['windspeed_10m_0'],\n",
986988
" width_direction,width_velocity)"
987989
]
988990
},
@@ -999,19 +1001,10 @@
9991001
"execution_count": 14,
10001002
"metadata": {},
10011003
"outputs": [
1002-
{
1003-
"name": "stderr",
1004-
"output_type": "stream",
1005-
"text": [
1006-
"WARNING:urllib3.connectionpool:Retrying (Retry(total=6, connect=10, read=10, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /api/hsds/datasets/d-bf1ee746-f22af1ee-ce40-863b0e-18a71b?domain=%2Fnrel%2Fwtk%2Foffshore_ca%2FOffshore_CA_2018.h5&api_key=x9f0SNincVSAIeKKuGDUOhyvfRYmrTzg06vZyeuw\n",
1007-
"WARNING:urllib3.connectionpool:Retrying (Retry(total=6, connect=10, read=10, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /api/hsds/datasets/d-bf1ee746-f22af1ee-3ec7-709e83-7740a7?domain=%2Fnrel%2Fwtk%2Foffshore_ca%2FOffshore_CA_2018.h5&api_key=x9f0SNincVSAIeKKuGDUOhyvfRYmrTzg06vZyeuw\n",
1008-
"WARNING:urllib3.connectionpool:Retrying (Retry(total=4, connect=10, read=10, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /api/hsds/datasets/d-bf1ee746-f22af1ee-8082-2ff043-910c51?domain=%2Fnrel%2Fwtk%2Foffshore_ca%2FOffshore_CA_2018.h5&api_key=x9f0SNincVSAIeKKuGDUOhyvfRYmrTzg06vZyeuw\n"
1009-
]
1010-
},
10111004
{
10121005
"data": {
10131006
"text/plain": [
1014-
"<matplotlib.legend.Legend at 0x1d0af709e20>"
1007+
"<matplotlib.legend.Legend at 0x29b2f45adc0>"
10151008
]
10161009
},
10171010
"execution_count": 14,

0 commit comments

Comments
 (0)