Changeset 2566
- Timestamp:
- 10/29/09 16:54:35 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/classes/public/plugvelocities.m
r2296 r2566 27 27 28 28 %find x,y,vx and vy 29 xenum=NaN; yenum=NaN; vxenum=NaN; vyenum=NaN; 29 xenum=NaN; yenum=NaN; vxenum=NaN; vyenum=NaN; indexenum=NaN; 30 30 if length(A)==4, 31 isgrid=1; 31 32 for i=1:4 32 33 if strcmpi(A(i).name(1),'x'); … … 42 43 end 43 44 end 45 elseif length(A)==5, 46 isgrid=0; 47 for i=1:5 48 if strcmpi(A(i).name(1),'x'); 49 xenum=i; 50 elseif strcmpi(A(i).name(1),'y'); 51 yenum=i; 52 elseif (strcmpi(A(i).name(1),'index') | strcmpi(A(i).name(1),'elements')); 53 indexenum=i; 54 else 55 if (strcmpi(A(i).name(end),'x') | strncmpi(A(i).name,'vx',2)); 56 vxenum=i; 57 elseif (strcmpi(A(i).name(end),'y') | strncmpi(A(i).name,'vy',2)); 58 vyenum=i; 59 end 60 end 61 end 44 62 else 45 error(['plugvelocities error message: file ' filename ' not supported yet (it should hold 4 variables x,y,vx and vy )']);63 error(['plugvelocities error message: file ' filename ' not supported yet (it should hold 4 variables x,y,vx and vy (for grids) OR 5 variables x,y,index,vx and vy (for mesh))']); 46 64 end 47 65 48 66 %assum that we have found at least vxenum and vyenum 49 67 if ( isnan(vxenum) | isnan(vyenum)) 50 error(['plugvelocities error message: file ' filename ' not supported yet (it should hold 4 variables x,y,vx and vy)']); 68 error(['plugvelocities error message: file ' filename ' not supported yet (the velocities should be named vx and vy)']); 69 end 70 71 %find index 72 if (~isgrid & insnan(indexenum)), 73 for i=1:5 74 lengthi=min(A(i).size); 75 if (lengthi==3), 76 indexenum=i; 77 end 78 end 79 if isnan(indexenum), 80 error(['plugvelocities error message: file ' filename ' not supported yet (index not found)']); 81 end 51 82 end 52 83 … … 83 114 vxname=A(vxenum).name; 84 115 vyname=A(vyenum).name; 116 if ~isgrid, indexname=A(indexenum).name; end 85 117 86 118 %load data … … 88 120 89 121 %get x y vx and vy 90 eval(['x=B.' xname ';']) 91 eval(['y=B.' yname ';']) 92 eval(['vx=B.' vxname ';']) 93 eval(['vy=B.' vyname ';']) 122 eval(['x=B.' xname ';']); 123 eval(['y=B.' yname ';']); 124 eval(['vx=B.' vxname ';']); 125 eval(['vy=B.' vyname ';']); 126 if ~isgrid, eval(['index=B.' indexname ';']); end 94 127 95 128 %interpolate 96 md.vx_obs=InterpFromGridToMesh(x,y,vx,md.x,md.y,default_value); 97 md.vy_obs=InterpFromGridToMesh(x,y,vy,md.x,md.y,default_value); 129 if isgrid, 130 md.vx_obs=InterpFromGridToMesh(x,y,vx,md.x,md.y,default_value); 131 md.vy_obs=InterpFromGridToMesh(x,y,vy,md.x,md.y,default_value); 132 else 133 md.vx_obs=InterpFromMeshToMesh2d(index,x,y,vx,md.x,md.y,default_value); 134 md.vy_obs=InterpFromMeshToMesh2d(index,x,y,vy,md.x,md.y,default_value); 135 end 98 136 md.vx=md.vx_obs; 99 137 md.vy=md.vy_obs;
Note:
See TracChangeset
for help on using the changeset viewer.