CalMresfdaH.m 2.13 KB
Newer Older
1
function [normI,phi,firstX,MresH,MresVH] = CalMresfdaH(n_and_dateX,Xamp,qemres)
2
3
%uses calculated sine and cosine instead of fda Cor96XZstuf signals with a shift by 22 samples for the Q Cor signal
% to get the Iand Q data
4
%set_path
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
clockstart=clock
%load lastMresV
[Xsnif, Zsnif] =getFDAreaderXZ(n_and_dateX);
[XCor, ZCor] =getFDAreaderXZCor(n_and_dateX);
siz=size(Xsnif)
MresH=zeros(224,96);
MresV=zeros(224,96);
MresVH=zeros(224,96);
MresHI=zeros(224,96);
MresVI=zeros(224,96);

MresHQ=zeros(224,96);
MresVQ=zeros(224,96);
MresHVQ=zeros(224,96);



22
23
24
%[Cor96Xstuf,Cor96Zstuf ] = SortCorrXZstuf( XZCor );

for i=1:96
25
26
    Cor96Xstuf(i,1:siz(2))=XCor(i,1:siz(2))-mean(XCor(i,:));
    
27
28
29
30
31
32
33
34
35
36
37
38
39
40
end

[ CXI,CXQ,firstX,lastX,lengthX]  = Corfast_fda2(Cor96Xstuf,Xamp,Xamp/20);
%[ CZI,CZQ,firstZ,lastZ,lengthZ]  = Corfast_fda2(Cor96Zstuf,Zamp,Zamp/20);


Xres=zeros(1,siz(2));
Zres=zeros(1,siz(2));
CX=zeros(1,siz(2));
CZ=zeros(1,siz(2));


for j=1:96
    j
41
42
    
    
43
44
45
46
47
48
49
50
51
52
53
54
    for k=1:224
        
        
        Xres(1:siz(2))=Xsnif(k,1:siz(2));
        Zres(1:siz(2))=Zsnif(k,1:siz(2));
        CX(1:siz(2))=CXI(j,1:siz(2));
        %CZ(1:siz(2))=CZI(j,1:siz(2));
        
        C=CX/sum(abs(CX));
        A=max(abs(CX));
        
        
55
56
57
        
        MresHI(k,j)=MresH(k,j)+Xres*C'/A;
        MresVI(k,j)=MresV(k,j)+Zres*C'/A;
58
59
60
61
62
63
64
65
66
        
        
        [ CX] = CXQ(j,1:siz(2));
        
        
        C=CX/sum(abs(CX));
        A=max(abs(CX));
        
        
67
68
69
        MresHQ(k,j)=MresH(k,j)+Xres*C'/A;
        MresVQ(k,j)=MresV(k,j)+Zres*C'/A;
        
70
        
71
    end
72
73
    
end
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

stdHI=std(MresHI);
stdHQ=std(MresHQ);
stdVI=std(MresVI);
stdVQ=std(MresVQ);
%calibration factor OK for.1A=32768
G=1e9*.2/pi*2*.5/32768;

normI=sqrt(stdHI.^2+stdHQ.^2)./stdHI;
normQ=sqrt(stdHI.^2+stdHQ.^2)./stdHQ;
phi=stdHQ./sqrt(stdHI.^2+stdHQ.^2);



for i=1:96
    if phi(i)< .8
90
91
        MresH(:,i)=MresHI(:,i)*normI(i)/G;
        MresVH(:,i)=MresVI(:,i)*normI(i)/G;
92
    else
93
94
95
        MresH(:,i)=MresHQ(:,i)*normQ(i)/G;
        MresVH(:,i)=MresVQ(:,i)*normQ(i)/G;
    end
96
97
98
99
end

time=time_label;
file=['TimeLabelMresX',time];
100
101

save(fullfile(qemres.datadir,file),'n_and_dateX' , 'MresH','MresVH')
102
103

clock-clockstart