/[MITgcm]/MITgcm_contrib/enderton/Diagnostics/DiagLoadMonitor.m
ViewVC logotype

Annotation of /MITgcm_contrib/enderton/Diagnostics/DiagLoadMonitor.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (hide annotations) (download)
Mon Feb 7 16:22:30 2005 UTC (20 years, 5 months ago) by enderton
Branch: MAIN
Changes since 1.1: +5 -3 lines
 o Fixed bug to allow for DiagLoadMonitor to handle multiple monitor files
from the same time span while not duplicating data plotted.

1 enderton 1.1 function [data,time] = ...
2     DiagLoadMonitor(fln,mnchandle,dad,itr,tst,SecPerYear,DiagDebug);
3    
4     % Read in files names.
5     %files = dir([dad,'/',mnchandle]);
6     filesin=ls([dad,'/',mnchandle]);
7     index=1;
8     while ~isempty(filesin)
9     [token,filesin] = strtok(filesin);
10     if ~isempty(filesin)
11     files(index).name=token; index=index+1;
12     end
13     end
14    
15    
16     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17     % Read in data %
18     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19    
20     % Initialize result arrays.
21     if isempty(itr),
22     time=[];
23     data=[];
24     else
25     time=NaN.*zeros(size(itr));
26     data=NaN.*zeros(size(itr));
27     end
28    
29     for ifile = 1:length(files)
30    
31     % Open monitor file.
32     if DiagDebug, disp(['Entering file: ',files(ifile).name]); end
33     nc=netcdf(files(ifile).name,'read');
34    
35     % Read time and data information.
36     nciter=nc{'T'}; if isempty(nciter), nciter=nc{'iter'}; end
37     ncdata=nc{fln};
38     if isempty(nciter), error('Monitor time axis not found!'); end
39     if isempty(ncdata), error(['Monitor field not found: ',fln]); end
40    
41     % Load desired indecies.
42     if isempty(itr)
43     if isempty(time),
44     time=nciter(:);
45     data=ncdata(:);
46     else
47     index=find(~ismember(nciter(:),time));
48 enderton 1.2 if ~isempty(index)
49     nciter=nciter(index); time=[time;nciter];
50     ncdata=ncdata(index); data=[data;ncdata];
51     end
52 enderton 1.1 end
53     else
54     [test,loc]=ismember(itr,nciter(:));
55     index=find(test);
56     if ~isempty(index)
57     time(index)=nciter(loc(index));
58     data(index)=ncdata(loc(index));
59     end
60     end
61    
62     close(nc);
63     end
64    
65     % Check for missing indecies.
66     if ~isempty(find(isnan(time))) || ~isempty(find(isnan(data)))
67     error('Missing monitor data for specified indecies!');
68     end
69    
70 enderton 1.2 time=time*tst./SecPerYear;

  ViewVC Help
Powered by ViewVC 1.1.22