Changeset 2566


Ignore:
Timestamp:
10/29/09 16:54:35 (15 years ago)
Author:
Mathieu Morlighem
Message:

Added support of mesh data plugvelocities

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/classes/public/plugvelocities.m

    r2296 r2566  
    2727
    2828%find x,y,vx and vy
    29 xenum=NaN; yenum=NaN; vxenum=NaN; vyenum=NaN;
     29xenum=NaN; yenum=NaN; vxenum=NaN; vyenum=NaN; indexenum=NaN;
    3030if length(A)==4,
     31        isgrid=1;
    3132        for i=1:4
    3233                if strcmpi(A(i).name(1),'x');
     
    4243                end
    4344        end
     45elseif 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
    4462else
    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))']);
    4664end
    4765
    4866%assum that we have found at least vxenum and vyenum
    4967if ( 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)']);
     69end
     70
     71%find index
     72if (~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
    5182end
    5283
     
    83114vxname=A(vxenum).name;
    84115vyname=A(vyenum).name;
     116if ~isgrid, indexname=A(indexenum).name; end
    85117
    86118%load data
     
    88120
    89121%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 ';'])
     122eval(['x=B.' xname ';']);
     123eval(['y=B.' yname ';']);
     124eval(['vx=B.' vxname ';']);
     125eval(['vy=B.' vyname ';']);
     126if ~isgrid, eval(['index=B.' indexname ';']); end
    94127
    95128%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);
     129if 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);
     132else
     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);
     135end
    98136md.vx=md.vx_obs;
    99137md.vy=md.vy_obs;
Note: See TracChangeset for help on using the changeset viewer.