aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-09-22 18:06:07 +0200
committerThomas White <taw@physics.org>2014-09-22 18:06:07 +0200
commit0a5a04cc90619a1973c91489c71585ce127df045 (patch)
treec1903fc77534cd97840330b914b98b7b1187bce0 /libcrystfel
parent142e1ad4e0fad73d223c67a842dfb9728a3bf34c (diff)
Beam file removal, part I
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/Makefile.am4
-rw-r--r--libcrystfel/src/beam-parameters.h76
-rw-r--r--libcrystfel/src/detector.c24
-rw-r--r--libcrystfel/src/detector.h4
-rw-r--r--libcrystfel/src/dirax.c3
-rw-r--r--libcrystfel/src/dirax.h6
-rw-r--r--libcrystfel/src/geometry.c1
-rw-r--r--libcrystfel/src/grainspotter.c9
-rw-r--r--libcrystfel/src/grainspotter.h1
-rw-r--r--libcrystfel/src/hdf5-file.c15
-rw-r--r--libcrystfel/src/image.h15
-rw-r--r--libcrystfel/src/index.c22
-rw-r--r--libcrystfel/src/index.h4
-rw-r--r--libcrystfel/src/mosflm.c7
-rw-r--r--libcrystfel/src/mosflm.h7
-rw-r--r--libcrystfel/src/peaks.c1
-rw-r--r--libcrystfel/src/reax.c3
-rw-r--r--libcrystfel/src/reax.h7
-rw-r--r--libcrystfel/src/xds.c4
-rw-r--r--libcrystfel/src/xds.h3
20 files changed, 83 insertions, 133 deletions
diff --git a/libcrystfel/Makefile.am b/libcrystfel/Makefile.am
index 1be1d952..2cdfba10 100644
--- a/libcrystfel/Makefile.am
+++ b/libcrystfel/Makefile.am
@@ -4,7 +4,7 @@ libcrystfel_la_LDFLAGS = -version-info 5:0:0
libcrystfel_la_SOURCES = src/reflist.c src/utils.c src/cell.c src/detector.c \
src/thread-pool.c src/image.c src/hdf5-file.c \
- src/beam-parameters.c src/geometry.c src/statistics.c \
+ src/geometry.c src/statistics.c \
src/symmetry.c src/stream.c src/peaks.c \
src/reflist-utils.c src/filters.c \
src/render.c src/index.c src/dirax.c src/mosflm.c \
@@ -18,7 +18,7 @@ endif
libcrystfel_la_includedir=$(includedir)/crystfel/
-libcrystfel_la_include_HEADERS = ${top_srcdir}/version.h src/beam-parameters.h \
+libcrystfel_la_include_HEADERS = ${top_srcdir}/version.h \
src/hdf5-file.h src/reflist.h src/symmetry.h \
src/cell.h src/reflist-utils.h \
src/thread-pool.h src/statistics.h \
diff --git a/libcrystfel/src/beam-parameters.h b/libcrystfel/src/beam-parameters.h
deleted file mode 100644
index 245c7c16..00000000
--- a/libcrystfel/src/beam-parameters.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * beam-parameters.h
- *
- * Beam parameters
- *
- * Copyright © 2013-2014 Deutsches Elektronen-Synchrotron DESY,
- * a research centre of the Helmholtz Association.
- *
- * Authors:
- * 2010,2012-2014 Thomas White <taw@physics.org>
- * 2014 Valerio Mariani <valerio.mariani@desy.de>
- * 2012 Chunhong Yoon
- *
- * This file is part of CrystFEL.
- *
- * CrystFEL is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * CrystFEL is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with CrystFEL. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef BEAM_PARAMETERS_H
-#define BEAM_PARAMETERS_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-struct beam_params;
-struct event;
-struct hdfile;
-
-#include "events.h"
-#include "hdf5-file.h"
-
-struct beam_params
-{
- double fluence; /* photons per pulse */
- double beam_radius; /* metres */
- double photon_energy; /* eV per photon */
- char *photon_energy_from; /* HDF5 dataset name */
- double photon_energy_scale; /* Scale factor for photon energy, if the
- * energy is to be from the HDF5 file */
- double bandwidth; /* FWHM(wavelength) over wavelength.
- * Note: current simulation code just uses
- * a rectangular distribution with this as
- * its (full) width. */
- double divergence; /* divergence (radians) */
-
- double profile_radius; /* Reciprocal space size of a reflection */
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern struct beam_params *get_beam_parameters(const char *filename);
-extern void free_beam_parameters(struct beam_params *beam);
-
-extern void fill_in_beam_parameters(struct beam_params *beam, struct hdfile *f,
- struct event* ev);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BEAM_PARAMETERS_H */
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c
index 4cf6dac9..3cf59786 100644
--- a/libcrystfel/src/detector.c
+++ b/libcrystfel/src/detector.c
@@ -43,7 +43,6 @@
#include "image.h"
#include "utils.h"
#include "detector.h"
-#include "beam-parameters.h"
#include "hdf5-file.h"
@@ -784,8 +783,8 @@ static int parse_field_bad(struct badregion *panel, const char *key,
}
-static void parse_toplevel(struct detector *det, const char *key,
- const char *val)
+static void parse_toplevel(struct detector *det, struct beam_params *beam,
+ const char *key, const char *val)
{
if ( strcmp(key, "mask_bad") == 0 ) {
@@ -807,6 +806,20 @@ static void parse_toplevel(struct detector *det, const char *key,
} else if ( strcmp(key, "coffset") == 0 ) {
det->defaults.coffset = atof(val);
+
+ } else if ( strcmp(key, "photon_energy") == 0 ) {
+ if ( beam == NULL ) {
+ ERROR("Geometry file contains a reference to "
+ "photon_energy, which is inappropriate in this "
+ "situation.\n");
+ } else if ( strncmp(val, "/", 1) == 0 ) {
+ beam->photon_energy = 0.0;
+ beam->photon_energy_from = strdup(val);
+ } else {
+ beam->photon_energy = atof(val);
+ beam->photon_energy_from = NULL;
+ }
+
} else if ( parse_field_for_panel(&det->defaults, key, val, det) ) {
ERROR("Unrecognised top level field '%s'\n", key);
}
@@ -871,7 +884,8 @@ static void find_min_max_d(struct detector *det)
}
-struct detector *get_detector_geometry(const char *filename)
+struct detector *get_detector_geometry(const char *filename,
+ struct beam_params *beam)
{
FILE *fh;
struct detector *det;
@@ -971,7 +985,7 @@ struct detector *get_detector_geometry(const char *filename)
n2 = assplode(bits[0], "/\\.", &path, ASSPLODE_NONE);
if ( n2 < 2 ) {
/* This was a top-level option, not handled above. */
- parse_toplevel(det, bits[0], bits[2]);
+ parse_toplevel(det, beam, bits[0], bits[2]);
for ( i=0; i<n1; i++ ) free(bits[i]);
free(bits);
for ( i=0; i<n2; i++ ) free(path[i]);
diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h
index e99fb7fc..ba88c12e 100644
--- a/libcrystfel/src/detector.h
+++ b/libcrystfel/src/detector.h
@@ -42,6 +42,7 @@ struct detector;
struct panel;
struct badregion;
struct detector;
+struct beam_params;
struct hdfile;
struct event;
@@ -186,7 +187,8 @@ extern struct panel *find_panel(struct detector *det, double fs, double ss);
extern signed int find_panel_number(struct detector *det, double fs, double ss);
-extern struct detector *get_detector_geometry(const char *filename);
+extern struct detector *get_detector_geometry(const char *filename,
+ struct beam_params *beam);
extern void free_detector_geometry(struct detector *det);
diff --git a/libcrystfel/src/dirax.c b/libcrystfel/src/dirax.c
index 4c674313..0a137784 100644
--- a/libcrystfel/src/dirax.c
+++ b/libcrystfel/src/dirax.c
@@ -639,8 +639,7 @@ int run_dirax(struct image *image, IndexingPrivate *ipriv)
IndexingPrivate *dirax_prepare(IndexingMethod *indm, UnitCell *cell,
- struct detector *det,
- struct beam_params *beam, float *ltl)
+ struct detector *det, float *ltl)
{
struct dirax_private *dp;
int need_cell = 0;
diff --git a/libcrystfel/src/dirax.h b/libcrystfel/src/dirax.h
index c2d8abdb..9776f3f0 100644
--- a/libcrystfel/src/dirax.h
+++ b/libcrystfel/src/dirax.h
@@ -3,11 +3,11 @@
*
* Invoke the DirAx auto-indexing program
*
- * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
- * 2010,2012-2013 Thomas White <taw@physics.org>
+ * 2010,2012-2014 Thomas White <taw@physics.org>
*
* This file is part of CrystFEL.
*
@@ -43,7 +43,7 @@ extern int run_dirax(struct image *image, IndexingPrivate *ipriv);
extern IndexingPrivate *dirax_prepare(IndexingMethod *indm,
UnitCell *cell, struct detector *det,
- struct beam_params *beam, float *ltl);
+ float *ltl);
extern void dirax_cleanup(IndexingPrivate *pp);
diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c
index 21f81915..aff19198 100644
--- a/libcrystfel/src/geometry.c
+++ b/libcrystfel/src/geometry.c
@@ -41,7 +41,6 @@
#include "cell-utils.h"
#include "image.h"
#include "peaks.h"
-#include "beam-parameters.h"
#include "reflist.h"
#include "reflist-utils.h"
#include "symmetry.h"
diff --git a/libcrystfel/src/grainspotter.c b/libcrystfel/src/grainspotter.c
index 5a0130f4..261756d6 100644
--- a/libcrystfel/src/grainspotter.c
+++ b/libcrystfel/src/grainspotter.c
@@ -3,11 +3,11 @@
*
* Invoke GrainSpotter for multi-crystal autoindexing
*
- * Copyright © 2013 Deutsches Elektronen-Synchrotron DESY,
- * a research centre of the Helmholtz Association.
+ * Copyright © 2013-2014 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
*
* Authors:
- * 2010-2013 Thomas White <taw@physics.org>
+ * 2010-2014 Thomas White <taw@physics.org>
*
* This file is part of CrystFEL.
*
@@ -468,8 +468,7 @@ int grainspotter_index(struct image *image, IndexingPrivate *ipriv)
IndexingPrivate *grainspotter_prepare(IndexingMethod *indm, UnitCell *cell,
- struct detector *det,
- struct beam_params *beam, float *ltl)
+ struct detector *det, float *ltl)
{
struct grainspotter_private *gp;
diff --git a/libcrystfel/src/grainspotter.h b/libcrystfel/src/grainspotter.h
index b6a83725..3ab823ad 100644
--- a/libcrystfel/src/grainspotter.h
+++ b/libcrystfel/src/grainspotter.h
@@ -42,7 +42,6 @@ extern "C" {
extern IndexingPrivate *grainspotter_prepare(IndexingMethod *indm,
UnitCell *cell,
struct detector *det,
- struct beam_params *beam,
float *ltl);
extern void grainspotter_cleanup(IndexingPrivate *pp);
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c
index 5093ed84..3fe088d6 100644
--- a/libcrystfel/src/hdf5-file.c
+++ b/libcrystfel/src/hdf5-file.c
@@ -900,6 +900,21 @@ static int unpack_panels(struct image *image, struct detector *det)
}
+void fill_in_beam_parameters(struct beam_params *beam, struct hdfile *f,
+ struct event* ev)
+{
+ if ( beam->photon_energy_from == NULL ) return;
+
+ if ( ev != NULL ) {
+ beam->photon_energy = get_ev_based_value(f,
+ beam->photon_energy_from, ev);
+ } else {
+ beam->photon_energy = get_value(f, beam->photon_energy_from);
+ }
+ beam->photon_energy *= beam->photon_energy_scale;
+}
+
+
int hdf5_read(struct hdfile *f, struct image *image,
const char *element, int satcorr)
{
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index 10e1eef7..0a64e081 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -98,6 +98,21 @@ struct sample
};
+struct beam_params
+{
+ double fluence; /* photons per pulse */
+ double beam_radius; /* metres */
+ double photon_energy; /* eV per photon */
+ char *photon_energy_from; /* HDF5 dataset name */
+ double photon_energy_scale; /* Scale factor for photon energy, if the
+ * energy is to be from the HDF5 file */
+ double bandwidth; /* FWHM(wavelength) over wavelength. */
+ double divergence; /* divergence (radians) */
+
+ double profile_radius; /* Reciprocal space size of a reflection */
+};
+
+
/**
* image:
*
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c
index 241d9311..07f563b7 100644
--- a/libcrystfel/src/index.c
+++ b/libcrystfel/src/index.c
@@ -3,12 +3,12 @@
*
* Perform indexing (somehow)
*
- * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
* Copyright © 2012 Lorenzo Galli
*
* Authors:
- * 2010-2013 Thomas White <taw@physics.org>
+ * 2010-2014 Thomas White <taw@physics.org>
* 2010-2011 Richard Kirian <rkirian@asu.edu>
* 2012 Lorenzo Galli
* 2013 Cornelius Gati <cornelius.gati@cfel.de>
@@ -56,8 +56,7 @@
IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell,
- struct detector *det,
- struct beam_params *beam, float *ltl)
+ struct detector *det, float *ltl)
{
int n;
int nm = 0;
@@ -77,27 +76,24 @@ IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell,
switch ( indm[n] & INDEXING_METHOD_MASK ) {
case INDEXING_DIRAX :
- iprivs[n] = dirax_prepare(&indm[n], cell,
- det, beam, ltl);
+ iprivs[n] = dirax_prepare(&indm[n], cell, det, ltl);
break;
case INDEXING_MOSFLM :
- iprivs[n] = mosflm_prepare(&indm[n], cell,
- det, beam, ltl);
+ iprivs[n] = mosflm_prepare(&indm[n], cell, det, ltl);
break;
case INDEXING_XDS :
- iprivs[n] = xds_prepare(&indm[n], cell, det, beam, ltl);
+ iprivs[n] = xds_prepare(&indm[n], cell, det, ltl);
break;
case INDEXING_REAX :
- iprivs[n] = reax_prepare(&indm[n], cell,
- det, beam, ltl);
+ iprivs[n] = reax_prepare(&indm[n], cell, det, ltl);
break;
case INDEXING_GRAINSPOTTER :
iprivs[n] = grainspotter_prepare(&indm[n], cell,
- det, beam, ltl);
+ det, ltl);
break;
default :
@@ -477,4 +473,4 @@ IndexingMethod *build_indexer_list(const char *str)
list[++nmeth] = INDEXING_NONE;
return list;
-} \ No newline at end of file
+}
diff --git a/libcrystfel/src/index.h b/libcrystfel/src/index.h
index 76ecfad4..0e105aeb 100644
--- a/libcrystfel/src/index.h
+++ b/libcrystfel/src/index.h
@@ -125,14 +125,12 @@ typedef void *IndexingPrivate;
extern IndexingMethod *build_indexer_list(const char *str);
extern char *indexer_str(IndexingMethod indm);
-#include "beam-parameters.h"
#include "detector.h"
#include "cell.h"
#include "image.h"
extern IndexingPrivate **prepare_indexing(IndexingMethod *indm, UnitCell *cell,
- struct detector *det,
- struct beam_params *beam, float *ltl);
+ struct detector *det, float *ltl);
extern void index_pattern(struct image *image,
IndexingMethod *indms, IndexingPrivate **iprivs);
diff --git a/libcrystfel/src/mosflm.c b/libcrystfel/src/mosflm.c
index cf0852bf..3319a261 100644
--- a/libcrystfel/src/mosflm.c
+++ b/libcrystfel/src/mosflm.c
@@ -3,13 +3,13 @@
*
* Invoke the DPS auto-indexing algorithm through MOSFLM
*
- * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
* Copyright © 2012 Richard Kirian
*
* Authors:
* 2010 Richard Kirian <rkirian@asu.edu>
- * 2010-2013 Thomas White <taw@physics.org>
+ * 2010-2014 Thomas White <taw@physics.org>
*
* This file is part of CrystFEL.
*
@@ -831,8 +831,7 @@ int run_mosflm(struct image *image, IndexingPrivate *ipriv)
IndexingPrivate *mosflm_prepare(IndexingMethod *indm, UnitCell *cell,
- struct detector *det, struct beam_params *beam,
- float *ltl)
+ struct detector *det, float *ltl)
{
struct mosflm_private *mp;
int need_cell = 0;
diff --git a/libcrystfel/src/mosflm.h b/libcrystfel/src/mosflm.h
index 40282cec..572741dd 100644
--- a/libcrystfel/src/mosflm.h
+++ b/libcrystfel/src/mosflm.h
@@ -3,13 +3,13 @@
*
* Invoke the DPS auto-indexing algorithm through MOSFLM
*
- * Copyright © 2012-2013 Deutsches Elektronen-Synchrotron DESY,
+ * Copyright © 2012-2014 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
* Copyright © 2012 Richard Kirian
*
* Authors:
* 2010 Richard Kirian <rkirian@asu.edu>
- * 2012-2013 Thomas White <taw@physics.org>
+ * 2012-2014 Thomas White <taw@physics.org>
*
* This file is part of CrystFEL.
*
@@ -44,8 +44,7 @@ extern "C" {
extern int run_mosflm(struct image *image, IndexingPrivate *ipriv);
extern IndexingPrivate *mosflm_prepare(IndexingMethod *indm, UnitCell *cell,
- struct detector *det,
- struct beam_params *beam, float *ltl);
+ struct detector *det, float *ltl);
extern void mosflm_cleanup(IndexingPrivate *pp);
diff --git a/libcrystfel/src/peaks.c b/libcrystfel/src/peaks.c
index 90ac9334..9e3c5e77 100644
--- a/libcrystfel/src/peaks.c
+++ b/libcrystfel/src/peaks.c
@@ -50,7 +50,6 @@
#include "detector.h"
#include "filters.h"
#include "reflist-utils.h"
-#include "beam-parameters.h"
#include "cell-utils.h"
#include "geometry.h"
diff --git a/libcrystfel/src/reax.c b/libcrystfel/src/reax.c
index 5448d1a7..4313b058 100644
--- a/libcrystfel/src/reax.c
+++ b/libcrystfel/src/reax.c
@@ -1103,8 +1103,7 @@ int reax_index(IndexingPrivate *pp, struct image *image)
IndexingPrivate *reax_prepare(IndexingMethod *indm, UnitCell *cell,
- struct detector *det, struct beam_params *beam,
- float *ltl)
+ struct detector *det, float *ltl)
{
struct reax_private *p;
int samp;
diff --git a/libcrystfel/src/reax.h b/libcrystfel/src/reax.h
index b5c6d058..0bc96d9e 100644
--- a/libcrystfel/src/reax.h
+++ b/libcrystfel/src/reax.h
@@ -35,7 +35,6 @@
#include "index.h"
#include "cell.h"
-#include "beam-parameters.h"
#include "detector.h"
#ifdef __cplusplus
@@ -45,8 +44,7 @@ extern "C" {
#ifdef HAVE_FFTW
extern IndexingPrivate *reax_prepare(IndexingMethod *indm, UnitCell *cell,
- struct detector *det,
- struct beam_params *beam, float *ltl);
+ struct detector *det, float *ltl);
extern void reax_cleanup(IndexingPrivate *pp);
@@ -55,8 +53,7 @@ extern int reax_index(IndexingPrivate *pp, struct image *image);
#else /* HAVE_FFTW */
static IndexingPrivate *reax_prepare(IndexingMethod *indm, UnitCell *cell,
- struct detector *det,
- struct beam_params *beam, float *ltl)
+ struct detector *det, float *ltl)
{
return NULL;
}
diff --git a/libcrystfel/src/xds.c b/libcrystfel/src/xds.c
index 4a8ef30e..b4f66740 100644
--- a/libcrystfel/src/xds.c
+++ b/libcrystfel/src/xds.c
@@ -56,7 +56,6 @@
#include "utils.h"
#include "peaks.h"
#include "detector.h"
-#include "beam-parameters.h"
#include "cell-utils.h"
@@ -619,8 +618,7 @@ int run_xds(struct image *image, IndexingPrivate *priv)
IndexingPrivate *xds_prepare(IndexingMethod *indm, UnitCell *cell,
- struct detector *det, struct beam_params *beam,
- float *ltl)
+ struct detector *det, float *ltl)
{
struct xds_private *xp;
diff --git a/libcrystfel/src/xds.h b/libcrystfel/src/xds.h
index b42d8dbf..a0db2054 100644
--- a/libcrystfel/src/xds.h
+++ b/libcrystfel/src/xds.h
@@ -45,8 +45,7 @@ extern "C" {
extern int run_xds(struct image *image, IndexingPrivate *ipriv);
extern IndexingPrivate *xds_prepare(IndexingMethod *indm, UnitCell *cell,
- struct detector *det,
- struct beam_params *beam, float *ltl);
+ struct detector *det, float *ltl);
extern void xds_cleanup(IndexingPrivate *pp);