diff options
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/hdf5-file.c | 4 | ||||
-rw-r--r-- | libcrystfel/src/image.h | 21 | ||||
-rw-r--r-- | libcrystfel/src/stream.c | 1 | ||||
-rw-r--r-- | libcrystfel/src/utils.h | 2 |
4 files changed, 23 insertions, 5 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c index 7e3d6b11..f9c2aa97 100644 --- a/libcrystfel/src/hdf5-file.c +++ b/libcrystfel/src/hdf5-file.c @@ -1047,9 +1047,9 @@ int hdf5_write_image(const char *filename, const struct image *image, write_photon_energy(fh, ph_lambda_to_eV(image->lambda), ph_en_loc); - if ( image->spectrum != NULL && image->spectrum_size > 0 ) { + if ( image->spectrum0 != NULL && image->spectrum_size > 0 ) { - write_spectrum(fh, image->spectrum, image->spectrum_size, + write_spectrum(fh, image->spectrum0, image->spectrum_size, image->nsamples); } diff --git a/libcrystfel/src/image.h b/libcrystfel/src/image.h index dffcdb3a..3e46575e 100644 --- a/libcrystfel/src/image.h +++ b/libcrystfel/src/image.h @@ -60,6 +60,7 @@ struct imagefile_field_list; * @SPECTRUM_TOPHAT: A top hat distribution of wavelengths * @SPECTRUM_SASE: A simulated SASE spectrum * @SPECTRUM_TWOCOLOUR: A spectrum containing two peaks + * @SPECTRUM_FROMFILE: An arbitrary spectrum read from input file * * A %SpectrumType represents a type of X-ray energy spectrum to use for * generating simulated data. @@ -67,7 +68,8 @@ struct imagefile_field_list; typedef enum { SPECTRUM_TOPHAT, SPECTRUM_SASE, - SPECTRUM_TWOCOLOUR + SPECTRUM_TWOCOLOUR, + SPECTRUM_FROMFILE } SpectrumType; @@ -121,10 +123,19 @@ enum imagefile_type /* An opaque type representing a list of image features */ typedef struct _imagefeaturelist ImageFeatureList; + +struct spectrum +{ + int n; + double *ks; /* 1/m */ + double *weights; +}; + + /* Structure describing a wavelength sample from a spectrum */ struct sample { - double k; + double k; /* 1/m */ double weight; }; @@ -211,7 +222,11 @@ struct image { int serial; /* Monotonically ascending serial * number for this image */ - struct sample *spectrum; + struct spectrum *spectrum; /* Beam spectrum for pink beam data */ + + /* FIXME: These are only used in pattern_sim, which should be changed to + * use the "struct spectrum" from above later */ + struct sample *spectrum0; int nsamples; /* Number of wavelengths */ int spectrum_size; /* Size of "spectrum" */ diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 5cd8e560..40133c93 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -1358,6 +1358,7 @@ static void read_audit_lines(Stream *st) ERROR("Failed to allocate memory for audit information\n"); return; } + st->audit_info[0] = '\0'; /* Read lines from stream until one of them starts with "-----", * then rewind to the start of that line */ diff --git a/libcrystfel/src/utils.h b/libcrystfel/src/utils.h index a759ff15..2c756ad7 100644 --- a/libcrystfel/src/utils.h +++ b/libcrystfel/src/utils.h @@ -185,6 +185,8 @@ static inline int within_tolerance(double a, double b, double percent) /* Photon energy (eV) to wavelength (m) */ #define ph_eV_to_lambda(a) ph_en_to_lambda(eV_to_J(a)) +/* Photon energy (eV) to k (1/m) */ +#define ph_eV_to_k(a) ((a)*ELECTRON_CHARGE/PLANCK/C_VACUO) /* ------------------------------ Message macros ---------------------------- */ |