1 | function 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=contourlevelzero(md,md.mask.groundedice_levelset,0);
|
---|
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 | xm=min(md.mesh.x):posting:max(md.mesh.x);
|
---|
49 | ym=min(md.mesh.y):posting:max(md.mesh.y);
|
---|
50 |
|
---|
51 | vel=InterpFromMeshToGrid(md.mesh.elements,md.mesh.x,md.mesh.y,vel,xm,ym,0.);
|
---|
52 | vel=uint16(flipud(vel));
|
---|
53 |
|
---|
54 | imwrite(vel,[path '/veltemp.tif'],'tiff');
|
---|
55 |
|
---|
56 | string=sprintf('!gdal_translate -a_srs EPSG:3031 -a_ullr %g %g %g %g %s/veltemp.tif %s/vel.tif',...
|
---|
57 | min(md.mesh.x),max(md.mesh.y),max(md.mesh.x),min(md.mesh.y),path,path);
|
---|
58 | eval(string);
|
---|
59 | delete([path '/veltemp.tif']);
|
---|
60 | end
|
---|
61 |
|
---|
62 | %hot spots:
|
---|
63 | if getfieldvalue(options,'hotspots',0),
|
---|
64 | threshold=getfieldvalue(options,'threshold',5000);
|
---|
65 | i=getfieldvalue(options,'hotspotsi',length(md.results.TransientSolution));
|
---|
66 | pos=find(md.results.TransientSolution(i).Vel>threshold);
|
---|
67 | contour.x=md.mesh.x(pos); contour.y=md.mesh.y(pos); contour.density=1;
|
---|
68 | expwrite(contour,[path '/hotspots.exp']);
|
---|
69 | exp2shp([path '/hotspots.shp'],[path '/hotspots.exp']);
|
---|
70 | end
|
---|