Changeset 18307


Ignore:
Timestamp:
07/31/14 00:20:59 (11 years ago)
Author:
Eric.Larour
Message:

CHG: new versions of plot_gl.

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  
    1414
    1515%Setup unique directory in present dir:
    16 directory=['.webgl'];
     16directory=getfieldvalue(options,'webpagename','.webgl');
    1717database=['./generic/'];
    1818cd(directory);
     
    3232replacestringinfile('./generic/editables.js','var height_scaling = 60.0;',['var height_scaling = ' num2str(getfieldvalue(options,'height_scaling',60)) ';']);
    3333
     34%size of frame:
     35replacestringinfile('./css/mystyle.css','height: 55%; /*editable*/',['height: ' num2str(getfieldvalue(options,'frame_height',55)) '%; /*editable*/']);
     36
    3437%high resolution:
    3538if ~getfieldvalue(options,'highres',0);
     
    3942%ocean zero threshold:
    4043replacestringinfile('./generic/editables.js','var ocean_threshold = .001;',['var ocean_threshold = ' num2str(getfieldvalue(options,'ocean_threshold',.001)) ';']);
     44
     45%intial view angle:
     46replacestringinfile('./generic/editables.js','var view_number_default = 3;',['var view_number_default = ' num2str(getfieldvalue(options,'view_number_default',3)) ';']);
    4147
    4248%Deal with mesh and results {{{
  • issm/branches/trunk-jpl-ad2/src/m/plot/prepare_gl.m

    r18292 r18307  
    44scriptsdir=['~/issm-projects/visl/externalicelab/fem'];
    55if 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';
    77        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'];
    810elseif strcmpi(md.mesh.hemisphere','n'),
    911        triangulation='/u/astrid-r1b/ModelData/HowatDEMGreenland2012/triangulated/triangulation_15.mat';
    1012        radar_image='/u/astrid-r1b/ModelData/HowatDEMGreenland2012/triangulated/radar.png';
     13        triangulation_hd='/u/astrid-r1b/ModelData/HowatDEMGreenland2012/triangulated/triangulation_2.mat';
    1114else
    1215        error('prepare_gl error usage: ''hemisphere'' should be set to ''s'' or ''n''');
     
    1720
    1821%Setup unique directory in present dir:
    19 directory='.webgl';
     22directory=getfieldvalue(options,'webpagename','.webgl');
    2023mkdir(directory);
    2124cd(directory);
     
    8891fclose(fid);
    8992%}}}
    90 %Write high-res Greenland triangulation to disk  {{{
     93%Write high-res triangulation to disk  {{{
    9194if getfieldvalue(options,'highres',0);
     95       
    9296        x0=min(md.mesh.x);
    9397        x1=max(md.mesh.x);
     
    124128        [status,height]=system(['convert radar_hd.png -format %h info:']); height=str2num(height);
    125129
    126         %get these a powers of 2:
     130        %get these a power of 2:
    127131        width=2^(nextpow2(width));
    128132        height=2^(nextpow2(height));
     
    133137        system(['mv radar_hd.png ' database '/radar_hd.png']);
    134138
    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);
    149171
    150172        %write triangulation and surface to disk:
     
    154176        fprintf(fid,'<!-- index_surface_hd{{{-->\n');
    155177        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));
    160182        fprintf(fid,'<!--}}}-->\n');
    161183        %write x:
    162184        fprintf(fid,'<!-- x_surface_hd{{{-->\n');
    163185        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));
    168190        fprintf(fid,'<!--}}}-->\n');
    169191
     
    171193        fprintf(fid,'<!-- y_surface_hd{{{-->\n');
    172194        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));
    177199        fprintf(fid,'<!--}}}-->\n');
    178200
     
    180202        fprintf(fid,'<!-- surface_surface_hd{{{-->\n');
    181203        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));
    186208        fprintf(fid,'<!--}}}-->\n');
    187209
    188210        fclose(fid);
     211        a2=trhd;
     212        save temp2 a2 a
    189213else
    190214        delete([database '/radar_hd.png']);
Note: See TracChangeset for help on using the changeset viewer.