Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Credentials"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"import copernicusmarine\n",
"\n",
"project_root = os.path.abspath(os.path.join(os.path.dirname(\"__file__\"), '..'))\n",
"sys.path.append(project_root)\n",
"from source.download_forcing import *\n",
"from source.widgets import *\n",
"\n",
"# ----------------------- COPERNICUS ---------------------------------------------------------------------------------\n",
"# copernicusmarine.login()\n",
"\n",
"# ----------------------- NAOS ---------------------------------------------------------------------------------\n",
"WRITE_IN_NAOS: bool = True \n",
"NAOS_TOKEN = \"your token\"\n",
"\n",
"os.environ[\"WRITE_IN_NAOS\"] = str(WRITE_IN_NAOS)\n",
"os.environ[\"NAOS_TOKEN\"] = NAOS_TOKEN"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Execute"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Command Line"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO - 2024-07-26T08:13:49Z - Dataset version was not specified, the latest one was selected: \"202211\"\n",
"INFO - 2024-07-26T08:13:49Z - You forced selection of dataset part \"default\"\n",
"INFO - 2024-07-26T08:13:49Z - You forced selection of service: arco-time-series\n",
"INFO - 2024-07-26T08:13:53Z - Dataset version was not specified, the latest one was selected: \"202211\"\n",
"INFO - 2024-07-26T08:13:53Z - You forced selection of dataset part \"default\"\n",
"INFO - 2024-07-26T08:13:53Z - You forced selection of service: arco-time-series\n"
]
},
{
"data": {
"text/plain": [
"'Creation of new simulation parameters failed : Error while downloading datas for copernicus-temp : Error in dowloading Copernicus datas : Some or all of your subset selection [2024-06-23 00:00:00, 2024-06-24 00:00:00] for the time dimension exceed the dataset coordinates [2024-07-12 22:00:00, 2024-07-29 23:00:00]'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"sources3D=['constants-3d', 'copernicus-o2', 'copernicus-temp', 'hub-eau-3d', 'magest', 'open-meteo']\n",
"model3D = \"gironde-xl-3d\"\n",
"ProjectId3D=893\n",
"\n",
"create_simulation(SimulationParameters( model=model3D,\n",
" project_id=ProjectId3D,\n",
" sources=sources3D,\n",
" start_date=\"2024-06-23T00:00:00.000000Z\",\n",
" end_date=\"2024-06-24T00:00:00.000000Z\",\n",
" naos_token=NAOS_TOKEN,\n",
" write_in_naos=WRITE_IN_NAOS,\n",
" ))[\"result\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\"\"\"\n",
"Temperature :\n",
"- variables : so (sea_water_salinity)\n",
" thetao (sea_water_potential_temperature)\n",
"- HISTORICAL :\n",
" - cmems_mod_ibi_phy_my_0.083deg-3D_P1D-m \n",
"- FORECAST :\n",
" - cmems_mod_ibi_phy_anfc_0.027deg-3D_PT1H-m \n",
" - cmems_mod_ibi_phy_anfc_0.027deg-3D_P1D-m \n",
"\n",
"Oxygene :\n",
"- variables : o2 (mole_concentration_of_dissolved_molecular_oxygen_in_sea_water)\n",
" nh4 (mole_concentration_of_ammonium_in_sea_water)\n",
"- HISTORICAL :\n",
" - cmems_mod_ibi_bgc_my_0.083deg-3D_P1D-m \n",
"- FORECAST :\n",
" - cmems_mod_ibi_bgc_anfc_0.027deg-3D_P1D-m \n",
"\n",
"Sea :\n",
"- Variables : VHM0 (sea_surface_wave_significant_height)\n",
" VTPK (sea_surface_wave_period_at_variance_spectral_density_maximum)\n",
" VMDR (sea_surface_wave_from_direction)\n",
"- HISTORICAL :\n",
" - cmems_mod_ibi_wav_my_0.027deg_PT1H-i \n",
"- FORECAST :\n",
" - cmems_mod_ibi_wav_anfc_0.05deg_PT1H-i \n",
"\n",
"\n",
"1- cmems = Copernicus Marine Environment Monitoring Service\n",
"2- mod = model\n",
"3- ibi = atlantic - Iberian + golfe de Biscay + Irish (European waters)\n",
"4- phy = physical products, bgc = BioGeoChimical, wav = Waves\n",
"5- anfc = ANalysis and ForCast, my = MultiYear\n",
"6- 0.027deg, 0.083deg, 0.05deg = ??\n"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"TEMP\n",
"- forecast1\n",
"[1720821600000, 1722380400000]\n",
"[1720821600000, 1722380400000]\n",
"2024-07-13 00:00:00\n",
"2024-07-31 01:00:00\n",
"- forecast2\n",
"[1617408000000, 1722297600000]\n",
"[1617408000000, 1722297600000]\n",
"2021-04-03 02:00:00\n",
"2024-07-30 02:00:00\n",
"historical\n",
"[725846400000, 1640649600000]\n",
"[725846400000, 1640649600000]\n",
"1993-01-01 01:00:00\n",
"2021-12-28 01:00:00\n",
"---------------------\n",
"02\n",
"forecast\n",
"[1617408000000, 1722643200000]\n",
"[1617408000000, 1722643200000]\n",
"2021-04-03 02:00:00\n",
"2024-08-03 02:00:00\n",
"historical\n",
"[725846400000, 1640649600000]\n",
"[725846400000, 1640649600000]\n",
"1993-01-01 01:00:00\n",
"2021-12-28 01:00:00\n",
"---------------------\n",
"SEA\n",
"forecast\n",
"[1637971200000, 1722726000000]\n",
"[1637971200000, 1722726000000]\n",
"[1637971200000, 1722726000000]\n",
"2021-11-27 01:00:00\n",
"2024-08-04 01:00:00\n",
"historical\n",
"1993-01-02 01:00:00\n",
"2021-12-27 00:00:00\n"
]
}
],
"source": [
"from pprint import pprint\n",
"\n",
"copernicus_catalog = copernicusmarine.describe(include_datasets=True)\n",
"all_datasets_list = [data['datasets'] for data in copernicus_catalog['products']]\n",
"all_datasets = [item for sublist in all_datasets_list for item in sublist]\n",
"\n",
"def find_subset(dataset: dict, key_filtered: str, key_filter: str, value_filter: str)-> dict :\n",
" return [data[key_filtered] for data in dataset if data[key_filter] == value_filter][0]\n",
"\n",
"def find_source_limits(dataset: dict, copernicus_dataset: str, copernicus_variable: str) -> list :\n",
" versions = find_subset(all_datasets, 'versions', 'dataset_id', copernicus_dataset)\n",
" labels = [data['label'] for data in versions]\n",
" labels.sort()\n",
" label = labels[-1]\n",
" parts = find_subset(versions, 'parts', 'label', label)\n",
" services = find_subset(parts, 'services', 'name', 'default')\n",
" variables = [data['variables'] for data in services if data['service_type']['service_name'] == 'arco-time-series'][0]\n",
" coordinates = find_subset(variables, 'coordinates', 'short_name', copernicus_variable)\n",
" return [[data['minimum_value'],data['maximum_value']] for data in coordinates if data['coordinates_id'] == 'time'][0]\n",
"\n",
"\n",
"print(\"TEMP\")\n",
"print(\"- forecast1\")\n",
"dataset_id = \"cmems_mod_ibi_phy_anfc_0.027deg-3D_PT1H-m\" \n",
"temp_forecast_1_thetao = find_source_limits(all_datasets, dataset_id, 'thetao')\n",
"temp_forecast_1_so = find_source_limits(all_datasets, dataset_id, 'so')\n",
"print(temp_forecast_1_thetao)\n",
"print(temp_forecast_1_so)\n",
"print(datetime.fromtimestamp(temp_forecast_1_so[0]/1000))\n",
"print(datetime.fromtimestamp(temp_forecast_1_so[1]/1000))\n",
"\n",
"print(\"- forecast2\")\n",
"dataset_id = \"cmems_mod_ibi_phy_anfc_0.027deg-3D_P1D-m\" \n",
"temp_forecast_2_thetao = find_source_limits(all_datasets, dataset_id, 'thetao')\n",
"temp_forecast_2_so = find_source_limits(all_datasets, dataset_id, 'so')\n",
"print(temp_forecast_2_thetao)\n",
"print(temp_forecast_2_so)\n",
"print(datetime.fromtimestamp(temp_forecast_2_so[0]/1000))\n",
"print(datetime.fromtimestamp(temp_forecast_2_so[1]/1000))\n",
"\n",
"print(\"historical\")\n",
"dataset_id = \"cmems_mod_ibi_phy_my_0.083deg-3D_P1D-m\" \n",
"copernicus_temp_historical_thetao = find_source_limits(all_datasets, dataset_id, 'thetao')\n",
"copernicus_temp_historical_so = find_source_limits(all_datasets, dataset_id, 'so')\n",
"print(copernicus_temp_historical_thetao)\n",
"print(copernicus_temp_historical_so)\n",
"print(datetime.fromtimestamp(copernicus_temp_historical_so[0]/1000))\n",
"print(datetime.fromtimestamp(copernicus_temp_historical_so[1]/1000))\n",
"\n",
"print(\"---------------------\")\n",
"print(\"02\")\n",
"\n",
"print(\"forecast\")\n",
"dataset_id = \"cmems_mod_ibi_bgc_anfc_0.027deg-3D_P1D-m\" \n",
"o2_forecast_o2 = find_source_limits(all_datasets, dataset_id, 'o2')\n",
"o2_forecast_nh4 = find_source_limits(all_datasets, dataset_id, 'nh4')\n",
"pprint(o2_forecast_o2)\n",
"pprint(o2_forecast_nh4)\n",
"print(datetime.fromtimestamp(o2_forecast_nh4[0]/1000))\n",
"print(datetime.fromtimestamp(o2_forecast_nh4[1]/1000))\n",
"\n",
"print(\"historical\")\n",
"dataset_id = \"cmems_mod_ibi_bgc_my_0.083deg-3D_P1D-m\" \n",
"o2_historical_o2 = find_source_limits(all_datasets, dataset_id, 'o2')\n",
"o2_historical_nh4 = find_source_limits(all_datasets, dataset_id, 'nh4')\n",
"pprint(o2_historical_o2)\n",
"pprint(o2_historical_nh4)\n",
"print(datetime.fromtimestamp(o2_historical_nh4[0]/1000))\n",
"print(datetime.fromtimestamp(o2_historical_nh4[1]/1000))\n",
"\n",
"print(\"---------------------\")\n",
"print(\"SEA\")\n",
"\n",
"print(\"forecast\")\n",
"dataset_id = \"cmems_mod_ibi_wav_anfc_0.05deg_PT1H-i\" \n",
"sea_forecast_VHMO = find_source_limits(all_datasets, dataset_id, 'VHM0')\n",
"sea_forecast_VTPK = find_source_limits(all_datasets, dataset_id, 'VTPK')\n",
"sea_forecast_VMDR = find_source_limits(all_datasets, dataset_id, 'VMDR')\n",
"pprint(sea_forecast_VHMO)\n",
"pprint(sea_forecast_VTPK)\n",
"pprint(sea_forecast_VMDR)\n",
"print(datetime.fromtimestamp(sea_forecast_VMDR[0]/1000))\n",
"print(datetime.fromtimestamp(sea_forecast_VMDR[1]/1000))\n",
"\n",
"print(\"historical\")\n",
"dataset_id = \"cmems_mod_ibi_wav_my_0.027deg_PT1H-i\" \n",
"sea_historical_VHM0 = find_source_limits(all_datasets, dataset_id, 'VHM0')\n",
"sea_historical_VTPK = find_source_limits(all_datasets, dataset_id, 'VTPK')\n",
"sea_historical_VMDR = find_source_limits(all_datasets, dataset_id, 'VMDR')\n",
"print(datetime.fromtimestamp(sea_historical_VMDR[0]/1000))\n",
"print(datetime.fromtimestamp(sea_historical_VMDR[1]/1000))\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"---------------- O2 forecast\n",
"min = 1617408000.0\n",
"2021-04-03 02:00:00\n",
"max = 1722643200.0\n",
"2024-08-03 02:00:00\n",
"105235200.0 = 1218.0 jours\n",
"---------------- O2 history\n",
"min = 725846400.0\n",
"1993-01-01 01:00:00\n",
"max = 1640649600.0\n",
"2021-12-28 01:00:00\n",
"914803200.0 = 10588.0 jours\n"
]
}
],
"source": [
"\"\"\"\n",
"02\n",
"forecast\n",
"[1617408000000, 1722643200000]\n",
"historical\n",
"[725846400000, 1640649600000]\n",
"\n",
"\"\"\"\n",
"\n",
"print(\"---------------- O2 forecast\")\n",
"min_date=1617408000000\n",
"max_date=1722643200000\n",
"print(f\"min = {min_date/1000}\") # 2024-07-13 00:00:00\n",
"print(datetime.fromtimestamp(min_date/1000.0))\n",
"print(f\"max = {max_date/1000}\") # 2024-07-30 01:00:00\n",
"print(datetime.fromtimestamp(max_date/1000.0))\n",
"\n",
"forecast_duration = max_date/1000 - min_date/1000\n",
"print(f\"{forecast_duration} = {forecast_duration/86400} jours\")\n",
"\n",
"print(\"---------------- O2 history\")\n",
"min_date=725846400000\n",
"max_date=1640649600000\n",
"print(f\"min = {min_date/1000}\") # 2024-07-13 00:00:00\n",
"print(datetime.fromtimestamp(min_date/1000.0))\n",
"print(f\"max = {max_date/1000}\") # 2024-07-30 01:00:00\n",
"print(datetime.fromtimestamp(max_date/1000.0))\n",
"\n",
"history_duration = max_date/1000 - min_date/1000\n",
"print(f\"{history_duration} = {history_duration/86400} jours\")\n"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"--------------------------------------------\n",
"'source = copernicus-o2'\n",
"'end_date = 2024-07-02 00:00:00'\n",
"'start_date = 2024-07-01 00:00:00'\n",
"'download forecast'\n",
"INFO - 2024-07-26T19:11:47Z - You forced selection of dataset version \"202211\"\n",
"INFO - 2024-07-26T19:11:47Z - You forced selection of dataset part \"default\"\n",
"INFO - 2024-07-26T19:11:47Z - You forced selection of service: arco-time-series\n",
"\n",
"--------------------------------------------\n",
"'source = copernicus-sea'\n",
"'end_date = 2024-07-02 00:00:00'\n",
"'start_date = 2024-07-01 00:00:00'\n",
"'download forecast'\n",
"INFO - 2024-07-26T19:11:50Z - You forced selection of dataset version \"202311\"\n",
"INFO - 2024-07-26T19:11:50Z - You forced selection of dataset part \"default\"\n",
"INFO - 2024-07-26T19:11:50Z - You forced selection of service: arco-time-series\n",
"\n",
"--------------------------------------------\n",
"'source = copernicus-temp'\n",
"'end_date = 2024-07-02 00:00:00'\n",
"'start_date = 2024-07-01 00:00:00'\n",
"'download forecast'\n",
"INFO - 2024-07-26T19:11:54Z - You forced selection of dataset version \"202211\"\n",
"INFO - 2024-07-26T19:11:54Z - You forced selection of dataset part \"default\"\n",
"INFO - 2024-07-26T19:11:54Z - You forced selection of service: arco-time-series\n"
]
}
],
"source": [
"from datetime import datetime, timedelta\n",
"from pprint import pprint\n",
"\n",
"CopernicusTempSourceNew = Source(\n",
" \"copernicus-temp\",\n",
" 1472400,\n",
" [1720821600, 1722294000],\n",
" {\n",
" SourceMode.FORECAST: None,\n",
" SourceMode.HISTORICAL: None,\n",
" },\n",
" {\n",
" SourceMode.FORECAST: [\n",
" (\n",
" \"\"\"\n",
" {\n",
" \"dataset_id\" : \"cmems_mod_ibi_phy_anfc_0.027deg-3D_P1D-m\", \n",
" \"minimum_longitude\" : -1.4161,\n",
" \"maximum_longitude\" : -1.4161,\n",
" \"minimum_latitude\" : 45.5839,\n",
" \"maximum_latitude\" : 45.5839,\n",
" \"minimum_depth\" : 0.4940,\n",
" \"maximum_depth\" : 0.4941,\n",
" \"variables\" : [\"so\", \"thetao\"]\n",
" }\n",
" \"\"\"\n",
" ),\n",
" ],\n",
" SourceMode.HISTORICAL: [\n",
" (\n",
" \"\"\"\n",
" {\n",
" \"dataset_id\" : \"cmems_mod_ibi_phy_my_0.083deg-3D_P1D-m\", \n",
" \"minimum_longitude\" : -1.4167,\n",
" \"maximum_longitude\" : -1.4167,\n",
" \"minimum_latitude\" : 45.5833,\n",
" \"maximum_latitude\" : 45.5833,\n",
" \"minimum_depth\" : 0.50576,\n",
" \"maximum_depth\" : 0.50577,\n",
" \"variables\" : [\"so\", \"thetao\"]\n",
" }\n",
" \"\"\"\n",
" )\n",
" ],\n",
" },\n",
" [VariableFrLiq3D.SALINITE_OCEAN, VariableFrLiq3D.TEMP_OCEAN],\n",
")\n",
"\n",
"\n",
"CopernicusO2SourceNew = Source(\n",
" \"copernicus-o2\", # name\n",
" 345600, # forecast_duration\n",
" [75340800], # history_duration\n",
" {\n",
" SourceMode.FORECAST: None,\n",
" SourceMode.HISTORICAL: None,\n",
" },\n",
" {\n",
" SourceMode.FORECAST: [\n",
" (\n",
" \"\"\"\n",
" {\n",
" \"dataset_id\" : \"cmems_mod_ibi_bgc_anfc_0.027deg-3D_P1D-m\", \n",
" \"minimum_longitude\" : -1.4167,\n",
" \"maximum_longitude\" : -1.4167,\n",
" \"minimum_latitude\" : 45.5833,\n",
" \"maximum_latitude\" : 45.5833,\n",
" \"minimum_depth\" : 0.4940,\n",
" \"maximum_depth\" : 0.4941,\n",
" \"variables\" : [\"o2\", \"nh4\"]\n",
" }\n",
" \"\"\"\n",
" ),\n",
" ],\n",
" SourceMode.HISTORICAL: [\n",
" (\n",
" \"\"\"\n",
" {\n",
" \"dataset_id\" : \"cmems_mod_ibi_bgc_my_0.083deg-3D_P1D-m\", \n",
" \"minimum_longitude\" : -1.4167,\n",
" \"maximum_longitude\" : -1.4167,\n",
" \"minimum_latitude\" : 45.5833,\n",
" \"maximum_latitude\" : 45.5833,\n",
" \"minimum_depth\" : 0.50576,\n",
" \"maximum_depth\" : 0.50577,\n",
" \"variables\" : [\"o2\", \"nh4\"]\n",
" }\n",
" \"\"\"\n",
" )\n",
" ],\n",
" },\n",
" # variables : \n",
" [VariableFrLiq3D.O2_OCEAN, VariableFrLiq3D.AMMONIUM_OCEAN],\n",
")\n",
"\n",
"CopernicusSeaSourceNew = Source(\n",
" \"copernicus-sea\",\n",
" 691200,\n",
" [75340800],\n",
" {\n",
" SourceMode.FORECAST: None,\n",
" SourceMode.HISTORICAL: None,\n",
" },\n",
" {\n",
" SourceMode.FORECAST: [\n",
" (\n",
" \"\"\"\n",
" {\n",
" \"dataset_id\" : \"cmems_mod_ibi_wav_anfc_0.05deg_PT1H-i\", \n",
" \"minimum_longitude\" : -2.10,\n",
" \"maximum_longitude\" : -2.10,\n",
" \"minimum_latitude\" : 45.60,\n",
" \"maximum_latitude\" : 45.60,\n",
" \"minimum_depth\" : 0.50576,\n",
" \"maximum_depth\" : 0.50577,\n",
" \"variables\" : [\"VHM0\", \"VTPK\", \"VMDR\"]\n",
" }\n",
" \"\"\"\n",
" ),\n",
" ],\n",
" SourceMode.HISTORICAL: [\n",
" (\n",
" \"\"\"\n",
" {\n",
" \"dataset_id\" : \"cmems_mod_ibi_wav_my_0.027deg_PT1H-i\", \n",
" \"minimum_longitude\" : -2.10,\n",
" \"maximum_longitude\" : -2.10,\n",
" \"minimum_latitude\" : 45.60,\n",
" \"maximum_latitude\" : 45.60,\n",
" \"minimum_depth\" : 0.50576,\n",
" \"maximum_depth\" : 0.50577,\n",
" \"variables\" : [\"VHM0\", \"VTPK\", \"VMDR\"]\n",
" }\n",
" \"\"\"\n",
" )\n",
" ],\n",
" },\n",
" [\n",
" VariableHoule.HAUTEUR_VAGUE,\n",
" VariableHoule.FREQUENCE_VAGUE,\n",
" VariableHoule.DIRECTION_VAGUE,\n",
" ],\n",
")\n",
"\n",
"def find_subset(dataset: dict, key_filtered: str, key_filter: str, value_filter: str)-> dict :\n",
" return [data[key_filtered] for data in dataset if data[key_filter] == value_filter][0]\n",
"\n",
"copernicus_versions: dict = {}\n",
"\n",
"def find_source_limits(dataset: dict, copernicus_dataset: str, copernicus_variable: str) -> list :\n",
" versions = find_subset(all_datasets, 'versions', 'dataset_id', copernicus_dataset)\n",
" labels = [data['label'] for data in versions]\n",
"\n",
" labels.sort()\n",
" label = labels[-1]\n",
" copernicus_versions[copernicus_dataset] = label\n",
" \n",
" parts = find_subset(versions, 'parts', 'label', label)\n",
" services = find_subset(parts, 'services', 'name', 'default')\n",
" variables = [data['variables'] for data in services if data['service_type']['service_name'] == 'arco-time-series'][0]\n",
" coordinates = find_subset(variables, 'coordinates', 'short_name', copernicus_variable)\n",
" return [[data['minimum_value'],data['maximum_value']] for data in coordinates if data['coordinates_id'] == 'time'][0]\n",
"\n",
"\n",
"\n",
"def check_limits(all_datasets: list, source: str, var: str) -> (datetime, datetime) : \n",
" limits = find_source_limits(all_datasets, source, var)\n",
" return datetime.fromtimestamp(limits[0]/1000), datetime.fromtimestamp(limits[1]/1000)\n",
"\n",
"\n",
"def download_copernicus(all_datasets: list, source_remplacer_par_self: Source, start_date: datetime, end_date: datetime) -> bool:\n",
" \"\"\"Download forecast data from copernicus website\n",
" Data are requested from a center point defined in the parameters\n",
"\n",
" :param CopernicusSource self: copernicus source\n",
" :param datetime start_date: start date\n",
" :param datetime end_date: end date\n",
" :returns: bool\n",
" \"\"\"\n",
" try:\n",
" print(\"\")\n",
" print(\"--------------------------------------------\")\n",
" pprint(f\"source = {source_remplacer_par_self.name}\")\n",
"\n",
" paramsForecast = json.loads(source_remplacer_par_self.api_params[SourceMode.FORECAST][0])\n",
" start_forecast, end_forecast = check_limits(all_datasets, paramsForecast[\"dataset_id\"], paramsForecast[\"variables\"][0])\n",
" \n",
" paramsHistorical = json.loads(source_remplacer_par_self.api_params[SourceMode.HISTORICAL][0])\n",
" start_historical, end_historical = check_limits(all_datasets, paramsHistorical[\"dataset_id\"], paramsHistorical[\"variables\"][0])\n",
" \n",
"\n",
" if (end_date > end_forecast):\n",
" pprint(\"date de fin > aux dernières estimations\")\n",
" elif(start_date < start_historical):\n",
" pprint(\"date de début < aux premiers relevés\")\n",
" \n",
" end_date = min(end_date, end_forecast)\n",
" start_date = max(start_date, start_historical)\n",
" pprint(f\"end_date = {end_date}\")\n",
" pprint(f\"start_date = {start_date}\")\n",
" \n",
" if start_date >= start_forecast :\n",
" mode = SourceMode.FORECAST\n",
" pprint(\"download forecast\")\n",
" \n",
" elif end_date < start_forecast :\n",
" mode = SourceMode.HISTORICAL\n",
" pprint(\"download history\")\n",
" \n",
" paramsCopernicus = json.loads(source_remplacer_par_self.api_params[mode][0])\n",
" \n",
" dataset = copernicusmarine.open_dataset(\n",
" dataset_id = paramsCopernicus[\"dataset_id\"],\n",
" dataset_part = \"default\",\n",
" service = \"arco-time-series\",\n",
" minimum_longitude = paramsCopernicus[\"minimum_longitude\"],\n",
" maximum_longitude = paramsCopernicus[\"maximum_longitude\"],\n",
" minimum_latitude = paramsCopernicus[\"minimum_latitude\"],\n",
" maximum_latitude = paramsCopernicus[\"maximum_latitude\"],\n",
" minimum_depth = paramsCopernicus[\"minimum_depth\"],\n",
" maximum_depth = paramsCopernicus[\"maximum_depth\"],\n",
" dataset_version = copernicus_versions[paramsCopernicus[\"dataset_id\"]],\n",
" start_datetime = start_date.isoformat(), \n",
" end_datetime = end_date.isoformat(), \n",
" variables = paramsCopernicus[\"variables\"])\n",
" \n",
"\n",
" return True\n",
"\n",
" except Exception as err:\n",
" raise ValueError(f\"Error in dowloading Copernicus datas : {err}\") from err\n",
"\n",
"formatting = \"%Y-%m-%d %H:%M:%S\"\n",
"start_date = datetime.strptime('2024-07-01 00:00:00',formatting)\n",
"end_date = datetime.strptime('2024-07-02 00:00:00',formatting)\n",
"\n",
"copernicus_catalog = copernicusmarine.describe(include_datasets=True)\n",
"all_datasets_list = [data['datasets'] for data in copernicus_catalog['products']]\n",
"all_datasets = [item for sublist in all_datasets_list for item in sublist]\n",
"\n",
"for source in [CopernicusO2SourceNew, CopernicusSeaSourceNew, CopernicusTempSourceNew]:\n",
" download_copernicus(all_datasets, source, start_date, end_date)\n"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[0;31mSignature:\u001b[0m\n",
"\u001b[0mcopernicusmarine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen_dataset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mdataset_url\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mdataset_id\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mdataset_version\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mdataset_part\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0musername\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mpassword\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mvariables\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mList\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mminimum_longitude\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfloat\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mmaximum_longitude\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfloat\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mminimum_latitude\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfloat\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mmaximum_latitude\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfloat\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mminimum_depth\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfloat\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mmaximum_depth\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfloat\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mvertical_dimension_as_originally_produced\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mstart_datetime\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mUnion\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mdatetime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdatetime\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mNoneType\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mend_datetime\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mUnion\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mdatetime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdatetime\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mNoneType\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0msubset_method\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mLiteral\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'nearest'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'strict'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'nearest'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mservice\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mOptional\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mcredentials_file\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mUnion\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mpathlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mPath\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mNoneType\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0moverwrite_metadata_cache\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mno_metadata_cache\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m \u001b[0mdisable_progress_bar\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mbool\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n",
"\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0mxarray\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcore\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdataset\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDataset\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mDocstring:\u001b[0m\n",
"Load an xarray dataset using \"lazy-loading\" mode from a Copernicus Marine data source using either the ARCO series protocol.\n",
"This means that data is only loaded into memory when a computation is called, optimizing RAM usage by avoiding immediate loading.\n",
"It supports various parameters for customization, such as specifying ge ographical bounds, temporal range, depth range, and more.\n",
"\n",
"Args:\n",
" dataset_url (str, optional): The URL of the dataset. Either `dataset_url` or `dataset_id` should be provided.\n",
" dataset_id (str, optional): The ID of the dataset. Either `dataset_url` or `dataset_id` should be provided.\n",
" dataset_version (str, optional): Force the use of a specific dataset version.\n",
" dataset_part (str, optional): Force the use of a specific dataset part.\n",
" username (str, optional): Username for authentication, if required.\n",
" password (str, optional): Password for authentication, if required.\n",
" variables (List[str], optional): List of variable names to be loaded from the dataset.\n",
" minimum_longitude (float, optional): The minimum longitude for subsetting the data.\n",
" maximum_longitude (float, optional): The maximum longitude for subsetting the data.\n",
" minimum_latitude (float, optional): The minimum latitude for subsetting the data.\n",
" maximum_latitude (float, optional): The maximum latitude for subsetting the data.\n",
" minimum_depth (float, optional): The minimum depth for subsetting the data.\n",
" maximum_depth (float, optional): The maximum depth for subsetting the data.\n",
" vertical_dimension_as_originally_produced (bool, optional): If True, use the vertical dimension as originally produced.\n",
" start_datetime (datetime, optional): The start datetime for temporal subsetting.\n",
" end_datetime (datetime, optional): The end datetime for temporal subsetting.\n",
" service (str, optional): Force the use of a specific service (ARCO geo series or time series).\n",
" credentials_file (Union[pathlib.Path, str], optional): Path to a file containing authentication credentials.\n",
" overwrite_metadata_cache (bool, optional): If True, overwrite the metadata cache.\n",
" no_metadata_cache (bool, optional): If True, do not use the metadata cache.\n",
"\n",
"Returns:\n",
" xarray.Dataset: The loaded xarray dataset.\n",
"\u001b[0;31mFile:\u001b[0m ~/.pyenv/versions/3.10.12/envs/gpmb/lib/python3.10/site-packages/copernicusmarine/python_interface/open_dataset.py\n",
"\u001b[0;31mType:\u001b[0m function"
]
}
],
"source": [
"copernicusmarine.open_dataset?"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"forecast_end_date = 2027-11-26 23:59:59\n",
"end_date_cut = 2024-07-25 02:00:00\n",
"forecast_limit = 1972-07-30 10:15:57.104582\n",
"end_date_cut = 2024-07-26 00:00:00\n",
"start_date_cut = 2024-07-24 00:00:00\n",
"Result : mode = FORECAST, start = 2024-07-24 00:00:00, end = 2024-07-26 00:00:00\n"
]
}
],
"source": [
"from datetime import datetime, timedelta\n",
"formatting = \"%Y-%m-%d %I:%M:%S\"\n",
"\n",
"forecast_duration = 105235200\n",
"forecast_end_date = '2024-08-03 02:00:00'\n",
"history_duration = [105235200]\n",
"#------------------------------------\n",
"start_date = datetime.strptime('2024-07-24 02:00:00',formatting)\n",
"end_date = datetime.strptime('2024-07-25 02:00:00',formatting)\n",
"#------------------------------------\n",
"forecast_end_date = datetime.now().replace(hour=23, minute=59, second=59, microsecond=0) + timedelta(seconds=forecast_duration)\n",
"print(f\"forecast_end_date = {forecast_end_date}\")\n",
"end_date_cut = min(forecast_end_date, end_date)\n",
"print(f\"end_date_cut = {end_date_cut}\")\n",
"\n",
"for history_duration in history_duration:\n",
" forecast_limit = datetime.now() - timedelta(seconds=history_duration)\n",
" print(f\"forecast_limit = {forecast_limit}\")\n",
"\n",
" if end_date_cut < forecast_limit:\n",
" mode = \"HISTORICAL\"\n",
" else:\n",
" mode = \"FORECAST\"\n",
" break\n",
" print(f\"mode = {mode}\")\n",
"\n",
"# If the end date has been cut, because of the forecast limit,\n",
"# it needs to end the next day at midnight.\n",
"if (end_date_cut.hour != 0 or end_date_cut.minute != 0 or end_date_cut.second != 0 or end_date_cut.microsecond != 0):\n",
" end_date_cut = (end_date_cut + timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)\n",
" print(f\"end_date_cut = {end_date_cut}\")\n",
"\n",
"\n",
"start_date_cut = start_date.replace(hour=0, minute=0, second=0, microsecond=0)\n",
"print(f\"start_date_cut = {start_date_cut}\")\n",
"\n",
"\n",
"print(f\"Result : mode = {mode}, start = {start_date_cut}, end = {end_date_cut}\")\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Fetching catalog: 100%|██████████| 3/3 [00:13<00:00, 4.61s/it]\n"
]
},
{
"ename": "KeyError",
"evalue": "\"The requested dataset 'IBI_ANALYSISFORECAST_PHY_005_001' was not found in the catalogue, you can use 'copernicusmarine describe --include-datasets --contains <search_token>' to find datasets\"",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mStopIteration\u001b[0m Traceback (most recent call last)",
"File \u001b[0;32m~/.pyenv/versions/3.10.12/envs/gpmb/lib/python3.10/site-packages/copernicusmarine/core_functions/utils.py:105\u001b[0m, in \u001b[0;36mnext_or_raise_exception\u001b[0;34m(iterator, exception_to_raise)\u001b[0m\n\u001b[1;32m 104\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 105\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mnext\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43miterator\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 106\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exception:\n",
"\u001b[0;31mStopIteration\u001b[0m: ",
"\nThe above exception was the direct cause of the following exception:\n",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[36], line 30\u001b[0m\n\u001b[1;32m 10\u001b[0m paramsCopernicus \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 11\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdataset_id\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcmems_mod_ibi_bgc_anfc_0.027deg-3D_P1D-m\u001b[39m\u001b[38;5;124m'\u001b[39m, \n\u001b[1;32m 12\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mminimum_longitude\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1.4167\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmaximum_longitude\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1.4167\u001b[39m, \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mvariables\u001b[39m\u001b[38;5;124m'\u001b[39m: [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mo2\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mnh4\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m 16\u001b[0m }\n\u001b[1;32m 18\u001b[0m paramsCopernicus \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 19\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdataset_id\u001b[39m\u001b[38;5;124m'\u001b[39m: \n\u001b[1;32m 20\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mIBI_ANALYSISFORECAST_PHY_005_001\u001b[39m\u001b[38;5;124m'\u001b[39m, \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 26\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mmaximum_depth\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;241m0.494\u001b[39m, \n\u001b[1;32m 27\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mvariables\u001b[39m\u001b[38;5;124m'\u001b[39m: [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mso\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mthetao\u001b[39m\u001b[38;5;124m'\u001b[39m]}\n\u001b[0;32m---> 30\u001b[0m dataset \u001b[38;5;241m=\u001b[39m \u001b[43mcopernicusmarine\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mopen_dataset\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 31\u001b[0m \u001b[43m \u001b[49m\u001b[43mdataset_id\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mparamsCopernicus\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mdataset_id\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 32\u001b[0m \u001b[43m \u001b[49m\u001b[43mdataset_part\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mdefault\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 33\u001b[0m \u001b[43m \u001b[49m\u001b[43mservice\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43marco-time-series\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 34\u001b[0m \u001b[43m \u001b[49m\u001b[43mminimum_longitude\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mparamsCopernicus\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mminimum_longitude\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 35\u001b[0m \u001b[43m \u001b[49m\u001b[43mmaximum_longitude\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mparamsCopernicus\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmaximum_longitude\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 36\u001b[0m \u001b[43m \u001b[49m\u001b[43mminimum_latitude\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mparamsCopernicus\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mminimum_latitude\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 37\u001b[0m \u001b[43m \u001b[49m\u001b[43mmaximum_latitude\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mparamsCopernicus\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmaximum_latitude\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 38\u001b[0m \u001b[43m \u001b[49m\u001b[43mminimum_depth\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mparamsCopernicus\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mminimum_depth\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 39\u001b[0m \u001b[43m \u001b[49m\u001b[43mmaximum_depth\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mparamsCopernicus\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmaximum_depth\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 40\u001b[0m \u001b[43m \u001b[49m\u001b[43mstart_datetime\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstart_date\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43misoformat\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# todo au format yyyy-mm-dd?\u001b[39;49;00m\n\u001b[1;32m 41\u001b[0m \u001b[43m \u001b[49m\u001b[43mend_datetime\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mend_date\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43misoformat\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# todo au format yyyy-mm-dd?\u001b[39;49;00m\n\u001b[1;32m 42\u001b[0m \u001b[43m \u001b[49m\u001b[43mvariables\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mparamsCopernicus\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mvariables\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/.pyenv/versions/3.10.12/envs/gpmb/lib/python3.10/site-packages/copernicusmarine/core_functions/deprecated.py:77\u001b[0m, in \u001b[0;36mdeprecated_python_option.<locals>.deco.<locals>.wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 74\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(f)\n\u001b[1;32m 75\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 76\u001b[0m rename_kwargs(f\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m, kwargs, aliases)\n\u001b[0;32m---> 77\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mf\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/.pyenv/versions/3.10.12/envs/gpmb/lib/python3.10/site-packages/copernicusmarine/python_interface/exception_handler.py:17\u001b[0m, in \u001b[0;36mlog_exception_and_exit.<locals>.wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAbort\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 16\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exception:\n\u001b[0;32m---> 17\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m exception\n",
"File \u001b[0;32m~/.pyenv/versions/3.10.12/envs/gpmb/lib/python3.10/site-packages/copernicusmarine/python_interface/exception_handler.py:13\u001b[0m, in \u001b[0;36mlog_exception_and_exit.<locals>.wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;129m@wraps\u001b[39m(function)\n\u001b[1;32m 11\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 12\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m---> 13\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunction\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 14\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m click\u001b[38;5;241m.\u001b[39mAbort:\n\u001b[1;32m 15\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAbort\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"File \u001b[0;32m~/.pyenv/versions/3.10.12/envs/gpmb/lib/python3.10/site-packages/copernicusmarine/python_interface/open_dataset.py:141\u001b[0m, in \u001b[0;36mopen_dataset\u001b[0;34m(dataset_url, dataset_id, dataset_version, dataset_part, username, password, variables, minimum_longitude, maximum_longitude, minimum_latitude, maximum_latitude, minimum_depth, maximum_depth, vertical_dimension_as_originally_produced, start_datetime, end_datetime, subset_method, service, credentials_file, overwrite_metadata_cache, no_metadata_cache, disable_progress_bar)\u001b[0m\n\u001b[1;32m 105\u001b[0m credentials_file \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 106\u001b[0m pathlib\u001b[38;5;241m.\u001b[39mPath(credentials_file) \u001b[38;5;28;01mif\u001b[39;00m credentials_file \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 107\u001b[0m )\n\u001b[1;32m 108\u001b[0m load_request \u001b[38;5;241m=\u001b[39m LoadRequest(\n\u001b[1;32m 109\u001b[0m dataset_url\u001b[38;5;241m=\u001b[39mdataset_url,\n\u001b[1;32m 110\u001b[0m dataset_id\u001b[38;5;241m=\u001b[39mdataset_id,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 139\u001b[0m no_metadata_cache\u001b[38;5;241m=\u001b[39mno_metadata_cache,\n\u001b[1;32m 140\u001b[0m )\n\u001b[0;32m--> 141\u001b[0m dataset \u001b[38;5;241m=\u001b[39m \u001b[43mload_data_object_from_load_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 142\u001b[0m \u001b[43m \u001b[49m\u001b[43mload_request\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 143\u001b[0m \u001b[43m \u001b[49m\u001b[43mdisable_progress_bar\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 144\u001b[0m \u001b[43m \u001b[49m\u001b[43mopen_dataset_from_arco_series\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 145\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 146\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m dataset\n",
"File \u001b[0;32m~/.pyenv/versions/3.10.12/envs/gpmb/lib/python3.10/site-packages/copernicusmarine/python_interface/load_utils.py:41\u001b[0m, in \u001b[0;36mload_data_object_from_load_request\u001b[0;34m(load_request, disable_progress_bar, arco_series_load_function)\u001b[0m\n\u001b[1;32m 35\u001b[0m delete_cache_folder()\n\u001b[1;32m 37\u001b[0m catalogue \u001b[38;5;241m=\u001b[39m parse_catalogue(\n\u001b[1;32m 38\u001b[0m no_metadata_cache\u001b[38;5;241m=\u001b[39mload_request\u001b[38;5;241m.\u001b[39mno_metadata_cache,\n\u001b[1;32m 39\u001b[0m disable_progress_bar\u001b[38;5;241m=\u001b[39mdisable_progress_bar,\n\u001b[1;32m 40\u001b[0m )\n\u001b[0;32m---> 41\u001b[0m retrieval_service: RetrievalService \u001b[38;5;241m=\u001b[39m \u001b[43mget_retrieval_service\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 42\u001b[0m \u001b[43m \u001b[49m\u001b[43mcatalogue\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcatalogue\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 43\u001b[0m \u001b[43m \u001b[49m\u001b[43mdataset_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mload_request\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdataset_id\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 44\u001b[0m \u001b[43m \u001b[49m\u001b[43mdataset_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mload_request\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdataset_url\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 45\u001b[0m \u001b[43m \u001b[49m\u001b[43mforce_dataset_version_label\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mload_request\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mforce_dataset_version\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 46\u001b[0m \u001b[43m \u001b[49m\u001b[43mforce_dataset_part_label\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mload_request\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mforce_dataset_part\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 47\u001b[0m \u001b[43m \u001b[49m\u001b[43mforce_service_type_string\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mload_request\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mforce_service\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 48\u001b[0m \u001b[43m \u001b[49m\u001b[43mcommand_type\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mCommandType\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mLOAD\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 49\u001b[0m \u001b[43m \u001b[49m\u001b[43mdataset_subset\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mload_request\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_time_and_geographical_subset\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 50\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 51\u001b[0m username, password \u001b[38;5;241m=\u001b[39m get_username_password(\n\u001b[1;32m 52\u001b[0m load_request\u001b[38;5;241m.\u001b[39musername,\n\u001b[1;32m 53\u001b[0m load_request\u001b[38;5;241m.\u001b[39mpassword,\n\u001b[1;32m 54\u001b[0m load_request\u001b[38;5;241m.\u001b[39mcredentials_file,\n\u001b[1;32m 55\u001b[0m )\n\u001b[1;32m 56\u001b[0m load_request\u001b[38;5;241m.\u001b[39mdataset_url \u001b[38;5;241m=\u001b[39m retrieval_service\u001b[38;5;241m.\u001b[39muri\n",
"File \u001b[0;32m~/.pyenv/versions/3.10.12/envs/gpmb/lib/python3.10/site-packages/copernicusmarine/core_functions/services_utils.py:340\u001b[0m, in \u001b[0;36mget_retrieval_service\u001b[0;34m(catalogue, dataset_id, dataset_url, force_dataset_version_label, force_dataset_part_label, force_service_type_string, command_type, index_parts, dataset_subset, dataset_sync, username)\u001b[0m\n\u001b[1;32m 337\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m syntax_error\n\u001b[1;32m 338\u001b[0m suffix_path \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m--> 340\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_get_retrieval_service_from_dataset_id\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 341\u001b[0m \u001b[43m \u001b[49m\u001b[43mcatalogue\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcatalogue\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 342\u001b[0m \u001b[43m \u001b[49m\u001b[43mdataset_id\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdataset_id\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 343\u001b[0m \u001b[43m \u001b[49m\u001b[43msuffix_path\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msuffix_path\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 344\u001b[0m \u001b[43m \u001b[49m\u001b[43mforce_dataset_version_label\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mforce_dataset_version_label\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 345\u001b[0m \u001b[43m \u001b[49m\u001b[43mforce_dataset_part_label\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mforce_dataset_part_label\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 346\u001b[0m \u001b[43m \u001b[49m\u001b[43mforce_service_type\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mforce_service_type\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 347\u001b[0m \u001b[43m \u001b[49m\u001b[43mcommand_type\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcommand_type\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 348\u001b[0m \u001b[43m \u001b[49m\u001b[43mindex_parts\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindex_parts\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 349\u001b[0m \u001b[43m \u001b[49m\u001b[43mdataset_subset\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdataset_subset\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 350\u001b[0m \u001b[43m \u001b[49m\u001b[43mdataset_sync\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdataset_sync\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 351\u001b[0m \u001b[43m \u001b[49m\u001b[43musername\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43musername\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 352\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/.pyenv/versions/3.10.12/envs/gpmb/lib/python3.10/site-packages/copernicusmarine/core_functions/services_utils.py:368\u001b[0m, in \u001b[0;36m_get_retrieval_service_from_dataset_id\u001b[0;34m(catalogue, dataset_id, suffix_path, force_dataset_version_label, force_dataset_part_label, force_service_type, command_type, index_parts, dataset_subset, dataset_sync, username)\u001b[0m\n\u001b[1;32m 355\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_get_retrieval_service_from_dataset_id\u001b[39m(\n\u001b[1;32m 356\u001b[0m catalogue: CopernicusMarineCatalogue,\n\u001b[1;32m 357\u001b[0m dataset_id: \u001b[38;5;28mstr\u001b[39m,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 366\u001b[0m username: Optional[\u001b[38;5;28mstr\u001b[39m],\n\u001b[1;32m 367\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m RetrievalService:\n\u001b[0;32m--> 368\u001b[0m dataset: CopernicusMarineProductDataset \u001b[38;5;241m=\u001b[39m \u001b[43mnext_or_raise_exception\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 369\u001b[0m \u001b[43m \u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 370\u001b[0m \u001b[43m \u001b[49m\u001b[43mdataset\u001b[49m\n\u001b[1;32m 371\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mproduct\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mcatalogue\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mproducts\u001b[49m\n\u001b[1;32m 372\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mdataset\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mproduct\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdatasets\u001b[49m\n\u001b[1;32m 373\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mdataset_id\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m==\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mdataset\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdataset_id\u001b[49m\n\u001b[1;32m 374\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 375\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;167;43;01mKeyError\u001b[39;49;00m\u001b[43m(\u001b[49m\n\u001b[1;32m 376\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mThe requested dataset \u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mdataset_id\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m was not found in the catalogue,\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m 377\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m you can use \u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mcopernicusmarine describe --include-datasets \u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m 378\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m--contains <search_token>\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m to find datasets\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[1;32m 379\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 380\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 381\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m _get_retrieval_service_from_dataset(\n\u001b[1;32m 382\u001b[0m dataset\u001b[38;5;241m=\u001b[39mdataset,\n\u001b[1;32m 383\u001b[0m suffix_path\u001b[38;5;241m=\u001b[39msuffix_path,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 391\u001b[0m username\u001b[38;5;241m=\u001b[39musername,\n\u001b[1;32m 392\u001b[0m )\n",
"File \u001b[0;32m~/.pyenv/versions/3.10.12/envs/gpmb/lib/python3.10/site-packages/copernicusmarine/core_functions/utils.py:107\u001b[0m, in \u001b[0;36mnext_or_raise_exception\u001b[0;34m(iterator, exception_to_raise)\u001b[0m\n\u001b[1;32m 105\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mnext\u001b[39m(iterator)\n\u001b[1;32m 106\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exception:\n\u001b[0;32m--> 107\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m exception_to_raise \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mexception\u001b[39;00m\n",
"\u001b[0;31mKeyError\u001b[0m: \"The requested dataset 'IBI_ANALYSISFORECAST_PHY_005_001' was not found in the catalogue, you can use 'copernicusmarine describe --include-datasets --contains <search_token>' to find datasets\""
]
}
],
"source": [
"params = SimulationParameters( model=model3D,\n",
" project_id=ProjectId3D,\n",
" sources=sources3D,\n",
" start_date=\"2024-06-26 00:00:00\",\n",
" end_date=\"2024-06-28 00:00:00\",\n",
" naos_token=NAOS_TOKEN,\n",
" write_in_naos=WRITE_IN_NAOS,\n",
" )\n",
" \n",
"paramsCopernicus = {\n",
" 'dataset_id': 'cmems_mod_ibi_bgc_anfc_0.027deg-3D_P1D-m', \n",
" 'minimum_longitude': -1.4167, 'maximum_longitude': -1.4167, \n",
" 'minimum_latitude': 45.5833, 'maximum_latitude': 45.5833, \n",
" 'minimum_depth': 0.494, 'maximum_depth': 0.4941, \n",
" 'variables': ['o2', 'nh4']\n",
" }\n",
"\n",
"paramsCopernicus = {\n",
" 'dataset_id': \n",
" 'cmems_mod_ibi_phy_anfc_0.027deg-3D_PT1H-m', \n",
" 'minimum_longitude': -1.4161, \n",
" 'maximum_longitude': -1.4161, \n",
" 'minimum_latitude': 45.5839, \n",
" 'maximum_latitude': 45.5839, \n",
" 'minimum_depth': 0.4939, \n",
" 'maximum_depth': 0.494, \n",
" 'variables': ['so', 'thetao']}\n",
"\n",
"\n",
"dataset = copernicusmarine.open_dataset(\n",
" dataset_id = paramsCopernicus[\"dataset_id\"],\n",
" dataset_part = \"default\",\n",
" service = \"arco-time-series\",\n",
" minimum_longitude = paramsCopernicus[\"minimum_longitude\"],\n",
" maximum_longitude = paramsCopernicus[\"maximum_longitude\"],\n",
" minimum_latitude = paramsCopernicus[\"minimum_latitude\"],\n",
" maximum_latitude = paramsCopernicus[\"maximum_latitude\"],\n",
" minimum_depth = paramsCopernicus[\"minimum_depth\"],\n",
" maximum_depth = paramsCopernicus[\"maximum_depth\"],\n",
" start_datetime = params.start_date.isoformat(), # todo au format yyyy-mm-dd?\n",
" end_datetime = params.end_date.isoformat(), # todo au format yyyy-mm-dd?\n",
" variables = paramsCopernicus[\"variables\"])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "gpmb",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}