aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-05-11 12:24:44 +0200
committerThomas White <taw@physics.org>2021-05-11 12:24:44 +0200
commit967c094253f89dbb21ffed95bd8381610298e046 (patch)
treee7447b0b812cbe8cb09d70de48108137285b9902
parentbbb5ce788392222ed745aa65895f90a6490bc3c5 (diff)
indexamajig: Put cell tolerances and pk/int radii into separate objects
Rationale: it makes the JSON structure a bit more logical, and enables things like the following: set_of_params_1.integration.radii == set_of_params_2.integration.radii params.peaksearch.radii == params.integration.radii Previously, these would have required multiple comparisons.
-rw-r--r--src/indexamajig.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 16822989..894eac60 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -140,6 +140,30 @@ static void write_json_cell(FILE *fh, const char *name, UnitCell *cell)
}
+static void write_json_tolerances(FILE *fh, const char *name, float tols[6])
+{
+ fprintf(fh, " \"%s\": {\n", name);
+ fprintf(fh, " \"a_percent\": %f,\n", 100.0*tols[0]);
+ fprintf(fh, " \"b_percent\": %f,\n", 100.0*tols[1]);
+ fprintf(fh, " \"c_percent\": %f,\n", 100.0*tols[2]);
+ fprintf(fh, " \"alpha_deg\": %f,\n", rad2deg(tols[3]));
+ fprintf(fh, " \"beta_deg\": %f,\n", rad2deg(tols[4]));
+ fprintf(fh, " \"gamma_deg\": %f\n", rad2deg(tols[5]));
+ fprintf(fh, " },\n");
+}
+
+
+static void write_json_radii(FILE *fh, const char *name,
+ double inn, double mid, double out)
+{
+ fprintf(fh, " \"%s\": {\n", name);
+ fprintf(fh, " \"inner_px\": %f,\n", inn);
+ fprintf(fh, " \"middle_px\": %f,\n", mid);
+ fprintf(fh, " \"outer_px\": %f\n", out);
+ fprintf(fh, " },\n");
+}
+
+
static void write_methods(FILE *fh, const char *name, IndexingPrivate *ipriv)
{
int i, n;
@@ -181,9 +205,7 @@ static void write_harvest_file(struct index_args *args,
fprintf(fh, " \"peaksearch\": {\n");
write_str(fh, 1, "method", str_peaksearch(args->peaks));
- write_float(fh, 1, "radius_inner_px", args->pk_inn);
- write_float(fh, 1, "radius_middle_px", args->pk_mid);
- write_float(fh, 1, "radius_outer_px", args->pk_out);
+ write_json_radii(fh, "radii", args->pk_inn, args->pk_mid, args->pk_out);
write_bool(fh, 1, "noise_filter", args->noisefilter);
write_int(fh, 1, "median_filter", args->median_filter);
write_float(fh, 1, "threshold_adu", args->threshold);
@@ -215,12 +237,7 @@ static void write_harvest_file(struct index_args *args,
fprintf(fh, " \"indexing\": {\n");
write_methods(fh, "methods", args->ipriv);
write_json_cell(fh, "target_cell", args->cell);
- write_float(fh, 1, "tolerance_a_percent", 100.0*args->tols[0]);
- write_float(fh, 1, "tolerance_b_percent", 100.0*args->tols[1]);
- write_float(fh, 1, "tolerance_c_percent", 100.0*args->tols[2]);
- write_float(fh, 1, "tolerance_alpha_deg", rad2deg(args->tols[3]));
- write_float(fh, 1, "tolerance_beta_deg", rad2deg(args->tols[4]));
- write_float(fh, 1, "tolerance_gamma_deg", rad2deg(args->tols[5]));
+ write_json_tolerances(fh, "tolerances", args->tols);
write_bool(fh, 1, "multi_lattice", if_multi);
write_bool(fh, 1, "refine", if_refine);
write_bool(fh, 1, "retry", if_retry);
@@ -234,9 +251,7 @@ static void write_harvest_file(struct index_args *args,
tmp = str_integration_method(args->int_meth);
write_str(fh, 1, "method", tmp);
free(tmp);
- write_float(fh, 1, "radius_inner_px", args->ir_inn);
- write_float(fh, 1, "radius_middle_px", args->ir_mid);
- write_float(fh, 1, "radius_outer_px", args->ir_out);
+ write_json_radii(fh, "radii", args->ir_inn, args->ir_mid, args->ir_out);
write_float(fh, 1, "push_res_invm", args->push_res);
write_float(fh, 1, "fix_profile_radius_invm", nan_if_neg(args->fix_profile_r));
write_float(fh, 1, "fix_divergence_rad", nan_if_neg(args->fix_divergence));