Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/dopplercorr.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % Dopplercorr coorects data for Doppler shift | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: dopplercorr coorects time series data for Doppler shift. | |
5 % When the optical path difference (OPD) in the LTP interferometer | |
6 % is scanned fast, a doppler shift adds up to the data. | |
7 % The Doppler shift depends on the velocity with wich the OPD is scanned. | |
8 % This function calculates the Doppler shift% and | |
9 % subtracts it from the data to correct the 'Doppler error'. | |
10 % In the variable 'delta' the Doppler shift is stored and from | |
11 % their the 'Doppler error' stored in 'g' is calculated and finally | |
12 % subtracted from the input data. | |
13 % CALL: b = dopplercorr(a,pl) | |
14 % | |
15 % INPUTS: a - analysis object(s) (time series) | |
16 % pl - parameter list(s) - bin | |
17 % | |
18 % OUTPUTS: b - analysis object (time series) | |
19 % | |
20 % | |
21 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'dopplercorr')">Parameters Description</a> | |
22 % | |
23 % VERSION: $Id: dopplercorr.m,v 1.19 2011/04/08 08:56:16 hewitson Exp $ | |
24 % | |
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
26 | |
27 function varargout = dopplercorr(varargin) | |
28 | |
29 %%% Check if this is a call for parameters | |
30 if utils.helper.isinfocall(varargin{:}) | |
31 varargout{1} = getInfo(varargin{3}); | |
32 return | |
33 end | |
34 | |
35 %%% Collect input variable names | |
36 in_names = cell(size(varargin)); | |
37 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
38 | |
39 %%% Collect all AOs | |
40 [as, ao_invars, rest] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
41 [pli, pl_invars, rest] = utils.helper.collect_objects(rest, 'plist', in_names); | |
42 | |
43 %%% Decide on a deep copy or a modify | |
44 %%% REMARK: If you create a new AO (call the constructor) then | |
45 %%% it is not necessay to copy the input-AOs !!!!!!!!!!!!!!!!!!!!!!!!! | |
46 bs = copy(as, nargout); | |
47 | |
48 %%% Combine plists | |
49 pl = parse(pli, getDefaultPlist); | |
50 k = find(pl,'bin'); | |
51 if isempty(k) | |
52 error('### Please specify the bin parameter ''bin'''); | |
53 end | |
54 %%% go through analysis objects | |
55 for kk = 1:numel(bs) | |
56 %%%%%%%%%% some calculations %%%%%%%%%% | |
57 ydata = bs(kk).data.getY; | |
58 leng = length(ydata); | |
59 delta = zeros(leng,1); | |
60 delta(1) = (ydata(2)-ydata(1))/(2*pi); | |
61 delta(leng) = (ydata(leng)-ydata(leng-1))/(2*pi); | |
62 | |
63 for i=2:(leng-1) | |
64 delta(i) = (ydata(i+1)-ydata(i-1))/(4*pi); | |
65 end | |
66 | |
67 g = -1./(2*k).*delta.*sin(2.*ydata)... | |
68 + 1./(4*k*k).*delta.^2.*sin(2.*ydata) ... | |
69 + 1./(8*k*k).*delta.^2.*sin(4.*ydata); | |
70 ydata_new = ydata + g; | |
71 | |
72 %%create new ao | |
73 bs(kk).data.setY(ydata_new); | |
74 | |
75 %% Set Name | |
76 bs(kk).name = 'new name'; | |
77 | |
78 %%% Add History | |
79 bs(kk).addHistory(getInfo('None'), pl, ao_invars(kk), bs(kk).hist); | |
80 | |
81 end | |
82 | |
83 % Clear the errors since they don't make sense anymore | |
84 clearErrors(bs); | |
85 | |
86 % Set output | |
87 if nargout == numel(bs) | |
88 % List of outputs | |
89 for ii = 1:numel(bs) | |
90 varargout{ii} = bs(ii); | |
91 end | |
92 else | |
93 % Single output | |
94 varargout{1} = bs; | |
95 end | |
96 | |
97 end | |
98 | |
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
100 % Local Functions % | |
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
102 | |
103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
104 % | |
105 % FUNCTION: getInfo | |
106 % | |
107 % DESCRIPTION: Get Info Object | |
108 % | |
109 % HISTORY: 11-07-07 M Hewitson | |
110 % Creation. | |
111 % | |
112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
113 | |
114 function ii = getInfo(varargin) | |
115 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
116 sets = {}; | |
117 pl = []; | |
118 else | |
119 sets = {'Default'}; | |
120 pl = getDefaultPlist; | |
121 end | |
122 % Build info object | |
123 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.sigproc, '$Id: dopplercorr.m,v 1.19 2011/04/08 08:56:16 hewitson Exp $', sets, pl); | |
124 end | |
125 | |
126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
127 % | |
128 % FUNCTION: getDefaultPlist | |
129 % | |
130 % DESCRIPTION: Get Default Plist | |
131 % | |
132 % HISTORY: 11-07-07 M Hewitson | |
133 % Creation. | |
134 % | |
135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
136 | |
137 function plout = getDefaultPlist() | |
138 persistent pl; | |
139 if exist('pl', 'var')==0 || isempty(pl) | |
140 pl = buildplist(); | |
141 end | |
142 plout = pl; | |
143 end | |
144 | |
145 function pl = buildplist() | |
146 pl = plist(); | |
147 p = param('bin', 50, 'grid size for the doppler correction'); | |
148 pl.append(p); | |
149 end | |
150 | |
151 |