annotate argo_getdata.py @ 1:77787acbd793 draft default tip

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