diff options
-rw-r--r-- | libcrystfel/src/datatemplate.c | 17 | ||||
-rw-r--r-- | libcrystfel/src/datatemplate.h | 8 |
2 files changed, 23 insertions, 2 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c index 2593a7f9..7117a62e 100644 --- a/libcrystfel/src/datatemplate.c +++ b/libcrystfel/src/datatemplate.c @@ -1303,6 +1303,23 @@ const char *data_template_panel_name(const DataTemplate *dt, int pn) } +int data_template_panel_name_to_number(const DataTemplate *dt, + const char *panel_name, + int *pn) +{ + if ( panel_name == NULL ) return 1; + + for ( i=0; i<dt->n_panels; i++ ) { + if ( strcmp(panel_name, dt->panels[i].name) == 0 ) { + *pn = i; + return 0; + } + } + + return 1; +} + + void data_template_add_copy_header(DataTemplate *dt, const char *header) { diff --git a/libcrystfel/src/datatemplate.h b/libcrystfel/src/datatemplate.h index 9cb60bf1..a4520ba2 100644 --- a/libcrystfel/src/datatemplate.h +++ b/libcrystfel/src/datatemplate.h @@ -54,8 +54,12 @@ extern "C" { extern DataTemplate *data_template_new_from_file(const char *filename); extern void data_template_free(DataTemplate *dt); -extern const char *data_template_panel_name(const DataTemplate *dt, - int pn); +extern const char *data_template_panel_number_to_name(const DataTemplate *dt, + int pn); + +extern int data_template_panel_name_to_number(const DataTemplate *dt, + const char *panel_name, + int *pn); extern int data_template_file_to_panel_coords(const DataTemplate *dt, float *pfs, float *pss, |