diff options
author | Thomas White <taw@physics.org> | 2020-11-30 17:29:52 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-11-30 17:45:00 +0100 |
commit | 9a5b52cd6cbc9ed9bb391a71c3eb724bd19322f0 (patch) | |
tree | 43a3101ca6d74730c762ca4dab2ab0caf78618aa /src/gui_merge.c | |
parent | d6f6658a29ed309b47a0b8fd0fc6bfdb023cb258 (diff) |
Add merging_command_line()
Diffstat (limited to 'src/gui_merge.c')
-rw-r--r-- | src/gui_merge.c | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/src/gui_merge.c b/src/gui_merge.c index 6d0afe35..95444880 100644 --- a/src/gui_merge.c +++ b/src/gui_merge.c @@ -360,3 +360,171 @@ gint merge_sig(GtkWidget *widget, struct crystfelproject *proj) return FALSE; } + + +static GSList *append_arg_str(GSList *args, + const char *label, + const char *val) +{ + size_t len; + char *str; + + len = strlen(label)+strlen(val)+4; + str = malloc(len); + if ( str == NULL ) return args; + snprintf(str, 63, "--%s=%s", label, val); + + return g_slist_append(args, str); +} + + +static GSList *append_arg_int(GSList *args, + const char *label, + int val) +{ + char *str = malloc(64); + if ( str == NULL ) return args; + snprintf(str, 63, "--%s=%i", label, val); + return g_slist_append(args, str); +} + + +static GSList *append_arg_float(GSList *args, + const char *label, + float val) +{ + char *str = malloc(64); + if ( str == NULL ) return args; + snprintf(str, 63, "--%s=%f", label, val); + return g_slist_append(args, str); +} + + +static GSList *process_hkl_command_line(struct gui_result *input, + struct merging_params *params) +{ + GSList *args = NULL; + char *exe_path; + + exe_path = get_crystfel_exe("process_hkl"); + if ( exe_path == NULL ) return NULL; + args = g_slist_append(args, exe_path); + + /* FIXME: For each stream */ + args = append_arg_str(args, "input", input->streams[0]); + + args = append_arg_str(args, "symmetry", params->symmetry); + + if ( params->scale ) { + args = g_slist_append(args, strdup("--scale")); + } + + args = append_arg_str(args, "polarisation", + params->polarisation); + + args = append_arg_int(args, "min-measurements", + params->min_measurements); + + args = append_arg_float(args, "max-adu", params->max_adu); + + args = append_arg_float(args, "min-res", params->min_res); + + args = append_arg_float(args, "push-res", params->push_res); + + return args; +} + + +static GSList *partialator_command_line(const char *n_thread_str, + struct gui_result *input, + struct merging_params *params) +{ + GSList *args = NULL; + char *exe_path; + + exe_path = get_crystfel_exe("partialator"); + if ( exe_path == NULL ) return NULL; + args = g_slist_append(args, exe_path); + + /* FIXME: For each stream */ + args = append_arg_str(args, "input", input->streams[0]); + + args = append_arg_str(args, "symmetry", params->symmetry); + + if ( params->twin_sym != NULL ) { + args = g_slist_append(args, "-w"); + args = g_slist_append(args, strdup(params->twin_sym)); + } + + if ( params->custom_split != NULL ) { + args = append_arg_str(args, "custom-split", + params->custom_split); + } + + if ( !params->scale ) { + args = g_slist_append(args, "--no-scale"); + } + + if ( !params->bscale ) { + args = g_slist_append(args, "--no-bscale"); + } + + if ( !params->postref ) { + args = g_slist_append(args, "--no-pr"); + } + + if ( !params->deltacchalf ) { + args = g_slist_append(args, "no-deltacchalf"); + } + + args = append_arg_int(args, "iterations", params->niter); + + args = append_arg_str(args, "polarisation", + params->polarisation); + + args = append_arg_int(args, "min-measurements", + params->min_measurements); + + args = append_arg_float(args, "max-adu", params->max_adu); + + args = append_arg_float(args, "min-res", params->min_res); + + args = append_arg_float(args, "push-res", params->push_res); + + return args; +} + + +char **merging_command_line(const char *n_thread_str, + struct gui_result *input, + struct merging_params *params) +{ + GSList *args; + char **arg_strings; + GSList *args2; + int i, n; + + if ( strcmp(params->model, "process_hkl") == 0 ) { + args = process_hkl_command_line(input, params); + } else { + args = partialator_command_line(n_thread_str, + input, + params); + } + + if ( args == NULL ) return NULL; + + n = g_slist_length(args); + arg_strings = malloc((n+1)*sizeof(char *)); + if ( arg_strings == NULL ) return NULL; + + args2 = args; + for ( i=0; i<n; i++ ) { + arg_strings[i] = args2->data; + args2 = args2->next; + } + arg_strings[n] = NULL; + g_slist_free(args); + + return arg_strings; +} |