aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-08-19 12:30:10 +0200
committerThomas White <taw@physics.org>2020-08-19 12:30:10 +0200
commit1d8f71504ece9da2164d680d52823a865b60faab (patch)
tree80104a634b1be9e087937077521100217d8385a2
parent5f4c120e3c74284e72525d9bb5a9a8da13871968 (diff)
Remove STREAM_UNITCELL and STREAM_CRYSTALS
These flags weren't orthogonal at all, which was turning some routines into spaghetti-code. It's still possible to avoid read/write of peak lists, reflection data or image data. But that's it.
-rw-r--r--libcrystfel/src/stream.c40
-rw-r--r--libcrystfel/src/stream.h14
-rw-r--r--src/ambigator.c3
-rw-r--r--src/cell_explorer.c2
-rw-r--r--src/crystfel_gui.c4
-rw-r--r--src/indexamajig.c3
-rw-r--r--src/partial_sim.c6
-rw-r--r--src/partialator.c3
-rw-r--r--src/pattern_sim.c3
-rw-r--r--src/process_hkl.c3
-rw-r--r--src/whirligig.c3
11 files changed, 26 insertions, 58 deletions
diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c
index 5b4b777b..2df1bb72 100644
--- a/libcrystfel/src/stream.c
+++ b/libcrystfel/src/stream.c
@@ -619,9 +619,6 @@ int stream_write_chunk(Stream *st, const struct image *i,
char *indexer;
int ret = 0;
- if ( srf & STREAM_REFLECTIONS ) srf |= STREAM_CRYSTALS;
- if ( srf & STREAM_UNITCELL ) srf |= STREAM_CRYSTALS;
-
fprintf(st->fh, STREAM_CHUNK_START_MARKER"\n");
fprintf(st->fh, "Image filename: %s\n", i->filename);
@@ -666,14 +663,12 @@ int stream_write_chunk(Stream *st, const struct image *i,
ret = write_peaks(i, st->dtempl, st->fh);
}
- if ( srf & STREAM_CRYSTALS ) {
- for ( j=0; j<i->n_crystals; j++ ) {
- if ( crystal_get_user_flag(i->crystals[j]) ) {
- continue;
- }
- ret = write_crystal(st, i->crystals[j],
- srf & STREAM_REFLECTIONS);
+ for ( j=0; j<i->n_crystals; j++ ) {
+ if ( crystal_get_user_flag(i->crystals[j]) ) {
+ continue;
}
+ ret = write_crystal(st, i->crystals[j],
+ srf & STREAM_REFLECTIONS);
}
fprintf(st->fh, STREAM_CHUNK_END_MARKER"\n");
@@ -755,29 +750,25 @@ static void read_crystal(Stream *st, struct image *image,
if ( rval == NULL ) break;
chomp(line);
- if ( (srf & STREAM_UNITCELL)
- && (sscanf(line, "astar = %f %f %f", &u, &v, &w) == 3) )
+ if ( sscanf(line, "astar = %f %f %f", &u, &v, &w) == 3 )
{
as.u = u*1e9; as.v = v*1e9; as.w = w*1e9;
have_as = 1;
}
- if ( (srf & STREAM_UNITCELL)
- && (sscanf(line, "bstar = %f %f %f", &u, &v, &w) == 3) )
+ if ( sscanf(line, "bstar = %f %f %f", &u, &v, &w) == 3 )
{
bs.u = u*1e9; bs.v = v*1e9; bs.w = w*1e9;
have_bs = 1;
}
- if ( (srf & STREAM_UNITCELL)
- && (sscanf(line, "cstar = %f %f %f", &u, &v, &w) == 3) )
+ if ( sscanf(line, "cstar = %f %f %f", &u, &v, &w) == 3 )
{
cs.u = u*1e9; cs.v = v*1e9; cs.w = w*1e9;
have_cs = 1;
}
- if ( (srf & STREAM_UNITCELL)
- && (sscanf(line, "centering = %c", &c) == 1) )
+ if ( sscanf(line, "centering = %c", &c) == 1 )
{
if ( !have_cen ) {
centering = c;
@@ -788,8 +779,7 @@ static void read_crystal(Stream *st, struct image *image,
}
}
- if ( (srf & STREAM_UNITCELL)
- && (sscanf(line, "unique_axis = %c", &c) == 1) )
+ if ( sscanf(line, "unique_axis = %c", &c) == 1 )
{
if ( !have_ua ) {
unique_axis = c;
@@ -800,8 +790,7 @@ static void read_crystal(Stream *st, struct image *image,
}
}
- if ( (srf & STREAM_UNITCELL)
- && (strncmp(line, "lattice_type = ", 15) == 0) )
+ if ( strncmp(line, "lattice_type = ", 15) == 0 )
{
if ( !have_latt ) {
lattice_type = lattice_from_str(line+15);
@@ -926,10 +915,6 @@ struct image *stream_read_chunk(Stream *st, StreamFlags srf)
image = image_new();
if ( image == NULL ) return NULL;
- if ( (srf & STREAM_REFLECTIONS) || (srf & STREAM_UNITCELL) ) {
- srf |= STREAM_CRYSTALS;
- }
-
do {
int ser;
float div, bw;
@@ -997,8 +982,7 @@ struct image *stream_read_chunk(Stream *st, StreamFlags srf)
}
- if ( (srf & STREAM_CRYSTALS)
- && (strcmp(line, STREAM_CRYSTAL_START_MARKER) == 0) ) {
+ if ( strcmp(line, STREAM_CRYSTAL_START_MARKER) == 0 ) {
read_crystal(st, image, srf);
}
diff --git a/libcrystfel/src/stream.h b/libcrystfel/src/stream.h
index 9e92b35a..7bb1b6ab 100644
--- a/libcrystfel/src/stream.h
+++ b/libcrystfel/src/stream.h
@@ -61,26 +61,20 @@ typedef struct _stream Stream;
/**
* A bitfield of things that can be read from or written to a stream.
- * Use this (and \ref read_chunk) to read the stream faster if you
- * don't need the entire contents of the stream.
+ * Use this together with stream_{read,write}_chunk to read/write the
+ * stream faster if you don't need all the information.
*
- * Using either of \p STREAM_REFLECTIONS or * \p STREAM_UNITCELL
- * implies \p STREAM_CRYSTALS.
+ * General information about crystals (including unit cell parameters)
+ * is always read and written.
**/
typedef enum {
- /** Read the unit cell */
- STREAM_UNITCELL = 1,
-
/** Read the integrated reflections */
STREAM_REFLECTIONS = 2,
/** Read the peak search results */
STREAM_PEAKS = 4,
- /** Read the general information about crystals */
- STREAM_CRYSTALS = 8,
-
/** Read the image data */
STREAM_IMAGE_DATA = 16,
diff --git a/src/ambigator.c b/src/ambigator.c
index c3afd6c1..c14b1051 100644
--- a/src/ambigator.c
+++ b/src/ambigator.c
@@ -1259,8 +1259,7 @@ int main(int argc, char *argv[])
struct image *image;
int i;
- image = stream_read_chunk(st, STREAM_UNITCELL
- | STREAM_REFLECTIONS);
+ image = stream_read_chunk(st, STREAM_REFLECTIONS);
if ( image == NULL ) break;
image_feature_list_free(image->features);
diff --git a/src/cell_explorer.c b/src/cell_explorer.c
index 84a8aa16..9d4cdeec 100644
--- a/src/cell_explorer.c
+++ b/src/cell_explorer.c
@@ -2002,7 +2002,7 @@ int main(int argc, char *argv[])
struct image *image;
int i;
- image = stream_read_chunk(st, STREAM_UNITCELL);
+ image = stream_read_chunk(st, 0);
if ( image == NULL ) break;
for ( i=0; i<image->n_crystals; i++ ) {
diff --git a/src/crystfel_gui.c b/src/crystfel_gui.c
index 7f4f29f0..3d07f35b 100644
--- a/src/crystfel_gui.c
+++ b/src/crystfel_gui.c
@@ -145,10 +145,8 @@ static void update_imageview(struct crystfelproject *proj)
}
image = stream_read_chunk(proj->stream,
- STREAM_UNITCELL
- | STREAM_REFLECTIONS
+ STREAM_REFLECTIONS
| STREAM_PEAKS
- | STREAM_CRYSTALS
| STREAM_IMAGE_DATA);
if ( image == NULL ) {
diff --git a/src/indexamajig.c b/src/indexamajig.c
index 15315952..774a7ffc 100644
--- a/src/indexamajig.c
+++ b/src/indexamajig.c
@@ -650,8 +650,7 @@ int main(int argc, char *argv[])
args.iargs.ir_out = -1.0;
args.iargs.use_saturated = 1;
args.iargs.no_revalidate = 0;
- args.iargs.stream_flags = STREAM_PEAKS | STREAM_REFLECTIONS
- | STREAM_CRYSTALS | STREAM_UNITCELL;
+ args.iargs.stream_flags = STREAM_PEAKS | STREAM_REFLECTIONS;
args.iargs.stream_nonhits = 1;
args.iargs.int_diag = INTDIAG_NONE;
args.iargs.min_peaks = 0;
diff --git a/src/partial_sim.c b/src/partial_sim.c
index a0f60e1e..85222dd2 100644
--- a/src/partial_sim.c
+++ b/src/partial_sim.c
@@ -346,7 +346,7 @@ static void *create_job(void *vqargs)
struct image *image;
image = stream_read_chunk(qargs->template_stream,
- STREAM_UNITCELL | STREAM_REFLECTIONS);
+ STREAM_REFLECTIONS);
if ( image == NULL ) {
ERROR("Failed to read template chunk!\n");
return NULL;
@@ -473,9 +473,7 @@ static void finalise_job(void *vqargs, void *vwargs)
int ret;
ret = stream_write_chunk(qargs->stream, wargs->image,
- STREAM_UNITCELL
- | STREAM_REFLECTIONS
- | STREAM_CRYSTALS);
+ STREAM_REFLECTIONS);
if ( ret != 0 ) {
ERROR("WARNING: error writing stream file.\n");
}
diff --git a/src/partialator.c b/src/partialator.c
index 1a28e3f3..40c7c4eb 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -1405,8 +1405,7 @@ int main(int argc, char *argv[])
RefList *as;
int i;
- image = stream_read_chunk(st, STREAM_REFLECTIONS
- | STREAM_UNITCELL);
+ image = stream_read_chunk(st, STREAM_REFLECTIONS);
if ( image == NULL ) break;
if ( isnan(image->div) || isnan(image->bw) ) {
diff --git a/src/pattern_sim.c b/src/pattern_sim.c
index b83677b7..b6988dea 100644
--- a/src/pattern_sim.c
+++ b/src/pattern_sim.c
@@ -1049,8 +1049,7 @@ int main(int argc, char *argv[])
Crystal *cr;
/* Get data from next chunk */
- templ_image = stream_read_chunk(st,
- STREAM_CRYSTALS);
+ templ_image = stream_read_chunk(st, 0);
if ( templ_image == NULL ) break;
if ( templ_image->n_crystals == 0 ) continue;
diff --git a/src/process_hkl.c b/src/process_hkl.c
index 812903a2..440ad3ee 100644
--- a/src/process_hkl.c
+++ b/src/process_hkl.c
@@ -432,8 +432,7 @@ static int merge_all(Stream *st,
/* Get data from next chunk */
image = stream_read_chunk(st,
- STREAM_REFLECTIONS
- | STREAM_UNITCELL);
+ STREAM_REFLECTIONS);
if ( image == NULL ) break;
n_images++;
diff --git a/src/whirligig.c b/src/whirligig.c
index 0d5a2f0d..cac51902 100644
--- a/src/whirligig.c
+++ b/src/whirligig.c
@@ -720,8 +720,7 @@ int main(int argc, char *argv[])
struct image *image;
- image = stream_read_chunk(st, STREAM_REFLECTIONS
- | STREAM_UNITCELL);
+ image = stream_read_chunk(st, STREAM_REFLECTIONS);
if ( image == NULL ) break;