/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_convert/convert2vector.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_convert/convert2vector.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (hide annotations) (download)
Sun Mar 20 15:11:56 2016 UTC (9 years, 4 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65v, checkpoint65w, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.2: +5 -4 lines
- gcmfaces_calc/calc_barostream.m: set 0 on North America rather than Antarctica
- gcmfaces_calc/gcmfaces_subset.m: use convert2array directly
- gcmfaces_convert/convert2vector.m: set new method as default method
- gcmfaces_diags/diags_set_LAYERS.m: update after convert2vector.m revision

1 gforget 1.2 function [a]=convert2vector(b,method);
2     %[a]=CONVERT2VECTOR(b,method);
3     % converts gcmfaces object b to vector format a -- and vice versa
4     % when b is instead a vector obtained ealier using convert2vector.
5 gforget 1.1 %
6 gforget 1.3 % With the 'new' method (default): each 2D field becomes a column vector,
7 gforget 1.2 % while the other dimensions remain the same; convert2gcmfaces is used.
8 gforget 1.3 % With the 'old' method : convert2array is used and the third+
9 gforget 1.2 % dimensions of b get conflated in the column vector length.
10     %
11     % The 'old' method will get removed after updating routines that use convert2vector.
12 gforget 1.1
13     global mygrid;
14    
15     if isa(b,'gcmfaces'); do_gcmfaces2vector=1; else; do_gcmfaces2vector=0; end;
16 gforget 1.3 if isempty(whos('method')); method='new'; end;
17 gforget 1.2
18     if strcmp(method,'new');
19     if do_gcmfaces2vector;
20     bb=convert2gcmfaces(b);
21     siz=size(bb); if length(siz)==2; siz=[siz 1]; end;
22     a=reshape(bb,[prod(siz(1:2)) siz(3:end)]);
23     else;
24     bb=convert2gcmfaces(mygrid.XC);
25     siz=size(b);
26     bb=reshape(b,[size(bb) siz(2:end)]);
27     a=convert2gcmfaces(bb);
28     end;
29     end;
30 gforget 1.1
31 gforget 1.3 if strcmp(method,'old');
32 gforget 1.1 if do_gcmfaces2vector;
33     bb=convert2array(b);
34     a=bb(:);
35     else;
36     bb=convert2array(mygrid.XC);
37     if mod(length(b(:)),length(bb(:)))~=0;
38     error('vector length is inconsistent with gcmfaces objects');
39     else;
40     n3=length(b(:))/length(bb(:));
41     end;
42     b=reshape(b,[size(bb) n3]);
43     a=convert2array(b);
44     end;
45 gforget 1.3 end;
46 gforget 1.1
47    
48    

  ViewVC Help
Powered by ViewVC 1.1.22