From cfb9a9979cab8eacc4636a8360502c3d33c66f2a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 5 Jun 2014 14:17:07 +0200 Subject: ambigator: Add --corr-matrix --- doc/man/ambigator.1 | 3 ++ src/ambigator.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/doc/man/ambigator.1 b/doc/man/ambigator.1 index 4aa5da98..14b87491 100644 --- a/doc/man/ambigator.1 +++ b/doc/man/ambigator.1 @@ -100,6 +100,9 @@ Use \fIn\fR correlations per crystal. The default is to correlate against every .IP \fB--really-random\fR Be non-deterministic by seeding the random number generator (used to make the initial indexing assignments and select patterns to correlate against) from /dev/urandom. Otherwise, with single-threaded operation (\fB-j 1\fR) on the same data, the results from this program should be the same if it is re-run. Using more than one thread already introduces some non-deterministic behaviour. +.PD 0 +.IP \fB--corr-matrix=\fR\fIfilename\fR +Write the the correlation matrices in HDF5 format to \fIfilename\fR. The file will contain two datasets: \fBcorrelation_matrix\fR and \fBcorrelation_matrix_reindexed\fR. They contain, respectively, the correlation matrix with all crystals in their original orientations and all crystals in the reindexed orientations. If the ambiguity operator is unknown (i.e. neither \fB--operator\fR nor \fB-w\fR were used), then the latter will be zero everywhere. .SH AUTHOR This page was written by Thomas White. diff --git a/src/ambigator.c b/src/ambigator.c index 1c11578d..26722aad 100644 --- a/src/ambigator.c +++ b/src/ambigator.c @@ -78,6 +78,7 @@ static void show_help(const char *s) " --ncorr= Use correlations per crystal. Default 1000\n" " -j Use threads for CC calculation.\n" " --really-random Be non-deterministic.\n" +" --corr-matrix= Write the correlation matrix to file.\n" ); } @@ -789,6 +790,110 @@ static void write_reindexed_stream(const char *infile, const char *outfile, } +static void save_corr(const char *filename, struct cc_list *ccs, int n_crystals, + int *assignments) +{ + hid_t fh, sh, dh; + hid_t ph; /* Property list */ + herr_t r; + hsize_t size[2]; + float *matrix; + float *rmatrix; + int i; + + matrix = malloc(n_crystals*n_crystals*sizeof(float)); + rmatrix = malloc(n_crystals*n_crystals*sizeof(float)); + if ( (matrix == NULL) || (rmatrix == NULL) ) return; + + for ( i=0; i