source: issm/trunk-jpl/src/m/plot/plot_gridded.m@ 14411

Last change on this file since 14411 was 14411, checked in by Mathieu Morlighem, 12 years ago

NEW: added forcecolormap options in plot_gridded to fix the colormap once for all

File size: 2.2 KB
Line 
1function plot_gridded(md,data,options,plotlines,plotcols,i)
2%PLOT_OVERLAY - superimpose radar image to a given field
3%
4% Usage:
5% plot_gridded(md,options,plotlines,plotcols,i)
6%
7% See also: PLOTMODEL
8
9%process mesh and data
10[x y z elements is2d isplanet]=processmesh(md,[],options);
11[data datatype]=processdata(md,data,options);
12
13%check is2d
14if ~is2d,
15 error('buildgridded error message: gridded not supported for 3d meshes, project on a layer');
16end
17
18%Get xlim and ylim (used to extract radar image)
19xlim=getfieldvalue(options,'xlim',[min(x) max(x)]);
20ylim=getfieldvalue(options,'ylim',[min(y) max(y)]);
21post=getfieldvalue(options,'posting',diff(xlim)/1000);
22
23%Interpolating data on grid
24[x_m y_m data_grid]=InterpFromMeshToGrid(elements,x,y,data,xlim(1),ylim(2),post,post,round(diff(ylim)/post),round(diff(xlim)/post),NaN);
25if size(data_grid,1)<3 | size(data_grid,2)<3,
26 error('data_grid size too small in plot_gridded, check posting and units');
27end
28
29%Get and change colormap
30map = getcolormap(options);
31lenmap = size(map,1);
32map = [1 1 1; map];
33options=changefieldvalue(options,'colormap',map);
34
35%Process data_grid: add white in NaN and correct caxis accordingly
36if exist(options,'caxis'),
37 caxis_opt=getfieldvalue(options,'caxis');
38 data_grid(find(data_grid<caxis_opt(1)))=caxis_opt(1);
39 data_grid(find(data_grid>caxis_opt(2)))=caxis_opt(2);
40 data_min=caxis_opt(1);
41 data_max=caxis_opt(2);
42else
43 data_min=min(data_grid(:));
44 data_max=max(data_grid(:));
45end
46options = changefieldvalue(options,'cbYLim',[data_min data_max]);
47white = data_min - (data_max-data_min)/(lenmap);
48options = changefieldvalue(options,'caxis',[white data_max]);
49data_grid(isnan(data_grid))=white;
50
51%Select plot area
52subplotmodel(plotlines,plotcols,i,options);
53
54%shading interp;
55if exist(options,'forcecolormap'),
56 image_rgb = ind2rgb(uint16((data_grid - data_min)*(length(map)/(data_max-data_min))),map);
57 h=imagesc(xlim,ylim,image_rgb);
58else
59 h=imagesc(xlim,ylim,data_grid);
60end
61axis xy
62
63%last step: mesh gridded?
64if exist(options,'edgecolor'),
65 A=elements(:,1); B=elements(:,2); C=elements(:,3);
66 patch('Faces',[A B C],'Vertices', [x y z],'FaceVertexCData',data_grid(1)*ones(size(x)),'FaceColor','none','EdgeColor',getfieldvalue(options,'edgecolor'));
67end
68
69%Apply options
70applyoptions(md,data,options);
Note: See TracBrowser for help on using the repository browser.