forked from timhoar/DART
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_ensemble_indices.m
More file actions
52 lines (40 loc) · 1.41 KB
/
Copy pathget_ensemble_indices.m
File metadata and controls
52 lines (40 loc) · 1.41 KB
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
function [ens_size, ens_indices] = get_ensemble_indices(fname)
%% DART:GET_ENSEMBLE_INDICES returns the number of ensemble members in the file and their 'copy' indices.
%
% Example:
% fname = 'Prior_Diag.nc';
% [ens_size, ens_indices] = get_ensemble_indices(fname);
%
% Example to return just the size ...
% [ens_size, ~] = get_ensemble_indices(fname);
%% DART software - Copyright 2004 - 2013 UCAR. This open source software is
% provided by UCAR, "as is", without charge, subject to all terms of use at
% http://www.image.ucar.edu/DAReS/DART/DART_download
%
% DART $Id$
if ( exist(fname,'file') ~= 2 ), error('%s does not exist.',fname); end
ens_size = [];
ens_indices = [];
metastrings = nc_varget(fname,'CopyMetaData');
if(size(metastrings,2) == 1), metastrings = metastrings'; end
metadata = cellstr(metastrings);
% If the only copy is the true state, return without issuing the warning.
if strncmpi('true state',metadata,length('true state'))
return
end
% see what we have ...
ens_indices = find(strncmpi('ensemble member',metadata,length('ensemble member')));
if (isempty(ens_indices))
fprintf('WARNING: unable to find any valid ensemble members in %s\n', fname)
disp('valid metadata strings are: ')
for i = 1:length(metadata),
fprintf('%s\n',metadata{i})
end
ens_size = [];
else
ens_size = length(ens_indices);
end
% <next few lines under version control, do not edit>
% $URL$
% $Revision$
% $Date$