1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
* spectrum.h
*
* A class representing a radiation spectrum
*
* Copyright © 2019-2021 Deutsches Elektronen-Synchrotron DESY,
* a research centre of the Helmholtz Association.
*
* Authors:
* 2019 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 SPECTRUM_H
#define SPECTRUM_H
#include <gsl/gsl_rng.h>
/**
* \file spectrum.h
* Data structure representing a radiation spectrum
*/
/**
* This data structure is opaque. You must use the available accessor functions
* to read and write its contents.
**/
typedef struct _spectrum Spectrum;
/**
* Structure representing a Gaussian distribution of spectral density.
*/
struct gaussian
{
double kcen; /**< k value at centre of Gaussian (in 1/m) */
double sigma; /**< Standard deviation of Gaussian (in 1/m) */
double area; /**< Area under Gaussian (fraction of radiation) */
};
#ifdef __cplusplus
extern "C" {
#endif
/* Alloc/free */
extern Spectrum *spectrum_new(void);
extern void spectrum_free(Spectrum *s);
extern Spectrum *spectrum_load(const char *filename);
/* Representation as Gaussians */
extern void spectrum_set_gaussians(Spectrum *s, struct gaussian *gs,
int n_gauss);
extern int spectrum_get_num_gaussians(Spectrum *s);
extern struct gaussian spectrum_get_gaussian(Spectrum *s, int n);
/* Representation as PDF */
extern void spectrum_set_pdf(Spectrum *s, double *kcens, double *heights,
int nbins);
extern void spectrum_get_range(Spectrum *s, double *kmin, double *kmax);
extern double spectrum_get_density_at_k(Spectrum *s, double k);
/* Generation of spectra */
extern Spectrum *spectrum_generate_tophat(double wavelength, double bandwidth);
extern Spectrum *spectrum_generate_gaussian(double wavelength, double bandwidth);
extern Spectrum *spectrum_generate_sase(double wavelength, double bandwidth,
double spike_width, gsl_rng *rng);
extern Spectrum *spectrum_generate_twocolour(double wavelength, double bandwidth,
double separation);
#ifdef __cplusplus
}
#endif
#endif /* SPECTRUM_H */
|