|
92 | 92 | "Granules used:\n",
|
93 | 93 | "\n",
|
94 | 94 | "* [GPM_3IMERGHH](https://cmr.uat.earthdata.nasa.gov/search/concepts/G1256265181-EEDTEST.umm_json)\n",
|
| 95 | + " * [OPeNDAP DMR](https://opendap.uat.earthdata.nasa.gov/collections/C1245618475-EEDTEST/granules/GPM_3IMERGHH.06:3B-HHR.MS.MRG.3IMERG.20200201-S233000-E235959.1410.V06B.HDF5.dmr.xml)\n", |
95 | 96 | "* [GEDI L4A](https://cmr.uat.earthdata.nasa.gov/search/concepts/G1245557637-EEDTEST.umm_json)\n",
|
96 | 97 | "\n",
|
97 | 98 | "The granules linked to above will not be circulated with this notebook, but can be downloaded via the `GET DATA` URLs in the UMM-G records."
|
|
106 | 107 | "source": [
|
107 | 108 | "import json\n",
|
108 | 109 | "\n",
|
109 |
| - "from varinfo import VarInfoFromNetCDF4\n", |
| 110 | + "from varinfo import VarInfoFromNetCDF4, VarInfoFromDmr\n", |
110 | 111 | "\n",
|
111 | 112 | "# Update the following paths to where you have downloaded the data using the links above:\n",
|
112 | 113 | "gpm_granule_path = '/path/to/locally/saved/file/3B-HHR.MS.MRG.3IMERG.20200201-S233000-E235959.1410.V06B.HDF5'\n",
|
| 114 | + "gpm_dmr_granule_path = '/path/to/locally/saved/file/GPM_3IMERGHH.06_3B-HHR.MS.MRG.3IMERG.20200201-S233000-E235959.1410.V06B.HDF5.dmr.xml'\n", |
113 | 115 | "gedi_l4a_granule_path = '/path/to/locally/saved/file/GEDI04_A_2021216232727_O14984_01_T04304_02_002_01_V002.h5'"
|
114 | 116 | ]
|
115 | 117 | },
|
|
118 | 120 | "id": "c1ef3f8a",
|
119 | 121 | "metadata": {},
|
120 | 122 | "source": [
|
121 |
| - "### Instantiate VarInfoFromNetCDF4 for GPM_3IMERGHH collection:" |
| 123 | + "### Instantiate VarInfoFromNetCDF4 and VarInfoFromDmr for GPM_3IMERGHH collection:" |
122 | 124 | ]
|
123 | 125 | },
|
124 | 126 | {
|
|
128 | 130 | "metadata": {},
|
129 | 131 | "outputs": [],
|
130 | 132 | "source": [
|
131 |
| - "gpm_imerg = VarInfoFromNetCDF4(gpm_granule_path, short_name='GPM_3IMERGHH')" |
| 133 | + "# Instantiate VarInfoFromNetCDF4\n", |
| 134 | + "gpm_imerg = VarInfoFromNetCDF4(gpm_granule_path, short_name='GPM_3IMERGHH')\n", |
| 135 | + "\n", |
| 136 | + "# Instantiate VarInfoFromDmr\n", |
| 137 | + "gpm_imerg_dmr = VarInfoFromDmr(gpm_dmr_granule_path, short_name='GPM_3IMERGHH')" |
132 | 138 | ]
|
133 | 139 | },
|
134 | 140 | {
|
|
146 | 152 | "metadata": {},
|
147 | 153 | "outputs": [],
|
148 | 154 | "source": [
|
| 155 | + "# Get all variables from VarInfoFromNetCDF4\n", |
149 | 156 | "gpm_imerg.get_all_variables()"
|
150 | 157 | ]
|
151 | 158 | },
|
| 159 | + { |
| 160 | + "cell_type": "code", |
| 161 | + "execution_count": null, |
| 162 | + "id": "640c4fdf", |
| 163 | + "metadata": {}, |
| 164 | + "outputs": [], |
| 165 | + "source": [ |
| 166 | + "# Get all variables from VarInfoFromDmr\n", |
| 167 | + "gpm_imerg_dmr.get_all_variables()" |
| 168 | + ] |
| 169 | + }, |
152 | 170 | {
|
153 | 171 | "cell_type": "markdown",
|
154 | 172 | "id": "0f91829a",
|
|
164 | 182 | "metadata": {},
|
165 | 183 | "outputs": [],
|
166 | 184 | "source": [
|
| 185 | + "# Get variables from VarInfoFromNetCDF4\n", |
167 | 186 | "calibrated_precipitation = gpm_imerg.get_variable('/Grid/precipitationCal')\n",
|
168 |
| - "print('Variable attributes:')\n", |
| 187 | + "print('Variable attributes from NetCDF4:')\n", |
169 | 188 | "print(calibrated_precipitation.attributes)\n",
|
170 | 189 | "\n",
|
171 |
| - "print('\\n\\nVariable references:')\n", |
| 190 | + "# Get references from VarInfoFromNetCDF4\n", |
| 191 | + "print('\\n\\nVariable references from NetCDF4:')\n", |
172 | 192 | "print(calibrated_precipitation.get_references())"
|
173 | 193 | ]
|
174 | 194 | },
|
| 195 | + { |
| 196 | + "cell_type": "code", |
| 197 | + "execution_count": null, |
| 198 | + "id": "ee2d7dbc", |
| 199 | + "metadata": {}, |
| 200 | + "outputs": [], |
| 201 | + "source": [ |
| 202 | + "# Get variables from VarInfoFromDmr\n", |
| 203 | + "calibrated_precipitation_dmr = gpm_imerg_dmr.get_variable('/Grid/precipitationCal')\n", |
| 204 | + "print('Variable attributes from DMR:')\n", |
| 205 | + "print(calibrated_precipitation_dmr.attributes)\n", |
| 206 | + "\n", |
| 207 | + "# Get references from VarInfoFromDmr\n", |
| 208 | + "print('\\n\\nVariable references from DMR:')\n", |
| 209 | + "print(calibrated_precipitation_dmr.get_references())" |
| 210 | + ] |
| 211 | + }, |
175 | 212 | {
|
176 | 213 | "cell_type": "markdown",
|
177 | 214 | "id": "0a69e2ab",
|
|
189 | 226 | "metadata": {},
|
190 | 227 | "outputs": [],
|
191 | 228 | "source": [
|
| 229 | + "# Get required variables from VarInfoFromNetCDF4\n", |
192 | 230 | "gpm_imerg.get_required_variables(\n",
|
193 | 231 | " {\n",
|
194 | 232 | " '/Grid/precipitationCal',\n",
|
195 | 233 | " }\n",
|
196 | 234 | ")"
|
197 | 235 | ]
|
198 | 236 | },
|
| 237 | + { |
| 238 | + "cell_type": "code", |
| 239 | + "execution_count": null, |
| 240 | + "id": "3c5310cb", |
| 241 | + "metadata": {}, |
| 242 | + "outputs": [], |
| 243 | + "source": [ |
| 244 | + "# Get required variables from VarInfoFromDmr\n", |
| 245 | + "gpm_imerg_dmr.get_required_variables(\n", |
| 246 | + " {\n", |
| 247 | + " '/Grid/precipitationCal',\n", |
| 248 | + " }\n", |
| 249 | + ")" |
| 250 | + ] |
| 251 | + }, |
199 | 252 | {
|
200 | 253 | "cell_type": "markdown",
|
201 | 254 | "id": "61c8e746",
|
|
231 | 284 | "metadata": {},
|
232 | 285 | "outputs": [],
|
233 | 286 | "source": [
|
234 |
| - "print('Spatial dimensions for /Grid/precipitationCal')\n", |
| 287 | + "# Spatial dimensions for /Grid/precipitationCal from VarInfoFromNetCDF4\n", |
| 288 | + "print('Spatial dimensions for /Grid/precipitationCal from VarInfoFromNetCDF4')\n", |
235 | 289 | "print(\n",
|
236 | 290 | " gpm_imerg.get_spatial_dimensions(\n",
|
237 | 291 | " {\n",
|
|
240 | 294 | " )\n",
|
241 | 295 | ")\n",
|
242 | 296 | "\n",
|
243 |
| - "print('\\nTemporal dimensions for /Grid/precipationCal')\n", |
| 297 | + "# Temporal dimensions for /Grid/precipationCal from VarInfoFromNetCDF4\n", |
| 298 | + "\n", |
| 299 | + "print('\\nTemporal dimensions for /Grid/precipationCal from VarInfoFromNetCDF4')\n", |
244 | 300 | "print(\n",
|
245 | 301 | " gpm_imerg.get_temporal_dimensions(\n",
|
246 | 302 | " {\n",
|
|
250 | 306 | ")"
|
251 | 307 | ]
|
252 | 308 | },
|
| 309 | + { |
| 310 | + "cell_type": "code", |
| 311 | + "execution_count": null, |
| 312 | + "id": "3afe54bb", |
| 313 | + "metadata": {}, |
| 314 | + "outputs": [], |
| 315 | + "source": [ |
| 316 | + "# Spatial dimensions for /Grid/precipitationCal from VarInfoFromDmr'\n", |
| 317 | + "print('Spatial dimensions for /Grid/precipitationCal from VarInfoFromDmr')\n", |
| 318 | + "print(\n", |
| 319 | + " gpm_imerg_dmr.get_spatial_dimensions(\n", |
| 320 | + " {\n", |
| 321 | + " '/Grid/precipitationCal',\n", |
| 322 | + " }\n", |
| 323 | + " )\n", |
| 324 | + ")\n", |
| 325 | + "\n", |
| 326 | + "# Temporal dimensions for /Grid/precipationCal from VarInfoFromDmr\n", |
| 327 | + "print('\\nTemporal dimensions for /Grid/precipationCal from VarInfoFromDmr')\n", |
| 328 | + "print(\n", |
| 329 | + " gpm_imerg_dmr.get_temporal_dimensions(\n", |
| 330 | + " {\n", |
| 331 | + " '/Grid/precipitationCal',\n", |
| 332 | + " }\n", |
| 333 | + " )\n", |
| 334 | + ")" |
| 335 | + ] |
| 336 | + }, |
253 | 337 | {
|
254 | 338 | "cell_type": "markdown",
|
255 | 339 | "id": "b187e644",
|
|
273 | 357 | "metadata": {},
|
274 | 358 | "outputs": [],
|
275 | 359 | "source": [
|
| 360 | + "# Get group variables by dimensions from VarInfoFromNetCDF4\n", |
276 | 361 | "gpm_imerg.group_variables_by_dimensions()"
|
277 | 362 | ]
|
278 | 363 | },
|
| 364 | + { |
| 365 | + "cell_type": "code", |
| 366 | + "execution_count": null, |
| 367 | + "id": "9fe25a71", |
| 368 | + "metadata": {}, |
| 369 | + "outputs": [], |
| 370 | + "source": [ |
| 371 | + "# Get group variables by dimensions from VarInfoFromDmr\n", |
| 372 | + "gpm_imerg_dmr.group_variables_by_dimensions()" |
| 373 | + ] |
| 374 | + }, |
279 | 375 | {
|
280 | 376 | "cell_type": "markdown",
|
281 | 377 | "id": "8299fc18",
|
|
308 | 404 | "metadata": {},
|
309 | 405 | "outputs": [],
|
310 | 406 | "source": [
|
| 407 | + "# Get UMM-Var from VarInfoFromNetCDF4\n", |
311 | 408 | "from varinfo import VarInfoFromNetCDF4\n",
|
312 | 409 | "from varinfo.umm_var import get_all_umm_var, get_umm_var\n",
|
313 | 410 | "\n",
|
|
320 | 417 | "print(json.dumps(single_umm_var, indent=2))"
|
321 | 418 | ]
|
322 | 419 | },
|
| 420 | + { |
| 421 | + "cell_type": "code", |
| 422 | + "execution_count": null, |
| 423 | + "id": "c4f2e607", |
| 424 | + "metadata": {}, |
| 425 | + "outputs": [], |
| 426 | + "source": [ |
| 427 | + "# Get UMM-Var from VarInfoFromDmr\n", |
| 428 | + "from varinfo import VarInfoFromDmr\n", |
| 429 | + "from varinfo.umm_var import get_umm_var\n", |
| 430 | + "\n", |
| 431 | + "var_info_dmr = VarInfoFromDmr(gpm_dmr_granule_path, short_name='GPM_3IMERGHH')\n", |
| 432 | + "\n", |
| 433 | + "# Get single UMM-Var record by variable name:\n", |
| 434 | + "precipitation_variable_dmr = var_info_dmr.get_variable('/Grid/precipitationCal')\n", |
| 435 | + "single_umm_var_dmr = get_umm_var(var_info_dmr, precipitation_variable_dmr)\n", |
| 436 | + "\n", |
| 437 | + "print(json.dumps(single_umm_var_dmr, indent=2))" |
| 438 | + ] |
| 439 | + }, |
323 | 440 | {
|
324 | 441 | "cell_type": "markdown",
|
325 | 442 | "id": "6fc563c3",
|
|
337 | 454 | "metadata": {},
|
338 | 455 | "outputs": [],
|
339 | 456 | "source": [
|
| 457 | + "# Get all UMM-Var from VarInfoFromNetCDF4\n", |
340 | 458 | "all_umm_var = get_all_umm_var(var_info)\n",
|
341 | 459 | "\n",
|
342 | 460 | "print(json.dumps(all_umm_var, indent=2))"
|
343 | 461 | ]
|
344 | 462 | },
|
| 463 | + { |
| 464 | + "cell_type": "code", |
| 465 | + "execution_count": null, |
| 466 | + "id": "9ab64897", |
| 467 | + "metadata": {}, |
| 468 | + "outputs": [], |
| 469 | + "source": [ |
| 470 | + "# Get all UMM-Var from VarInfoFromDmr\n", |
| 471 | + "all_umm_var_dmr = get_all_umm_var(var_info_dmr)\n", |
| 472 | + "\n", |
| 473 | + "print(json.dumps(all_umm_var_dmr, indent=2))" |
| 474 | + ] |
| 475 | + }, |
345 | 476 | {
|
346 | 477 | "cell_type": "markdown",
|
347 | 478 | "id": "5cf8246b",
|
|
434 | 565 | "\n",
|
435 | 566 | "The list below refers to potential improvements that can be made within the core Python package to improve the schema coverage of the generated UMM-Var records:\n",
|
436 | 567 | "\n",
|
437 |
| - "* Ensuring variables parsed from a DMR file also contain shape information, similar to current functionality of NetCDF-4 file parsing. This information is stored within a DMR in separate `<Dimension />` XML elements. This would allow UMM-Var JSON generated from DMR data to have sizes on their dimensions.\n", |
438 | 568 | "* Adding suitable heuristics to the `VariableBase` class to identify vertical spatial dimensions. Currently these map to the dimension type of \"OTHER\".\n",
|
439 | 569 | "* Adding along- and across-track swath dimension identification heuristics to `VariableBase`.\n",
|
440 | 570 | "* Improving the metadata for projected horizontal spatial dimensions. These are currently mapped to a dimension type of \"OTHER\". While they can be identified within the `Variable` classes, there is not currently an applicable UMM-Var option in the `DimensionType.Type` enumeration:\n",
|
|
470 | 600 | "name": "python",
|
471 | 601 | "nbconvert_exporter": "python",
|
472 | 602 | "pygments_lexer": "ipython3",
|
473 |
| - "version": "3.11.9" |
| 603 | + "version": "3.11.11" |
474 | 604 | }
|
475 | 605 | },
|
476 | 606 | "nbformat": 4,
|
|
0 commit comments