comparison Allan.c @ 138:02044ad2749a

Coding style
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Wed, 22 Jan 2014 14:45:07 +0100
parents 792ac7151f0f
children be87c8e78266
comparison
equal deleted inserted replaced
137:792ac7151f0f 138:02044ad2749a
34 34
35 void Allan_ClosePanel(Allan_Data * Instance) 35 void Allan_ClosePanel(Allan_Data * Instance)
36 { 36 {
37 Instance->active = FALSE; 37 Instance->active = FALSE;
38 SetCtrlVal(Instance->parent, Instance->control, FALSE); 38 SetCtrlVal(Instance->parent, Instance->control, FALSE);
39 DiscardPanel (Instance->AllanPanel); 39 DiscardPanel(Instance->AllanPanel);
40 } 40 }
41 41
42 42
43 void Allan_AddFrequency(Allan_Data * Instance, double Freq) 43 void Allan_AddFrequency(Allan_Data * Instance, double Freq)
44 { 44 {
92 } 92 }
93 93
94 94
95 static void Allan_Display(Allan_Data *Instance) 95 static void Allan_Display(Allan_Data *Instance)
96 { 96 {
97 double x[ALLAN_NUM_DATAPOINTS];
98 double y[ALLAN_NUM_DATAPOINTS];
99 double error;
100 int dedrift;
97 int i; 101 int i;
98 double X[ALLAN_NUM_DATAPOINTS];
99 double Y[ALLAN_NUM_DATAPOINTS];
100 double Error;
101 int dedrift;
102 102
103 GetCtrlVal(Instance->AllanPanel, ALLANPANEL_DEDRIFT, &dedrift); 103 GetCtrlVal(Instance->AllanPanel, ALLANPANEL_DEDRIFT, &dedrift);
104 SetCtrlVal(Instance->AllanPanel, ALLANPANEL_DRIFT, Instance->Drift); 104 SetCtrlVal(Instance->AllanPanel, ALLANPANEL_DRIFT, Instance->Drift);
105 105
106 for (i = 0; i < ALLAN_NUM_DATAPOINTS; i++) { 106 for (i = 0; i < ALLAN_NUM_DATAPOINTS; i++) {
107 if (Instance->AllanVar[i] == 0.0) 107 if (Instance->AllanVar[i] == 0.0)
108 break; 108 break;
109 X[i] = pow(2, i); 109 x[i] = pow(2, i);
110 /* remove linear drift estimated contribution to the allan variance */ 110 /* remove linear drift estimated contribution to the allan variance */
111 if (dedrift) { 111 if (dedrift) {
112 double corr = 0.5 * (Instance->Drift * X[i]) * (Instance->Drift * X[i]); 112 double corr = 0.5 * (Instance->Drift * x[i]) * (Instance->Drift * x[i]);
113 /* uncertainty in the estimate of the drift rate may over correct 113 /* uncertainty in the estimate of the drift rate may over correct
114 the estimated allan variance and result in a negative value. in 114 the estimated allan variance and result in a negative value. in
115 this case we take the absolute value of the corrected value as 115 this case we take the absolute value of the corrected value as
116 the best estimator of the allan variance */ 116 the best estimator of the allan variance */
117 Y[i] = sqrt(fabs(Instance->AllanVar[i] - corr)) / Instance->normalization; 117 y[i] = sqrt(fabs(Instance->AllanVar[i] - corr)) / Instance->normalization;
118 } else { 118 } else {
119 Y[i] = sqrt(Instance->AllanVar[i]) / Instance->normalization; 119 y[i] = sqrt(Instance->AllanVar[i]) / Instance->normalization;
120 } 120 }
121 } 121 }
122 122
123 DeleteGraphPlot(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, -1, VAL_IMMEDIATE_DRAW); 123 DeleteGraphPlot(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, -1, VAL_IMMEDIATE_DRAW);
124 PlotXY(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, X, Y, ALLAN_NUM_DATAPOINTS, 124 PlotXY(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, x, y, ALLAN_NUM_DATAPOINTS,
125 VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SOLID_SQUARE, VAL_SOLID, 1, DATAPOINT_COLOR); 125 VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SOLID_SQUARE, VAL_SOLID, 1, DATAPOINT_COLOR);
126 126
127 for (i = 0; i < ALLAN_NUM_DATAPOINTS; i++) { 127 for (i = 0; i < ALLAN_NUM_DATAPOINTS; i++) {
128 Error = 1/sqrt(Instance->BlocksNumber[i]); 128 error = 1 / sqrt(Instance->BlocksNumber[i]);
129 PlotLine(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, X[i], Y[i]*(1-Error), X[i], Y[i]*(1+Error), ERRORBAR_COLOR); 129 PlotLine(Instance->AllanPanel, ALLANPANEL_ALLANPLOT,
130 x[i], y[i] * (1 - error), x[i], y[i] * (1 + error), ERRORBAR_COLOR);
130 } 131 }
131 } 132 }
132 133
133 134
134 /* callbacks */ 135 /* callbacks */