aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcrystfel/src/spectrum.c6
-rw-r--r--tests/spectrum_check.c15
2 files changed, 17 insertions, 4 deletions
diff --git a/libcrystfel/src/spectrum.c b/libcrystfel/src/spectrum.c
index 5cb5c47d..a1b1c899 100644
--- a/libcrystfel/src/spectrum.c
+++ b/libcrystfel/src/spectrum.c
@@ -535,9 +535,9 @@ Spectrum *spectrum_generate_sase(double wavelength, double bandwidth,
if ( s == NULL ) return NULL;
for ( i=0; i<15; i++ ) {
- g[0].kcen = 1.0/wavelength + (gsl_rng_uniform_pos(rng)-0.5) * bandwidth/wavelength;
- g[0].sigma = spike_width/wavelength;
- g[0].height = 1;
+ g[i].kcen = 1.0/wavelength + (gsl_rng_uniform_pos(rng)-0.5) * bandwidth/wavelength;
+ g[i].sigma = spike_width/wavelength;
+ g[i].height = gsl_rng_uniform(rng);
}
spectrum_set_gaussians(s, g, 15);
diff --git a/tests/spectrum_check.c b/tests/spectrum_check.c
index e910aad3..5ee85dcc 100644
--- a/tests/spectrum_check.c
+++ b/tests/spectrum_check.c
@@ -91,10 +91,23 @@ int main(int argc, char *argv[])
r += check_integral(s, 100);
spectrum_free(s);
- s = spectrum_generate_sase(ph_eV_to_k(9000), 0.01, 0.0005, rng);
+ s = spectrum_generate_sase(ph_eV_to_lambda(9000), 0.01, 0.0001, rng);
+ r += check_integral(s, 100);
plot_spectrum(s);
spectrum_free(s);
+ s = spectrum_generate_gaussian(ph_eV_to_lambda(9000), 0.01);
+ r += check_integral(s, 100);
+ spectrum_free(s);
+
+ s = spectrum_generate_tophat(ph_eV_to_lambda(9000), 0.01);
+ r += check_integral(s, 100);
+ spectrum_free(s);
+
+ s = spectrum_generate_twocolour(ph_eV_to_lambda(9000), 0.001, ph_eV_to_k(100));
+ r += check_integral(s, 100);
+ spectrum_free(s);
+
gsl_rng_free(rng);
return r;