|
10 | 10 |
|
11 | 11 | import argparse |
12 | 12 | import os |
| 13 | +import sys |
13 | 14 | import uuid |
14 | 15 | from datetime import datetime, timedelta |
15 | 16 |
|
|
25 | 26 | from matplotlib.colors import ListedColormap |
26 | 27 |
|
27 | 28 | # pylint: disable=import-error, disable=no-name-in-module |
| 29 | +import copernicusmarine |
28 | 30 | from opendrift.models.leeway import Leeway |
29 | 31 | from opendrift.readers import reader_global_landmask |
| 32 | +from opendrift.readers.reader_netCDF_CF_generic import Reader |
30 | 33 |
|
31 | 34 | INPUTDIR = "/code/leeway/input" |
32 | 35 |
|
@@ -96,20 +99,30 @@ def main(): |
96 | 99 | elif not args.no_web: |
97 | 100 | if "COPERNICUSMARINE_SERVICE_USERNAME" in os.environ: |
98 | 101 | print("Using CMEMS") |
99 | | - sources = [ |
| 102 | + cmems_dataset_ids = [ |
100 | 103 | "cmems_mod_med_phy-cur_anfc_4.2km_PT15M-i", |
101 | 104 | "cmems_mod_glo_phy_anfc_merged-uv_PT1H-i", |
102 | 105 | "cmems_obs-wind_glo_phy_nrt_l4_0.125deg_PT1H-i", |
103 | 106 | ] |
| 107 | + print("Using sources:\n - {}".format("\n - ".join(cmems_dataset_ids))) |
| 108 | + readers = [] |
| 109 | + for dataset_id in cmems_dataset_ids: |
| 110 | + try: |
| 111 | + ds = copernicusmarine.open_dataset(dataset_id=dataset_id, chunk_size_limit=0) |
| 112 | + print(f"Opened {dataset_id}:") |
| 113 | + print(ds) |
| 114 | + except Exception as exc: |
| 115 | + print(f"ERROR opening {dataset_id}: {exc}", file=sys.stderr) |
| 116 | + raise |
| 117 | + readers.append(Reader(ds, name=dataset_id)) |
| 118 | + simulation.add_reader(readers) |
104 | 119 | else: |
105 | 120 | sources = [ |
106 | 121 | "https://tds.hycom.org/thredds/dodsC/GLBy0.08/latest", |
107 | 122 | "https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd", |
108 | 123 | ] |
109 | | - |
110 | | - print("Using sources:\n - {}".format("\n - ".join(sources))) |
111 | | - |
112 | | - simulation.add_readers_from_list(sources, lazy=True) |
| 124 | + print("Using sources:\n - {}".format("\n - ".join(sources))) |
| 125 | + simulation.add_readers_from_list(sources, lazy=False) |
113 | 126 |
|
114 | 127 | reader_landmask = reader_global_landmask.Reader() |
115 | 128 | simulation.add_reader([reader_landmask]) |
|
0 commit comments