-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTesting_1.R
221 lines (155 loc) · 7.99 KB
/
Testing_1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# Script for Testing the Basic Model Setting in the Tracer Budget Toolbox
# Author: Yibin Huang
# Location: Fuzhou
# Date: 10/09/2023)
# Note 1:
# Please ensure you are using the most recent version of the toolbox available on my GitHub:
# https://github.com/yibin-huang-ocean/NCP_Argotoolbox_test
# Also, make sure to provide the correct information for "root_path_tracer_budget_toolbox" and "appkey_Earthdata".
# Note 2:
# The toolbox is designed to automatically stop running if the selected float does not meet the tracer budget requirements.
# If this script runs without crashing, it indicates that the toolbox is working well under different settings.
# Close figures, clean up workspace, clear command window
cat("\014")
rm(list = ls())
# Step 1: Specify the root path of tracer budget toolbox and appkey_Earthda--------------------------
root_path_tracer_budget_toolbox<- ""
appkey_Earthdata <- "069271272ca0a0af44726d603a730a4c1c5c6cfe"
# copy the APPKEY archived from NASA EARTHDATA website at https://oceandata.sci.gsfc.nasa.gov/appkey/
# This appkey is required to download the remotely sensed chl data from Ocean Color Data
# Note: appkey_Earthdat may need to be periodically renewed
# Instructions to obtain the appkey_Earthdata:
# Step (1): 1. Go to the Earthdata Login page: https://oceandata.sci.gsfc.nasa.gov/appkey/
# Step (2): If you already have an account, log in with your username and passcode to obtain the APPKEY.
# Step (3): If you don't have an account, create a new one by clicking on the "Register" button and providing the required information.
# Step 2: Initialize tracer budget toolbox ----------------------------------------
# For the first time running the toolbox, the script will automatically download
# the ancillary parameters from the Internet.
# The total file size is ~11Gb, with an estimated time of 20 min to complete the downloading
setwd(paste( root_path_tracer_budget_toolbox,
"Main functions",sep="/"))
source("01_Initialize_tracer_budget_toolbox.R")
# Start testing the different model settings for basic options -----------------------------------------------------------------------
float_list_Southern_Ocean= c(5906222,
5904182,
5904183,
5904184,
5904185,
5904187,
5904188,
5904469,
5904183,
5904678,
5905072,
5906309
)
float_list_North_Pacific= c(5904028,
5904033,
5906474,
5904029,
5904030,
5906470,
5903405,
5903891,
5904125,
5905988,
5901468)
float_list_Indian_ocean= c(5906539)
float_list_Atlatntic= c(5903108,
5902460,
5903106,
1902384,
5906474,
4903365,
5904029,
5904030,
1902383)
float_list_equator= c(5903108,
5902460,
5903106,
4903365,
5904029,
5906503,
5904030)
float_list=c(float_list_Southern_Ocean,
float_list_equator,
float_list_North_Pacific,
float_list_Indian_ocean,
float_list_Atlatntic)
testing_record=data.frame(WMOID=NaN,
tracer=NaN,
background_correction=NaN,
integration_depth=NaN,
ekman_pumping_velocity=NaN,
model_run=NaN,
model_output=NaN
)
i=1
ii=1
iii=1
iiii=1
iiiii=1
# test 1: different floats
for (i in 1:length(float_list)){
# test 2: different tracers choices
for (ii in 1:5){
# test 3: different integration depths
for (iii in 1:3){
# test 4: different background correction approaches
for (iiii in 1:3){
# test 5: different ways to obtain the ekman pumping velocity
for (iiiii in 1:1){
Model_setting_list=tracer_budget_toolbox_settings (
root_path_tracer_budget_toolbox= root_path_tracer_budget_toolbox,
WMOID=float_list[i], # a single float ID; some examples 1: 5905988 (OSP); 2: 5906222 (Southern Ocean); 3. 5904279 (Core float) 4. 2902753 (float without adjusted data)
tracer=ii, # 1. DIC; 2. NO3; 3. Oxygen; 4.TA; 5.POC_bbp
integration_depth=iii, # 1. MLD;
# 2. varying monthly euphotic zone;
# 3. Fixed depth equal to mean euphotic zone over the float lifetime;
# or user-defined fixed depth (must be an integer and greater than 10m).
background_correction= iiii, # 1. NO; 2. Quasi_lagrangian correction (not applicable for oxygen and POC budget);
# 3. Quasi_Eulerian correction (not applicable for oxygen and POC budget)
ekman_pumping_velocity=iiiii, # 1. Real time (longer waiting time because of the online matchup);
# 2. Monthly climatology (short waiting time because of local matchup)
advanced_setting=1 # 1: Default; 2: Customization
)
Model_setting_list$iterations_uncertainty_simulation=4
# Step 4: Perform the tracer budget ------------------------------------
Output<- Tracer_budget_model_entire_procedure (
Model_setting_list = Model_setting_list)
# save the testing information
testing_record_1=data.frame(WMOID=Model_setting_list$WMOID,
tracer=Model_setting_list$tracer,
background_correction=Model_setting_list$background_correction,
integration_depth=Model_setting_list$integration_depth,
ekman_pumping_velocity=Model_setting_list$ekman_pumping_velocity,
model_run="good",
model_output="no" )
if (!is.null( Output)){
testing_record_1$model_output[1]="yes"
# Extract the output
tracer_budget= Output$tracer_budget # time-series of various terms in the tracer budget
float_profile_data= Output$float_profile_data # depth profile of float data with ancillary environmental parameters
# Plot float trajectory
plot_float_trajectory(tracer_budget,
Model_setting_list)
# Plot time-series tracer profile with integration depth embedded
plot_tracer_profile (float_profile_data,
tracer_budget )
# Plot the tracer budget
plot_tracer_budget( tracer_budget=tracer_budget,
Model_setting_list= Model_setting_list,
show_cycle_dot =1, # 1. yes; 2. NO
vertical_term_merge= 1) # 1. Yes (merge three vertical terms); 2.No
rm( Model_setting_list)
rm( Output)
}else{
testing_record= rbind( testing_record,testing_record_1)
rm( Model_setting_list)
rm( Output)
} # loop for " if (!is.null( Output)){"
} # loop for "iiiii"
} # loop for "iiii"
} # loop for "iii"
} # loop for "ii"
} # loop for "i"