Manage spectra
spectra
¶
MakeSpectra
¶
Class to create spectra from event lists output by SIXTE. This creates one spectrum per bin, given a binning, with the corresponding ARF that accounts for the vignetting.
Source code in src/xifu_cluster_sim/spectra.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
__init__(binning, xifu_config=XIFU_Config())
¶
Instantiate the class
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
binning
|
binning
|
Binning object created with the binning functions |
required |
xifu_config
|
XIFU_Config
|
X-IFU Config object |
XIFU_Config()
|
Source code in src/xifu_cluster_sim/spectra.py
162 163 164 165 166 167 168 169 170 171 172 173 | |
load_event(event_file_path, grades_to_keep=[1])
¶
Load event file to transform into spectra
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_file_path
|
str
|
Path to the event file |
required |
grades_to_keep
|
list
|
List of valid grades to keep for event making |
[1]
|
Source code in src/xifu_cluster_sim/spectra.py
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
load_vignetting(vign_file_path='/xifu/usr/share/sixte/instruments/athena-xifu_2024_11/baseline/instdata/athena_vig_13rows_20240326.fits', arf_file_path='/xifu/home/mola/XIFU_Sims_Turbulence_NewConfig/ARF.arf')
¶
Load the vignetting file and compute the vignetting as a continuous function of energy using a quadratic function. This allows to take the vignetting into account without awkwarldy dealing with the fact that it is binned in energy. The vignetting file contains the average vignetting for a given offset angle and within a given energy bin. I approximate it by a smooth continuous quadratic function in energy in each bin, such that the average in each bin corresponds to the file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vign_file_path
|
str
|
Path to the vignetting file |
'/xifu/usr/share/sixte/instruments/athena-xifu_2024_11/baseline/instdata/athena_vig_13rows_20240326.fits'
|
arf_file_path
|
str
|
Path to the ARF file |
'/xifu/home/mola/XIFU_Sims_Turbulence_NewConfig/ARF.arf'
|
Source code in src/xifu_cluster_sim/spectra.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
make_arfs_and_spectra(spectra_path, numproc=1)
¶
Create one spectrum and one arf per bin in the binning. Parallelized over N processes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spectra_path
|
str
|
Path to where the events and spectra should be stored |
required |
numproc
|
int
|
Number of parallel processes |
1
|
Source code in src/xifu_cluster_sim/spectra.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
make_single_arf_and_spectrum(bin_number, spectra_path)
¶
Create a spectrum and arf for a given bin number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bin_number
|
int
|
Bin number in the binning object |
required |
spectra_path
|
str
|
Where to save the ARF, event file and spectrum that have been created |
required |
Source code in src/xifu_cluster_sim/spectra.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
eval_quadratic_piecewise(E_edges, coeffs, E_eval)
¶
Evaluates a quadratic function, given its coefficients as computed by quadratic_from_bin_averages. In each bin, the function is \(\(f(x) = a x^2 + bx + c\)\)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
E_edges
|
array
|
Edges of the bins used for the computation of the coefficients |
required |
coeffs
|
array
|
Coefficients of the quadratic function |
required |
E_eval
|
array
|
Points at which to compute the quadratic function |
required |
Source code in src/xifu_cluster_sim/spectra.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
quadratic_from_bin_averages(E_edges, V_row, boundary='natural', reg_eps=1e-12)
¶
Build piecewise quadratic function per bin with exact bin averages and C1 continuity. This function is used to build a smooth function of vignetting that is not binned. It defines the right system of equations as a matrix multiplication and then solves it to obtain the coefficients of the quadratic function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
E_edges
|
array
|
Edges of the bins at which the averages are computed |
required |
V_row
|
array
|
Average in each bin |
required |
boundary
|
str
|
'zero_slope', 'natural', or 'extrapolate'. 'zero_slope': enforce derivative = 0 at both ends. 'natural' : enforce second derivative = 0 at both ends (a_0 = a_last = 0). 'extrapolate': set right-end derivative from trend of last bins (left derivative = 0) |
'natural'
|
reg_eps
|
float
|
Regularization term |
1e-12
|
Source code in src/xifu_cluster_sim/spectra.py
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |