Changeset 838


Ignore:
Timestamp:
06/08/09 10:39:58 (16 years ago)
Author:
Mathieu Morlighem
Message:

extended plot options to plot_overlay (caxis,layer projection, icehself none,....)

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  
    116116smooth_values=findarg(optionstring,'smooth');
    117117if ~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;
    120120        else
    121121                options_struct.smooth=smooth_values.value;
     
    395395        options_struct.highres=highresvalues.value;
    396396else
    397         options_struct.highres=NaN;
     397        options_struct.highres=0;
    398398end
    399399
     
    407407        end
    408408else
    409         options_struct.windowsize=NaN;
     409        options_struct.windowsize=1;
    410410end
    411411
     
    419419        end
    420420else
    421         options_struct.alpha=NaN;
     421        options_struct.alpha=1.5; %Rignot setting.
    422422end
    423423       
     
    628628        options_struct.border=bordervalues(1).value;
    629629else
    630         options_struct.border=NaN;
    631 end
     630        options_struct.border=0;
     631end
  • issm/trunk/src/m/classes/public/plot/plot_overlay.m

    r826 r838  
    77%   See also: PLOTMODEL
    88
    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
     11redo=1;
     12if (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
    1218end
    1319
    14 %highres?
    15 if ~isnan(options_structure.highres),
    16         highres=options_structure.highres;
     20if 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);
    1753else
    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)));
    1960end
    2061
    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:
     63radar=md.sarpwr;
    2764
    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
     66data_mesh2grid(find(isnan(data_mesh2grid)))=0;
    3467
    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
     69transparency=options_structure.alpha;
     70border=options_structure.border;
    4071
    41 %border?
    42 if ~isnan(options_structure.border),
    43         border=options_structure.border;
    44 else
    45         border=0;
    46 end
     72%intensity
     73v=radar/max(max(radar));
    4774
    48 [image_rgb xm ym]=buildoverlay(md,data,transparency,highres,smoothing,windowsize,border);
     75%hue
     76%cut results under 1.5, and log
     77data_mesh2grid(find(data_mesh2grid<1.5))=1.5;
     78h=bytscl(log(data_mesh2grid))/(255+1); %1 offset on colormap
     79
     80%saturation
     81s=(0.5+data_mesh2grid/125)/transparency;s(find(s>1))=1;s(find(s<0))=0;
     82s(find(data_mesh2grid==1.5))=0;
     83
     84%Include border
     85v((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
     88image_hsv=zeros(size(data_mesh2grid,1),size(data_mesh2grid,2),3);
     89image_hsv(:,:,1)=h;
     90image_hsv(:,:,2)=s;
     91image_hsv(:,:,3)=v;
     92image_rgb=hsv2rgb(image_hsv);
    4993
    5094%Select plot area
    5195subplot(width,width,i);
    5296
    53 if ~isnan(options_structure.unitmultiplier),
    54         xm=xm*options_structure.unitmultiplier;
    55         ym=ym*options_structure.unitmultiplier;
    56 end
    57 
    5897%Plot:
    59 imagesc(xm,ym,image_rgb);set(gca,'YDir','normal');
     98imagesc(md.sarxm,md.sarym,image_rgb);set(gca,'YDir','normal');
    6099
    61100%Apply options, without colorbar and without grid
     101if ~isnan(options_structure.fontsize),
     102        fontsize=options_structure.fontsize;
     103else
     104        fontsize=14;
     105end
     106if isnan(options_structure.axis),
     107        options_structure.axis='equal off';
     108end
     109if isnan(options_structure.colorbarpos),
     110        options_structure.colorbarpos=[0.82 0.65 0.03 0.2];
     111end
    62112iscolorbar=(options_structure.colorbar==1 | isnan(options_structure.colorbar));
    63113options_structure.colorbar=0;
    64 
    65114applyoptions(md,data,options_structure);
    66115
     
    69118
    70119        %create colorbar with correct colors and position
    71         colorbar_rgb=buildoverlaycolorbar(md,data,transparency);
     120        colorbar_rgb=buildoverlaycolorbar(md,data,options_structure.alpha);
    72121        colorbar_handle=colorbar;
    73122        colorbar_image_handle=get(colorbar_handle,'Children');
    74123        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);
    80125
    81126        %modify ticks.
    82         if isfield(struct(md),data) data=eval(['md.' data ';']); end
    83127        data(find(data<1.5))=1.5;
    84        
    85128        scalestring=get(colorbar_handle,'YTickLabel');
    86129        scalevalues=get(colorbar_handle,'YTick');
     
    91134        for i=1:numvalues,
    92135                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);
    94137                scalestring=[scalestring; sprintf('%8.4g',scalevalues(i))];
    95138        end
    96139        set(colorbar_handle,'YTickLabel',scalestring);
    97140        set(colorbar_handle,'YColor','y');
    98         set(colorbar_handle,'FontSize',14);
     141        set(colorbar_handle,'FontSize',fontsize);
    99142end
    100 
    101 %take axis off
    102 axis off;
    103 
    104 %put axis equal
    105 axis equal;
Note: See TracChangeset for help on using the changeset viewer.