Changeset 16137 for issm/trunk/src/m/plot/plot_gridded.m
- Timestamp:
- 09/16/13 09:43:55 (12 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:ignore
-
old new 1 nightlylog 2 configure.sh 1 3 par 2 4 ad
-
- Property svn:mergeinfo changed
/issm/trunk-jpl merged: 15397-15401,15403-15487,15489-15701,15704-15735,15737-16076,16082-16133
- Property svn:ignore
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/plot/plot_gridded.m
r15396 r16137 23 23 %Interpolating data on grid 24 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); 25 data_grid_save = data_grid; 25 26 if size(data_grid,1)<3 | size(data_grid,2)<3, 26 27 error('data_grid size too small in plot_gridded, check posting and units'); 27 28 end 28 29 29 %Get and change colormap30 map = getcolormap(options);31 lenmap = size(map,1);32 map = [1 1 1; map];33 options=changefieldvalue(options,'colormap',map);34 35 30 %Process data_grid: add white in NaN and correct caxis accordingly 31 [data_nani data_nanj]=find(isnan(data_grid) | data_grid==-9999); 36 32 if exist(options,'caxis'), 37 33 caxis_opt=getfieldvalue(options,'caxis'); … … 44 40 data_max=max(data_grid(:)); 45 41 end 46 options = changefieldvalue(options,'cbYLim',[data_min data_max]);47 white = data_min - (data_max-data_min)/(lenmap);48 options = changefieldvalue(options,'caxis',[white data_max]);49 data_grid(isnan(data_grid))=white;50 42 51 43 %Select plot area … … 53 45 54 46 %shading interp; 55 if 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); 58 else 59 h=imagesc(xlim,ylim,data_grid); 47 map = getcolormap(options); 48 image_rgb = ind2rgb(uint16((data_grid - data_min)*(length(map)/(data_max-data_min))),map); 49 if exist(options,'shaded'), 50 a = -45; 51 scut = 0.2; 52 c = 1; 53 % computes lighting from elevation gradient 54 [fx,fy] = gradient(data_grid_save,x_m,y_m); 55 fxy = -fx*sind(a) - fy*cosd(a); 56 clear fx fy % free some memory... 57 fxy(isnan(fxy)) = 0; 58 59 % computes maximum absolute gradient (median-style), normalizes, saturates and duplicates in 3-D matrix 60 r = repmat(max(min(fxy/nmedian(abs(fxy),1 - scut/100),1),-1),[1,1,3]); 61 62 % applies contrast using exponent 63 rp = (1 - abs(r)).^c; 64 image_rgb = image_rgb.*rp; 65 66 % lighter for positive gradient 67 k = find(r > 0); 68 image_rgb(k) = image_rgb(k) + (1 - rp(k)); 60 69 end 70 71 % set novalues / NaN to black color 72 if ~isempty(data_nani) 73 nancolor=getfieldvalue(options,'nancolor',[1 1 1]); 74 image_rgb(sub2ind(size(image_rgb),repmat(data_nani,1,3),repmat(data_nanj,1,3),repmat(1:3,size(data_nani,1),1))) = repmat(nancolor,size(data_nani,1),1); 75 end 76 77 %plot grid 78 h=imagesc(xlim,ylim,image_rgb); 61 79 axis xy 62 80 … … 68 86 69 87 %Apply options 88 if ~isnan(data_min), 89 options=changefieldvalue(options,'caxis',[data_min data_max]); % force caxis so that the colorbar is ready 90 end 91 options=addfielddefault(options,'axis','xy equal'); % default axis 70 92 applyoptions(md,data,options);
Note:
See TracChangeset
for help on using the changeset viewer.