Changeset 18307
- Timestamp:
- 07/31/14 00:20:59 (11 years ago)
- Location:
- issm/branches/trunk-jpl-ad2/src/m/plot
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/branches/trunk-jpl-ad2/src/m/plot/plot_gl.m
r18292 r18307 14 14 15 15 %Setup unique directory in present dir: 16 directory= ['.webgl'];16 directory=getfieldvalue(options,'webpagename','.webgl'); 17 17 database=['./generic/']; 18 18 cd(directory); … … 32 32 replacestringinfile('./generic/editables.js','var height_scaling = 60.0;',['var height_scaling = ' num2str(getfieldvalue(options,'height_scaling',60)) ';']); 33 33 34 %size of frame: 35 replacestringinfile('./css/mystyle.css','height: 55%; /*editable*/',['height: ' num2str(getfieldvalue(options,'frame_height',55)) '%; /*editable*/']); 36 34 37 %high resolution: 35 38 if ~getfieldvalue(options,'highres',0); … … 39 42 %ocean zero threshold: 40 43 replacestringinfile('./generic/editables.js','var ocean_threshold = .001;',['var ocean_threshold = ' num2str(getfieldvalue(options,'ocean_threshold',.001)) ';']); 44 45 %intial view angle: 46 replacestringinfile('./generic/editables.js','var view_number_default = 3;',['var view_number_default = ' num2str(getfieldvalue(options,'view_number_default',3)) ';']); 41 47 42 48 %Deal with mesh and results {{{ -
issm/branches/trunk-jpl-ad2/src/m/plot/prepare_gl.m
r18292 r18307 4 4 scriptsdir=['~/issm-projects/visl/externalicelab/fem']; 5 5 if strcmpi(md.mesh.hemisphere','s'), 6 triangulation='/Users/larour/ModelData/BamberDEMAntarctica1km/triangulated/triangulation_ 15.mat';6 triangulation='/Users/larour/ModelData/BamberDEMAntarctica1km/triangulated/triangulation_2.mat'; 7 7 radar_image='/Users/larour/ModelData/BamberDEMAntarctica1km/triangulated/radar.png'; 8 triangulation_hd='/Users/larour/ModelData/BamberDEMAntarctica1km/triangulated/triangulation_2.mat'; 9 geotiff_name_hd=['/u/astrid-r1b/ModelData/MosaicTiffRsat/amm125m_v2_200m.tif']; 8 10 elseif strcmpi(md.mesh.hemisphere','n'), 9 11 triangulation='/u/astrid-r1b/ModelData/HowatDEMGreenland2012/triangulated/triangulation_15.mat'; 10 12 radar_image='/u/astrid-r1b/ModelData/HowatDEMGreenland2012/triangulated/radar.png'; 13 triangulation_hd='/u/astrid-r1b/ModelData/HowatDEMGreenland2012/triangulated/triangulation_2.mat'; 11 14 else 12 15 error('prepare_gl error usage: ''hemisphere'' should be set to ''s'' or ''n'''); … … 17 20 18 21 %Setup unique directory in present dir: 19 directory= '.webgl';22 directory=getfieldvalue(options,'webpagename','.webgl'); 20 23 mkdir(directory); 21 24 cd(directory); … … 88 91 fclose(fid); 89 92 %}}} 90 %Write high-res Greenlandtriangulation to disk {{{93 %Write high-res triangulation to disk {{{ 91 94 if getfieldvalue(options,'highres',0); 95 92 96 x0=min(md.mesh.x); 93 97 x1=max(md.mesh.x); … … 124 128 [status,height]=system(['convert radar_hd.png -format %h info:']); height=str2num(height); 125 129 126 %get these a power sof 2:130 %get these a power of 2: 127 131 width=2^(nextpow2(width)); 128 132 height=2^(nextpow2(height)); … … 133 137 system(['mv radar_hd.png ' database '/radar_hd.png']); 134 138 135 %create square mesh initially: 136 md_temp=squaremesh(model,1,1,100,100); 137 138 %scale: 139 md_temp.mesh.x=x0+md_temp.mesh.x*(x1-x0); 140 md_temp.mesh.y=y0+md_temp.mesh.y*(y1-y0); 141 142 %now refine to better capture surface: 143 hmax=500000; 144 hmin=500; 145 err=2; 146 sobs=InterpFromGridToMesh(x_m,y_m,surface,md_temp.mesh.x,md_temp.mesh.y,0); 147 md_temp=bamg(md_temp,'hmax',hmax,'hmin',hmin,'gradation',10,'field',sobs,'err',err,'splitcorner',1,'KeepVertices',0); 148 sobs=InterpFromGridToMesh(x_m,y_m,surface,md_temp.mesh.x,md_temp.mesh.y,0); 139 %now, extract higher resolution triangulation: 140 trhd=load(triangulation_hd); a=trhd; 141 trhd.xelem=trhd.x(trhd.index)*[1;1;1]/3; 142 trhd.yelem=trhd.y(trhd.index)*[1;1;1]/3; 143 144 pos_elem=find(x0<=trhd.xelem & trhd.xelem<=x1 & y0<=trhd.yelem & trhd.yelem<=y1); 145 pos_node=sort(unique(trhd.index(pos_elem,:))); 146 147 %keep track of some fields 148 numberofvertices1=length(trhd.x); 149 numberofelements1=length(trhd.index); 150 numberofvertices2=length(pos_node); 151 numberofelements2=length(pos_elem); 152 flag_node=zeros(numberofvertices1,1); 153 flag_node(pos_node)=1; 154 155 %Create Pelem and Pnode (transform old nodes in new nodes and same thing for the elements) 156 Pelem=zeros(numberofelements1,1); 157 Pelem(pos_elem)=[1:numberofelements2]'; 158 Pnode=zeros(numberofvertices1,1); 159 Pnode(pos_node)=[1:numberofvertices2]'; 160 161 %renumber the elements (some nodes won't exist anymore) 162 index2=trhd.index(pos_elem,:); 163 index2(:,1)=Pnode(index2(:,1)); 164 index2(:,2)=Pnode(index2(:,2)); 165 index2(:,3)=Pnode(index2(:,3)); 166 167 trhd.index=index2; 168 trhd.x=trhd.x(pos_node); 169 trhd.y=trhd.y(pos_node); 170 trhd.surface=trhd.surface(pos_node); 149 171 150 172 %write triangulation and surface to disk: … … 154 176 fprintf(fid,'<!-- index_surface_hd{{{-->\n'); 155 177 fprintf(fid,'var index_surface_hd=['); 156 for i=1: md_temp.mesh.numberofelements-1,157 fprintf(fid,'[%i, %i, %i],', md_temp.mesh.elements(i,1),md_temp.mesh.elements(i,2),md_temp.mesh.elements(i,3));158 end 159 fprintf(fid,'[%i, %i, %i]];\n', md_temp.mesh.elements(end,1),md_temp.mesh.elements(end,2),md_temp.mesh.elements(end,3));178 for i=1:length(trhd.index)-1, 179 fprintf(fid,'[%i, %i, %i],',trhd.index(i,1),trhd.index(i,2),trhd.index(i,3)); 180 end 181 fprintf(fid,'[%i, %i, %i]];\n',trhd.index(end,1),trhd.index(end,2),trhd.index(end,3)); 160 182 fprintf(fid,'<!--}}}-->\n'); 161 183 %write x: 162 184 fprintf(fid,'<!-- x_surface_hd{{{-->\n'); 163 185 fprintf(fid,'var x_surface_hd=['); 164 for i=1: md_temp.mesh.numberofvertices-1,165 fprintf(fid,'%g,', md_temp.mesh.x(i,1));166 end 167 fprintf(fid,'%g];\n', md_temp.mesh.x(end,1));186 for i=1:length(trhd.x)-1, 187 fprintf(fid,'%g,',trhd.x(i,1)); 188 end 189 fprintf(fid,'%g];\n',trhd.x(end,1)); 168 190 fprintf(fid,'<!--}}}-->\n'); 169 191 … … 171 193 fprintf(fid,'<!-- y_surface_hd{{{-->\n'); 172 194 fprintf(fid,'var y_surface_hd=['); 173 for i=1: md_temp.mesh.numberofvertices-1,174 fprintf(fid,'%g,', md_temp.mesh.y(i,1));175 end 176 fprintf(fid,'%g];\n', md_temp.mesh.y(end,1));195 for i=1:length(trhd.y)-1, 196 fprintf(fid,'%g,',trhd.y(i,1)); 197 end 198 fprintf(fid,'%g];\n',trhd.y(end,1)); 177 199 fprintf(fid,'<!--}}}-->\n'); 178 200 … … 180 202 fprintf(fid,'<!-- surface_surface_hd{{{-->\n'); 181 203 fprintf(fid,'var surface_surface_hd=['); 182 for i=1: md_temp.mesh.numberofvertices-1,183 fprintf(fid,'%g,', sobs(i));184 end 185 fprintf(fid,'%g];\n', sobs(end));204 for i=1:length(trhd.surface)-1, 205 fprintf(fid,'%g,',trhd.surface(i)); 206 end 207 fprintf(fid,'%g];\n',trhd.surface(end)); 186 208 fprintf(fid,'<!--}}}-->\n'); 187 209 188 210 fclose(fid); 211 a2=trhd; 212 save temp2 a2 a 189 213 else 190 214 delete([database '/radar_hd.png']);
Note:
See TracChangeset
for help on using the changeset viewer.