Changeset 838
- Timestamp:
- 06/08/09 10:39:58 (16 years ago)
- Location:
- issm/trunk/src/m/classes/public/plot
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/classes/public/plot/parse_options.m
r27 r838 116 116 smooth_values=findarg(optionstring,'smooth'); 117 117 if ~isempty(smooth_values), 118 if strcmpi(smooth_values.value,' yes'),119 options_struct.smooth= 0;118 if strcmpi(smooth_values.value,'on'), 119 options_struct.smooth=1; 120 120 else 121 121 options_struct.smooth=smooth_values.value; … … 395 395 options_struct.highres=highresvalues.value; 396 396 else 397 options_struct.highres= NaN;397 options_struct.highres=0; 398 398 end 399 399 … … 407 407 end 408 408 else 409 options_struct.windowsize= NaN;409 options_struct.windowsize=1; 410 410 end 411 411 … … 419 419 end 420 420 else 421 options_struct.alpha= NaN;421 options_struct.alpha=1.5; %Rignot setting. 422 422 end 423 423 … … 628 628 options_struct.border=bordervalues(1).value; 629 629 else 630 options_struct.border= NaN;631 end 630 options_struct.border=0; 631 end -
issm/trunk/src/m/classes/public/plot/plot_overlay.m
r826 r838 7 7 % See also: PLOTMODEL 8 8 9 %2d plots only 10 if ~strcmpi(md.type,'2d'), 11 error('plot_overlay error message: only 2d plots allowed'); 9 10 %check that buildoverlay has not already been called 11 redo=1; 12 if (ischar(data) & isstruct(md.mesh2grid_parameters) & ismember(data,mesh2grid_parameters)), 13 choice=input(['mesh2grid has already been called for the parameter ''' data '''. Do you want to call it again (y/n)?'],'s'); 14 if strcmp(choice,'y') 15 disp('use previous mesh2grid result'); 16 redo=0; 17 end 12 18 end 13 19 14 %highres? 15 if ~isnan(options_structure.highres), 16 highres=options_structure.highres; 20 if redo 21 %process mesh and data 22 [x y z elements is2d]=processmesh(md,options_structure); 23 [data isongrid]=processdata(md,data,options_structure); 24 25 %apply caxis if required 26 if ~isnan(options_structure.caxis), 27 data(find(data<options_structure.caxis(1)))=options_structure.caxis(1); 28 data(find(data>options_structure.caxis(2)))=options_structure.caxis(2); 29 end 30 31 %check is2d 32 if ~is2d, 33 error('buildoverlay error message: overlay not supported for 3d meshes, project on a layer'); 34 end 35 36 %Ok, first we need to recover the radar map. 37 md=radarpower(md,options_structure.highres); 38 39 writefile('contours.exp',md.domainoutline); 40 contours=expread('contours.exp',0); 41 contours=contours(1); %just keep the outer domain outline. 42 delete('contours.exp'); 43 44 %use mesh2grid solution to get an gridded data to display using imagesc 45 if isongrid, 46 interpolation='node'; 47 else 48 interpolation='element'; 49 end 50 data_mesh2grid=GriddataMeshToGrid(elements,x,y,contours,data,min(x),max(y),... 51 (max(x)-min(x))/length(md.sarxm),(max(y)-min(y))/length(md.sarym),length(md.sarym),length(md.sarxm),... 52 interpolation,'average',options_structure.windowsize); 17 53 else 18 highres=0; 54 %process mesh and data 55 [x y z elements is2d]=processmesh(md,options_structure); 56 [data isongrid]=processdata(md,data,options_structure); 57 58 %get previous result 59 data_mesh2grid=mesh2grid_results(find(ismember(data,mesh2grid_parameters))); 19 60 end 20 61 21 %alpha? 22 if ~isnan(options_structure.alpha), 23 transparency=options_structure.alpha; 24 else 25 transparency=1.5; %Rignot setting. 26 end 62 %Ok, we have two images, double format: 63 radar=md.sarpwr; 27 64 28 %smoothing? 29 if strcmpi(options_structure.smooth,'yes') & length(data)==md.numberofelements 30 smoothing=1; 31 else 32 smoothing=0; 33 end 65 %nullify NaN in results 66 data_mesh2grid(find(isnan(data_mesh2grid)))=0; 34 67 35 if ~isnan(options_structure.windowsize), 36 windowsize=options_structure.windowsize; 37 else 38 windowsize=1; 39 end 68 %Build hsv color image from radar and results 69 transparency=options_structure.alpha; 70 border=options_structure.border; 40 71 41 %border? 42 if ~isnan(options_structure.border), 43 border=options_structure.border; 44 else 45 border=0; 46 end 72 %intensity 73 v=radar/max(max(radar)); 47 74 48 [image_rgb xm ym]=buildoverlay(md,data,transparency,highres,smoothing,windowsize,border); 75 %hue 76 %cut results under 1.5, and log 77 data_mesh2grid(find(data_mesh2grid<1.5))=1.5; 78 h=bytscl(log(data_mesh2grid))/(255+1); %1 offset on colormap 79 80 %saturation 81 s=(0.5+data_mesh2grid/125)/transparency;s(find(s>1))=1;s(find(s<0))=0; 82 s(find(data_mesh2grid==1.5))=0; 83 84 %Include border 85 v((1:border),:)=0; v((end-border+1:end),:)=0; v(:,1:border)=0;v(:,(end-border+1:end))=0; 86 87 %Transform hsv to rgb 88 image_hsv=zeros(size(data_mesh2grid,1),size(data_mesh2grid,2),3); 89 image_hsv(:,:,1)=h; 90 image_hsv(:,:,2)=s; 91 image_hsv(:,:,3)=v; 92 image_rgb=hsv2rgb(image_hsv); 49 93 50 94 %Select plot area 51 95 subplot(width,width,i); 52 96 53 if ~isnan(options_structure.unitmultiplier),54 xm=xm*options_structure.unitmultiplier;55 ym=ym*options_structure.unitmultiplier;56 end57 58 97 %Plot: 59 imagesc( xm,ym,image_rgb);set(gca,'YDir','normal');98 imagesc(md.sarxm,md.sarym,image_rgb);set(gca,'YDir','normal'); 60 99 61 100 %Apply options, without colorbar and without grid 101 if ~isnan(options_structure.fontsize), 102 fontsize=options_structure.fontsize; 103 else 104 fontsize=14; 105 end 106 if isnan(options_structure.axis), 107 options_structure.axis='equal off'; 108 end 109 if isnan(options_structure.colorbarpos), 110 options_structure.colorbarpos=[0.82 0.65 0.03 0.2]; 111 end 62 112 iscolorbar=(options_structure.colorbar==1 | isnan(options_structure.colorbar)); 63 113 options_structure.colorbar=0; 64 65 114 applyoptions(md,data,options_structure); 66 115 … … 69 118 70 119 %create colorbar with correct colors and position 71 colorbar_rgb=buildoverlaycolorbar(md,data, transparency);120 colorbar_rgb=buildoverlaycolorbar(md,data,options_structure.alpha); 72 121 colorbar_handle=colorbar; 73 122 colorbar_image_handle=get(colorbar_handle,'Children'); 74 123 set(colorbar_image_handle,'CData',colorbar_rgb); 75 if ~isnan(options_structure.colorbarpos), 76 set(colorbar_handle,'Position',options_structure.colorbarpos); 77 else 78 set(colorbar_handle,'Position',[0.82 0.65 0.03 0.2]) 79 end 124 set(colorbar_handle,'Position',options_structure.colorbarpos); 80 125 81 126 %modify ticks. 82 if isfield(struct(md),data) data=eval(['md.' data ';']); end83 127 data(find(data<1.5))=1.5; 84 85 128 scalestring=get(colorbar_handle,'YTickLabel'); 86 129 scalevalues=get(colorbar_handle,'YTick'); … … 91 134 for i=1:numvalues, 92 135 fraction=(scalevalues(i)-scaleminmax(1))/(scaleminmax(2)-scaleminmax(1)); 93 scalevalues(i)=round_ice(exp(min(log(data))+(max(log(data))-min(log(data)))*fraction), 1);136 scalevalues(i)=round_ice(exp(min(log(data))+(max(log(data))-min(log(data)))*fraction),2); 94 137 scalestring=[scalestring; sprintf('%8.4g',scalevalues(i))]; 95 138 end 96 139 set(colorbar_handle,'YTickLabel',scalestring); 97 140 set(colorbar_handle,'YColor','y'); 98 set(colorbar_handle,'FontSize', 14);141 set(colorbar_handle,'FontSize',fontsize); 99 142 end 100 101 %take axis off102 axis off;103 104 %put axis equal105 axis equal;
Note:
See TracChangeset
for help on using the changeset viewer.