Home > constants > check_encoder.m

check_encoder

PURPOSE ^

SYNOPSIS ^

function [meanval, errval] = check_encoder(d)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [meanval, errval] = check_encoder(d)
0002 
0003 
0004 t(1,:) = [0 date2mjd(2013, 03, 01)];
0005 t(2,:) = [date2mjd(2013, 03, 01) date2mjd(2013, 05, 13)];
0006 t(3,:) = [date2mjd(2013, 05, 13) date2mjd(2013, 06, 28)];
0007 t(4,:) = [date2mjd(2013, 06, 28) date2mjd(2013, 12, 10)];
0008 t(5,:) = [date2mjd(2013, 12, 10) inf];
0009 %% only up to date to Feb 10, 2014
0010 
0011 x = [308.0950  308.3847  308.2313  307.9101  307.9042];
0012 v = [ 0.0097    0.0061    0.0092    0.0031    0.0021];
0013 
0014 f = find(d.array.frame.utc(1) >= t(:,1) & d.array.frame.utc(1) < t(:,2));
0015 
0016 meanval = x(f);
0017 errval = sqrt(v(f));
0018 
0019 return;
0020 
0021 
0022 
0023 
0024 function [meanVal, stdVal] = findMeanVal()
0025 
0026 %  first we want to make sure we know the mean.
0027 load encoder_switch_vis_21feb.txt
0028 aa = encoder_switch_vis_21feb;
0029 aa(aa(:,1)==0,:) = [];
0030 
0031 % utc_start utc_stop mean_val error numsamps
0032 aa(aa(:,5) < 100,:) = [];
0033 
0034 % need to split it up into periods
0035 % next we do a rejection.
0036 bb = 1;
0037 while(~isempty(bb))
0038   indbad = logical(outlier(aa(:,3), 3));
0039   bb = find(indbad)
0040   aa(indbad,:) = [];
0041 end
0042 
0043 % next let's re-order everything
0044 tDate  = aa(:,1);
0045 % first put things in chronological order
0046 [tDateChron, sortOrder] = sort(tDate);
0047 tChron     = aa(sortOrder,:);
0048 
0049 % redefine the variables in chronologiacl order
0050 tDate     = tDateChron;
0051 tEnc    = tChron;
0052 
0053 % let's get rid of the repeats - always trust the lastest one
0054 reps   = find(diff(tDate)==0);
0055 tDate(reps,:) = [];
0056 tEnc(reps,:) = [];
0057 
0058 % next, we need to split it up in time.
0059 
0060 % period 1:
0061 t(1,:) = [0 date2mjd(2013, 03, 01)];
0062 t(2,:) = [date2mjd(2013, 03, 01) date2mjd(2013, 05, 13)];
0063 t(3,:) = [date2mjd(2013, 05, 13) date2mjd(2013, 06, 28)];
0064 t(4,:) = [date2mjd(2013, 06, 28) date2mjd(2013, 12, 10)];
0065 t(5,:) = [date2mjd(2013, 06, 28) inf];
0066 
0067 
0068 load encoder_switch_vis_21feb.txt
0069 aa = encoder_switch_vis_21feb;
0070 aa(aa(:,1)==0,:) = [];
0071 
0072 % utc_start utc_stop mean_val error numsamps
0073 aa(aa(:,5) < 100,:) = [];
0074 
0075 % next let's re-order everything
0076 tDate  = aa(:,1);
0077 % first put things in chronological order
0078 [tDateChron, sortOrder] = sort(tDate);
0079 tChron     = aa(sortOrder,:);
0080 
0081 % redefine the variables in chronologiacl order
0082 tDate     = tDateChron;
0083 tEnc    = tChron;
0084 
0085 % let's get rid of the repeats - always trust the lastest one
0086 reps   = find(diff(tDate)==0);
0087 tDate(reps,:) = [];
0088 tEnc(reps,:) = [];
0089 
0090 for m=1:size(t,1)
0091   
0092   ind = tEnc(:,1) >= t(m,1) & tEnc(:,2) < t(m,2);
0093   aa = tEnc(ind,:);
0094   
0095   % next we do a rejection.
0096   bb = 1;
0097   while(~isempty(bb))
0098     indbad = logical(outlier(aa(:,3), 3));
0099     bb = find(indbad)
0100     aa(indbad,:) = [];
0101   end
0102   
0103   hist(aa(:,3),100);
0104 
0105   % find the weighted mean.
0106   [x(m),v(m)] = vwstat(aa(:,3), aa(:,4));
0107 
0108 end
0109

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005