aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/reference/libcrystfel/CrystFEL-sections.txt61
-rw-r--r--libcrystfel/src/utils.c276
-rw-r--r--libcrystfel/src/utils.h86
3 files changed, 221 insertions, 202 deletions
diff --git a/doc/reference/libcrystfel/CrystFEL-sections.txt b/doc/reference/libcrystfel/CrystFEL-sections.txt
index d58c5725..3968dd5d 100644
--- a/doc/reference/libcrystfel/CrystFEL-sections.txt
+++ b/doc/reference/libcrystfel/CrystFEL-sections.txt
@@ -8,6 +8,8 @@ reflist_new
reflist_free
reflection_new
reflection_free
+reflist_add_notes
+reflist_get_notes
<SUBSECTION>
add_refl
add_refl_to_list
@@ -18,7 +20,6 @@ next_refl
find_refl
next_found_refl
<SUBSECTION>
-get_excitation_error
get_detector_pos
get_panel
get_partiality
@@ -77,6 +78,7 @@ copy_reflist
find_equiv_in_list
resolution_limits
max_intensity
+reflist_add_command_and_version
</SECTION>
<SECTION>
@@ -151,32 +153,32 @@ solve_svd
AssplodeFlag
C_VACUO
ELECTRON_CHARGE
-ERROR
-J_to_eV
PLANCK
-STATUS
THOMSON_LENGTH
assplode
-biggest
-check_prefix
chomp
-deg2rad
-eV_to_J
gaussian_noise
-safe_basename
progress_bar
-rad2deg
-is_odd
poisson_noise
notrail
+random_flat
+flat_noise
+show_matrix
+STATUS
+ERROR
+J_to_eV
+eV_to_J
+biggest
smallest
+check_prefix
+safe_basename
+deg2rad
+rad2deg
+is_odd
ph_en_to_lambda
ph_lambda_to_en
ph_eV_to_lambda
ph_lambda_to_eV
-random_flat
-flat_noise
-show_matrix
likely
unlikely
UNUSED
@@ -218,6 +220,20 @@ ImageFeatureList
SpectrumType
sample
<SUBSECTION>
+imagefile
+imagefile_close
+imagefile_copy_fields
+imagefile_field_list
+imagefile_get_hdfile
+imagefile_get_type
+imagefile_open
+imagefile_read
+imagefile_read_simple
+<SUBSECTION>
+new_imagefile_field_list
+add_imagefile_field
+free_imagefile_field_list
+<SUBSECTION>
image_add_feature
image_feature_closest
image_reflection_closest
@@ -268,10 +284,11 @@ INDEXING_DEFAULTS_ASDF
INDEXING_DEFAULTS_FELIX
INDEXING_METHOD_MASK
INDEXING_CONTROL_FLAGS
-build_indexer_list
+setup_indexing
cleanup_indexing
-prepare_indexing
+get_indm_from_string
index_pattern
+index_pattern_2
indexer_str
dirax_prepare
run_dirax
@@ -314,6 +331,7 @@ describe_symmetry
symmetry_name
set_symmetry_name
get_matrix_name
+pointgroup_warning
is_centrosymmetric
is_centric
</SECTION>
@@ -351,15 +369,14 @@ rigid_group
rg_collection
<SUBSECTION>
copy_geom
-fill_in_values
+fill_in_adu
free_detector_geometry
get_detector_geometry
get_detector_geometry_2
write_detector_geometry
write_detector_geometry_2
-find_panel
+panel_number
find_panel_by_name
-find_panel_number
simple_geometry
record_image
get_pixel_extents
@@ -378,6 +395,7 @@ rigid_group_is_in_collection
single_panel_data_source
find_rigid_group_collection_by_name
detector_has_clen_references
+adjust_centering_for_rail
</SECTION>
<SECTION>
@@ -466,6 +484,7 @@ crystal_get_resolution_limit
crystal_get_user_flag
crystal_get_num_implausible_reflections
crystal_get_notes
+crystal_get_det_shift
crystal_set_cell
crystal_set_image
crystal_set_mosaicity
@@ -479,6 +498,7 @@ crystal_set_user_flag
crystal_set_num_implausible_reflections
crystal_set_notes
crystal_add_notes
+crystal_set_det_shift
</SECTION>
<SECTION>
@@ -500,7 +520,9 @@ y_gradient
<FILE>peaks</FILE>
peak_sanity_check
search_peaks
+search_peaks_peakfinder8
make_BgMask
+peakfinder8
validate_peaks
sort_peaks
</SECTION>
@@ -557,6 +579,7 @@ close_stream
read_chunk
read_chunk_2
write_chunk
+write_chunk_2
rewind_stream
is_stream
write_command
diff --git a/libcrystfel/src/utils.c b/libcrystfel/src/utils.c
index 461da0cd..90d81a71 100644
--- a/libcrystfel/src/utils.c
+++ b/libcrystfel/src/utils.c
@@ -387,144 +387,6 @@ int poisson_noise(gsl_rng *rng, double expected)
}
-/**
- * SECTION:quaternion
- * @short_description: Simple quaternion handling
- * @title: Quaternion
- * @section_id:
- * @see_also:
- * @include: "utils.h"
- * @Image:
- *
- * There is a simple quaternion structure in CrystFEL. At the moment, it is
- * only used when simulating patterns, as an argument to cell_rotate() to
- * orient the unit cell.
- */
-
-/**
- * quaternion_modulus:
- * @q: A %quaternion
- *
- * If a quaternion represents a pure rotation, its modulus should be unity.
- *
- * Returns: the modulus of the given quaternion.
- **/
-double quaternion_modulus(struct quaternion q)
-{
- return sqrt(q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
-}
-
-
-/**
- * normalise_quaternion:
- * @q: A %quaternion
- *
- * Rescales the quaternion such that its modulus is unity.
- *
- * Returns: the normalised version of @q
- **/
-struct quaternion normalise_quaternion(struct quaternion q)
-{
- double mod;
- struct quaternion r;
-
- mod = quaternion_modulus(q);
-
- r.w = q.w / mod;
- r.x = q.x / mod;
- r.y = q.y / mod;
- r.z = q.z / mod;
-
- return r;
-}
-
-
-/**
- * random_quaternion:
- * @rng: A GSL random number generator to use
- *
- * Returns: a randomly generated, normalised, quaternion.
- **/
-struct quaternion random_quaternion(gsl_rng *rng)
-{
- struct quaternion q;
-
- q.w = 2.0*gsl_rng_uniform(rng) - 1.0;
- q.x = 2.0*gsl_rng_uniform(rng) - 1.0;
- q.y = 2.0*gsl_rng_uniform(rng) - 1.0;
- q.z = 2.0*gsl_rng_uniform(rng) - 1.0;
- q = normalise_quaternion(q);
-
- return q;
-}
-
-
-/**
- * quaternion_valid:
- * @q: A %quaternion
- *
- * Checks if the given quaternion is normalised.
- *
- * This function performs a nasty floating point comparison of the form
- * <code>(modulus > 0.999) && (modulus < 1.001)</code>, and so should not be
- * relied upon to spot anything other than the most obvious input error.
- *
- * Returns: 1 if the quaternion is normalised, 0 if not.
- **/
-int quaternion_valid(struct quaternion q)
-{
- double qmod;
-
- qmod = quaternion_modulus(q);
-
- /* Modulus = 1 to within some tolerance?
- * Nasty allowance for floating-point accuracy follows... */
- if ( (qmod > 0.999) && (qmod < 1.001) ) return 1;
-
- return 0;
-}
-
-
-/**
- * quat_rot
- * @q: A vector (in the form of a "struct rvec")
- * @z: A %quaternion
- *
- * Rotates a vector according to a quaternion.
- *
- * Returns: A rotated version of @p.
- **/
-struct rvec quat_rot(struct rvec q, struct quaternion z)
-{
- struct rvec res;
- double t01, t02, t03, t11, t12, t13, t22, t23, t33;
-
- t01 = z.w*z.x;
- t02 = z.w*z.y;
- t03 = z.w*z.z;
- t11 = z.x*z.x;
- t12 = z.x*z.y;
- t13 = z.x*z.z;
- t22 = z.y*z.y;
- t23 = z.y*z.z;
- t33 = z.z*z.z;
-
- res.u = (1.0 - 2.0 * (t22 + t33)) * q.u
- + (2.0 * (t12 + t03)) * q.v
- + (2.0 * (t13 - t02)) * q.w;
-
- res.v = (2.0 * (t12 - t03)) * q.u
- + (1.0 - 2.0 * (t11 + t33)) * q.v
- + (2.0 * (t01 + t23)) * q.w;
-
- res.w = (2.0 * (t02 + t13)) * q.u
- + (2.0 * (t23 - t01)) * q.v
- + (1.0 - 2.0 * (t11 + t22)) * q.w;
-
- return res;
-}
-
-
/* Return non-zero if c is in delims */
static int assplode_isdelim(const char c, const char *delims)
{
@@ -691,3 +553,141 @@ void utils_fudge_gslcblas()
{
STATUS("%p\n", cblas_sgemm);
}
+
+
+/**
+ * SECTION:quaternion
+ * @short_description: Simple quaternion handling
+ * @title: Quaternion
+ * @section_id:
+ * @see_also:
+ * @include: "utils.h"
+ * @Image:
+ *
+ * There is a simple quaternion structure in CrystFEL. At the moment, it is
+ * only used when simulating patterns, as an argument to cell_rotate() to
+ * orient the unit cell.
+ */
+
+/**
+ * quaternion_modulus:
+ * @q: A %quaternion
+ *
+ * If a quaternion represents a pure rotation, its modulus should be unity.
+ *
+ * Returns: the modulus of the given quaternion.
+ **/
+double quaternion_modulus(struct quaternion q)
+{
+ return sqrt(q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
+}
+
+
+/**
+ * normalise_quaternion:
+ * @q: A %quaternion
+ *
+ * Rescales the quaternion such that its modulus is unity.
+ *
+ * Returns: the normalised version of @q
+ **/
+struct quaternion normalise_quaternion(struct quaternion q)
+{
+ double mod;
+ struct quaternion r;
+
+ mod = quaternion_modulus(q);
+
+ r.w = q.w / mod;
+ r.x = q.x / mod;
+ r.y = q.y / mod;
+ r.z = q.z / mod;
+
+ return r;
+}
+
+
+/**
+ * random_quaternion:
+ * @rng: A GSL random number generator to use
+ *
+ * Returns: a randomly generated, normalised, quaternion.
+ **/
+struct quaternion random_quaternion(gsl_rng *rng)
+{
+ struct quaternion q;
+
+ q.w = 2.0*gsl_rng_uniform(rng) - 1.0;
+ q.x = 2.0*gsl_rng_uniform(rng) - 1.0;
+ q.y = 2.0*gsl_rng_uniform(rng) - 1.0;
+ q.z = 2.0*gsl_rng_uniform(rng) - 1.0;
+ q = normalise_quaternion(q);
+
+ return q;
+}
+
+
+/**
+ * quaternion_valid:
+ * @q: A %quaternion
+ *
+ * Checks if the given quaternion is normalised.
+ *
+ * This function performs a nasty floating point comparison of the form
+ * <code>(modulus > 0.999) && (modulus < 1.001)</code>, and so should not be
+ * relied upon to spot anything other than the most obvious input error.
+ *
+ * Returns: 1 if the quaternion is normalised, 0 if not.
+ **/
+int quaternion_valid(struct quaternion q)
+{
+ double qmod;
+
+ qmod = quaternion_modulus(q);
+
+ /* Modulus = 1 to within some tolerance?
+ * Nasty allowance for floating-point accuracy follows... */
+ if ( (qmod > 0.999) && (qmod < 1.001) ) return 1;
+
+ return 0;
+}
+
+
+/**
+ * quat_rot
+ * @q: A vector (in the form of a "struct rvec")
+ * @z: A %quaternion
+ *
+ * Rotates a vector according to a quaternion.
+ *
+ * Returns: A rotated version of @p.
+ **/
+struct rvec quat_rot(struct rvec q, struct quaternion z)
+{
+ struct rvec res;
+ double t01, t02, t03, t11, t12, t13, t22, t23, t33;
+
+ t01 = z.w*z.x;
+ t02 = z.w*z.y;
+ t03 = z.w*z.z;
+ t11 = z.x*z.x;
+ t12 = z.x*z.y;
+ t13 = z.x*z.z;
+ t22 = z.y*z.y;
+ t23 = z.y*z.z;
+ t33 = z.z*z.z;
+
+ res.u = (1.0 - 2.0 * (t22 + t33)) * q.u
+ + (2.0 * (t12 + t03)) * q.v
+ + (2.0 * (t13 - t02)) * q.w;
+
+ res.v = (2.0 * (t12 - t03)) * q.u
+ + (1.0 - 2.0 * (t11 + t33)) * q.v
+ + (2.0 * (t01 + t23)) * q.w;
+
+ res.w = (2.0 * (t02 + t13)) * q.u
+ + (2.0 * (t23 - t01)) * q.v
+ + (1.0 - 2.0 * (t11 + t22)) * q.w;
+
+ return res;
+}
diff --git a/libcrystfel/src/utils.h b/libcrystfel/src/utils.h
index 4955f875..a759ff15 100644
--- a/libcrystfel/src/utils.h
+++ b/libcrystfel/src/utils.h
@@ -61,44 +61,10 @@
#define THOMSON_LENGTH (2.81794e-15)
-/* ------------------------------ Quaternions ------------------------------- */
-
-/**
- * quaternion:
- *
- * <programlisting>
- * struct quaternion
- * {
- * double w
- * double x
- * double y
- * double z
- * };
- * </programlisting>
- *
- * A structure representing a quaternion.
- *
- **/
-struct quaternion;
-
-struct quaternion {
- double w;
- double x;
- double y;
- double z;
-};
-
#ifdef __cplusplus
extern "C" {
#endif
-extern struct quaternion normalise_quaternion(struct quaternion q);
-extern double quaternion_modulus(struct quaternion q);
-extern struct quaternion random_quaternion(gsl_rng *rng);
-extern int quaternion_valid(struct quaternion q);
-extern struct rvec quat_rot(struct rvec q, struct quaternion z);
-
-
/* --------------------------- Useful functions ----------------------------- */
extern void show_matrix_eqn(gsl_matrix *M, gsl_vector *v);
@@ -126,17 +92,6 @@ extern double flat_noise(gsl_rng *rng, double expected, double width);
extern double gaussian_noise(gsl_rng *rng, double expected, double stddev);
extern int poisson_noise(gsl_rng *rng, double expected);
-/* Keep these ones inline, to avoid function call overhead */
-static inline struct quaternion invalid_quaternion(void)
-{
- struct quaternion quat;
- quat.w = 0.0;
- quat.x = 0.0;
- quat.y = 0.0;
- quat.z = 0.0;
- return quat;
-}
-
static inline double distance(double x1, double y1, double x2, double y2)
{
return sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
@@ -275,6 +230,47 @@ extern char *safe_basename(const char *in);
#define unlikely(x) (x)
#endif
+
+/* ------------------------------ Quaternions ------------------------------- */
+
+/**
+ * quaternion:
+ * @w: component
+ * @x: component
+ * @y: component
+ * @z: component
+ *
+ * A structure representing a quaternion.
+ *
+ **/
+struct quaternion;
+
+struct quaternion {
+ double w;
+ double x;
+ double y;
+ double z;
+};
+
+extern struct quaternion normalise_quaternion(struct quaternion q);
+extern double quaternion_modulus(struct quaternion q);
+extern struct quaternion random_quaternion(gsl_rng *rng);
+extern int quaternion_valid(struct quaternion q);
+extern struct rvec quat_rot(struct rvec q, struct quaternion z);
+
+/* Keep these ones inline, to avoid function call overhead */
+static inline struct quaternion invalid_quaternion(void)
+{
+ struct quaternion quat;
+ quat.w = 0.0;
+ quat.x = 0.0;
+ quat.y = 0.0;
+ quat.z = 0.0;
+ return quat;
+}
+
+
+
#ifdef __cplusplus
}
#endif