Mercurial > repos > ecology > argo_getdata
annotate argo_getdata.py @ 1:28c8f085d1b4 draft default tip
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit e395cfee9cab90bbed58ac52fb8467c896f51824
author | ecology |
---|---|
date | Thu, 01 Aug 2024 09:46:52 +0000 |
parents | 055a934a380f |
children |
rev | line source |
---|---|
0
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
1 # author: Marie Jossé |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
2 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
3 # Python script |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
4 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
5 ############################# |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
6 # Argo data access # |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
7 ############################# |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
8 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
9 # Packages : argopy |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
10 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
11 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
12 # Load arguments |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
13 import argparse |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
14 import sys |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
15 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
16 import argopy |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
17 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
18 command_line_args = sys.argv[1:] |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
19 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
20 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
21 parser = argparse.ArgumentParser(description="Retrieve argo Data") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
22 # Add arguments |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
23 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
24 parser.add_argument("--user", type=str, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
25 help="User mode : standard, expert or research") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
26 parser.add_argument("--cardinal_1", type=float, help="Longitude min") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
27 parser.add_argument("--cardinal_2", type=float, help="Longitude max") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
28 parser.add_argument("--cardinal_3", type=float, help="Latitude min") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
29 parser.add_argument("--cardinal_4", type=float, help="Latitude max") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
30 parser.add_argument("--pressure_1", type=float, help="Pressure min") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
31 parser.add_argument("--pressure_2", type=float, help="Pressure max") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
32 parser.add_argument("--date_1", type=str, help="Starting date") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
33 parser.add_argument("--date_2", type=str, help="Ending date.") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
34 parser.add_argument("--wmo", type=str, help="WMO: argo's identifier") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
35 parser.add_argument("--profile", type=str, help="Number of profiles") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
36 parser.add_argument("--params", type=str, help="List of bgc parameters") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
37 parser.add_argument("--measured", type=str, help="List of bgc parameters") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
38 parser.add_argument("--output_argo", type=str, help="Output data from argo") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
39 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
40 args = parser.parse_args(command_line_args) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
41 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
42 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
43 # Parse the command line arguments |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
44 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
45 print(args) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
46 # Import data |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
47 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
48 user = args.user |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
49 cardinal_1 = args.cardinal_1 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
50 cardinal_2 = args.cardinal_2 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
51 cardinal_3 = args.cardinal_3 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
52 cardinal_4 = args.cardinal_4 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
53 pressure_1 = args.pressure_1 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
54 pressure_2 = args.pressure_2 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
55 date_1 = args.date_1 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
56 date_2 = args.date_2 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
57 wmo = args.wmo |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
58 if wmo is not None: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
59 wmo = list(map(int, wmo.split(","))) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
60 profile = args.profile |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
61 if profile is not None: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
62 profile = list(map(int, profile.split(","))) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
63 params = args.params |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
64 if params is not None: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
65 params = params.split(",") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
66 if len(params) == 83: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
67 params = "all" |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
68 measured = args.measured |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
69 if measured is not None: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
70 measured = measured.split(",") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
71 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
72 # Let’s import the argopy data fetcher: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
73 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
74 ###################### |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
75 # User mode # |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
76 ###################### |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
77 # By default, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
78 # all argopy data fetchers are set to work with a standard user mode. |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
79 # To change that |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
80 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
81 argopy.set_options(mode=user) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
82 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
83 ###################### |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
84 # Fetching Argo data # |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
85 ###################### |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
86 # Data selection # |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
87 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
88 # To access Argo data with a DataFetcher, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
89 # you need to define how to select your data of interest. |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
90 # argopy provides 3 different data selection methods: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
91 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
92 argo_data = argopy.DataFetcher() |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
93 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
94 # 🗺 For a space/time domain # |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
95 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
96 if (cardinal_1 is not None): |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
97 mode = "region" |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
98 argo_data = argo_data.region([cardinal_1, cardinal_2, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
99 cardinal_3, cardinal_4, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
100 pressure_1, pressure_2, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
101 date_1, date_2]) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
102 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
103 # ⚓ For one or more profiles # |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
104 # Use the fetcher access point argopy.DataFetcher.profile() |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
105 # to specify the float WMO platform number |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
106 # and the profile cycle number(s) to retrieve profiles for. |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
107 elif (wmo is not None and profile is not None): |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
108 argo_data = argo_data.profile(wmo, profile) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
109 # can also be argo_data = argo_data.profile(6902755, [3, 12]) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
110 mode = "profile" |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
111 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
112 # 🤖 For one or more floats # |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
113 # If you know the Argo float unique identifier number called a WMO number |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
114 # you can use the fetcher access point DataFetcher.float() |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
115 # to specify one or more float WMO platform numbers to select. |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
116 else: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
117 argo_data = argo_data.float(wmo) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
118 # can also be argo_data = argo_data.float([6902746, 6902755]) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
119 mode = "float" |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
120 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
121 # Data sources # |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
122 # Let’s start with standard import: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
123 # argopy.reset_options() |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
124 # Specify data source erddap, gdac or argovis |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
125 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
126 # if (ftp != "") : |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
127 # argopy.set_options(src = "gdac", ftp = ftp) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
128 # else : |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
129 # argopy.set_options(src = "erddap") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
130 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
131 # With remote, online data sources, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
132 # it may happens that the data server is experiencing down time. |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
133 print(argopy.status()) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
134 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
135 # Dataset # |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
136 # Argo data are distributed as a single dataset. |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
137 # It is referenced at https://doi.org/10.17882/42182. |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
138 # But they are several Argo missions with specific files and parameters |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
139 # that need special handling by argopy, namely: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
140 # - the core Argo Mission: from floats that measure temperature, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
141 # salinity, pressure down to 2000m, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
142 # - the Deep Argo Mission: from floats that measure temperature, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
143 # salinity, pressure down to 6000m, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
144 # - and the BGC-Argo Mission: from floats that measure temperature, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
145 # salinity, pressure and oxygen, pH, nitrate, chlorophyll, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
146 # backscatter, irradiance down to 2000m. |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
147 # You can choose between phy or bgc |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
148 if (params is None): |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
149 argopy.set_options(dataset="phy") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
150 else: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
151 argopy.set_options(dataset="bgc") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
152 if (measured != ['None'] and measured is not None): |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
153 argo_data = argopy.DataFetcher(params=params, measured=measured) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
154 if (mode == "region"): |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
155 argo_data = argo_data.region([cardinal_1, cardinal_2, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
156 cardinal_3, cardinal_4, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
157 pressure_1, pressure_2, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
158 date_1, date_2]) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
159 elif (mode == "profile"): |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
160 argo_data = argo_data.profile(wmo, profile) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
161 else: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
162 argo_data = argo_data.float(wmo) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
163 else: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
164 argo_data = argopy.DataFetcher(params=params, measured=None) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
165 if (mode == "region"): |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
166 argo_data = argo_data.region([cardinal_1, cardinal_2, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
167 cardinal_3, cardinal_4, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
168 pressure_1, pressure_2, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
169 date_1, date_2]) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
170 elif (mode == "profile"): |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
171 argo_data = argo_data.profile(wmo, profile) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
172 else: |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
173 argo_data = argo_data.float(wmo) |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
174 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
175 # Data fetching # |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
176 # To fetch (i.e. access, download, format) Argo data, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
177 # argopy provides the DataFetcher class. |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
178 # Several DataFetcher arguments exist to help you select the dataset, |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
179 # the data source and the user mode the most suited for your applications; |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
180 # and also to improve performances. |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
181 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
182 # You define the selection of data you want to fetch |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
183 # with one of the DataFetcher methods: region, float or profile. |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
184 # 2 lines to download Argo data: import and fetch ! |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
185 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
186 argo_data = argo_data.load().data |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
187 argo_data.to_netcdf("argo_data.nc") |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
188 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
189 # argo_metadata = argo_data.to_index() |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
190 |
055a934a380f
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/ocean commit d3171d27d35f51b8e7464082610431642f1e4660
ecology
parents:
diff
changeset
|
191 print(argo_data) |