# HG changeset patch # User Daniele Nicolodi # Date 1390398307 -3600 # Node ID 02044ad2749a0e69d7006d3f1d90dcaf237ea908 # Parent 792ac7151f0f67e53a2b83436b7f74e778c5b5dd Coding style diff -r 792ac7151f0f -r 02044ad2749a Allan.c --- a/Allan.c Wed Jan 22 13:41:07 2014 +0100 +++ b/Allan.c Wed Jan 22 14:45:07 2014 +0100 @@ -36,7 +36,7 @@ { Instance->active = FALSE; SetCtrlVal(Instance->parent, Instance->control, FALSE); - DiscardPanel (Instance->AllanPanel); + DiscardPanel(Instance->AllanPanel); } @@ -94,11 +94,11 @@ static void Allan_Display(Allan_Data *Instance) { + double x[ALLAN_NUM_DATAPOINTS]; + double y[ALLAN_NUM_DATAPOINTS]; + double error; + int dedrift; int i; - double X[ALLAN_NUM_DATAPOINTS]; - double Y[ALLAN_NUM_DATAPOINTS]; - double Error; - int dedrift; GetCtrlVal(Instance->AllanPanel, ALLANPANEL_DEDRIFT, &dedrift); SetCtrlVal(Instance->AllanPanel, ALLANPANEL_DRIFT, Instance->Drift); @@ -106,27 +106,28 @@ for (i = 0; i < ALLAN_NUM_DATAPOINTS; i++) { if (Instance->AllanVar[i] == 0.0) break; - X[i] = pow(2, i); + x[i] = pow(2, i); /* remove linear drift estimated contribution to the allan variance */ if (dedrift) { - double corr = 0.5 * (Instance->Drift * X[i]) * (Instance->Drift * X[i]); + double corr = 0.5 * (Instance->Drift * x[i]) * (Instance->Drift * x[i]); /* uncertainty in the estimate of the drift rate may over correct the estimated allan variance and result in a negative value. in this case we take the absolute value of the corrected value as the best estimator of the allan variance */ - Y[i] = sqrt(fabs(Instance->AllanVar[i] - corr)) / Instance->normalization; + y[i] = sqrt(fabs(Instance->AllanVar[i] - corr)) / Instance->normalization; } else { - Y[i] = sqrt(Instance->AllanVar[i]) / Instance->normalization; + y[i] = sqrt(Instance->AllanVar[i]) / Instance->normalization; } } DeleteGraphPlot(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, -1, VAL_IMMEDIATE_DRAW); - PlotXY(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, X, Y, ALLAN_NUM_DATAPOINTS, + PlotXY(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, x, y, ALLAN_NUM_DATAPOINTS, VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SOLID_SQUARE, VAL_SOLID, 1, DATAPOINT_COLOR); for (i = 0; i < ALLAN_NUM_DATAPOINTS; i++) { - Error = 1/sqrt(Instance->BlocksNumber[i]); - PlotLine(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, X[i], Y[i]*(1-Error), X[i], Y[i]*(1+Error), ERRORBAR_COLOR); + error = 1 / sqrt(Instance->BlocksNumber[i]); + PlotLine(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, + x[i], y[i] * (1 - error), x[i], y[i] * (1 + error), ERRORBAR_COLOR); } }