Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@helper/plot_gauss_hist.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 function plot_gauss_hist(varargin) | |
2 | |
3 % Check if this is a call for parameters | |
4 if utils.helper.isinfocall(varargin{:}) | |
5 varargout{1} = getInfo(varargin{3}); | |
6 return | |
7 end | |
8 | |
9 % Collect input variable names | |
10 in_names = cell(size(varargin)); | |
11 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
12 | |
13 % Collect all AOs | |
14 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
15 [pli, pl_invars, rest] = utils.helper.collect_objects(varargin(:), 'plist', in_names); | |
16 pl = parse(pli, getDefaultPlist()); | |
17 | |
18 % Decide on a deep copy or a modify | |
19 bs = copy(as, nargout); | |
20 % get parameters | |
21 timestring = find(pl, 'timestring'); | |
22 % We filter out the data3D objects here since we don't know what to do | |
23 % with them so far. | |
24 aos = []; | |
25 inhists = []; | |
26 for kk=1:numel(bs) | |
27 if isa(bs(kk).data, 'data3D') | |
28 warning('!!! Skipping ao [%s] - can''t operate on data3D objects at the moment.', bs(kk).name); | |
29 else | |
30 aos = [aos bs(kk)]; | |
31 inhists = [inhists bs(kk).hist]; | |
32 end | |
33 end | |
34 if isempty(aos) | |
35 error('### Please give at least one AO of type cdata or data2D'); | |
36 end | |
37 x = aos(2).y; | |
38 gauss_value = aos(1).y; | |
39 stdev = aos(1).dy; | |
40 mean_val = mean(aos(2)); | |
41 miny = find(aos(1).procinfo,'min'); | |
42 maxy = find(aos(1).procinfo,'max'); | |
43 n = find(aos(1).procinfo,'bins'); | |
44 | |
45 [ny,nx]=hist(x,n,miny,maxy); | |
46 max_val = max(ny); | |
47 | |
48 yunit = aos(2).yunits.strs; | |
49 % figure, | |
50 hist(x,n) | |
51 % xlabel(sprintf(' [%s]',yunit{1})); | |
52 ylabel('Counts'); | |
53 hold on | |
54 plot(nx,max_val*gauss_value,'r') | |
55 hold off | |
56 v = axis; | |
57 mean_value=['Mean: ',num2str(mean_val.y)]; | |
58 std_value=['Sigma: ',num2str(stdev)]; | |
59 max_value=['Max: ',num2str(max_val)]; | |
60 xper=.27;yper=.05; | |
61 text(v(1)*xper+v(2)*(1-xper),v(3)*yper+v(4)*(1-yper),mean_value) | |
62 yper=yper+.05; | |
63 text(v(1)*xper+v(2)*(1-xper),v(3)*yper+v(4)*(1-yper),std_value) | |
64 yper=yper+.05; | |
65 text(v(1)*xper+v(2)*(1-xper),v(3)*yper+v(4)*(1-yper),max_value) | |
66 | |
67 end | |
68 %-------------------------------------------------------------------------- | |
69 % Get Info Object | |
70 %-------------------------------------------------------------------------- | |
71 function ii = getInfo(varargin) | |
72 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
73 sets = {}; | |
74 pl = []; | |
75 else | |
76 sets = {'Default'}; | |
77 pl = getDefaultPlist; | |
78 end | |
79 % Build info object | |
80 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.op, '$Id: plot_gauss_hist.m,v 1.2 2011/03/28 12:45:45 hewitson Exp $', sets, pl); | |
81 end | |
82 | |
83 %-------------------------------------------------------------------------- | |
84 % Get Default Plist | |
85 %-------------------------------------------------------------------------- | |
86 function pl_default = getDefaultPlist() | |
87 pl_default = plist('timestring',''); | |
88 end | |
89 | |
90 % END |