|
1 |
| -function [varargout]=plotbathyexcite(c,la,lo,crng,popt,fgcolor,bgcolor,ax) |
| 1 | +function [varargout]=plotbathyexcite(c,la,lo,crng,varargin) |
2 | 2 | %PLOTBATHYEXCITE Plots 2ndary microseism bathymetric excitation coeff
|
3 | 3 | %
|
4 | 4 | % Usage: plotbathyexcite(c,lat,lon)
|
5 | 5 | % plotbathyexcite(c,lat,lon,clim)
|
6 |
| -% plotbathyexcite(c,lat,lon,clim,projopt) |
7 |
| -% plotbathyexcite(c,lat,lon,clim,projopt,fgcolor,bgcolor) |
8 |
| -% plotbathyexcite(c,lat,lon,clim,projopt,fgcolor,bgcolor,ax) |
| 6 | +% plotbathyexcite(c,lat,lon,clim,'mmap_opt1',mmap_val1,...) |
9 | 7 | % ax=plotbathyexcite(...)
|
10 | 8 | %
|
11 | 9 | % Description:
|
12 |
| -% PLOTBATHYEXCITE(C,LAT,LON) plots bathymetric coefficient data given |
| 10 | +% PLOTBATHYEXCITE(C,LAT,LON) maps bathymetric coefficient data given |
13 | 11 | % in the 2D array C. The data should be regularly sampled in latitude
|
14 |
| -% and longitude (given by vectors LAT & LON). The data is plotted on a |
15 |
| -% map with a Robinson projection and the map limits are scaled to |
16 |
| -% fit the latitude and longitude limits. This plots GSHHS coastlines |
17 |
| -% in a crude-resolution. Dimensions of C should be NLATxNLON. |
| 12 | +% and longitude (given by vectors LAT & LON). Dimensions of C should |
| 13 | +% be NLATxNLON. |
18 | 14 | %
|
19 |
| -% PLOTBATHYEXCITE(C,LAT,LON,CLIM) sets the coloring limits of the |
20 |
| -% coefficients limits for coloring. The default is [0 1]. CLIM must |
21 |
| -% be a real-valued 2-element vector. |
| 15 | +% PLOTBATHYEXCITE(C,LAT,LON,CLIM) sets the colormap limits of the |
| 16 | +% coefficients. The default is [0 1]. CLIM must be a real-valued |
| 17 | +% 2-element vector. |
| 18 | +% |
| 19 | +% PLOTBATHYEXCITE(C,LAT,LON,CLIM,'MMAP_OPT1',MMAP_VAL1,...) passes |
| 20 | +% additional options on to MMAP to alter the map. |
22 | 21 | %
|
23 |
| -% PLOTBATHYEXCITE(C,LAT,LON,CLIM,PROJOPT) allows passing options to |
24 |
| -% M_PROJ. See M_PROJ('SET') for possible projections and see |
25 |
| -% M_PROJ('GET',PROJ) for a list of possible additional options specific |
26 |
| -% to that projection. |
27 |
| -% |
28 |
| -% PLOTBATHYEXCITE(C,LAT,LON,CLIM,PROJOPT,FGCOLOR,BGCOLOR) specifies |
29 |
| -% foreground and background colors of the plot. The default is 'w' for |
30 |
| -% FGCOLOR & 'k' for BGCOLOR. Note that if one is specified and the |
31 |
| -% other is not, an opposing color is found using INVERTCOLOR. The |
32 |
| -% color scale is also changed so the lower color clip is at BGCOLOR. |
33 |
| -% |
34 |
| -% PLOTBATHYEXCITE(C,LAT,LON,CLIM,PROJOPT,FGCOLOR,BGCOLOR,AX) sets the |
35 |
| -% axes to draw in. This is useful for subplots, guis, etc. |
36 |
| -% |
37 |
| -% AX=PLOTBATHYEXCITE(...) |
| 22 | +% AX=PLOTBATHYEXCITE(...) returns the axes drawn in. |
38 | 23 | %
|
39 | 24 | % Notes:
|
40 |
| -% - This function can be easily altered to work for any image data. |
41 | 25 | %
|
42 | 26 | % Examples:
|
43 | 27 | % % Get bathymetric excitation coefficients for Crust2.0 and plot:
|
|
61 | 45 | % Feb. 15, 2011 - initial version
|
62 | 46 | % May 5, 2012 - minor doc update
|
63 | 47 | % May 18, 2012 - improved label of the colorbar, use gray colormap
|
| 48 | +% Aug. 27, 2013 - use mmap image option |
64 | 49 | %
|
65 | 50 | % Written by Garrett Euler (ggeuler at wustl dot edu)
|
66 |
| -% Last Updated May 18, 2012 at 15:05 GMT |
| 51 | +% Last Updated Aug. 27, 2013 at 15:05 GMT |
67 | 52 |
|
68 | 53 | % todo:
|
69 | 54 |
|
70 | 55 | % check nargin
|
71 |
| -error(nargchk(1,8,nargin)); |
| 56 | +error(nargchk(3,inf,nargin)); |
72 | 57 |
|
73 | 58 | % check coefficient array
|
74 | 59 | if(~isreal(c) || any(c(:)<0) || ndims(c)~=2)
|
|
96 | 81 | end
|
97 | 82 | crng=sort([crng(1) crng(2)]);
|
98 | 83 |
|
99 |
| -% check colors |
100 |
| -if(nargin<6); |
101 |
| - fgcolor='w'; bgcolor='k'; |
102 |
| -elseif(nargin<7) |
103 |
| - if(isempty(fgcolor)) |
104 |
| - fgcolor='w'; bgcolor='k'; |
105 |
| - else |
106 |
| - bgcolor=invertcolor(fgcolor,true); |
107 |
| - end |
108 |
| -else |
109 |
| - if(isempty(fgcolor)) |
110 |
| - if(isempty(bgcolor)) |
111 |
| - fgcolor='w'; bgcolor='k'; |
112 |
| - else |
113 |
| - fgcolor=invertcolor(bgcolor,true); |
114 |
| - end |
115 |
| - elseif(isempty(bgcolor)) |
116 |
| - bgcolor=invertcolor(fgcolor,true); |
117 |
| - end |
118 |
| -end |
119 |
| - |
120 |
| -% change char to something rgb |
121 |
| -if(ischar(fgcolor)); fgcolor=name2rgb(fgcolor); end |
122 |
| -if(ischar(bgcolor)); bgcolor=name2rgb(bgcolor); end |
| 84 | +% a couple mmap default changes |
| 85 | +% - use min/max of lat/lon as the map boundary |
| 86 | +% - do not show land/ocean |
| 87 | +varargin=[{'po' {'lat' [min(la) max(la)] ... |
| 88 | + 'lon' [min(lo) max(lo)]} 'l' false 'o' false} varargin]; |
123 | 89 |
|
124 |
| -% check handle |
125 |
| -if(nargin<8 || isempty(ax) || ~isscalar(ax) || ~isreal(ax) ... |
126 |
| - || ~ishandle(ax) || ~strcmp('axes',get(ax,'type'))) |
127 |
| - figure('color',bgcolor); |
128 |
| - ax=gca; |
129 |
| -else |
130 |
| - axes(ax); |
131 |
| - h=get(ax,'children'); delete(h); |
132 |
| - h=findobj(get(get(ax,'parent'),'children'),'peer',ax); delete(h); |
133 |
| -end |
134 |
| - |
135 |
| -% map colors & coast/border res |
136 |
| -%gshhs='c'; |
137 |
| -ocean=bgcolor; |
138 |
| -%land=fgcolor; |
139 |
| -land=[0.4 0.6 0.2]; |
140 |
| -%border=fgcolor; |
| 90 | +% draw map |
| 91 | +ax=mmap('image',{la lo c.'},varargin{:}); |
141 | 92 |
|
142 |
| -% access to m_map globals for map boundaries |
143 |
| -global MAP_VAR_LIST |
| 93 | +% extract color |
| 94 | +bg=get(get(ax,'parent'),'color'); |
| 95 | +fg=get(findobj(ax,'tag','m_grid_box'),'color'); |
144 | 96 |
|
145 |
| -% reshape beam & account for pcolor |
146 |
| -latstep=la(2)-la(1); |
147 |
| -lonstep=lo(2)-lo(1); |
148 |
| -la=[la(:)-latstep/2; la(end)+latstep/2]; |
149 |
| -lo=[lo(:)'-lonstep/2 lo(end)+lonstep/2]; |
150 |
| -c=c([1:end end],[1:end end]); |
151 |
| - |
152 |
| -% get max/min lat/lon of map & stations |
153 |
| -minlat=min(la); maxlat=max(la); |
154 |
| -minlon=min(lo); maxlon=max(lo); |
155 |
| - |
156 |
| -% default/check projopt |
157 |
| -if(nargin<5 || isempty(popt)) |
158 |
| - popt={'robinson','lat',[minlat maxlat],'lon',[minlon maxlon]}; |
159 |
| -end |
160 |
| -if(ischar(popt)); popt=cellstr(popt); end |
161 |
| -if(~iscell(popt)) |
162 |
| - error('seizmo:plotbathyexcite:badInput',... |
163 |
| - 'PROJOPT must be a cell array of args for M_PROJ!'); |
164 |
| -end |
165 |
| - |
166 |
| -% setup projection |
167 |
| -m_proj(popt{:}); |
168 |
| -set(ax,'color',ocean); |
169 |
| - |
170 |
| -% plot image data |
171 |
| -hold(ax,'on'); |
172 |
| -if(any(lo>MAP_VAR_LIST.longs(1) & lo<MAP_VAR_LIST.longs(2))) |
173 |
| - m_pcolor(lo,la,c,'parent',ax); |
174 |
| -end |
175 |
| -if(any(lo-360>MAP_VAR_LIST.longs(1) & lo-360<MAP_VAR_LIST.longs(2))) |
176 |
| - m_pcolor(lo-360,la,c,'parent',ax); |
177 |
| -end |
178 |
| -if(any(lo+360>MAP_VAR_LIST.longs(1) & lo+360<MAP_VAR_LIST.longs(2))) |
179 |
| - m_pcolor(lo+360,la,c,'parent',ax); |
180 |
| -end |
181 |
| - |
182 |
| -% modify |
183 |
| -shading(ax,'flat'); |
184 |
| -if(strcmp(bgcolor,'w') || isequal(bgcolor,[1 1 1])) |
| 97 | +% set colormap |
| 98 | +if(strcmp(bg,'w') || isequal(bg,[1 1 1])) |
185 | 99 | colormap(ax,flipud(gray));
|
186 |
| -elseif(strcmp(bgcolor,'k') || isequal(bgcolor,[0 0 0])) |
| 100 | +elseif(strcmp(bg,'k') || isequal(bg,[0 0 0])) |
187 | 101 | colormap(ax,gray);
|
188 | 102 | else
|
189 |
| - if(ischar(bgcolor)) |
190 |
| - bgcolor=name2rgb(bgcolor); |
191 |
| - end |
192 |
| - hsv=rgb2hsv(bgcolor); |
| 103 | + if(ischar(bg)); bg=name2rgb(bg); end |
| 104 | + hsv=rgb2hsv(bg); |
193 | 105 | colormap(ax,hsvcustom(hsv));
|
194 | 106 | end
|
195 | 107 | set(ax,'clim',crng);
|
196 |
| -hold(ax,'off'); |
197 |
| - |
198 |
| -% now add coastlines and political boundaries |
199 |
| -axes(ax); |
200 |
| -%m_gshhs([gshhs 'c'],'color',land); |
201 |
| -%m_gshhs([gshhs 'b'],'color',border); |
202 |
| -m_coast('line','color',fgcolor); |
203 |
| -%m_coast('patch',land); |
204 |
| -m_grid('color',fgcolor,'xtick',[],'ytick',[]); |
205 |
| - |
206 |
| -% hackery to color oceans at large when the above fails |
207 |
| -set(findobj(ax,'tag','m_grid_color'),'facecolor',ocean); |
208 | 108 |
|
209 | 109 | % colorbar & title
|
210 |
| -c=colorbar('eastoutside','peer',ax,'xcolor',fgcolor,'ycolor',fgcolor); |
211 |
| -xlabel(c,'$$\sum {c_{m}^2}$$','color',fgcolor,... |
212 |
| - 'interpreter','latex'); |
213 |
| -title(ax,{[] 'Bathymetric Excitation Coefficient Map' []},... |
214 |
| - 'color',fgcolor); |
215 |
| - |
216 |
| -% tag plot |
217 |
| -set(ax,'tag','bathyexcite'); |
| 110 | +c=colorbar('eastoutside','peer',ax,'xcolor',fg,'ycolor',fg); |
| 111 | +xlabel(c,'$$\sum {c_{m}^2}$$','color',fg,'interpreter','latex'); |
| 112 | +title(ax,{[] 'Bathymetric Excitation Coefficient Map' []},'color',fg); |
218 | 113 |
|
219 | 114 | % return figure handle
|
| 115 | +set(ax,'tag','bathyexcitemap'); |
220 | 116 | if(nargout); varargout{1}=ax; end
|
221 | 117 |
|
222 | 118 | end
|
0 commit comments