diff options
-rw-r--r-- | Makefile.am | 7 | ||||
-rw-r--r-- | Makefile.in | 42 | ||||
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | src/estimate_background.c | 231 |
4 files changed, 10 insertions, 273 deletions
diff --git a/Makefile.am b/Makefile.am index f7437acc..738c8949 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ ACLOCAL_AMFLAGS = -I m4 bin_PROGRAMS = src/pattern_sim src/process_hkl src/get_hkl src/indexamajig \ src/compare_hkl src/powder_plot src/render_hkl \ src/calibrate_detector src/partialator \ - src/estimate_background src/check_hkl src/sum_stack + src/check_hkl src/sum_stack noinst_PROGRAMS = tests/list_check @@ -109,11 +109,6 @@ src_cubeit_SOURCES = src/cubeit.c src/cell.c src/hdf5-file.c src/utils.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-utils.c - tests_list_check_SOURCES = tests/list_check.c src/reflist.c src/thread-pool.c \ src/utils.c diff --git a/Makefile.in b/Makefile.in index 402094df..499a2447 100644 --- a/Makefile.in +++ b/Makefile.in @@ -39,9 +39,8 @@ bin_PROGRAMS = src/pattern_sim$(EXEEXT) src/process_hkl$(EXEEXT) \ src/get_hkl$(EXEEXT) src/indexamajig$(EXEEXT) \ src/compare_hkl$(EXEEXT) src/powder_plot$(EXEEXT) \ src/render_hkl$(EXEEXT) src/calibrate_detector$(EXEEXT) \ - src/partialator$(EXEEXT) src/estimate_background$(EXEEXT) \ - src/check_hkl$(EXEEXT) src/sum_stack$(EXEEXT) $(am__EXEEXT_1) \ - $(am__EXEEXT_2) + src/partialator$(EXEEXT) src/check_hkl$(EXEEXT) \ + src/sum_stack$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2) noinst_PROGRAMS = tests/list_check$(EXEEXT) $(am__EXEEXT_3) TESTS = tests/list_check$(EXEEXT) $(am__EXEEXT_3) @BUILD_HDFSEE_TRUE@am__append_1 = src/hdfsee @@ -120,16 +119,6 @@ am__src_cubeit_SOURCES_DIST = src/cubeit.c src/cell.c src/hdf5-file.c \ src_cubeit_OBJECTS = $(am_src_cubeit_OBJECTS) src_cubeit_LDADD = $(LDADD) src_cubeit_DEPENDENCIES = $(top_builddir)/lib/libgnu.a -am_src_estimate_background_OBJECTS = \ - src/estimate_background.$(OBJEXT) src/stream.$(OBJEXT) \ - 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-utils.$(OBJEXT) -src_estimate_background_OBJECTS = \ - $(am_src_estimate_background_OBJECTS) -src_estimate_background_LDADD = $(LDADD) -src_estimate_background_DEPENDENCIES = $(top_builddir)/lib/libgnu.a am_src_get_hkl_OBJECTS = src/get_hkl.$(OBJEXT) src/sfac.$(OBJEXT) \ src/cell.$(OBJEXT) src/utils.$(OBJEXT) \ src/reflections.$(OBJEXT) src/symmetry.$(OBJEXT) \ @@ -277,16 +266,15 @@ am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(src_calibrate_detector_SOURCES) $(src_check_hkl_SOURCES) \ $(src_compare_hkl_SOURCES) $(src_cubeit_SOURCES) \ - $(src_estimate_background_SOURCES) $(src_get_hkl_SOURCES) \ - $(src_hdfsee_SOURCES) $(src_indexamajig_SOURCES) \ - $(src_partialator_SOURCES) $(src_pattern_sim_SOURCES) \ - $(src_powder_plot_SOURCES) $(src_process_hkl_SOURCES) \ - $(src_render_hkl_SOURCES) $(src_sum_stack_SOURCES) \ - $(tests_gpu_sim_check_SOURCES) $(tests_list_check_SOURCES) + $(src_get_hkl_SOURCES) $(src_hdfsee_SOURCES) \ + $(src_indexamajig_SOURCES) $(src_partialator_SOURCES) \ + $(src_pattern_sim_SOURCES) $(src_powder_plot_SOURCES) \ + $(src_process_hkl_SOURCES) $(src_render_hkl_SOURCES) \ + $(src_sum_stack_SOURCES) $(tests_gpu_sim_check_SOURCES) \ + $(tests_list_check_SOURCES) DIST_SOURCES = $(src_calibrate_detector_SOURCES) \ $(src_check_hkl_SOURCES) $(src_compare_hkl_SOURCES) \ - $(am__src_cubeit_SOURCES_DIST) \ - $(src_estimate_background_SOURCES) $(src_get_hkl_SOURCES) \ + $(am__src_cubeit_SOURCES_DIST) $(src_get_hkl_SOURCES) \ $(am__src_hdfsee_SOURCES_DIST) \ $(am__src_indexamajig_SOURCES_DIST) $(src_partialator_SOURCES) \ $(am__src_pattern_sim_SOURCES_DIST) $(src_powder_plot_SOURCES) \ @@ -670,11 +658,6 @@ src_partialator_SOURCES = src/partialator.c src/cell.c src/hdf5-file.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-utils.c - tests_list_check_SOURCES = tests/list_check.c src/reflist.c src/thread-pool.c \ src/utils.c @@ -859,11 +842,6 @@ src/reflist-utils.$(OBJEXT): src/$(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) -src/estimate_background.$(OBJEXT): src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) -src/estimate_background$(EXEEXT): $(src_estimate_background_OBJECTS) $(src_estimate_background_DEPENDENCIES) src/$(am__dirstamp) - @rm -f src/estimate_background$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(src_estimate_background_OBJECTS) $(src_estimate_background_LDADD) $(LIBS) src/get_hkl.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/beam-parameters.$(OBJEXT): src/$(am__dirstamp) \ @@ -963,7 +941,6 @@ mostlyclean-compile: -rm -f src/diffraction.$(OBJEXT) -rm -f src/dirax.$(OBJEXT) -rm -f src/dw-hdfsee.$(OBJEXT) - -rm -f src/estimate_background.$(OBJEXT) -rm -f src/filters.$(OBJEXT) -rm -f src/geometry.$(OBJEXT) -rm -f src/get_hkl.$(OBJEXT) @@ -1011,7 +988,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/diffraction.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dirax.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dw-hdfsee.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/estimate_background.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/filters.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/geometry.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/get_hkl.Po@am__quote@ @@ -58,9 +58,6 @@ In addition, there is also: - cubeit, for summing patterns in 3D to inspect the peak profiles. - - estimate_background, for calculating signal to noise ratios from - the indexed peaks. - - calibrate_detector, which does nothing useful at the moment. diff --git a/src/estimate_background.c b/src/estimate_background.c deleted file mode 100644 index 1f956377..00000000 --- a/src/estimate_background.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - * estimate-background.c - * - * Like 'process_hkl', but for signal/noise ratios - * - * (c) 2006-2010 Thomas White <taw@physics.org> - * - * Part of CrystFEL - crystallography with a FEL - * - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdarg.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <getopt.h> - -#include "utils.h" -#include "statistics.h" -#include "sfac.h" -#include "reflections.h" -#include "symmetry.h" -#include "stream.h" - - -/* Number of bins for plot of resolution shells */ -#define NBINS (10) - - - -static void show_help(const char *s) -{ - printf("Syntax: %s [options]\n\n", s); - printf( -"Estimate peak SNR from FEL Bragg intensities.\n" -"\n" -" -h, --help Display this help message.\n" -" -i, --input=<filename> Specify input filename (\"-\" for stdin).\n" -); -} - - - -int main(int argc, char *argv[]) -{ - int c; - char *filename = NULL; - FILE *fh; - int rval; - double total_vol, vol_per_shell; - double rmin, rmax; - double rmins[NBINS]; - double rmaxs[NBINS]; - double snrs[NBINS]; - unsigned int counts[NBINS]; - UnitCell *real_cell; - double overall_snr; - unsigned int overall_counts; - int i; - - /* Long options */ - const struct option longopts[] = { - {"help", 0, NULL, 'h'}, - {"input", 1, NULL, 'i'}, - {0, 0, NULL, 0} - }; - - /* Short options */ - while ((c = getopt_long(argc, argv, "hi:", - longopts, NULL)) != -1) { - - switch (c) { - case 'h' : - show_help(argv[0]); - return 0; - - case 'i' : - filename = strdup(optarg); - break; - - case 0 : - break; - - default : - return 1; - } - - } - - if ( filename == NULL ) { - ERROR("Please specify filename using the -i option\n"); - return 1; - } - - /* Open the data stream */ - if ( strcmp(filename, "-") == 0 ) { - fh = stdin; - } else { - fh = fopen(filename, "r"); - } - free(filename); - if ( fh == NULL ) { - ERROR("Failed to open input file\n"); - return 1; - } - - /* FIXME: Fixed resolution shells */ - rmin = 0.120e9; - rmax = 1.172e9; - - for ( i=0; i<NBINS; i++ ) { - counts[i] = 0; - snrs[i] = 0.0; - } - - total_vol = pow(rmax, 3.0) - pow(rmin, 3.0); - vol_per_shell = total_vol / NBINS; - rmins[0] = rmin; - for ( i=1; i<NBINS; i++ ) { - - double r; - - r = vol_per_shell + pow(rmins[i-1], 3.0); - r = pow(r, 1.0/3.0); - - /* Shells of constant volume */ - rmaxs[i-1] = r; - rmins[i] = r; - - /* Shells of constant thickness */ - //rmins[i] = rmins[i-1] + (rmax-rmin)/NBINS; - //rmaxs[i-1] = rmins[i-1] + (rmax-rmin)/NBINS; - - STATUS("Shell %i: %f to %f\n", i-1, - rmins[i-1]/1e9, rmaxs[i-1]/1e9); - - } - rmaxs[NBINS-1] = rmax; - STATUS("Shell %i: %f to %f\n", NBINS-1, - rmins[NBINS-1]/1e9, rmaxs[NBINS-1]/1e9); - - real_cell = load_cell_from_pdb("../../1JB0.pdb"); - - do { - - char *rval2; - UnitCell *cell; - char *filename; - char line[1024]; - int done = 0; - double ph_ev; - - rval = find_chunk(fh, &cell, &filename, &ph_ev); - if ( rval != 0 ) break; - - do { - - signed int h, k, l; - float intensity, x, y, max, bg; - int r, j; - double d, snr; - int bin; - - rval2 = fgets(line, 1024, fh); - - if ( strncmp(line, "Peak statistics:", 16) == 0 ) { - done = 1; - } - - r = sscanf(line, "%i %i %i %f (at %f,%f) max=%f bg=%f", - &h, &k, &l, &intensity, &x, &y, &max, &bg); - - if ( r != 8 ) { - continue; - } - - d = resolution(real_cell, h, k, l) * 2.0; - //STATUS("'%s'", line); - //STATUS("-> %i %i %i %f\n", h, k, l, d/1e9); - - bin = -1; - for ( j=0; j<NBINS; j++ ) { - if ( (d>rmins[j]) && (d<=rmaxs[j]) ) { - bin = j; - break; - } - } - if ( bin == -1 ) { - ERROR("Warnung! %i %i %i %f\n", h, k, l, d/1e9); - continue; - } - - snr = max/bg; - snrs[bin] += snr; - counts[bin]++; - - } while ( !done ); - - } while ( !rval ); - - /* Print out results */ - overall_snr = 0.0; - overall_counts = 0; - for ( i=0; i<NBINS; i++ ) { - - double snr, cen; - - cen = rmins[i] + (rmaxs[i] - rmins[i])/2.0; - snr = snrs[i] / (double)counts[i]; - printf("%f %f (%f / %i)\n", cen*1.0e-9, snr, snrs[i], counts[i]); - if ( i>0 ) { - overall_snr += snrs[i]; - overall_counts += counts[i]; - } - - } - - printf("Overall: %f (%f / %i)\n", overall_snr/(double)overall_counts, - overall_snr, overall_counts); - - - fclose(fh); - - return 0; -} |