/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_misc/sym_g.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_misc/sym_g.m

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


Revision 1.2 - (hide annotations) (download)
Sat Aug 27 20:40:54 2011 UTC (13 years, 10 months ago) by gforget
Branch: MAIN
Changes since 1.1: +1 -0 lines
- runmean: mask edge points with NaNs, and bug fix for fld_isa_gcmfaces.
- sym_g: allow not to specify op_in.

1 gforget 1.1 function [field_out]=sym_g(field_in,sym_in,op_in);
2    
3     %apply symmetry in the complex plane to field_in(z)
4     % where field_in and z are in the complex arrays.
5     %then, depending on op_in, we apply a compensating operation
6     %
7     %format of field_in:
8     % z(1,:) is z=-1+?i, z(end,:) is z=1+?i
9     % z(:,1) is z=?-i, z(:,end) is z=?+i
10     %
11     %sym_in: 1,2,3,4 are reflexions about x=0,y=0,x=y,x=-y
12     % 4+nRot is rotation by nRot*pi/2
13     %op_in: 1 apply the opposite complex operation
14    
15     field_out=field_in;
16 gforget 1.2 if isempty(whos('op_in')); op_in=0; end;
17 gforget 1.1
18     if sym_in==1;
19     field_out=flipdim(field_in,1);
20     if op_in==1; field_out=-real(field_out)+i*imag(field_out); end;
21     elseif sym_in==2;
22     field_out=flipdim(field_in,2);
23     if op_in==1; field_out=real(field_out)-i*imag(field_out); end;
24     elseif sym_in==3;
25     field_out=field_in.';
26     if op_in==1; field_out=imag(field_out)+i*real(field_out); end;
27     elseif sym_in==4;
28     field_out=flipdim(flipdim(field_in,1).',1);
29     if op_in==1; field_out=-imag(field_out)-i*real(field_out); end;
30     elseif sym_in>=5&sym_in<=7;
31     for icur=1:sym_in-4;
32     field_out=flipdim(field_out.',1);
33     if op_in==1; field_out=i*field_out; end;
34     end
35     else;
36     fprintf('error in sym_g2\n'); return;
37     end;
38    
39     %for test case:
40     %--------------
41     %xx=[1:10]'*ones(1,10); yy=xx';
42     %zz=zeros(10,10); zz(1:2,1:3)=1; zz(8,9)=2; zz(2,6:8)=-1; zz(7,3)=-2;
43     %sym_g(zz,1); %etc
44     %with the following uncommented:
45     %-------------------------------
46     %figure;
47     %subplot(2,2,1); imagesc(field_in);
48     %subplot(2,2,4); imagesc(field_out);
49     %xlabel('y'); xlabel('x');
50    
51    

  ViewVC Help
Powered by ViewVC 1.1.22