Skip to content

Commit ac98e58

Browse files
committed
Added option 'direction' to search criteria
1 parent 8c4016e commit ac98e58

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

select_profiles.m

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function [float_ids, float_profs] = select_profiles(lon_lim,lat_lim,...
22
start_date,end_date,varargin)
33
% 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.
55
%
66
% USAGE:
77
% [float_ids, float_profs] = select_profiles(lon_lim,lat_lim,...
@@ -42,6 +42,8 @@
4242
% 'csio'; 'csiro'; 'incois'; 'jma'; 'kma'; 'kordi'; 'meds'}
4343
% 'depth',depth: Select profiles that reach at least this depth
4444
% (positive downwards; in db)
45+
% 'direction',dir: Select profiles by direction ('a' for ascending,
46+
% 'd' for descending, '' for both directions)
4547
% 'floats',floats: Select profiles only from these floats that must
4648
% match all other criteria
4749
% 'interp_lonlat', intp : if intp is 'yes' (default), missing lon/lat
@@ -127,6 +129,7 @@
127129
min_num_prof = 0;
128130
interp_ll = Settings.interp_lonlat;
129131
type = []; % default assignment depends on sensor selection
132+
direction = '';
130133

131134
% parse optional arguments
132135
for i = 1:2:length(varargin)-1
@@ -150,6 +153,8 @@
150153
interp_ll = varargin{i+1};
151154
elseif strcmpi(varargin{i}, 'type')
152155
type = varargin{i+1};
156+
elseif strcmpi(varargin{i}, 'direction')
157+
direction = varargin{i+1};
153158
else
154159
warning('unknown option: %s', varargin{i});
155160
end
@@ -218,6 +223,13 @@
218223
end
219224
dac(bad == 1) = [];
220225

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+
221233
% make sure Prof and Sprof are initialized
222234
if isempty(Prof) || isempty(Sprof)
223235
initialize_argo();
@@ -421,20 +433,28 @@
421433
% used for all settings of outside:
422434
has_sensor = zeros(size(has_sensor));
423435
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
424444
% now apply the given constraints
425445
all_prof = 1:length(inpoly);
426446
if strcmp(outside, 'none')
427447
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);
429449
elseif strcmp(outside, 'time') % must meet space constraint
430450
float_profs{fl} = all_prof(inpoly & has_sensor & is_ocean & ...
431-
has_mode & has_press);
451+
has_mode & has_press & has_direct);
432452
elseif strcmp(outside, 'space') % must meet time constraint
433453
float_profs{fl} = all_prof(indate & has_sensor & is_ocean & ...
434-
has_mode & has_press);
454+
has_mode & has_press & has_direct);
435455
elseif strcmp(outside, 'both') % no time or space constraint
436456
float_profs{fl} = all_prof(has_sensor & is_ocean & ...
437-
has_mode & has_press);
457+
has_mode & has_press & has_direct);
438458
else
439459
warning('no such setting for "outside": %s', outside)
440460
float_profs{fl} = [];

0 commit comments

Comments
 (0)