Changeset 24855
- Timestamp:
- 05/14/20 23:11:18 (5 years ago)
- Location:
- issm/trunk-jpl/src/m/contrib/larour
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/contrib/larour/glacier_inventory.m
r24854 r24855 84 84 85 85 end % }}} 86 function mesh_connectivity(self,mesh) % {{{ 87 88 plotr=1; 86 function mesh_connectivity(self,mesh,varargin) % {{{ 87 88 %retrieve options: 89 options=pairoptions(varargin{:}); 90 91 subsetregions=getfieldvalue(options,'regions',1:length(self.boxes)); 92 errornotfound=getfieldvalue(options,'errornotfound',1); 89 93 90 94 %The way we run this is through the O2 zones defined in boxes. We go through … … 119 123 120 124 %Go through O2 regions: 121 for i= 1:length(self.boxes),125 for i=subsetregions, 122 126 string=self.boxes(i).RGI_CODE; 123 127 disp(['progressing with region ' num2str(i) ' ' string]); … … 138 142 radius=sqrt( (lat0-minlat)^2+(long0-maxlong)^2); 139 143 140 %some radius adjustment: {{{141 switch i,142 case 4, radius=40;143 case 12, radius=25;144 case 33, radius=5;145 case 41, radius=75;146 case 42, radius=45;147 case 68, radius=10;148 case 82, radius=30;149 otherwise,150 end % }}}144 %some radius adjustment: {{{ 145 switch i, 146 case 4, radius=40; 147 case 12, radius=25; 148 case 33, radius=5; 149 case 41, radius=75; 150 case 42, radius=45; 151 case 68, radius=10; 152 case 82, radius=30; 153 otherwise, 154 end % }}} 151 155 152 156 [lids,rids]=self.gidtolid(glaciers); … … 197 201 end 198 202 end 199 self.glacier_connectivity(glaciers(j))=el; 200 if ~found, 201 error(sprintf('could not find element for glacier %i with lid %i',j,lids(j))); 203 if ~found, 204 if errornotfound, 205 error(sprintf('could not find element for glacier %i with lid %i',j,lids(j))); 206 end 202 207 end 208 if(found)self.glacier_connectivity(glaciers(j))=el; end; 203 209 end 204 210 end … … 208 214 for j=1:length(self.glacier_connectivity), 209 215 el=self.glacier_connectivity(j); 216 if ~el,continue; end; 217 count=self.element_connectivity(el,ny); 218 if count>ny, 219 error('need to enlarge connectivity table to at least'); 220 end 221 self.element_connectivity(el,count+1)=j; 222 self.element_connectivity(el,ny)=count+1; 223 end 224 225 %Reduce the number of columns (we did not initially, so we chose an arbitrary ny: 226 nmax=max(self.element_connectivity(:,end)); 227 self.element_connectivity=self.element_connectivity(:,[1:nmax,ny]); 228 229 230 end % }}} 231 function mesh_connectivity2d(self,md,proj,varargin) % {{{ 232 233 %retrieve options: 234 options=pairoptions(varargin{:}); 235 236 subsetregions=getfieldvalue(options,'regions',1:self.nregions()); 237 238 %initialize glacier connectivity: 239 self.glacier_connectivity=zeros(self.nglaciers,1); 240 241 %assume maximum width for connectivity table and initialize 242 %as sparse matrix: 243 ny=self.nglaciers(); self.element_connectivity=sparse(md.mesh.numberofelements,ny); 244 245 disp('Building element and glacier connectivity table: '); 246 [lat0,long0]=projlatlong(proj); 247 248 [mpartition,npartition]=self.partition(); 249 for i=subsetregions, 250 region=self.regions(i); 251 disp(sprintf(' progress for region: %s',region.name)); 252 253 %project lat,long: 254 [xlid,ylid]=gdaltransform(region.CenLon,region.CenLat,'EPSG:4326',proj); 255 256 %go through lids: 257 x0=xlid; y0=ylid; 258 x1=md.mesh.x(md.mesh.elements(:,1)); y1=md.mesh.y(md.mesh.elements(:,1)); 259 x2=md.mesh.x(md.mesh.elements(:,2)); y2=md.mesh.y(md.mesh.elements(:,2)); 260 x3=md.mesh.x(md.mesh.elements(:,3)); y3=md.mesh.y(md.mesh.elements(:,3)); 261 in=isintrianglearraytotal(x0,x1,x2,x3,y0,y1,y2,y3); 262 [els,glacs]=find(in); 263 self.glacier_connectivity(mpartition(i)-1+glacs)=els; 264 end 265 266 %build element connectivity table: 267 for j=1:length(self.glacier_connectivity), 268 el=self.glacier_connectivity(j); 269 if ~el,continue; end; 210 270 count=self.element_connectivity(el,ny); 211 271 if count>ny, … … 332 392 end 333 393 %}}} 394 function listboxes(self) % {{{ 395 396 for i=1:length(self.boxes), 397 b=self.boxes(i); 398 disp(sprintf('Region #%i: %s (%s)',i,b.FULL_NAME,b.RGI_CODE)); 399 end 400 401 end 402 %}}} 334 403 end 335 404 end
Note:
See TracChangeset
for help on using the changeset viewer.