aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Hogan-Lamarre <pascal.hogan@gmail.com>2020-09-17 21:39:41 -0400
committerPascal Hogan-Lamarre <pascal.hogan@gmail.com>2020-09-17 21:39:41 -0400
commit4489ee99f7b75d43e2c098822cfcb916847b47e1 (patch)
treee5ae0ddb5097ff63765eb75e99d1d06a7393341c
parent07787a409f8c152bf5ce224b67ae2ca8f99fb1d5 (diff)
removed the crystal number key from the solution file, deduced during reading
-rw-r--r--libcrystfel/src/fromfile.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/libcrystfel/src/fromfile.c b/libcrystfel/src/fromfile.c
index f79bc0d1..8555e0f4 100644
--- a/libcrystfel/src/fromfile.c
+++ b/libcrystfel/src/fromfile.c
@@ -43,9 +43,9 @@
* 2 detector shifts, 1 profile radius,
* 1 resolution limit */
#define NPARAMS_PER_LINE 13
-/* The keys are the filename,
- * event, and crystal number */
-#define NKEYS_PER_LINE 3
+/* The keys read from file
+ * are the filename, event */
+#define NKEYS_PER_LINE 2
struct fromfile_keys
{
@@ -176,6 +176,7 @@ void *fromfile_prepare(char *solution_filename, UnitCell *cell)
int j = 0; /* follows the solution parameter [0,NPARAMS_PER_LINE] */
for(int i = 0; i < nentries; i++)
{
+ crystal_number = 0;
current_line = i/(NPARAMS_PER_LINE+NKEYS_PER_LINE);
@@ -200,15 +201,8 @@ void *fromfile_prepare(char *solution_filename, UnitCell *cell)
return 0;
}
}
-
- if ( position_in_current_line == 2 ){
- if ( fscanf(fh, "%d", &crystal_number) != 1 ) {
- printf("Failed to read a crystal number\n");
- return 0;
- }
- }
- if ( position_in_current_line > 2 ){
+ if ( position_in_current_line > 1 ){
if ( fscanf(fh, "%e", &params[j]) != 1 ) {
printf("Failed to read a parameter\n");
return 0;
@@ -231,13 +225,25 @@ void *fromfile_prepare(char *solution_filename, UnitCell *cell)
/* Verify the uniqueness of the key */
struct fromfile_entries *uniqueness_test;
HASH_FIND(hh, sol_hash, &item->key,
- sizeof(struct fromfile_keys), uniqueness_test);
- if (uniqueness_test==NULL) {
- HASH_ADD(hh, sol_hash, key, sizeof(struct fromfile_keys), item);
+ sizeof(struct fromfile_keys), uniqueness_test);
+
+ if ( uniqueness_test == NULL ) {
+ HASH_ADD(hh, sol_hash, key,
+ sizeof(struct fromfile_keys), item);
}
else{
- printf("Keys must be unique! Verify the combinations");
- return 0;
+ do
+ {
+ uniqueness_test = NULL;
+ crystal_number += 1;
+ item->key.crystal_number = crystal_number;
+ HASH_FIND(hh, sol_hash, &item->key,
+ sizeof(struct fromfile_keys), uniqueness_test);
+ }
+ while ( uniqueness_test != NULL );
+
+ HASH_ADD(hh, sol_hash, key,
+ sizeof(struct fromfile_keys), item);
}
j=0;