Commit 2bf32224 authored by Daniel Brown's avatar Daniel Brown

Merge branch 'develop' of git.ligo.org:finesse/finesse into develop

parents 5dfff0b8 6f0aed49
......@@ -263,12 +263,12 @@ void compute_data(void) {
double y_max = 0.0;
// initialising x-axis ------------------------------------------------
get_xaxis_values(&inter.x1, &dx, &x_min, &x_max, 1);
get_xaxis_values(&inter.x1, &dx, &x_min, &x_max, 0);
// initialising second x-axis for 3D plot --------------------------
int oneline = 0;
if (inter.splot) {
get_xaxis_values(&inter.x2, &dy, &y_min, &y_max, 1);
get_xaxis_values(&inter.x2, &dy, &y_min, &y_max, 0);
oneline = inter.num_output_cols * (inter.x2.xsteps + 1);
}
......@@ -319,15 +319,24 @@ void compute_data(void) {
// start running along x-axis -------------------------------------
int x_step_index;
double x_correction = 0;
double x_step = 0;
for (x_step_index = 0; x_step_index <= inter.x1.xsteps; x_step_index++) {
if (x_step_index > 0) {
// Kahan summation of step sizes to prevent accumulation of errors
volatile double tmp = dx - x_correction;
volatile double tmp2 = x_step + tmp;
x_correction = (tmp2 - x_step) - tmp;
x_step = tmp2;
}
if (inter.x1.xtype == FLOG) {
x_axis_point = exp(x_min + x_step_index * dx);
x_axis_point = exp(x_min + x_step);
// in order to avoid rounding error we explictly use the max value as last step
if (x_step_index == inter.x1.xsteps) {
x_axis_point = exp(x_max);
}
} else {
x_axis_point = x_min + x_step_index*dx;
x_axis_point = x_min + x_step;
// in order to avoid rounding error we explictly use the max value as last step
if (x_step_index == inter.x1.xsteps) {
......@@ -372,18 +381,27 @@ void compute_data(void) {
// start running along second x-axis ----------------------
int y_step_index;
double y_correction = 0;
double y_step = 0;
for (y_step_index = 0; y_step_index <= inter.x2.xsteps; y_step_index++) {
set_progress_action_text("Calculating");
//set_progress_message_text("");
if (y_step_index > 0) {
// Kahan summation of step sizes to prevent accumulation of errors
volatile double tmp = dy - y_correction;
volatile double tmp2 = y_step + tmp;
y_correction = (tmp2 - y_step) - tmp;
y_step = tmp2;
}
if (inter.x2.xtype == FLOG) {
y_axis_point = exp(y_min + y_step_index * dy);
y_axis_point = exp(y_min + y_step);
// in order to avoid rounding error we explictly use the max value as last step
if (y_step_index == inter.x2.xsteps) {
y_axis_point = exp(y_max);
}
} else {
y_axis_point = y_min + y_step_index*dy;
y_axis_point = y_min + y_step;
// in order to avoid rounding error we explictly use the max value as last step
if (y_step_index == inter.x2.xsteps) {
y_axis_point = y_max;
......
......@@ -1199,7 +1199,7 @@ void print_python_3Dconvert(FILE *fp)
fprintf(fp,"def convert3D(X,Y,Z):\n");
fprintf(fp,"\trow,col=Z.shape\n");
fprintf(fp,"\tnxp=len(np.nonzero(np.equal(Y,Y[0]))[0])\n");
fprintf(fp,"\tnyp=row/nxp\n");
fprintf(fp,"\tnyp=row//nxp\n");
fprintf(fp,"\ty=Y[0:nyp]\n");
fprintf(fp,"\tx=X[0:row:nyp]#note the order\n");
fprintf(fp,"\tM=np.zeros((nyp,nxp,col))\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment