aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2013-01-28 10:25:04 +0100
committerThomas White <taw@physics.org>2013-01-28 10:25:04 +0100
commit91f2cbf5d3dcb42b7e6762fb54734096425f4315 (patch)
tree440d41f134f3c969b84c231cba7f0f15c1917d59 /libcrystfel
parent1c82ece5bab805488ac31b3533ee327e030651e0 (diff)
First bit of Crystal
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/Makefile.am4
-rw-r--r--libcrystfel/src/crystal.c104
-rw-r--r--libcrystfel/src/crystal.h48
-rw-r--r--libcrystfel/src/image.h33
4 files changed, 160 insertions, 29 deletions
diff --git a/libcrystfel/Makefile.am b/libcrystfel/Makefile.am
index 1c35e03f..da7e8f64 100644
--- a/libcrystfel/Makefile.am
+++ b/libcrystfel/Makefile.am
@@ -8,7 +8,7 @@ libcrystfel_la_SOURCES = src/reflist.c src/utils.c src/cell.c src/detector.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 \
- src/cell-utils.c src/integer_matrix.c
+ src/cell-utils.c src/integer_matrix.c src/crystal.c
if HAVE_FFTW
libcrystfel_la_SOURCES += src/reax.c
@@ -24,7 +24,7 @@ libcrystfel_la_include_HEADERS = src/beam-parameters.h src/hdf5-file.h \
src/render.h src/index.h src/image.h \
src/filters.h src/dirax.h src/mosflm.h \
src/index-priv.h src/reax.h src/cell-utils.h \
- src/integer_matrix.h
+ src/integer_matrix.h src/crystal.h
AM_CPPFLAGS = -DDATADIR=\""$(datadir)"\" -I$(top_builddir)/lib -Wall
AM_CPPFLAGS += -I$(top_srcdir)/lib @LIBCRYSTFEL_CFLAGS@
diff --git a/libcrystfel/src/crystal.c b/libcrystfel/src/crystal.c
new file mode 100644
index 00000000..85430b6f
--- /dev/null
+++ b/libcrystfel/src/crystal.c
@@ -0,0 +1,104 @@
+/*
+ * crystal.c
+ *
+ * A class representing a single crystal
+ *
+ * Copyright © 2013 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2013 Thomas White <taw@physics.org>
+ *
+ * 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/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "crystal.h"
+#include "utils.h"
+
+
+/**
+ * SECTION:crystal
+ * @short_description: Crystal
+ * @title: Crystal
+ * @section_id:
+ * @see_also:
+ * @include: "crystal.h"
+ * @Image:
+ *
+ * This structure represents a single crystal.
+ */
+
+
+struct _crystal
+{
+ /* Information about the crystal */
+ UnitCell *indexed_cell;
+ UnitCell *candidate_cells[MAX_CELL_CANDIDATES];
+ int ncells;
+ double m; /* Mosaicity in radians */
+ double osf;
+ double profile_radius;
+ int pr_dud;
+ double diffracting_resolution;
+
+ /* Integrated (or about-to-be-integrated) reflections */
+ RefList *reflections;
+ long long int n_saturated; /* Number of overloads */
+};
+
+
+/************************** Setters and Constructors **************************/
+
+
+/**
+ * crystal_new:
+ *
+ * Create a new %Crystal.
+ *
+ * Returns: the new unit cell, or NULL on failure.
+ *
+ */
+Crystal *crystal_new()
+{
+ Crystal *cryst;
+
+ cryst = malloc(sizeof(Crystal));
+ if ( cryst == NULL ) return NULL;
+
+ return cryst;
+}
+
+
+/**
+ * crystal_free:
+ * @cryst: A %Crystal to free.
+ *
+ * Frees a %Crystal, and all internal resources concerning that crystal.
+ *
+ */
+void crystal_free(UnitCell *cryst)
+{
+ if ( cryst == NULL ) return;
+ free(crysta);
+}
+
+
+/********************************** Getters ***********************************/
diff --git a/libcrystfel/src/crystal.h b/libcrystfel/src/crystal.h
new file mode 100644
index 00000000..4f53eead
--- /dev/null
+++ b/libcrystfel/src/crystal.h
@@ -0,0 +1,48 @@
+/*
+ * crystal.h
+ *
+ * A class representing a single crystal
+ *
+ * Copyright © 2013 Deutsches Elektronen-Synchrotron DESY,
+ * a research centre of the Helmholtz Association.
+ *
+ * Authors:
+ * 2013 Thomas White <taw@physics.org>
+ *
+ * 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 CRYSTAL_H
+#define CRYSTAL_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/**
+ * Crystal:
+ *
+ * This data structure is opaque. You must use the available accessor functions
+ * to read and write its contents.
+ **/
+typedef struct _crystal Crystal;
+
+
+extern Crystal *crystal_new(void);
+extern void crystal_free(Crystal *cryst);
+
+#endif /* CRYSTAL_H */
diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h
index afa9e4a7..bd90a920 100644
--- a/libcrystfel/src/image.h
+++ b/libcrystfel/src/image.h
@@ -41,6 +41,7 @@
#include "cell.h"
#include "detector.h"
#include "reflist.h"
+#include "crystal.h"
#define MAX_CELL_CANDIDATES (32)
@@ -79,10 +80,9 @@ typedef struct _imagefeaturelist ImageFeatureList;
* uint16_t *flags;
* double *twotheta;
*
- * UnitCell *indexed_cell;
- * UnitCell *candidate_cells[MAX_CELL_CANDIDATES];
- * int ncells;
-
+ * Crystal **crystals;
+ * int n_crystals;
+ *
* struct detector *det;
* struct beam_params *beam;
* char *filename;
@@ -90,22 +90,13 @@ typedef struct _imagefeaturelist ImageFeatureList;
*
* int id;
*
- * double m;
- *
* double lambda;
* double div;
* double bw;
- * double osf;
- * double profile_radius;
- * int pr_dud;
- * double diffracting_resolution;
*
* int width;
* int height;
*
- * RefList *reflections;
- * long long unsigned int n_saturated;
- *
* ImageFeatureList *features;
* };
* </programlisting>
@@ -141,9 +132,8 @@ struct image {
uint16_t *flags;
double *twotheta;
- UnitCell *indexed_cell;
- UnitCell *candidate_cells[MAX_CELL_CANDIDATES];
- int ncells;
+ struct crystal **crystals;
+ int n_crystals;
struct detector *det;
struct beam_params *beam; /* The nominal beam parameters */
@@ -153,25 +143,14 @@ struct image {
int id; /* ID number of the thread
* handling this image */
- /* Information about the crystal */
- double m; /* Mosaicity in radians */
-
/* Per-shot radiation values */
double lambda; /* Wavelength in m */
double div; /* Divergence in radians */
double bw; /* Bandwidth as a fraction */
- double osf; /* Overall scaling factor */
- double profile_radius; /* Radius of reflection */
- int pr_dud; /* Post refinement failed */
- double diffracting_resolution; /* Max 1/d in m^-1 */
int width;
int height;
- /* Integrated (or about-to-be-integrated) reflections */
- RefList *reflections;
- long long int n_saturated; /* Number of overloads */
-
/* Detected peaks */
ImageFeatureList *features;