diff options
author | Thomas White <taw@physics.org> | 2020-05-05 12:26:40 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:42:57 +0200 |
commit | b73cd82b31281d2359fccf18f0b1a3d2b9ed3032 (patch) | |
tree | 0c4c7283baafbd6f0edde08e9168ba0c56464de5 | |
parent | a170c8d8f69f8682a17869a809aaede036fb0254 (diff) |
Implement save_project()
-rw-r--r-- | src/crystfel_gui.h | 1 | ||||
-rw-r--r-- | src/gui_backend_local.c | 1 | ||||
-rw-r--r-- | src/gui_project.c | 80 | ||||
-rw-r--r-- | src/gui_project.h | 2 |
4 files changed, 84 insertions, 0 deletions
diff --git a/src/crystfel_gui.h b/src/crystfel_gui.h index 6a61e29f..683c9261 100644 --- a/src/crystfel_gui.h +++ b/src/crystfel_gui.h @@ -32,6 +32,7 @@ #include "gui_project.h" struct crystfel_backend { + const char *name; int (*run_unitcell)(struct crystfelproject *proj, const char *algo); void (*cancel)(struct crystfelproject *proj); diff --git a/src/gui_backend_local.c b/src/gui_backend_local.c index 640dce5d..27887f94 100644 --- a/src/gui_backend_local.c +++ b/src/gui_backend_local.c @@ -307,6 +307,7 @@ static void init_backend(struct crystfelproject *proj) struct crystfel_backend _backend_local = { + .name = "local", .init = init_backend, .shutdown = shutdown_backend, .run_unitcell = run_unitcell, diff --git a/src/gui_project.c b/src/gui_project.c index fcfce995..f201d591 100644 --- a/src/gui_project.c +++ b/src/gui_project.c @@ -77,6 +77,19 @@ static struct crystfel_backend *parse_backend(const char *val) } +static const char *str_matchtype(enum match_type_id mt) +{ + switch ( mt ) { + case MATCH_EVERYTHING : return "everything"; + case MATCH_CHEETAH_LCLS_H5 : return "lcls-cheetah-hdf5"; + case MATCH_CHEETAH_CXI : return "cheetah-cxi"; + case MATCH_CBF : return "cbf"; + case MATCH_CBFGZ : return "cbfgz"; + } + return NULL; +} + + enum match_type_id decode_matchtype(const char *type_id) { if ( strcmp(type_id, "everything") == 0 ) return MATCH_EVERYTHING; @@ -304,3 +317,70 @@ int load_project(struct crystfelproject *proj) return 0; } + + +int save_project(struct crystfelproject *proj) +{ + int i; + FILE *fh; + + fh = fopen("crystfel.project", "w"); + if ( fh == NULL ) { + STATUS("Couldn't save project.\n"); + return 1; + } + + fprintf(fh, "geom %s\n", proj->geom_filename); + fprintf(fh, "data_folder %s\n", proj->data_top_folder); + fprintf(fh, "search_pattern %s\n", + str_matchtype(proj->data_search_pattern)); + + fprintf(fh, "peak_search_params.method %s\n", + str_peaksearch(proj->peak_search_params.method)); + fprintf(fh, "peak_search_params.threshold %f\n", + proj->peak_search_params.threshold); + fprintf(fh, "peak_search_params.min_sq_gradient %f\n", + proj->peak_search_params.min_sq_gradient); + fprintf(fh, "peak_search_params.min_snr %f\n", + proj->peak_search_params.min_snr); + fprintf(fh, "peak_search_params.min_pix_count %i\n", + proj->peak_search_params.min_pix_count); + fprintf(fh, "peak_search_params.max_pix_count %i\n", + proj->peak_search_params.max_pix_count); + fprintf(fh, "peak_search_params.local_bg_radius %i\n", + proj->peak_search_params.local_bg_radius); + fprintf(fh, "peak_search_params.min_res %i\n", + proj->peak_search_params.min_res); + fprintf(fh, "peak_search_params.max_res %i\n", + proj->peak_search_params.max_res); + fprintf(fh, "peak_search_params.min_snr_biggest_pix %f\n", + proj->peak_search_params.min_snr_biggest_pix); + fprintf(fh, "peak_search_params.min_snr_peak_pix %f\n", + proj->peak_search_params.min_snr_peak_pix); + fprintf(fh, "peak_search_params.min_peak_over_neighbour %f\n", + proj->peak_search_params.min_peak_over_neighbour); + fprintf(fh, "peak_search_params.pk_inn %f\n", + proj->peak_search_params.pk_inn); + fprintf(fh, "peak_search_params.pk_mid %f\n", + proj->peak_search_params.pk_mid); + fprintf(fh, "peak_search_params.pk_out %f\n", + proj->peak_search_params.pk_out); + fprintf(fh, "peak_search_params.half_pixel_shift %i\n", + proj->peak_search_params.half_pixel_shift); + fprintf(fh, "peak_search_params.revalidate %i\n", + proj->peak_search_params.revalidate); + + fprintf(fh, "backend %s\n", proj->backend->name); + + fprintf(fh, "-----\n"); + for ( i=0; i<proj->n_frames; i++ ) { + if ( proj->events[i] != NULL ) { + fprintf(fh, "%s %s\n", + proj->filenames[i], proj->events[i]); + } else { + fprintf(fh, "%s\n", proj->filenames[i]); + } + } + + return 0; +} diff --git a/src/gui_project.h b/src/gui_project.h index 77936f2a..37b38e29 100644 --- a/src/gui_project.h +++ b/src/gui_project.h @@ -114,6 +114,8 @@ extern int match_filename(const char *fn, enum match_type_id mt); extern int load_project(struct crystfelproject *proj); +extern int save_project(struct crystfelproject *proj); + extern void add_file_to_project(struct crystfelproject *proj, const char *filename, const char *event); |