| 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 | 
|---|
| 10 | [x y z elements is2d isplanet]=processmesh(md,[],options); | 
|---|
| 11 | [data datatype]=processdata(md,data,options); | 
|---|
| 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)]); | 
|---|
| 21 | post=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); | 
|---|
| 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 units'); | 
|---|
| 27 | end | 
|---|
| 28 |  | 
|---|
| 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 |  | 
|---|
| 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 | 
|---|
| 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 |  | 
|---|
| 51 | %Select plot area | 
|---|
| 52 | subplotmodel(plotlines,plotcols,i,options); | 
|---|
| 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); | 
|---|
| 60 | patch('Faces',[A B C],'Vertices', [x y z],'FaceVertexCData',data_grid(1)*ones(size(x)),'FaceColor','none','EdgeColor',getfieldvalue(options,'edgecolor')); | 
|---|
| 61 | end | 
|---|
| 62 |  | 
|---|
| 63 | %Apply options | 
|---|
| 64 | applyoptions(md,data,options); | 
|---|