/[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.1 - (hide annotations) (download)
Mon Feb 7 05:31:45 2005 UTC (20 years, 5 months ago) by enderton
Branch: MAIN
 o Added capability to read and plot monitor files in Diagnostics package.

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     nciter=nciter(index); time=[time;nciter];
49     ncdata=ncdata(index); data=[data;ncdata];
50     end
51     else
52     [test,loc]=ismember(itr,nciter(:));
53     index=find(test);
54     if ~isempty(index)
55     time(index)=nciter(loc(index));
56     data(index)=ncdata(loc(index));
57     end
58     end
59    
60     close(nc);
61     end
62    
63     % Check for missing indecies.
64     if ~isempty(find(isnan(time))) || ~isempty(find(isnan(data)))
65     error('Missing monitor data for specified indecies!');
66     end
67    
68     time=time*tst./SecPerYear;

  ViewVC Help
Powered by ViewVC 1.1.22