Index: /issm/trunk-jpl/examples/Pig/PigRegion.m
===================================================================
--- /issm/trunk-jpl/examples/Pig/PigRegion.m	(revision 20729)
+++ /issm/trunk-jpl/examples/Pig/PigRegion.m	(revision 20730)
@@ -6,47 +6,34 @@
 
 % Get necessary data to build up the velocity grid
-xmin = ncreadatt(nsidc_vel,'/','xmin');
+xmin    = ncreadatt(nsidc_vel,'/','xmin');
+ymax    = ncreadatt(nsidc_vel,'/','ymax');
+spacing = ncreadatt(nsidc_vel,'/','spacing');
+nx      = double(ncreadatt(nsidc_vel,'/','nx'));
+ny      = double(ncreadatt(nsidc_vel,'/','ny'));
+vx      = double(ncread(nsidc_vel,'vx'));
+vy      = double(ncread(nsidc_vel,'vy'));
+
 xmin = strtrim(xmin);  % this is a string, and we need to recover the double value
-xmin = xmin(1:end-2);  % get rid of the unit
-xmin = str2num(xmin);  % convert to double
+xmin = str2num(xmin(1:end-2));  % get rid of the unit and convert to double
 
-ymax = ncreadatt(nsidc_vel,'/','ymax'); 
 ymax = strtrim(ymax);  
-ymax = ymax(1:end-2);  
-ymax = str2num(ymax); 
-	
-nx = ncreadatt(nsidc_vel,'/','nx');
-ny = ncreadatt(nsidc_vel,'/','ny');
+ymax = str2num(ymax(1:end-2));  
 
-spacing = ncreadatt(nsidc_vel,'/','spacing'); 
 spacing = strtrim(spacing);
-spacing = spacing(1:end-2);  
-spacing = str2num(spacing); 
+spacing = str2num(spacing(1:end-2));  
 
+% Build the coordinates
+x=xmin+(0:1:nx)'*spacing;
+y=(ymax)-(0:1:ny)'*spacing; 
 
-x=xmin+(0:1:nx-1)'*spacing; 
-x=double(x);
-y=(ymax)-(0:1:ny-1)'*spacing; 
-y=double(y);
+%Limit the region to Pine Island
+posx=find(x<=-12.0e5 & x>=-18.0e5);
+x_pig=x(posx);
+posy=find(y<=1.0e5 & y>-4.0e5);
+y_pig=y(posy);
 
-posx=find(x<=-12.0e5);
-id1x=find(x>=-18.0e5,1);
-id2x=posx(end);
+vx_pig=flipud(vx(posx,posy)');
+vy_pig=flipud(vy(posx,posy)');
+vel_pig=sqrt(vx_pig.^2+vy_pig.^2);
 
-posy=find(y>=-4.0e5);
-id1y=find(y<=1.0e5,1);
-id2y=posy(end);
-
-%Get velocity subset
-vx = double(ncread(nsidc_vel,'vx'));
-vx_obs = vx(id1x:id2x,id1y:id2y);
-vx_obs = flipud(vx_obs');
-
-vy = double(ncread(nsidc_vel,'vy'));
-vy_obs = vy (id1x:id2x,id1y:id2y);
-vy_obs = flipud(vy_obs');
-
-xred=x(id1x:id2x);
-yred=y(id1y:id2y);
-vel_obs=sqrt(vx_obs.^2.+vy_obs.^2.);
-imagesc(xred,yred,vel_obs)
+imagesc(x_pig,y_pig,vel_pig)
