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

Contents of /MITgcm_contrib/enderton/Diagnostics/DiagSlice.m

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


Revision 1.1 - (show annotations) (download)
Mon Jan 31 15:43:27 2005 UTC (20 years, 5 months ago) by enderton
Branch: MAIN
 o Initial check in.

1 function [data,xax,yax,pltslc] = ...
2 DiagSlice(data,fln,exp,dat,dad,grd,itr,tst,...
3 flu,ddf,gdf,avg,slc,pst,LoadGridData,GridSuffix,ZcordFile);
4
5 % Function: DiagSlice
6 % Author: Daniel Enderton
7 %
8 % Input Fields:
9 %
10 % Field Type (Brief) Description
11 % -----------------------------------------------------------------------
12 % data array Field name
13 % fln string Field name
14 % dad string Data directory.
15 % grd string Grid data directory.
16 % avg string Averaging scheme ('Ann','DJF', 'JJA',...)
17 % slc string Slice type ('Zon','k=#',...)
18 % pst string Plot style ('Con','Sur',...)
19 % flu string Fluid ('A','O')
20 % dfm string Data format ('MDS' or 'MNC')
21 % LoadGridData 0/1 Optionally load grid data
22 %
23 % Output Fields:
24 %
25 % Field Type (Brief) Description
26 % -----------------------------------------------------------------------
27 % data array Sliced data.
28 %
29 % Descripton:
30 % This function slices the data according to SliceType 'slc'. Depending
31 % on the SliceType and PlotStyle, the data may be converted to a lat-lon
32 % grid. At the end there is also a range check. If the value is out of
33 % the user specified range given in 'DaigFieldParamA'.
34
35 % Load diagnostics parameters, grid data, mark data size
36 DiagGenParam;
37 DiagFieldParamA;
38 DiagFieldParamO;
39 DiagFieldParamC;
40 DiagFieldParamI;
41 [XC,XG,YC,YG,Ylat,ZC,ZG,RAC,drC,drF,HFacC,HFacW,HFacS,dxG,dyG,dxC,dyC] = ...
42 DiagLoadGridData(LoadGridData,grd,gdf,flu,GridSuffix,ZcordFile);
43 datasize = size(data);
44
45
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 % Surface plot %
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49
50 % All surface plots are direct cube sphere outputs, and therefore must have
51 % the dimensions defined in 'hres' in 'DiagLoadGridData'. This is commonly
52 % [192,32]. If the 'pst' is 'Grd' or 'Int', everything is already all set
53 % since those handle the cubed sphere data. If the 'pst' is 'Con' or 'Cnf',
54 % convert data to a lat-lon grid so that it can easily be contours.
55 if isequal(slc,'Sur')
56 if ismember(fln,{'TX','TY','USTR','VSTR'})
57 data = data'; xax = XL; yax = YL;
58 elseif ~isequal(datasize,[faces*hres,hres])
59 error('Incorrect dimensions for slc: ',slc);
60 else
61 if ismember(pst,{'Grd','Int'})
62 if isequal(pst,'Grd'),
63 xax = XG(1:faces*hres,1:hres);
64 yax = YG(1:faces*hres,1:hres);
65 elseif isequal(pst,'Int'),
66 xax = XC(1:faces*hres,1:hres);
67 yax = YC(1:faces*hres,1:hres);
68 end
69 elseif ismember(pst,{'Con','Cnf'})
70 data = cube2latlon(XC,YC,data,XL,YL)';
71 xax = XL; yax = YL;
72 else
73 error(['slc = ''Sur'' can not use pst: ',pst]);
74 end
75 end
76 pltslc='lonlat';
77
78
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 % Zonal average plot %
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82
83 % When computing a zonal average, there are many different options for the
84 % initial data. If the data is cube-sphere, it could be of the size
85 % [hres,z-axis length] or just [hres]. In either case, 'calc_ZonAv_CS' (a
86 % nifty zonally averaging script from JMC) is called to compute the zonal
87 % average for raw cube sphere data. For horizontal velocities, the data
88 % could be of the size [length(XL),length(YL),z-axis length], in which case
89 % you just need to take the mean over the longitude axis (always 1).
90 elseif isequal(slc,'Zon')
91 if isequal(datasize(1:2),[faces*hres,hres])
92 if isequal(flu,'O'), nBas = 0; end
93 [data,dump1,dump2] = ...
94 calc_ZonAv_CS(data,kpr,kwr,nBas,XC,YC,XG,YG,RAC,dad,HFacC);
95 if isequal(avg,'Tse')
96 data=data(:,:,1); xax=years; yax=Ylat; pltslc='timlat';
97 elseif isequal(avg,'Tyr')
98 data=data(:,:,1); xax=[0:12]; yax=Ylat; pltslc='timlat';
99 elseif isequal(pst,'Lin')
100 data=data(:,:,1)'; xax=Ylat; yax=NaN; pltslc='latfld';
101 else
102 data=data(:,:,1)'; xax=Ylat; yax=ZC; pltslc='lathgt';
103 end
104 elseif isequal(datasize(1:2),[length(XL),length(YL)])
105 if ismember(fln,{'U','V','uVel','vVel'})
106 data = squeeze(mean(data,1))'; xax=YL; yax=ZC; pltslc='lathgt';
107 elseif ismember(fln,{'TX','TY','USTR','VSTR'})
108 data = squeeze(mean(data,1))'; xax=YL; yax=NaN; pltslc='latfld';
109 else
110 error(['Unknown field for U,V type zonal average data: ',fln]);
111 end
112 else
113 error('Incorrect dimensions for slc = ''Zon''');
114 end
115
116
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 % i,j,k=# %
119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120
121 % These slicing settings just take a slice on one of the axes. If the
122 % slice option is 'i=' or 'j=' and the data is cube-sphere, it is converted
123 % to lat-lon first and indexed then (thus the index number should be based
124 % off of the XL and YL interpolated grids defined in 'DiagGenParam'. It
125 % would be nice to add functions that can slice by longitude, latitude, and
126 % height values directly. Note that there is transposing of all the data
127 % to prepare it for contour plots (harmless is line plots).
128 elseif isequal(slc(1:2),'i=')
129 ii = str2num(slc(3:end));
130 data = cube2latlon(XC,YC,data,XL,YL);
131 if ismember(fln,fields2D)
132 data=squeeze(data(ii,:));
133 xax=YL; yax=NaN; pltslc='latfld';
134 elseif ismember(fln,fields3D)
135 data=squeeze(data(ii,:,:))';
136 xax=YL; yax=ZC; pltslc='lathgt';
137 end
138
139 elseif isequal(slc(1:2),'j=')
140 jj = str2num(slc(3:end));
141 data = cube2latlon(XC,YC,data,XL,YL);
142 if ismember(fln,fields2D)
143 data = squeeze(data(:,jj));
144 xax=XL; yax=NaN; pltslc='lonfld';
145 elseif ismember(fln,fields3D)
146 data = squeeze(data(:,jj,:))';
147 xax=XL; yax=ZC; pltslc='lonhgt';
148 end
149
150 elseif isequal(slc(1:2),'k=')
151 kk = str2num(slc(3:end));
152 data = squeeze(data(:,:,kk));
153 if ismember(fln,{'U','V','uVel','vVel'})
154 data = data'; xax = XL; yax = YL;
155 elseif ismember(pst,{'Grd','Int'})
156 if isequal(pst,'Grd'),
157 xax = XG(1:faces*hres,1:hres);
158 yax = YG(1:faces*hres,1:hres);
159 elseif isequal(pst,'Int'),
160 xax = XC(1:faces*hres,1:hres);
161 yax = YC(1:faces*hres,1:hres);
162 end
163 elseif ismember(pst,{'Con','Cnf'})
164 data = cube2latlon(XC,YC,data,XL,YL)'; xax = XL; yax = YL;
165 end
166 pltslc='lonlat';
167
168 else
169 error(['Unrecognized SliceType: ',slc]);
170 end
171
172
173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174 % Check range %
175 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176
177 % Load fixed and data ranges, throw a warning is data out of range.
178 datarange = [min(data(:)),max(data(:))];
179 try
180 eval(['fixedrange = ',fln,'range',flu,';']);
181 if datarange(1) < fixedrange(1) | ...
182 datarange(2) > fixedrange(2)
183 disp(['***Warning*** Value out of range for ',fln]);
184 disp([' Data range: ',mat2str(datarange)]);
185 disp([' Fixed range: ',mat2str(fixedrange)]);
186 end
187 catch
188 disp(['***Warning*** No range information found for ',fln]);
189 disp([' Data range: ',mat2str(datarange)]);
190 end

  ViewVC Help
Powered by ViewVC 1.1.22