@@ -107,6 +107,7 @@ def fetch(path: str | Path, username: str | None, password: str | None) -> None:
107107 time_range = schedule .space_time_region .time_range
108108 start_datetime = time_range .start_time
109109 end_datetime = time_range .end_time
110+ instruments_in_schedule = [waypoint .instrument .name for waypoint in schedule .waypoints ]
110111
111112 # Create download folder and set download metadata
112113 download_folder = data_folder / hash_to_filename (space_time_region_hash )
@@ -116,7 +117,7 @@ def fetch(path: str | Path, username: str | None, password: str | None) -> None:
116117 )
117118 shutil .copyfile (path / SCHEDULE , download_folder / SCHEDULE )
118119
119- # Define all datasets to download, including bathymetry
120+ # Define all default datasets to download, including bathymetry
120121 download_dict = {
121122 "Bathymetry" : {
122123 "dataset_id" : "cmems_mod_glo_phy_my_0.083deg_static" ,
@@ -168,6 +169,97 @@ def fetch(path: str | Path, username: str | None, password: str | None) -> None:
168169 complete_download (download_folder )
169170 click .echo ("Data download based on space-time region completed." )
170171
172+ if "DRIFTER" in instruments_in_schedule :
173+ print ("Additional drifter data will be downloaded" )
174+ drifter_download_dict = {
175+ "UVdata" : {
176+ "dataset_id" : "cmems_mod_glo_phy-cur_anfc_0.083deg_PT6H-i" ,
177+ "variables" : ["uo" , "vo" ],
178+ "output_filename" : "drifter_uv.nc" ,
179+ },
180+ "Tdata" : {
181+ "dataset_id" : "cmems_mod_glo_phy-thetao_anfc_0.083deg_PT6H-i" ,
182+ "variables" : ["thetao" ],
183+ "output_filename" : "drifter_t.nc" ,
184+ },
185+ }
186+
187+ # Iterate over all datasets and download each based on space_time_region
188+ try :
189+ for dataset in drifter_download_dict .values ():
190+ copernicusmarine .subset (
191+ dataset_id = dataset ["dataset_id" ],
192+ variables = dataset ["variables" ],
193+ minimum_longitude = spatial_range .minimum_longitude + 3.0 ,
194+ maximum_longitude = spatial_range .maximum_longitude + 3.0 ,
195+ minimum_latitude = spatial_range .minimum_latitude + 3.0 ,
196+ maximum_latitude = spatial_range .maximum_latitude + 3.0 ,
197+ start_datetime = start_datetime ,
198+ end_datetime = end_datetime ,
199+ minimum_depth = abs (0 ),
200+ maximum_depth = abs (1 ),
201+ output_filename = dataset ["output_filename" ],
202+ output_directory = download_folder ,
203+ username = username ,
204+ password = password ,
205+ force_download = True ,
206+ overwrite = True ,
207+ )
208+ except InvalidUsernameOrPassword as e :
209+ shutil .rmtree (download_folder )
210+ raise e
211+
212+ complete_download (download_folder )
213+ click .echo ("Drifter data download based on space-time region completed." )
214+
215+ if "ARGO_FLOAT" in instruments_in_schedule :
216+ print ("Additional argo float data will be downloaded" )
217+ argo_download_dict = {
218+ "UVdata" : {
219+ "dataset_id" : "cmems_mod_glo_phy-cur_anfc_0.083deg_PT6H-i" ,
220+ "variables" : ["uo" , "vo" ],
221+ "output_filename" : "argo_float_uv.nc" ,
222+ },
223+ "Sdata" : {
224+ "dataset_id" : "cmems_mod_glo_phy-so_anfc_0.083deg_PT6H-i" ,
225+ "variables" : ["so" ],
226+ "output_filename" : "argo_float_s.nc" ,
227+ },
228+ "Tdata" : {
229+ "dataset_id" : "cmems_mod_glo_phy-thetao_anfc_0.083deg_PT6H-i" ,
230+ "variables" : ["thetao" ],
231+ "output_filename" : "argo_float_t.nc" ,
232+ },
233+ }
234+
235+ # Iterate over all datasets and download each based on space_time_region
236+ try :
237+ for dataset in argo_download_dict .values ():
238+ copernicusmarine .subset (
239+ dataset_id = dataset ["dataset_id" ],
240+ variables = dataset ["variables" ],
241+ minimum_longitude = spatial_range .minimum_longitude + 3.0 ,
242+ maximum_longitude = spatial_range .maximum_longitude + 3.0 ,
243+ minimum_latitude = spatial_range .minimum_latitude + 3.0 ,
244+ maximum_latitude = spatial_range .maximum_latitude + 3.0 ,
245+ start_datetime = start_datetime ,
246+ end_datetime = end_datetime ,
247+ minimum_depth = abs (0 ),
248+ maximum_depth = abs (spatial_range .maximum_depth ),
249+ output_filename = dataset ["output_filename" ],
250+ output_directory = download_folder ,
251+ username = username ,
252+ password = password ,
253+ force_download = True ,
254+ overwrite = True ,
255+ )
256+ except InvalidUsernameOrPassword as e :
257+ shutil .rmtree (download_folder )
258+ raise e
259+
260+ complete_download (download_folder )
261+ click .echo ("Argo_float data download based on space-time region completed." )
262+
171263
172264@click .command ()
173265@click .argument (
0 commit comments