|
10 | 10 | TIME = xr.date_range("2000", "2001", T) |
11 | 11 |
|
12 | 12 |
|
13 | | -datasets = { |
14 | | - "ds_copernicusmarine": xr.Dataset( |
15 | | - # Copernicus Marine Service dataset as retrieved by the `copernicusmarine` toolkit |
| 13 | +def _copernicusmarine(): |
| 14 | + """Copernicus Marine Service dataset as retrieved by the `copernicusmarine` toolkit""" |
| 15 | + return xr.Dataset( |
16 | 16 | { |
17 | 17 | "uo": ( |
18 | 18 | ["time", "depth", "latitude", "longitude"], |
|
85 | 85 | }, |
86 | 86 | ), |
87 | 87 | }, |
88 | | - ), |
89 | | - "ds_copernicusmarine_globcurrents": xr.Dataset( |
90 | | - # Copernicus Marine Service GlobCurrent dataset (MULTIOBS_GLO_PHY_MYNRT_015_003) |
| 88 | + ) |
| 89 | + |
| 90 | + |
| 91 | +def _copernicusmarine_globcurrents(): |
| 92 | + """Copernicus Marine Service GlobCurrent dataset (MULTIOBS_GLO_PHY_MYNRT_015_003)""" |
| 93 | + return xr.Dataset( |
91 | 94 | { |
92 | 95 | "ue": ( |
93 | 96 | ["time", "depth", "latitude", "longitude"], |
|
154 | 157 | }, |
155 | 158 | ), |
156 | 159 | }, |
157 | | - ), |
158 | | - "ds_NEMO_MOI_U": xr.Dataset( |
159 | | - # NEMO model dataset (U component) as serviced by Mercator Ocean International |
| 160 | + ) |
| 161 | + |
| 162 | + |
| 163 | +def _NEMO_MOI_U(): |
| 164 | + """NEMO model dataset (U component) as serviced by Mercator Ocean International""" |
| 165 | + return xr.Dataset( |
160 | 166 | { |
161 | 167 | "vozocrtx": ( |
162 | 168 | ["deptht", "y", "x"], |
|
259 | 265 | }, |
260 | 266 | ), |
261 | 267 | }, |
262 | | - ), |
263 | | - "ds_NEMO_MOI_V": xr.Dataset( |
264 | | - # NEMO model dataset (V component) as serviced by Mercator Ocean International |
| 268 | + ) |
| 269 | + |
| 270 | + |
| 271 | +def _NEMO_MOI_V(): |
| 272 | + """NEMO model dataset (V component) as serviced by Mercator Ocean International""" |
| 273 | + return xr.Dataset( |
265 | 274 | { |
266 | 275 | "vomecrty": ( |
267 | 276 | ["deptht", "y", "x"], |
|
348 | 357 | }, |
349 | 358 | ), |
350 | 359 | }, |
351 | | - ), |
352 | | - "ds_CESM": xr.Dataset( |
353 | | - # CESM model dataset |
354 | | - { |
355 | | - "UVEL": ( |
356 | | - ["time", "z_t", "nlat", "nlon"], |
357 | | - np.random.rand(T, Z, Y, X, dtype="float32"), |
358 | | - { |
359 | | - "long_name": "Velocity in grid-x direction", |
360 | | - "units": "centimeter/s", |
361 | | - "grid_loc": 3221, |
362 | | - "cell_methods": "time:mean", |
363 | | - }, |
364 | | - ), |
365 | | - "VVEL": ( |
366 | | - ["time", "z_t", "nlat", "nlon"], |
367 | | - np.random.rand(T, Z, Y, X, dtype="float32"), |
368 | | - { |
369 | | - "long_name": "Velocity in grid-y direction", |
370 | | - "units": "centimeter/s", |
371 | | - "grid_loc": 3221, |
372 | | - "cell_methods": "time:mean", |
373 | | - }, |
374 | | - ), |
375 | | - "WVEL": ( |
376 | | - ["time", "z_w_top", "nlat", "nlon"], |
377 | | - np.random.rand(T, Z, Y, X, dtype="float32"), |
378 | | - { |
379 | | - "long_name": "Vertical Velocity", |
380 | | - "units": "centimeter/s", |
381 | | - "grid_loc": 3112, |
382 | | - "cell_methods": "time:mean", |
383 | | - }, |
384 | | - ), |
385 | | - }, |
386 | | - coords={ |
387 | | - "time": ( |
388 | | - ["time"], |
389 | | - TIME, |
390 | | - { |
391 | | - "long_name": "time", |
392 | | - "bounds": "time_bounds", |
393 | | - }, |
394 | | - ), |
395 | | - "z_t": ( |
396 | | - ["z_t"], |
397 | | - np.linspace(0, 5000, Z, dtype="float32"), |
398 | | - { |
399 | | - "long_name": "depth from surface to midpoint of layer", |
400 | | - "units": "centimeters", |
401 | | - "positive": "down", |
402 | | - "valid_min": 500.0, |
403 | | - "valid_max": 537500.0, |
404 | | - }, |
405 | | - ), |
406 | | - "z_w_top": ( |
407 | | - ["z_w_top"], |
408 | | - np.linspace(0, 5000, Z, dtype="float32"), |
409 | | - { |
410 | | - "long_name": "depth from surface to top of layer", |
411 | | - "units": "centimeters", |
412 | | - "positive": "down", |
413 | | - "valid_min": 0.0, |
414 | | - "valid_max": 525000.94, |
415 | | - }, |
416 | | - ), |
417 | | - "ULONG": ( |
418 | | - ["nlat", "nlon"], |
419 | | - np.tile(np.linspace(-179, 179, X, endpoint=False), (Y, 1)), # note that this is not curvilinear |
420 | | - { |
421 | | - "long_name": "array of u-grid longitudes", |
422 | | - "units": "degrees_east", |
423 | | - }, |
424 | | - ), |
425 | | - "ULAT": ( |
426 | | - ["nlat", "nlon"], |
427 | | - np.tile(np.linspace(-75, 85, Y).reshape(-1, 1), (1, X)), # note that this is not curvilinear |
428 | | - { |
429 | | - "long_name": "array of u-grid latitudes", |
430 | | - "units": "degrees_north", |
431 | | - }, |
432 | | - ), |
433 | | - }, |
434 | | - ), |
435 | | - "ds_MITgcm_netcdf": xr.Dataset( |
436 | | - # MITgcm model dataset in netCDF format |
| 360 | + ) |
| 361 | + |
| 362 | + |
| 363 | +def _CESM(): |
| 364 | + """CESM model dataset""" |
| 365 | + return ( |
| 366 | + xr.Dataset( |
| 367 | + { |
| 368 | + "UVEL": ( |
| 369 | + ["time", "z_t", "nlat", "nlon"], |
| 370 | + np.random.rand(T, Z, Y, X, dtype="float32"), |
| 371 | + { |
| 372 | + "long_name": "Velocity in grid-x direction", |
| 373 | + "units": "centimeter/s", |
| 374 | + "grid_loc": 3221, |
| 375 | + "cell_methods": "time:mean", |
| 376 | + }, |
| 377 | + ), |
| 378 | + "VVEL": ( |
| 379 | + ["time", "z_t", "nlat", "nlon"], |
| 380 | + np.random.rand(T, Z, Y, X, dtype="float32"), |
| 381 | + { |
| 382 | + "long_name": "Velocity in grid-y direction", |
| 383 | + "units": "centimeter/s", |
| 384 | + "grid_loc": 3221, |
| 385 | + "cell_methods": "time:mean", |
| 386 | + }, |
| 387 | + ), |
| 388 | + "WVEL": ( |
| 389 | + ["time", "z_w_top", "nlat", "nlon"], |
| 390 | + np.random.rand(T, Z, Y, X, dtype="float32"), |
| 391 | + { |
| 392 | + "long_name": "Vertical Velocity", |
| 393 | + "units": "centimeter/s", |
| 394 | + "grid_loc": 3112, |
| 395 | + "cell_methods": "time:mean", |
| 396 | + }, |
| 397 | + ), |
| 398 | + }, |
| 399 | + coords={ |
| 400 | + "time": ( |
| 401 | + ["time"], |
| 402 | + TIME, |
| 403 | + { |
| 404 | + "long_name": "time", |
| 405 | + "bounds": "time_bounds", |
| 406 | + }, |
| 407 | + ), |
| 408 | + "z_t": ( |
| 409 | + ["z_t"], |
| 410 | + np.linspace(0, 5000, Z, dtype="float32"), |
| 411 | + { |
| 412 | + "long_name": "depth from surface to midpoint of layer", |
| 413 | + "units": "centimeters", |
| 414 | + "positive": "down", |
| 415 | + "valid_min": 500.0, |
| 416 | + "valid_max": 537500.0, |
| 417 | + }, |
| 418 | + ), |
| 419 | + "z_w_top": ( |
| 420 | + ["z_w_top"], |
| 421 | + np.linspace(0, 5000, Z, dtype="float32"), |
| 422 | + { |
| 423 | + "long_name": "depth from surface to top of layer", |
| 424 | + "units": "centimeters", |
| 425 | + "positive": "down", |
| 426 | + "valid_min": 0.0, |
| 427 | + "valid_max": 525000.94, |
| 428 | + }, |
| 429 | + ), |
| 430 | + "ULONG": ( |
| 431 | + ["nlat", "nlon"], |
| 432 | + np.tile(np.linspace(-179, 179, X, endpoint=False), (Y, 1)), # note that this is not curvilinear |
| 433 | + { |
| 434 | + "long_name": "array of u-grid longitudes", |
| 435 | + "units": "degrees_east", |
| 436 | + }, |
| 437 | + ), |
| 438 | + "ULAT": ( |
| 439 | + ["nlat", "nlon"], |
| 440 | + np.tile(np.linspace(-75, 85, Y).reshape(-1, 1), (1, X)), # note that this is not curvilinear |
| 441 | + { |
| 442 | + "long_name": "array of u-grid latitudes", |
| 443 | + "units": "degrees_north", |
| 444 | + }, |
| 445 | + ), |
| 446 | + }, |
| 447 | + ), |
| 448 | + ) |
| 449 | + |
| 450 | + |
| 451 | +def _MITgcm_netcdf(): |
| 452 | + """MITgcm model dataset in netCDF format""" |
| 453 | + return xr.Dataset( |
| 454 | + # |
437 | 455 | { |
438 | 456 | "U": ( |
439 | 457 | ["T", "Z", "Y", "Xp1"], |
|
529 | 547 | }, |
530 | 548 | ), |
531 | 549 | }, |
532 | | - ), |
533 | | - "ds_ERA5_wind": xr.Dataset( |
534 | | - # ERA5 10m wind model dataset |
| 550 | + ) |
| 551 | + |
| 552 | + |
| 553 | +def _ERA5_wind(): |
| 554 | + """ERA5 10m wind model dataset""" |
| 555 | + return xr.Dataset( |
535 | 556 | { |
536 | 557 | "u10": ( |
537 | 558 | ["time", "latitude", "longitude"], |
|
575 | 596 | }, |
576 | 597 | ), |
577 | 598 | }, |
578 | | - ), |
579 | | - "ds_FES_tides": xr.Dataset( |
580 | | - # FES tidal model dataset |
| 599 | + ) |
| 600 | + |
| 601 | + |
| 602 | +def _FES_tides(): |
| 603 | + """FES tidal model dataset""" |
| 604 | + return xr.Dataset( |
581 | 605 | { |
582 | 606 | "Ug": ( |
583 | 607 | ["lat", "lon"], |
|
624 | 648 | }, |
625 | 649 | ), |
626 | 650 | }, |
627 | | - ), |
628 | | - "ds_hycom_espc": xr.Dataset( |
629 | | - # HYCOM ESPC model dataset from https://data.hycom.org/datasets/ESPC-D-V02/data/daily_netcdf/2025/ |
| 651 | + ) |
| 652 | + |
| 653 | + |
| 654 | +def _hycom_espc(): |
| 655 | + """HYCOM ESPC model dataset from https://data.hycom.org/datasets/ESPC-D-V02/data/daily_netcdf/2025/""" |
| 656 | + return xr.Dataset( |
630 | 657 | { |
631 | 658 | "water_u": ( |
632 | 659 | ["time", "depth", "lat", "lon"], |
|
703 | 730 | }, |
704 | 731 | ), |
705 | 732 | }, |
706 | | - ), |
707 | | - "ds_ecco4": xr.Dataset( |
708 | | - # ECCO V4r4 model dataset (from https://podaac.jpl.nasa.gov/dataset/ECCO_L4_OCEAN_VEL_LLC0090GRID_DAILY_V4R4#capability-modal-download) |
| 733 | + ) |
| 734 | + |
| 735 | + |
| 736 | +def _ecco4(): |
| 737 | + """ECCO V4r4 model dataset (from https://podaac.jpl.nasa.gov/dataset/ECCO_L4_OCEAN_VEL_LLC0090GRID_DAILY_V4R4#capability-modal-download)""" |
| 738 | + return xr.Dataset( |
709 | 739 | { |
710 | 740 | "UVEL": ( |
711 | 741 | ["time", "k", "tile", "j", "i_g"], |
|
925 | 955 | }, |
926 | 956 | ), |
927 | 957 | }, |
928 | | - ), |
929 | | - "ds_CROCO_idealized": xr.Dataset( |
930 | | - # CROCO idealized model dataset |
| 958 | + ) |
| 959 | + |
| 960 | + |
| 961 | +def _CROCO_idealized(): |
| 962 | + """CROCO idealized model dataset""" |
| 963 | + return xr.Dataset( |
931 | 964 | { |
932 | 965 | "u": ( |
933 | 966 | ["time", "s_rho", "eta_rho", "xi_u"], |
|
1049 | 1082 | "standard_name": "y_grid_index_at_v_location", |
1050 | 1083 | "axis": "Y", |
1051 | 1084 | "c_grid_axis_shift": 0.5, |
1052 | | - "c_grid_dynamic_range": f"2:{Y-1}", |
| 1085 | + "c_grid_dynamic_range": f"2:{Y - 1}", |
1053 | 1086 | }, |
1054 | 1087 | ), |
1055 | 1088 | "xi_rho": ( |
|
1070 | 1103 | "standard_name": "x_grid_index_at_u_location", |
1071 | 1104 | "axis": "X", |
1072 | 1105 | "c_grid_axis_shift": 0.5, |
1073 | | - "c_grid_dynamic_range": f"2:{X-1}", |
| 1106 | + "c_grid_dynamic_range": f"2:{X - 1}", |
1074 | 1107 | }, |
1075 | 1108 | ), |
1076 | 1109 | "x_rho": ( |
|
1094 | 1127 | }, |
1095 | 1128 | ), |
1096 | 1129 | }, |
1097 | | - ), |
| 1130 | + ) |
| 1131 | + |
| 1132 | + |
| 1133 | +datasets = { |
| 1134 | + "ds_copernicusmarine": _copernicusmarine(), |
| 1135 | + "ds_copernicusmarine_globcurrents": _copernicusmarine_globcurrents(), |
| 1136 | + "ds_NEMO_MOI_U": _NEMO_MOI_U(), |
| 1137 | + "ds_NEMO_MOI_V": _NEMO_MOI_V(), |
| 1138 | + "ds_CESM": _CESM(), |
| 1139 | + "ds_MITgcm_netcdf": _MITgcm_netcdf(), |
| 1140 | + "ds_ERA5_wind": _ERA5_wind(), |
| 1141 | + "ds_FES_tides": _FES_tides(), |
| 1142 | + "ds_hycom_espc": _hycom_espc(), |
| 1143 | + "ds_ecco4": _ecco4(), |
| 1144 | + "ds_CROCO_idealized": _CROCO_idealized(), |
1098 | 1145 | } |
0 commit comments