Commit b8ac0fae authored by Thomas White's avatar Thomas White
Browse files

WIP on new stream format in process_hkl

parent be49b97c
......@@ -42,10 +42,10 @@ tests_gpu_sim_check_SOURCES = tests/gpu_sim_check.c src/utils.c \
endif
src_process_hkl_SOURCES = src/process_hkl.c src/sfac.c src/statistics.c \
src/cell.c src/utils.c src/reflections.c \
src/cell.c src/utils.c \
src/symmetry.c src/stream.c src/beam-parameters.c \
src/thread-pool.c src/image.c src/detector.c \
src/hdf5-file.c src/reflist.c
src/hdf5-file.c src/reflist.c src/reflist-utils.c
src_indexamajig_SOURCES = src/indexamajig.c src/hdf5-file.c src/utils.c \
src/cell.c src/image.c src/peaks.c src/index.c \
......@@ -53,7 +53,8 @@ src_indexamajig_SOURCES = src/indexamajig.c src/hdf5-file.c src/utils.c \
src/sfac.c src/dirax.c src/mosflm.c \
src/reflections.c src/symmetry.c \
src/geometry.c src/thread-pool.c \
src/beam-parameters.c src/reflist.c src/stream.c
src/beam-parameters.c src/reflist.c src/stream.c \
src/reflist-utils.c
if HAVE_OPENCL
src_indexamajig_SOURCES += src/diffraction-gpu.c src/cl-utils.c
endif
......@@ -99,18 +100,19 @@ src_partialator_SOURCES = src/partialator.c src/cell.c src/hdf5-file.c \
src/geometry.c src/reflections.c src/stream.c \
src/thread-pool.c src/beam-parameters.c \
src/symmetry.c src/post-refinement.c \
src/hrs-scaling.c src/reflist.c
src/hrs-scaling.c src/reflist.c src/reflist-utils.c
if BUILD_CUBEIT
src_cubeit_SOURCES = src/cubeit.c src/cell.c src/hdf5-file.c src/utils.c \
src/detector.c src/render.c src/filters.c src/image.c \
src/symmetry.c src/stream.c src/thread-pool.c src/reflist.c
src/symmetry.c src/stream.c src/thread-pool.c \
src/reflist.c src/reflist-utils.c
endif
src_estimate_background_SOURCES = src/estimate_background.c src/stream.c \
src/utils.c src/cell.c src/thread-pool.c \
src/image.c src/detector.c src/hdf5-file.c \
src/reflist.c
src/reflist.c src/reflist-utils.c
tests_list_check_SOURCES = tests/list_check.c src/reflist.c src/thread-pool.c \
src/utils.c
......
......@@ -107,7 +107,7 @@ src_compare_hkl_DEPENDENCIES = $(top_builddir)/lib/libgnu.a
am__src_cubeit_SOURCES_DIST = src/cubeit.c src/cell.c src/hdf5-file.c \
src/utils.c src/detector.c src/render.c src/filters.c \
src/image.c src/symmetry.c src/stream.c src/thread-pool.c \
src/reflist.c
src/reflist.c src/reflist-utils.c
@BUILD_CUBEIT_TRUE@am_src_cubeit_OBJECTS = src/cubeit.$(OBJEXT) \
@BUILD_CUBEIT_TRUE@ src/cell.$(OBJEXT) src/hdf5-file.$(OBJEXT) \
@BUILD_CUBEIT_TRUE@ src/utils.$(OBJEXT) src/detector.$(OBJEXT) \
......@@ -115,7 +115,8 @@ am__src_cubeit_SOURCES_DIST = src/cubeit.c src/cell.c src/hdf5-file.c \
@BUILD_CUBEIT_TRUE@ src/image.$(OBJEXT) src/symmetry.$(OBJEXT) \
@BUILD_CUBEIT_TRUE@ src/stream.$(OBJEXT) \
@BUILD_CUBEIT_TRUE@ src/thread-pool.$(OBJEXT) \
@BUILD_CUBEIT_TRUE@ src/reflist.$(OBJEXT)
@BUILD_CUBEIT_TRUE@ src/reflist.$(OBJEXT) \
@BUILD_CUBEIT_TRUE@ src/reflist-utils.$(OBJEXT)
src_cubeit_OBJECTS = $(am_src_cubeit_OBJECTS)
src_cubeit_LDADD = $(LDADD)
src_cubeit_DEPENDENCIES = $(top_builddir)/lib/libgnu.a
......@@ -124,7 +125,7 @@ am_src_estimate_background_OBJECTS = \
src/utils.$(OBJEXT) src/cell.$(OBJEXT) \
src/thread-pool.$(OBJEXT) src/image.$(OBJEXT) \
src/detector.$(OBJEXT) src/hdf5-file.$(OBJEXT) \
src/reflist.$(OBJEXT)
src/reflist.$(OBJEXT) src/reflist-utils.$(OBJEXT)
src_estimate_background_OBJECTS = \
$(am_src_estimate_background_OBJECTS)
src_estimate_background_LDADD = $(LDADD)
......@@ -154,8 +155,8 @@ am__src_indexamajig_SOURCES_DIST = src/indexamajig.c src/hdf5-file.c \
src/filters.c src/diffraction.c src/detector.c src/sfac.c \
src/dirax.c src/mosflm.c src/reflections.c src/symmetry.c \
src/geometry.c src/thread-pool.c src/beam-parameters.c \
src/reflist.c src/stream.c src/diffraction-gpu.c \
src/cl-utils.c
src/reflist.c src/stream.c src/reflist-utils.c \
src/diffraction-gpu.c src/cl-utils.c
@HAVE_OPENCL_TRUE@am__objects_1 = src/diffraction-gpu.$(OBJEXT) \
@HAVE_OPENCL_TRUE@ src/cl-utils.$(OBJEXT)
am_src_indexamajig_OBJECTS = src/indexamajig.$(OBJEXT) \
......@@ -166,7 +167,8 @@ am_src_indexamajig_OBJECTS = src/indexamajig.$(OBJEXT) \
src/mosflm.$(OBJEXT) src/reflections.$(OBJEXT) \
src/symmetry.$(OBJEXT) src/geometry.$(OBJEXT) \
src/thread-pool.$(OBJEXT) src/beam-parameters.$(OBJEXT) \
src/reflist.$(OBJEXT) src/stream.$(OBJEXT) $(am__objects_1)
src/reflist.$(OBJEXT) src/stream.$(OBJEXT) \
src/reflist-utils.$(OBJEXT) $(am__objects_1)
src_indexamajig_OBJECTS = $(am_src_indexamajig_OBJECTS)
src_indexamajig_LDADD = $(LDADD)
src_indexamajig_DEPENDENCIES = $(top_builddir)/lib/libgnu.a
......@@ -177,7 +179,7 @@ am_src_partialator_OBJECTS = src/partialator.$(OBJEXT) \
src/stream.$(OBJEXT) src/thread-pool.$(OBJEXT) \
src/beam-parameters.$(OBJEXT) src/symmetry.$(OBJEXT) \
src/post-refinement.$(OBJEXT) src/hrs-scaling.$(OBJEXT) \
src/reflist.$(OBJEXT)
src/reflist.$(OBJEXT) src/reflist-utils.$(OBJEXT)
src_partialator_OBJECTS = $(am_src_partialator_OBJECTS)
src_partialator_LDADD = $(LDADD)
src_partialator_DEPENDENCIES = $(top_builddir)/lib/libgnu.a
......@@ -205,11 +207,11 @@ src_powder_plot_LDADD = $(LDADD)
src_powder_plot_DEPENDENCIES = $(top_builddir)/lib/libgnu.a
am_src_process_hkl_OBJECTS = src/process_hkl.$(OBJEXT) \
src/sfac.$(OBJEXT) src/statistics.$(OBJEXT) src/cell.$(OBJEXT) \
src/utils.$(OBJEXT) src/reflections.$(OBJEXT) \
src/symmetry.$(OBJEXT) src/stream.$(OBJEXT) \
src/beam-parameters.$(OBJEXT) src/thread-pool.$(OBJEXT) \
src/image.$(OBJEXT) src/detector.$(OBJEXT) \
src/hdf5-file.$(OBJEXT) src/reflist.$(OBJEXT)
src/utils.$(OBJEXT) src/symmetry.$(OBJEXT) \
src/stream.$(OBJEXT) src/beam-parameters.$(OBJEXT) \
src/thread-pool.$(OBJEXT) src/image.$(OBJEXT) \
src/detector.$(OBJEXT) src/hdf5-file.$(OBJEXT) \
src/reflist.$(OBJEXT) src/reflist-utils.$(OBJEXT)
src_process_hkl_OBJECTS = $(am_src_process_hkl_OBJECTS)
src_process_hkl_LDADD = $(LDADD)
src_process_hkl_DEPENDENCIES = $(top_builddir)/lib/libgnu.a
......@@ -612,17 +614,17 @@ src_pattern_sim_SOURCES = src/pattern_sim.c src/diffraction.c \
@HAVE_OPENCL_TRUE@ src/image.c
src_process_hkl_SOURCES = src/process_hkl.c src/sfac.c src/statistics.c \
src/cell.c src/utils.c src/reflections.c \
src/cell.c src/utils.c \
src/symmetry.c src/stream.c src/beam-parameters.c \
src/thread-pool.c src/image.c src/detector.c \
src/hdf5-file.c src/reflist.c
src/hdf5-file.c src/reflist.c src/reflist-utils.c
src_indexamajig_SOURCES = src/indexamajig.c src/hdf5-file.c \
src/utils.c src/cell.c src/image.c src/peaks.c src/index.c \
src/filters.c src/diffraction.c src/detector.c src/sfac.c \
src/dirax.c src/mosflm.c src/reflections.c src/symmetry.c \
src/geometry.c src/thread-pool.c src/beam-parameters.c \
src/reflist.c src/stream.c $(am__append_6)
src/reflist.c src/stream.c src/reflist-utils.c $(am__append_6)
@BUILD_HDFSEE_TRUE@src_hdfsee_SOURCES = src/hdfsee.c src/dw-hdfsee.c src/render.c \
@BUILD_HDFSEE_TRUE@ src/hdf5-file.c src/utils.c src/image.c src/filters.c \
@BUILD_HDFSEE_TRUE@ src/thread-pool.c src/detector.c
......@@ -661,16 +663,17 @@ src_partialator_SOURCES = src/partialator.c src/cell.c src/hdf5-file.c \
src/geometry.c src/reflections.c src/stream.c \
src/thread-pool.c src/beam-parameters.c \
src/symmetry.c src/post-refinement.c \
src/hrs-scaling.c src/reflist.c
src/hrs-scaling.c src/reflist.c src/reflist-utils.c
@BUILD_CUBEIT_TRUE@src_cubeit_SOURCES = src/cubeit.c src/cell.c src/hdf5-file.c src/utils.c \
@BUILD_CUBEIT_TRUE@ src/detector.c src/render.c src/filters.c src/image.c \
@BUILD_CUBEIT_TRUE@ src/symmetry.c src/stream.c src/thread-pool.c src/reflist.c
@BUILD_CUBEIT_TRUE@ src/symmetry.c src/stream.c src/thread-pool.c \
@BUILD_CUBEIT_TRUE@ src/reflist.c src/reflist-utils.c
src_estimate_background_SOURCES = src/estimate_background.c src/stream.c \
src/utils.c src/cell.c src/thread-pool.c \
src/image.c src/detector.c src/hdf5-file.c \
src/reflist.c
src/reflist.c src/reflist-utils.c
tests_list_check_SOURCES = tests/list_check.c src/reflist.c src/thread-pool.c \
src/utils.c
......@@ -851,6 +854,8 @@ src/stream.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/reflist.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/reflist-utils.$(OBJEXT): src/$(am__dirstamp) \
src/$(DEPDIR)/$(am__dirstamp)
src/cubeit$(EXEEXT): $(src_cubeit_OBJECTS) $(src_cubeit_DEPENDENCIES) src/$(am__dirstamp)
@rm -f src/cubeit$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(src_cubeit_OBJECTS) $(src_cubeit_LDADD) $(LIBS)
......@@ -977,6 +982,7 @@ mostlyclean-compile:
-rm -f src/powder_plot.$(OBJEXT)
-rm -f src/process_hkl.$(OBJEXT)
-rm -f src/reflections.$(OBJEXT)
-rm -f src/reflist-utils.$(OBJEXT)
-rm -f src/reflist.$(OBJEXT)
-rm -f src/render.$(OBJEXT)
-rm -f src/render_hkl.$(OBJEXT)
......@@ -1024,6 +1030,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/powder_plot.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/process_hkl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/reflections.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/reflist-utils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/reflist.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/render.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/render_hkl.Po@am__quote@
......
This diff is collapsed.
/*
* reflist-utils.c
*
* Utilities to complement the core reflist.c
*
* (c) 2006-2011 Thomas White <taw@physics.org>
*
* Part of CrystFEL - crystallography with a FEL
*
*/
#include <stdio.h>
#include "reflist.h"
#include "cell.h"
void write_reflections_to_file(FILE *fh, RefList *list, UnitCell *cell)
{
Reflection *refl;
RefListIterator *iter;
fprintf(fh, " h k l I phase sigma(I) "
" 1/d(nm^-1) counts fs/px ss/px\n");
for ( refl = first_refl(list, &iter);
refl != NULL;
refl = next_refl(refl, iter) ) {
signed int h, k, l;
double intensity, esd_i, s;
double fs, ss;
get_indices(refl, &h, &k, &l);
get_detector_pos(refl, &fs, &ss);
intensity = get_intensity(refl);
esd_i = 0.0; /* FIXME! */
s = 0.0; /* FIXME! */
/* h, k, l, I, sigma(I), s */
fprintf(fh,
"%3i %3i %3i %10.2f %s %10.2f %10.2f %7i %6.1f %6.1f\n",
h, k, l, intensity, " -", esd_i, s/1.0e9, 1,
fs, ss);
}
}
int write_reflist(const char *filename, RefList *list, UnitCell *cell)
{
FILE *fh;
if ( filename == NULL ) {
fh = stdout;
} else {
fh = fopen(filename, "w");
}
if ( fh == NULL ) {
ERROR("Couldn't open output file '%s'.\n", filename);
return 1;
}
write_reflections_to_file(fh, list, cell);
fclose(fh);
return 0;
}
/*
* reflist-utils.h
*
* Utilities to complement the core reflist.c
*
* (c) 2006-2011 Thomas White <taw@physics.org>
*
* Part of CrystFEL - crystallography with a FEL
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef REFLIST_UTILS_H
#define REFLIST_UTILS_H
#include "reflist.h"
#include "cell.h"
extern void write_reflections_to_file(FILE *fh, RefList *list, UnitCell *cell);
extern int write_reflist(const char *filename, RefList *list,
UnitCell *cell);
#endif /* REFLIST_UTILS_H */
......@@ -45,6 +45,13 @@ struct _refldata {
/* Intensity */
double intensity;
double esd_i;
/* Redundancy */
int redundancy;
/* Total squared difference between all estimates of this reflection
* and the estimated mean value */
double sum_squared_dev;
};
......@@ -225,6 +232,24 @@ int get_scalable(Reflection *refl)
}
int get_redundancy(Reflection *refl)
{
return refl->data.redundancy;
}
double get_sum_squared_dev(Reflection *refl)
{
return refl->data.sum_squared_dev;
}
double get_esd_intensity(Reflection *refl)
{
return refl->data.esd_i;
}
/********************************** Setters ***********************************/
void set_detector_pos(Reflection *refl, double exerr, double x, double y)
......@@ -258,6 +283,24 @@ void set_scalable(Reflection *refl, int scalable)
}
void set_redundancy(Reflection *refl, int red)
{
refl->data.redundancy = red;
}
void set_sum_squared_dev(Reflection *refl, double dev)
{
refl->data.sum_squared_dev = dev;
}
void set_esd_intensity(Reflection *refl, double esd)
{
refl->data.esd_i = esd;
}
/********************************* Insertion **********************************/
static void insert_node(Reflection *head, Reflection *new)
......
......@@ -41,6 +41,9 @@ extern double get_intensity(Reflection *refl);
extern void get_partial(Reflection *refl, double *r1, double *r2, double *p,
int *clamp_low, int *clamp_high);
extern int get_scalable(Reflection *refl);
extern int get_redundancy(Reflection *refl);
extern double get_sum_squared_dev(Reflection *refl);
extern double get_esd_intensity(Reflection *refl);
/* Set */
extern void set_detector_pos(Reflection *refl, double exerr,
......@@ -49,6 +52,9 @@ extern void set_partial(Reflection *refl, double r1, double r2, double p,
double clamp_low, double clamp_high);
extern void set_int(Reflection *refl, double intensity);
extern void set_scalable(Reflection *refl, int scalable);
extern void set_redundancy(Reflection *refl, int red);
extern void set_sum_squared_dev(Reflection *refl, double dev);
extern void set_esd_intensity(Reflection *refl, double esd);
/* Insertion */
extern Reflection *add_refl(RefList *list, INDICES);
......
......@@ -23,6 +23,7 @@
#include "image.h"
#include "stream.h"
#include "reflist.h"
#include "reflist-utils.h"
#define CHUNK_START_MARKER "----- Begin chunk -----"
......@@ -32,7 +33,6 @@
#define REFLECTION_START_MARKER "Reflections measured after indexing"
#define REFLECTION_END_MARKER "End of reflections"
static void exclusive(const char *a, const char *b)
{
ERROR("The stream options '%s' and '%s' are mutually exclusive.\n",
......@@ -103,10 +103,9 @@ int count_patterns(FILE *fh)
rval = fgets(line, 1023, fh);
if ( rval == NULL ) continue;
if ( (strncmp(line, "Reflections from indexing", 25) == 0)
|| (strncmp(line, "New pattern", 11) == 0) ) {
n_total_patterns++;
}
chomp(line);
if ( strcmp(line, CHUNK_END_MARKER) == 0 ) n_total_patterns++;
} while ( rval != NULL );
return n_total_patterns;
......@@ -147,6 +146,7 @@ static UnitCell *read_orientation_matrix(FILE *fh)
static int read_reflections(FILE *fh, struct image *image)
{
char *rval = NULL;
int first = 1;
image->reflections = reflist_new();
......@@ -164,17 +164,20 @@ static int read_reflections(FILE *fh, struct image *image)
if ( rval == NULL ) continue;
chomp(line);
if ( strcmp(line, PEAK_LIST_END_MARKER) == 0 ) return 0;
if ( strcmp(line, REFLECTION_END_MARKER) == 0 ) return 0;
r = sscanf(line, "%i %i %i %f %s %f %f %i %f %f",
&h, &k, &l, &intensity, phs, &sigma, &res, &cts,
&fs, &ss);
if ( r != 10 ) return 1;
refl = add_refl(image->reflections, h, k, l);
set_int(refl, intensity);
set_detector_pos(refl, fs, ss, 0.0);
/* FIXME: Set ESD */
if ( (r != 10) && (!first) ) return 1;
first = 0;
if ( r == 10 ) {
refl = add_refl(image->reflections, h, k, l);
set_int(refl, intensity);
set_detector_pos(refl, fs, ss, 0.0);
set_esd_intensity(refl, sigma);
}
} while ( rval != NULL );
......@@ -184,45 +187,10 @@ static int read_reflections(FILE *fh, struct image *image)
}
static void write_reflections(struct image *image, FILE *ofh)
{
Reflection *refl;
RefListIterator *iter;
fprintf(ofh, REFLECTION_START_MARKER"\n");
/* FIXME: Unify this with write_reflections() over in reflections.c */
fprintf(ofh, " h k l I phase sigma(I) "
" 1/d(nm^-1) counts fs/px ss/px\n");
for ( refl = first_refl(image->reflections, &iter);
refl != NULL;
refl = next_refl(refl, iter) ) {
signed int h, k, l;
double intensity, esd_i, s;
double fs, ss;
get_indices(refl, &h, &k, &l);
get_detector_pos(refl, &fs, &ss);
intensity = get_intensity(refl);
esd_i = 0.0; /* FIXME! */
s = 0.0; /* FIXME! */
/* h, k, l, I, sigma(I), s */
fprintf(ofh,
"%3i %3i %3i %10.2f %s %10.2f %10.2f %7i %6.1f %6.1f\n",
h, k, l, intensity, " -", esd_i, s/1.0e9, 1,
fs, ss);
}
fprintf(ofh, REFLECTION_END_MARKER"\n");
}
static int read_peaks(FILE *fh, struct image *image)
{
char *rval = NULL;
int first = 1;
image->features = image_feature_list_new();
......@@ -239,9 +207,17 @@ static int read_peaks(FILE *fh, struct image *image)
if ( strcmp(line, PEAK_LIST_END_MARKER) == 0 ) return 0;
r = sscanf(line, "%f %f %f %f", &x, &y, &d, &intensity);
if ( r != 4 ) return 1;
if ( (r != 4) && (!first) ) {
ERROR("Failed to parse peak list line.\n");
ERROR("The failed line was: '%s'\n", line);
return 1;
}
image_add_feature(image->features, x, y, image, 1.0, NULL);
first = 0;
if ( r == 4 ) {
image_add_feature(image->features, x, y,
image, 1.0, NULL);
}
} while ( rval != NULL );
......@@ -255,7 +231,7 @@ static void write_peaks(struct image *image, FILE *ofh)
int i;
fprintf(ofh, PEAK_LIST_START_MARKER"\n");
fprintf(ofh, " fs/px ss/px (1/d)/nm^-1 Intensity\n");
fprintf(ofh, " fs/px ss/px (1/d)/nm^-1 Intensity\n");
for ( i=0; i<image_feature_count(image->features); i++ ) {
......@@ -269,7 +245,7 @@ static void write_peaks(struct image *image, FILE *ofh)
r = get_q(image, f->fs, f->ss, NULL, 1.0/image->lambda);
q = modulus(r.u, r.v, r.w);
fprintf(ofh, "%8.3f %8.3f %8.3f %12.3f\n",
fprintf(ofh, "%6.1f %6.1f %10.2f %10.2f\n",
f->fs, f->ss, q/1.0e9, f->intensity);
}
......@@ -330,8 +306,12 @@ void write_chunk(FILE *ofh, struct image *i, int f)
}
if ( (f & STREAM_PIXELS) || (f & STREAM_INTEGRATED) ) {
fprintf(ofh, "\n");
write_reflections(i, ofh);
fprintf(ofh, REFLECTION_START_MARKER"\n");
write_reflections_to_file(ofh, i->reflections, i->indexed_cell);
fprintf(ofh, REFLECTION_END_MARKER"\n");
}
fprintf(ofh, CHUNK_END_MARKER"\n\n");
......@@ -374,10 +354,11 @@ int read_chunk(FILE *fh, struct image *image)
if ( find_start_of_chunk(fh) ) return 1;
image->i0_available = 0;
if ( image->features != NULL ) {
image_feature_list_free(image->features);
image->features = NULL;
}
image->i0 = 1.0;
image->lambda = -1.0;
image->features = NULL;
image->reflections = NULL;
image->indexed_cell = NULL;
do {
......@@ -426,16 +407,22 @@ int read_chunk(FILE *fh, struct image *image)
}
if ( strcmp(line, PEAK_LIST_START_MARKER) == 0 ) {
if ( read_peaks(fh, image) ) return 1;
if ( read_peaks(fh, image) ) {
ERROR("Failed while reading peaks\n");
return 1;
}
}
if ( strcmp(line, REFLECTION_START_MARKER) == 0 ) {
if ( read_reflections(fh, image) ) return 1;
if ( read_reflections(fh, image) ) {
ERROR("Failed while reading reflections\n");
return 1;
}
}
} while ( strcmp(line, CHUNK_END_MARKER) != 0 );
if ( have_filename && have_cell && have_ev ) return 0;
if ( have_filename && have_ev ) return 0;
ERROR("Incomplete chunk found in input file.\n");
return 1;
......@@ -496,3 +483,24 @@ int find_chunk(FILE *fh, UnitCell **cell, char **filename, double *ev)
return 1;
}
int skip_some_files(FILE *fh, int n)
{
char *rval = NULL;
int n_patterns = 0;
do {
char line[1024];
if ( n_patterns == n ) return 0;
rval = fgets(line, 1023, fh);
if ( rval == NULL ) continue;
if ( strcmp(line, CHUNK_END_MARKER) == 0 ) n_patterns++;
} while ( rval != NULL );
return 1;
}
......@@ -38,4 +38,8 @@ extern void write_chunk(FILE *ofh, struct image *image, int flags);
extern int parse_stream_flags(const char *a);
extern int read_chunk(FILE *fh, struct image *image);
extern int skip_some_files(FILE *fh, int n);
#endif /* STREAM_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment