diff options
author | Thomas White <taw@physics.org> | 2019-05-17 17:03:48 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-05-29 10:42:04 +0200 |
commit | 94b0050cc7735c3e1635cbc89c13c6b2c49c69c8 (patch) | |
tree | 009039e182541db4544683632c9153ff46fa27ef /libcrystfel/src/spectrum.c | |
parent | 36e3370feddeb8dd18f97dc5db4da8e96c9f5c79 (diff) |
Use Spectrum API for simulation
Diffstat (limited to 'libcrystfel/src/spectrum.c')
-rw-r--r-- | libcrystfel/src/spectrum.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/libcrystfel/src/spectrum.c b/libcrystfel/src/spectrum.c index f1ada734..e083962c 100644 --- a/libcrystfel/src/spectrum.c +++ b/libcrystfel/src/spectrum.c @@ -451,3 +451,88 @@ Spectrum *spectrum_load(const char *filename) fclose(fh); return s; } + + +/** + * \param wavelength Wavelength in metres + * \param bandwidth Bandwidth as a fraction + * + * Generates a top-hat spectrum centered on 'wavelength', where the width of the + * flat top is bandwidth/wavelength + * + * \returns A newly-allocated \ref Spectrum, or NULL on error. + */ +Spectrum *spectrum_generate_tophat(double wavelength, double bandwidth) +{ + Spectrum *s; + double kvals[2]; + double samp[2]; + double kcen; + + s = spectrum_new(); + if ( s == NULL ) return NULL; + + kcen = 1.0/wavelength; + kvals[0] = kcen - kcen*bandwidth/2.0; + kvals[1] = kcen + kcen*bandwidth/2.0; + samp[0] = 1.0; + samp[1] = 1.0; + spectrum_set_pdf(s, kvals, samp, 2); + return s; +} + + +/** + * \param wavelength Wavelength in metres + * \param bandwidth Bandwidth as a fraction + * + * Generates a Gaussian spectrum centered on 'wavelength', where the standard + * deviation of the Gaussian is bandwidth/wavelength + * + * \returns A newly-allocated \ref Spectrum, or NULL on error. + */ +Spectrum *spectrum_generate_gaussian(double wavelength, double bandwidth) +{ + Spectrum *s; + struct gaussian g; + + s = spectrum_new(); + if ( s == NULL ) return NULL; + + g.kcen = 1.0/wavelength; + g.sigma = bandwidth/wavelength; + g.height = 1; + spectrum_set_gaussians(s, &g, 1); + + return s; +} + + +/** + * \param wavelength Wavelength in metres + * \param bandwidth Bandwidth as a fraction + * + * Generates a top-hat spectrum centered on 'wavelength', where the width of the + * flat top is bandwidth/wavelength + * + * \returns A newly-allocated \ref Spectrum, or NULL on error. + */ +Spectrum *spectrum_generate_sase(double wavelength, double bandwidth, + double spike_width, gsl_rng *rng) +{ +} + + +/** + * \param wavelength Wavelength in metres + * \param bandwidth Bandwidth as a fraction + * + * Generates a top-hat spectrum centered on 'wavelength', where the width of the + * flat top is bandwidth/wavelength + * + * \returns A newly-allocated \ref Spectrum, or NULL on error. + */ +Spectrum *spectrum_generate_twocolour(double wavelength, double bandwidth, + double separation) +{ +} |