annotate argo_getdata.py @ 0:4de886e6300d draft

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