aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-10-20 14:28:47 +0200
committerThomas White <taw@physics.org>2021-10-20 14:28:47 +0200
commitd6982b711b365477a3e44d2e20044f770fb9010f (patch)
tree7f5dd5b7e10efae8b93f18e5761d746e0fd0c37c
parent0b46b5003af6c6c45da1ff2455680f612f27fa47 (diff)
Set crystal name in MTZ files
When using the GUI, it will be set to the corresponding indexing result name.
-rw-r--r--libcrystfel/src/reflist-utils.c11
-rw-r--r--libcrystfel/src/reflist-utils.h3
-rw-r--r--src/get_hkl.c3
-rw-r--r--src/gui_export.c9
4 files changed, 16 insertions, 10 deletions
diff --git a/libcrystfel/src/reflist-utils.c b/libcrystfel/src/reflist-utils.c
index 8f461522..a2de12d8 100644
--- a/libcrystfel/src/reflist-utils.c
+++ b/libcrystfel/src/reflist-utils.c
@@ -1030,7 +1030,9 @@ int write_to_mtz(RefList *reflist,
double min_res,
double max_res,
const char *filename,
- const char *dataset_name)
+ const char *dataset_name,
+ const char *crystal_name,
+ const char *project_name)
{
#ifdef HAVE_LIBCCP4
MTZ *mtz;
@@ -1076,12 +1078,7 @@ int write_to_mtz(RefList *reflist,
cellp[4] = rad2deg(be);
cellp[5] = rad2deg(ga);
- /* FIXME: Proposed labelling (GitLab #28):
- * title = as above
- * project = basename of folder containing crystfel.project
- * crystal = name of indexing results run
- * dataset = name of merge results run */
- cr = MtzAddXtal(mtz, "Crystal_name", "Project_name", cellp);
+ cr = MtzAddXtal(mtz, crystal_name, project_name, cellp);
ds = MtzAddDataset(mtz, cr, dataset_name, 0.0);
columns[0] = MtzAddColumn(mtz, ds, "H", "H");
columns[1] = MtzAddColumn(mtz, ds, "K", "H");
diff --git a/libcrystfel/src/reflist-utils.h b/libcrystfel/src/reflist-utils.h
index bd60c642..ef65fba8 100644
--- a/libcrystfel/src/reflist-utils.h
+++ b/libcrystfel/src/reflist-utils.h
@@ -81,7 +81,8 @@ extern void reflist_add_command_and_version(RefList *list,
extern int write_to_mtz(RefList *reflist, SymOpList *sym, UnitCell *cell,
double min_res, double max_res,
- const char *filename, const char *dataset_name);
+ const char *filename, const char *dataset_name,
+ const char *crystal_name, const char *project_name);
extern int write_to_xds(RefList *reflist, SymOpList *sym, UnitCell *cell,
double min_res, double max_res, const char *filename);
diff --git a/src/get_hkl.c b/src/get_hkl.c
index fb0d04fc..e80383e5 100644
--- a/src/get_hkl.c
+++ b/src/get_hkl.c
@@ -915,7 +915,8 @@ int main(int argc, char *argv[])
ERROR("You must provide the MTZ output filename.\n");
r = 1;
} else {
- r = write_to_mtz(input, mero, cell, 0, INFINITY, output, "dataset");
+ r = write_to_mtz(input, mero, cell, 0, INFINITY, output,
+ "dataset", "crystal", "project");
}
} else if ( strcasecmp(output_format_str, "xds") == 0 ) {
if ( output == NULL ) {
diff --git a/src/gui_export.c b/src/gui_export.c
index 50bd126c..36f1a032 100644
--- a/src/gui_export.c
+++ b/src/gui_export.c
@@ -93,6 +93,7 @@ static int export_to_mtz(struct gui_merge_result *result,
char *sym_str;
SymOpList *sym;
int r;
+ char *crystal_name;
reflist = read_reflections_2(result->hkl, &sym_str);
if ( reflist == NULL ) return 1;
@@ -101,8 +102,14 @@ static int export_to_mtz(struct gui_merge_result *result,
sym = get_pointgroup(sym_str);
if ( sym == NULL ) return 1;
+ /* FIXME: Proposed labelling (GitLab #28):
+ * project = basename of folder containing crystfel.project */
+ crystal_name = result->indexing_result_name;
+ if ( crystal_name == NULL ) {
+ crystal_name = "unknown";
+ }
r = write_to_mtz(reflist, sym, cell, min_res, max_res, filename,
- result->name);
+ result->name, crystal_name, "project", bij);
free_symoplist(sym);
free(sym_str);