Instrument models¶
ConstantGain
¶
Bases: GainModel
A scalar gain factor, independent of energy.
The factor lives as factor (an nnx.Param). Its prior is provided
via the unified prior dict under the key "instrument.gain.factor"
(shared across instrumented obs) or "instrument.gain.factor[*]" /
"instrument.gain.factor[obs_name]" (per-obs).
Source code in src/jaxspec/model/instrument.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
ConstantShift
¶
Bases: ShiftModel
An additive energy shift, constant across the spectrum.
The offset lives as offset (an nnx.Param). Its prior is provided
via the unified prior dict under the key "instrument.shift.offset"
(shared) or "instrument.shift.offset[*]" / "instrument.shift.offset[obs_name]"
(per-obs).
Source code in src/jaxspec/model/instrument.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
GainModel
¶
Bases: HasDerivedQuantities, Module
Generic gain model. __call__(energies) returns the per-energy gain factor.
Source code in src/jaxspec/model/instrument.py
26 27 28 29 30 | |
InstrumentModel
¶
Bases: HasDerivedQuantities, Module
Per-observation instrument response.
Pass as a dict to BayesianModel
BayesianModel(
spectral_model, prior, observations,
instrument_model={
"PN": None,
"MOS1": InstrumentModel(gain=ConstantGain(), shift=ConstantShift()),
"MOS2": InstrumentModel(gain=ConstantGain(), shift=ConstantShift()),
},
)
None entries and omitted observations apply the identity fold
(transfer_matrix @ flux), allowing one instrument to serve as the reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gain
|
GainModel | None
|
Optional |
None
|
shift
|
ShiftModel | None
|
Optional |
None
|
Source code in src/jaxspec/model/instrument.py
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 123 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 154 155 156 157 158 | |
apply_gain(flux, energies)
¶
Multiply flux (or each branch in a pytree) by gain's factor.
Source code in src/jaxspec/model/instrument.py
121 122 123 124 125 126 | |
apply_shift(energies)
¶
Apply shift to energies and clip away non-positive values.
Source code in src/jaxspec/model/instrument.py
115 116 117 118 119 | |
default_prior(observation, obs_name)
¶
Return data-dependent default priors scoped to this obs.
Mirrors BackgroundModel.default_prior:
subclasses (e.g. pileup models with per-obs dead-time / grade-fraction
parameters) override this to inject [obs_name]-scoped defaults.
User prior entries override these defaults.
Source code in src/jaxspec/model/instrument.py
105 106 107 108 109 110 111 112 113 | |
fold(spectrum, cache, eval_energies=None)
¶
Fold the input spectrum (or branches of a pytree) into the instrument using the pre-computed transfer matrix.
Source code in src/jaxspec/model/instrument.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
PileupModel
¶
Bases: InstrumentModel
Per-observation instrument response including CCD photon pile-up.
The jaxspec counterpart of XSPEC
pileup
convolution model (Davis 2001) which
describes the mixing of photons that reach the same detector region within a
single CCD frame, the dominant calibration effect for bright point sources on
instruments such as Chandra/ACIS. PileupModel extends
InstrumentModel: pile-up is
applied to the effective-area–weighted (ARF) spectrum, before the
redistribution matrix (RMF) and grouping, matching the ordering of the XSPEC
pileup model.
Warning
PileupModel requires an explicit and linear evaluation
grid (pass energy_grid=jnp.linspace(low, high, n_bins) to the fitter /
BayesianModel).
Pass it per observation just like a plain
InstrumentModel:
from jaxspec.fit import MCMCFitter
from jaxspec.model.instrument import ConstantGain, ConstantShift, PileupModel
fitter = MCMCFitter(
spectral_model,
prior,
observations,
energy_grid=np.linspace(0.2, 11.0, 1_000),
instrument_model={
"ACIS": PileupModel(
gain=ConstantGain(),
shift=ConstantShift(),
frame_time=3.2, # CCD frame time / ACIS EXPTIME (s)
frac_expo=1.0, # ARF FRACEXPO keyword
),
},
)
alpha and psf_frac are fitted parameters whose
priors are supplied through the prior dictionary like any other instrument
parameter, e.g. "instrument.alpha" and "instrument.psf_frac" (see
MCMCFitter). The remaining arguments are fixed
configuration constants.
Note
Pile-up is non-linear in flux: as noted in the
XSPEC pileup documentation,
increasing the source normalisation does not scale the predicted count
rate linearly, and fluxes should be computed with the pile-up correction
removed. The extraction region should be large enough to contain
essentially all of the point-source PSF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gain
|
GainModel | None
|
Optional energy-independent flux scaling, as for
|
None
|
shift
|
ShiftModel | None
|
Optional energy shift, as for
|
None
|
frame_time
|
float | None
|
CCD frame (readout) time in seconds ( |
None
|
frac_expo
|
float | None
|
Fractional exposure per frame in |
None
|
g0
|
float | None
|
Grade correction for single-photon detection. |
1.0
|
npiled
|
int | None
|
Maximum number of photons piled up in a single frame |
5
|
num_regions
|
float | None
|
Number of regions over which the piled counts are distributed, |
1.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
alpha |
Grade-morphing parameter — the fraction of piled events that keep a good
grade, with the good-grade fraction of an order- |
|
psf_frac |
PSF fraction — only this fraction of the extracted counts is treated for
pile-up. Fitted; give it a prior under |
Source code in src/jaxspec/model/instrument.py
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 339 340 341 342 | |
ShiftModel
¶
Bases: HasDerivedQuantities, Module
Generic shift model. __call__(energies) returns shifted energies.
Source code in src/jaxspec/model/instrument.py
49 50 51 52 53 | |