source: issm/trunk-jpl/src/m/miscellaneous/diagnostics.m

Last change on this file was 26869, checked in by jdquinn, 3 years ago

CHG: Updated calls to isoline

File size: 2.5 KB
Line 
1function diagnostics(md,varargin)
2%DIAGNOSTICS - output diagnostics for use in qgis
3%
4%
5% Usage:
6% diagnostics(md,options)
7%
8% where options include:
9% 'path': where are the diagnostics file output
10% 'mesh': 0 or 1 (output mesh?, default 0)
11% 'gl': 0 or 1 (output grounding line position?, default 0)
12% 'vel': defaults to md.initialization.vel (can suplly another field if need be)
13% Suboptions include:
14% 'velposting': resolution at which the tiff file will be printed.
15% 'hotspots' (0 or 1, default 0). spots where md.results.TransientSolution(i).Vel>threshold
16% Suboptions include:
17% 'threshold': vel value
18% 'hotspotsi': index into results.TransientSolution
19%
20%
21%
22% Examples:
23% diagnostics(md,'vel',md.initialization.vel,'gl',1,'hotspots',1,'hotspotsi',10,'threshold',500);
24
25
26 %process options:
27 options=pairoptions(varargin{:});
28 path=getfieldvalue(options,'path','./');
29
30 %mesh:
31 if getfieldvalue(options,'mesh',0),
32 mesh2shp(md,[path '/mesh']);
33 end
34
35 %grounding line :
36 if getfieldvalue(options,'gl',0),
37 contours=isoline(md,md.mask.ocean_levelset);
38 expwrite(contours,[path '/groundingline.exp']);
39 exp2shp([path '/groundingline.shp'],[path '/groundingline.exp']);
40 end
41
42 %velocity:
43 if exist(options,'vel'),
44 vel=getfieldvalue(options,'vel',md.initialization.vel);
45 xposting=getfieldvalue(options,'velposting',500);
46 yposting=getfieldvalue(options,'velposting',500);
47
48 xmin=min(md.mesh.x); ymax=max(md.mesh.y);
49 ncols=(max(md.mesh.x)-min(md.mesh.x))/xposting+1;
50 nlines=(max(md.mesh.y)-min(md.mesh.y))/yposting+1;
51
52 [xm,ym,vel]=InterpFromMeshToGrid(md.mesh.elements,md.mesh.x,md.mesh.y,vel,xmin,ymax,xposting,yposting,nlines,ncols,0);
53 vel=uint16(flipud(vel));
54
55 imwrite(vel,[path '/veltemp.tif'],'tiff');
56
57 string=sprintf('!gdal_translate -a_srs EPSG:3031 -a_ullr %g %g %g %g %s/veltemp.tif %s/vel.tif',...
58 min(md.mesh.x),max(md.mesh.y),max(md.mesh.x),min(md.mesh.y),path,path);
59 eval(string);
60 delete([path '/veltemp.tif']);
61 end
62
63 %hot spots:
64 if getfieldvalue(options,'hotspots',0),
65 threshold=getfieldvalue(options,'threshold',5000);
66 i=getfieldvalue(options,'hotspotsi',length(md.results.TransientSolution));
67 pos=find(md.results.TransientSolution(i).Vel>threshold);
68 contour.x=md.mesh.x(pos); contour.y=md.mesh.y(pos); contour.density=1;
69 expwrite(contour,[path '/hotspots.exp']);
70 exp2shp([path '/hotspots.shp'],[path '/hotspots.exp']);
71 end
Note: See TracBrowser for help on using the repository browser.