From 88c41a8e26b31d86d6116cc5bc220e34bcb92ec1 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 15 Mar 2021 14:27:58 +0100 Subject: GUI: Add interface for --fix-profile-radius and --fix-divergence --- src/crystfelindexingopts.c | 68 +++++++++++++++++++++++++++++++++++++++++++++- src/crystfelindexingopts.h | 17 ++++++++++++ src/gui_index.c | 14 ++++++++++ src/gui_project.c | 18 ++++++++++++ src/gui_project.h | 3 ++ 5 files changed, 119 insertions(+), 1 deletion(-) diff --git a/src/crystfelindexingopts.c b/src/crystfelindexingopts.c index 82e0fa60..de83c731 100644 --- a/src/crystfelindexingopts.c +++ b/src/crystfelindexingopts.c @@ -464,8 +464,40 @@ static GtkWidget *integration_parameters(CrystFELIndexingOpts *io) gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->ir_out), FALSE, FALSE, 4.0); - /* FIXME: fix-bandwidth, divergence, profile-radius */ + /* --fix-profile-radius */ + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(hbox), + FALSE, FALSE, 4.0); + io->fix_profile_radius_p = gtk_check_button_new_with_label("Fix the reflection radius to"); + gtk_box_pack_start(GTK_BOX(hbox), + GTK_WIDGET(io->fix_profile_radius_p), + FALSE, FALSE, 0.0); + io->fix_profile_radius = gtk_entry_new(); + gtk_entry_set_width_chars(GTK_ENTRY(io->fix_profile_radius), 6); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->fix_profile_radius), + FALSE, FALSE, 4.0); + label = gtk_label_new("nm-1"); + gtk_label_set_markup(GTK_LABEL(label), "nm-1"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + FALSE, FALSE, 4.0); + i_disable_if_not(io->fix_profile_radius_p, io->fix_profile_radius); + gtk_widget_set_tooltip_text(io->fix_profile_radius, + "--fix-profile-radius"); + /* --fix-divergence */ + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(hbox), + FALSE, FALSE, 4.0); + label = gtk_label_new("Beam divergence (full angle) for spot prediction:"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), FALSE, FALSE, 0.0); + io->fix_divergence = gtk_entry_new(); + gtk_entry_set_width_chars(GTK_ENTRY(io->fix_divergence), 6); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(io->fix_divergence), + FALSE, FALSE, 4.0); + label = gtk_label_new("mrad"); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(label), + FALSE, FALSE, 4.0); + gtk_widget_set_tooltip_text(io->fix_profile_radius, "--fix-divergence"); gtk_widget_show_all(box); return box; @@ -879,6 +911,20 @@ char **crystfel_indexing_opts_get_metadata_to_copy(CrystFELIndexingOpts *opts, } +double crystfel_indexing_opts_get_fixed_profile_radius(CrystFELIndexingOpts *opts, + int *active) +{ + *active = get_bool(opts->fix_profile_radius_p); + return get_float(opts->fix_profile_radius)*1e9; +} + + +double crystfel_indexing_opts_get_fixed_divergence(CrystFELIndexingOpts *opts) +{ + return get_float(opts->fix_divergence)/1e3; +} + + /********************** Setters *************************/ @@ -1137,3 +1183,23 @@ void crystfel_indexing_opts_set_exclude_reflections(CrystFELIndexingOpts *opts, gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opts->no_refls_in_stream), flag); } + + +void crystfel_indexing_opts_set_fixed_profile_radius(CrystFELIndexingOpts *opts, + int active, + double val) +{ + char tmp[64]; + set_active(opts->fix_profile_radius_p, active); + snprintf(tmp, 63, "%.3f", val/1e9); + gtk_entry_set_text(GTK_ENTRY(opts->fix_profile_radius), tmp); +} + + +void crystfel_indexing_opts_set_fixed_divergence(CrystFELIndexingOpts *opts, + double val) +{ + char tmp[64]; + snprintf(tmp, 63, "%.3f", val*1e3); + gtk_entry_set_text(GTK_ENTRY(opts->fix_divergence), tmp); +} diff --git a/src/crystfelindexingopts.h b/src/crystfelindexingopts.h index 72ca8c37..fe5f4ccd 100644 --- a/src/crystfelindexingopts.h +++ b/src/crystfelindexingopts.h @@ -79,6 +79,9 @@ struct _crystfelindexingopts GtkWidget *ir_inn; GtkWidget *ir_mid; GtkWidget *ir_out; + GtkWidget *fix_profile_radius_p; + GtkWidget *fix_profile_radius; + GtkWidget *fix_divergence; GtkWidget *exclude_nonhits; GtkWidget *no_peaks_in_stream; @@ -120,6 +123,14 @@ extern int crystfel_indexing_opts_get_exclude_peaks(CrystFELIndexingOpts *opts); extern int crystfel_indexing_opts_get_exclude_reflections(CrystFELIndexingOpts *opts); extern char **crystfel_indexing_opts_get_metadata_to_copy(CrystFELIndexingOpts *opts, int *n); +extern double crystfel_indexing_opts_get_fixed_profile_radius(CrystFELIndexingOpts *opts, + int *active); +extern double crystfel_indexing_opts_get_fixed_divergence(CrystFELIndexingOpts *opts); + + + + + extern void crystfel_indexing_opts_set_show_stream_opts(CrystFELIndexingOpts *opts, int val); @@ -162,5 +173,11 @@ extern void crystfel_indexing_opts_set_exclude_peaks(CrystFELIndexingOpts *opts, int flag); extern void crystfel_indexing_opts_set_exclude_reflections(CrystFELIndexingOpts *opts, int flag); +extern void crystfel_indexing_opts_set_fixed_profile_radius(CrystFELIndexingOpts *opts, + int active, + double val); +extern void crystfel_indexing_opts_set_fixed_divergence(CrystFELIndexingOpts *opts, + double val); + #endif /* CRYSTFELINDEXINGOPTS_H */ diff --git a/src/gui_index.c b/src/gui_index.c index 4b7254de..c04ee197 100644 --- a/src/gui_index.c +++ b/src/gui_index.c @@ -122,6 +122,9 @@ static void get_indexing_opts(struct crystfelproject *proj, &proj->indexing_params.ir_inn, &proj->indexing_params.ir_mid, &proj->indexing_params.ir_out); + proj->indexing_params.fix_profile_radius = crystfel_indexing_opts_get_fixed_profile_radius(opts, + &proj->indexing_params.use_fix_profile_radius); + proj->indexing_params.fix_divergence = crystfel_indexing_opts_get_fixed_divergence(opts); /* Stream output */ proj->indexing_params.exclude_nonhits = crystfel_indexing_opts_get_exclude_blanks(opts); @@ -298,6 +301,11 @@ static void set_indexing_opts(struct crystfelproject *proj, proj->indexing_params.ir_inn, proj->indexing_params.ir_mid, proj->indexing_params.ir_out); + crystfel_indexing_opts_set_fixed_profile_radius(opts, + proj->indexing_params.use_fix_profile_radius, + proj->indexing_params.fix_profile_radius); + crystfel_indexing_opts_set_fixed_divergence(opts, + proj->indexing_params.fix_divergence); /* Stream output */ crystfel_indexing_opts_set_exclude_blanks(opts, @@ -778,6 +786,12 @@ static char **indexamajig_command_line(const char *geom_filename, indexing_params->ir_mid, indexing_params->ir_out); add_arg(args, n_args++, tols); + if ( indexing_params->use_fix_profile_radius ) { + add_arg_float(args, n_args++, "fix-profile-radius", + indexing_params->fix_profile_radius); + } + add_arg_float(args, n_args++, "fix-divergence", + indexing_params->fix_divergence); /* Stream output */ if ( indexing_params->exclude_nonhits ) add_arg(args, n_args++, "--no-non-hits-in-stream"); diff --git a/src/gui_project.c b/src/gui_project.c index 90b2b0fb..574e57dd 100644 --- a/src/gui_project.c +++ b/src/gui_project.c @@ -295,6 +295,15 @@ static void parse_integration_opt(const char *key, const char *val, if ( strcmp(key, "integration.ir_out") == 0 ) { proj->indexing_params.ir_out = parse_float(val); } + if ( strcmp(key, "integration.fix_divergence") == 0 ) { + proj->indexing_params.fix_divergence = parse_float(val); + } + if ( strcmp(key, "integration.fix_profile_radius") == 0 ) { + proj->indexing_params.use_fix_profile_radius = parse_int(val); + } + if ( strcmp(key, "integration.fix_profile_radius_val") == 0 ) { + proj->indexing_params.fix_profile_radius = parse_float(val); + } } @@ -928,6 +937,12 @@ int save_project(struct crystfelproject *proj) proj->indexing_params.ir_mid); fprintf(fh, "integration.ir_out %f\n", proj->indexing_params.ir_out); + fprintf(fh, "integration.fix_profile_radius %i\n", + proj->indexing_params.use_fix_profile_radius); + fprintf(fh, "integration.fix_profile_radius_val %e\n", + proj->indexing_params.fix_profile_radius); + fprintf(fh, "integration.fix_divergence %e\n", + proj->indexing_params.fix_divergence); fprintf(fh, "stream.exclude_blanks %i\n", proj->indexing_params.exclude_nonhits); @@ -1146,6 +1161,9 @@ void default_project(struct crystfelproject *proj) proj->indexing_params.exclude_refls = 0; proj->indexing_params.metadata_to_copy = NULL; proj->indexing_params.n_metadata = 0; + proj->indexing_params.fix_profile_radius = 0.01e9; + proj->indexing_params.use_fix_profile_radius = 0; + proj->indexing_params.fix_divergence = 0.0; proj->ambi_params.use_res = 1; proj->ambi_params.res_min = 20; /* Angstroms */ diff --git a/src/gui_project.h b/src/gui_project.h index 1bb22d74..59a93853 100644 --- a/src/gui_project.h +++ b/src/gui_project.h @@ -87,6 +87,9 @@ struct index_params { float ir_inn; float ir_mid; float ir_out; + float fix_profile_radius; + int use_fix_profile_radius; + float fix_divergence; /* Stream output */ int exclude_nonhits; -- cgit v1.2.3