[7197] | 1 | function 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
|
---|
[8472] | 10 | [x y z elements is2d isplanet]=processmesh(md,[],options);
|
---|
[8001] | 11 | [data datatype]=processdata(md,data,options);
|
---|
[7197] | 12 |
|
---|
| 13 | %check is2d
|
---|
| 14 | if ~is2d,
|
---|
| 15 | error('buildgridded error message: gridded not supported for 3d meshes, project on a layer');
|
---|
| 16 | end
|
---|
| 17 |
|
---|
| 18 | %Get xlim and ylim (used to extract radar image)
|
---|
| 19 | xlim=getfieldvalue(options,'xlim',[min(x) max(x)]);
|
---|
| 20 | ylim=getfieldvalue(options,'ylim',[min(y) max(y)]);
|
---|
[8001] | 21 | post=getfieldvalue(options,'posting',diff(xlim)/1000);
|
---|
[7197] | 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);
|
---|
[10413] | 25 | if size(data_grid,1)<3 | size(data_grid,2)<3,
|
---|
| 26 | error('data_grid size too small in plot_gridded, check posting and uni');
|
---|
| 27 | end
|
---|
[7197] | 28 |
|
---|
[12391] | 29 | %Get and change colormap
|
---|
| 30 | map = getcolormap(options);
|
---|
| 31 | lenmap = size(map,1);
|
---|
| 32 | map = [1 1 1; map];
|
---|
| 33 | options=changefieldvalue(options,'colormap',map);
|
---|
| 34 |
|
---|
[7197] | 35 | %Process data_grid: add white in NaN and correct caxis accordingly
|
---|
| 36 | if 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);
|
---|
| 42 | else
|
---|
| 43 | data_min=min(data_grid(:));
|
---|
| 44 | data_max=max(data_grid(:));
|
---|
| 45 | end
|
---|
[12391] | 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;
|
---|
[7197] | 50 |
|
---|
| 51 | %Select plot area
|
---|
[12732] | 52 | subplotmodel(plotlines,plotcols,i,options);
|
---|
[7197] | 53 |
|
---|
| 54 | %shading interp;
|
---|
| 55 | h=imagesc(xlim,ylim,data_grid);set(gca,'YDir','normal');
|
---|
| 56 |
|
---|
| 57 | %last step: mesh gridded?
|
---|
| 58 | if exist(options,'edgecolor'),
|
---|
| 59 | A=elements(:,1); B=elements(:,2); C=elements(:,3);
|
---|
[11009] | 60 | patch('Faces',[A B C],'Vertices', [x y z],'FaceVertexCData',data_grid(1)*ones(size(x)),'FaceColor','none','EdgeColor',getfieldvalue(options,'edgecolor'));
|
---|
[7197] | 61 | end
|
---|
| 62 |
|
---|
| 63 | %Apply options
|
---|
| 64 | applyoptions(md,data,options);
|
---|