|
1 | 1 | function [float_ids, float_profs] = select_profiles(lon_lim,lat_lim,... |
2 | 2 | start_date,end_date,varargin) |
3 | 3 | % select_profiles This function is part of the |
4 | | -% MATLAB toolbox for accessing BGC Argo float data. |
| 4 | +% MATLAB toolbox for accessing Argo float data. |
5 | 5 | % |
6 | 6 | % USAGE: |
7 | 7 | % [float_ids, float_profs] = select_profiles(lon_lim,lat_lim,... |
|
42 | 42 | % 'csio'; 'csiro'; 'incois'; 'jma'; 'kma'; 'kordi'; 'meds'} |
43 | 43 | % 'depth',depth: Select profiles that reach at least this depth |
44 | 44 | % (positive downwards; in db) |
| 45 | +% 'direction',dir: Select profiles by direction ('a' for ascending, |
| 46 | +% 'd' for descending, '' for both directions) |
45 | 47 | % 'floats',floats: Select profiles only from these floats that must |
46 | 48 | % match all other criteria |
47 | 49 | % 'interp_lonlat', intp : if intp is 'yes' (default), missing lon/lat |
|
127 | 129 | min_num_prof = 0; |
128 | 130 | interp_ll = Settings.interp_lonlat; |
129 | 131 | type = []; % default assignment depends on sensor selection |
| 132 | +direction = ''; |
130 | 133 |
|
131 | 134 | % parse optional arguments |
132 | 135 | for i = 1:2:length(varargin)-1 |
|
150 | 153 | interp_ll = varargin{i+1}; |
151 | 154 | elseif strcmpi(varargin{i}, 'type') |
152 | 155 | type = varargin{i+1}; |
| 156 | + elseif strcmpi(varargin{i}, 'direction') |
| 157 | + direction = varargin{i+1}; |
153 | 158 | else |
154 | 159 | warning('unknown option: %s', varargin{i}); |
155 | 160 | end |
|
218 | 223 | end |
219 | 224 | dac(bad == 1) = []; |
220 | 225 |
|
| 226 | +% check if specified direction is correct |
| 227 | +if ~isempty(direction) && ~strncmpi(direction, 'a', 1) && ... |
| 228 | + ~strncmpi(direction, 'd', 1) |
| 229 | + warning('no such direction: %s', direction); |
| 230 | + direction = ''; % reset to "all" |
| 231 | +end |
| 232 | + |
221 | 233 | % make sure Prof and Sprof are initialized |
222 | 234 | if isempty(Prof) || isempty(Sprof) |
223 | 235 | initialize_argo(); |
|
421 | 433 | % used for all settings of outside: |
422 | 434 | has_sensor = zeros(size(has_sensor)); |
423 | 435 | end |
| 436 | + if isempty(direction) |
| 437 | + has_direct = ones(size(has_sensor)); |
| 438 | + else |
| 439 | + has_direct = zeros(size(has_sensor)); |
| 440 | + float_direction = ncread(filename, 'DIRECTION'); |
| 441 | + is_direct = find(float_direction == upper(direction)); |
| 442 | + has_direct(is_direct) = 1; |
| 443 | + end |
424 | 444 | % now apply the given constraints |
425 | 445 | all_prof = 1:length(inpoly); |
426 | 446 | if strcmp(outside, 'none') |
427 | 447 | float_profs{fl} = all_prof(inpoly & indate & has_sensor & ... |
428 | | - is_ocean & has_mode & has_press); |
| 448 | + is_ocean & has_mode & has_press & has_direct); |
429 | 449 | elseif strcmp(outside, 'time') % must meet space constraint |
430 | 450 | float_profs{fl} = all_prof(inpoly & has_sensor & is_ocean & ... |
431 | | - has_mode & has_press); |
| 451 | + has_mode & has_press & has_direct); |
432 | 452 | elseif strcmp(outside, 'space') % must meet time constraint |
433 | 453 | float_profs{fl} = all_prof(indate & has_sensor & is_ocean & ... |
434 | | - has_mode & has_press); |
| 454 | + has_mode & has_press & has_direct); |
435 | 455 | elseif strcmp(outside, 'both') % no time or space constraint |
436 | 456 | float_profs{fl} = all_prof(has_sensor & is_ocean & ... |
437 | | - has_mode & has_press); |
| 457 | + has_mode & has_press & has_direct); |
438 | 458 | else |
439 | 459 | warning('no such setting for "outside": %s', outside) |
440 | 460 | float_profs{fl} = []; |
|
0 commit comments