Repository navigation
Expand file tree
/
Copy pathemline-model.tex
More file actions
615 lines (541 loc) · 25.4 KB
/
Copy pathemline-model.tex
File metadata and controls
615 lines (541 loc) · 25.4 KB
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
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
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{microtype}
% ── notation shortcuts ─────────────────────────────────────────────────────────
\newcommand{\lstar}{\lambda^{*}}
\newcommand{\sG}{\sigma_{\mathrm{G}}}
\newcommand{\sGl}{\sigma_{\mathrm{G},\ell}} % sigma_G in log-lambda
\newcommand{\seff}{\sigma_{\mathrm{eff}}}
\newcommand{\C}{c} % speed of light
\newcommand{\R}{\mathbf{R}}
\newcommand{\W}{\mathbf{W}}
\newcommand{\M}{\mathbf{M}}
\newcommand{\inv}[1]{#1^{-1}}
\title{FastSpecFit Emission-Line Model}
\author{John Moustakas%
\thanks{Emission-line model derivations and implementation assisted by
Claude Code (Claude Sonnet 4.6, Anthropic).}}
\date{\today}
\begin{document}
\maketitle
%\tableofcontents
%\bigskip
\section{Introduction}
This note documents the forward model used by \textsc{FastSpecFit} to
fit emission lines in DESI galaxy spectra. The new model supersedes
the earlier bin-integration approach developed by Jeremy Buhler
(@jbuhler) in 2024 and used in FastSpecFit versions 3.0.0 through
3.3.0, and reconciles it with the resolution-matrix deconvolution
framework recommended by Sergey Koposov (@segasai).
%The three topics covered are: (i)~the analytic pre-convolved Gaussian
%profile that serves as the forward model, (ii)~how that profile is
%coupled to the deconvolved DESI resolution matrix, and (iii)~the
%closed-form Jacobian used by the nonlinear least-squares optimizer.
\section{Intrinsic Emission-Line Profile}
\label{sec:intrinsic}
The intrinsic spectral profile of a single emission line is modeled as a
log-Gaussian in observed wavelength,
\begin{equation}
f(\lambda;\, A,\lstar,\sigma)
\;=\;
A \exp\!\left(-\frac{(\ln\lambda - \ln\lstar)^{2}}{2\sigma^{2}}\right),
\label{eq:intrinsic}
\end{equation}
where $A$ is the peak amplitude (in flux-density units, e.g.\
$10^{-17}$\,erg\,s$^{-1}$\,cm$^{-2}$\,\AA$^{-1}$), $\lstar$ is the
observed line center, and $\sigma$ is the intrinsic line width in
log-$\lambda$ units (dimensionless).
\paragraph{Line center.}
The observed center is determined by the rest-frame wavelength
$\lambda_{\mathrm{rest}}$, the spectroscopic redshift $z$ (fixed from
Redrock), and a residual velocity shift $\Delta v$ (km\,s$^{-1}$):
\begin{equation}
\lstar \;=\; \lambda_{\mathrm{rest}}\,\bigl(1 + z + \Delta v/\C\bigr)
\;\equiv\; \lambda_{\mathrm{rest}} \cdot \text{line\_shift}.
\label{eq:lstar}
\end{equation}
\paragraph{Line width.}
The width $\sigma$ is related to the physical velocity dispersion
$s$\,(km\,s$^{-1}$) by $\sigma = s/\C$. For astrophysical lines
$\sigma \lesssim 10^{-3}$, so the log-Gaussian is an excellent
approximation to a Gaussian in linear wavelength.
\paragraph{Integrated flux.}
The total flux of the intrinsic profile is
\begin{equation}
\Phi
\;=\; \int_0^{\infty} f(\lambda)\,d\lambda
\;=\; \sqrt{2\pi}\,A\,\lstar\,\sigma\,e^{\sigma^2/2}
\;\approx\; \sqrt{2\pi}\,A\,\lstar\,\sigma,
\label{eq:flux}
\end{equation}
where the correction factor $e^{\sigma^2/2} \approx 1 + \mathcal{O}(\sigma^2)$
is negligible for any astrophysical line width. In terms of the fitted
parameters,
\begin{equation}
\boxed{\Phi \;=\; \sqrt{2\pi}\,A\,\lstar\,s/\C.}
\label{eq:flux_phys}
\end{equation}
This result is independent of the pixel grid and of the instrumental
resolution matrix; \textsc{FastSpecFit} reports $\Phi$ as the measured line
flux.
\section{The DESI Resolution Matrix}
\label{sec:resolution}
\paragraph{Extraction model.}
DESI spectra are produced by an optimal extraction that encodes the
wavelength-dependent instrumental line-spread function (LSF) in a sparse
resolution matrix $\R$, stored in band (diagonal) format with ${\sim}11$
diagonals and row-normalized to preserve integrated flux. For an ideal
continuous spectrum $f(\lambda)$, the extracted flux at pixel $i$ is the
integral
\begin{equation}
d_i \;=\; \int_0^\infty K(\lambda_i,\lambda)\,f(\lambda)\,d\lambda,
\label{eq:continuous}
\end{equation}
where $K(\lambda_i,\lambda)$ is the effective extraction kernel encoded by
$\R$. The familiar discrete relation $\mathbf{d} \approx \R\,\mathbf{f}$
(with $\mathbf{f}$ evaluated at pixel centers) approximates $f$ as constant
within each pixel; it is accurate for broad, slowly varying features but
fails for unresolved emission lines.
\paragraph{Pre-convolved representation.}
A more accurate discretization rewrites \eqref{eq:continuous} in terms of
the $\sG$-pre-convolved spectrum evaluated at pixel centers,
$h_j = (G_{\sG}*f)(\lambda_j)$. Defining the Gaussian design matrix
$M_{ij} = G(\lambda_i - \lambda_j;\,0,\,\sG)$, so that
$\mathbf{h} \approx \M\,\mathbf{f}$ and $\mathbf{f} \approx \inv{\M}\,\mathbf{h}$,
gives
\begin{equation}
\mathbf{d} \;\approx\; \W\,\mathbf{h},
\qquad
\W \;=\; \R\,\inv{\M}.
\label{eq:deconv}
\end{equation}
Because $h_j = \int G(\lambda_j - \lambda;\,0,\,\sG)\,f(\lambda)\,d\lambda$
is a weighted integral of $f$ rather than a point evaluation, it more
faithfully represents the continuous spectrum even for features as narrow as
one pixel. \textsc{FastSpecFit} uses $\sG = \sigma_0 = 0.5$\,\AA\ (the
constant \texttt{SIGMA0\_ANGSTROM} in \texttt{resolution.py}), much smaller
than the DESI LSF FWHM (${\sim}2$\,\AA), so that $h_j \approx f_j$ for
broad features while providing an accurate discretization for narrow ones.
\paragraph{Forward-model strategy.}
Given an analytic expression for $h_j = (G_{\sG}*f)(\lambda_j)$,
equation~\eqref{eq:deconv} provides the predicted extracted spectrum
directly, without numerical integration. The problem reduces to evaluating
the pre-convolved profile $\mathbf{h}$ analytically.
\section{Pre-Convolved Forward Model}
\label{sec:model}
\subsection{Key approximation}
\label{ssec:approx}
In log-$\lambda$ coordinates $u = \ln\lambda$, the intrinsic profile
\eqref{eq:intrinsic} is an exact Gaussian:
\begin{equation}
f(u) \;=\; A\exp\!\left(-\frac{(u - u^*)^2}{2\sigma^2}\right),
\qquad u^* = \ln\lstar.
\end{equation}
The linear-space Gaussian kernel $G_{\sG}(\lambda)$ maps to log-$\lambda$
space as
\begin{equation}
G_{\sG}(\lambda) \;\longrightarrow\;
G\!\left(u - u^*;\, 0,\, \sGl\right)
\;+\; \mathcal{O}\!\left(\sGl^2\right),
\qquad
\sGl \;\equiv\; \sG/\lstar,
\label{eq:kernel_approx}
\end{equation}
where the approximation replaces the linear-space Gaussian with a
log-space Gaussian of width $\sGl = \sG/\lstar$. The relative error is
$\mathcal{O}(\sGl) = \mathcal{O}(\sG/\lstar) \approx 7\times10^{-5}$ for
DESI, and is negligible.
\subsection{Convolved profile}
\label{ssec:convolved}
Using the approximation \eqref{eq:kernel_approx}, the convolution of two
log-space Gaussians with widths $\sigma$ and $\sGl$ is itself a Gaussian
with quadrature-summed width. Defining the \emph{effective width}
\begin{equation}
\seff \;=\; \sqrt{\sigma^2 + \sGl^2},
\label{eq:seff}
\end{equation}
the pre-convolved profile evaluates at pixel center $\lambda_j$ as
\begin{equation}
\boxed{
F_j \;=\; A\,\frac{\sigma}{\seff}
\exp\!\left(-\frac{x_j^2}{2\seff^2}\right),
}
\label{eq:model}
\end{equation}
where $x_j = \ln\lambda_j - \ln\lstar$ is the log-$\lambda$ offset from
the line center. The amplitude factor $\sigma/\seff \leq 1$ accounts for
the broadening: a narrower intrinsic line ($\sigma \ll \sGl$) is dominated
by the pre-convolution and its peak is suppressed relative to a broad line.
Equation~\eqref{eq:model} is evaluated only over pixels within
$\pm N_\sigma\,\seff$ of the line center (with $N_\sigma = 5$ in
\textsc{FastSpecFit}); pixels outside this range are set to zero. The
complete emission-line model is the sum of all line profiles, projected
through $\W$ (equation~\ref{eq:deconv}).
\subsection{Comparison to the earlier bin-integration approach}
\label{ssec:comparison}
The earlier formulation (Buhler 2024) computed a \emph{bin-integrated} flux
\begin{equation}
F_j^{(\mathrm{old})}
\;=\; A\bigl[\Phi_\sigma(b_{j+1}) - \Phi_\sigma(b_j)\bigr],
\end{equation}
where $\Phi_\sigma$ is the CDF of the log-Gaussian and $b_j$,
$b_{j+1}$ are the bin edges. These values are exact per-bin averages
of the intrinsic profile~\eqref{eq:intrinsic}. However, $\W$ was
constructed to accept the Gaussian-\emph{convolved} point values $F_j$
(equation~\ref{eq:model}), not bin integrals. Feeding
$F_j^{(\mathrm{old})}$ into $\W$ therefore produces a systematic model
error: for lines narrower than approximately one DESI pixel
(${\sim}0.8$\,\AA), the mismatch between a bin integral and a
convolved point value is position-dependent, causing flux biases of
5\%--30\% depending on where the line center falls within the pixel.
The Gaussian-point-evaluation model~\eqref{eq:model} removes this
bias.
\section{Analytic Jacobian}
\label{sec:jacobian}
The emission-line optimizer (\texttt{scipy.optimize.least\_squares}) requires
the Jacobian of the \emph{pre-convolved} model $F_j$ with respect to the
three per-line parameters $(A,\, \Delta v,\, s)$. We define the shorthand
\begin{align}
g_j &\;\equiv\; A\,\frac{\sigma}{\seff}\,
\exp\!\left(-\frac{x_j^2}{2\seff^2}\right)
\;=\; \text{amp\_eff}\times\text{gauss}, \\[4pt]
\iota &\;\equiv\; \seff^{-2}, \\[4pt]
\text{line\_shift} &\;\equiv\; 1 + z + \Delta v/\C.
\end{align}
The Jacobian rows for pixel $j$ are derived below; they are nonzero only
within the support region $|x_j| < N_\sigma\,\seff$.
\subsection{Amplitude: \texorpdfstring{$\partial F_j/\partial A$}{dF/dA}}
The model is linear in $A$, and $\sigma$, $\seff$, $x_j$ are all independent
of $A$:
\begin{equation}
\frac{\partial F_j}{\partial A}
\;=\; \frac{\sigma}{\seff}
\exp\!\left(-\frac{x_j^2}{2\seff^2}\right)
\;=\; \frac{g_j}{A}.
\label{eq:dF_dA}
\end{equation}
\subsection{Velocity shift: \texorpdfstring{$\partial F_j/\partial \Delta v$}{dF/dv}}
\label{ssec:dFdv}
The dependence on $\Delta v$ enters through $\ln\lstar =
\ln(\lambda_{\rm rest} \cdot \text{line\_shift})$, so
\begin{equation}
\frac{\partial \ln\lstar}{\partial \Delta v}
\;=\; \frac{1}{\C\cdot\text{line\_shift}},
\qquad
\frac{\partial x_j}{\partial \Delta v}
\;=\; -\frac{1}{\C\cdot\text{line\_shift}}.
\label{eq:dlnl_dv}
\end{equation}
There is a secondary dependence through $\sGl = \sG/\lstar$, but its
contribution to $\partial F_j/\partial \Delta v$ is of order
$\sGl^2\,(1-x_j^2/\seff^2)/x_j \sim 10^{-5}$ relative to the primary term
and is neglected. The primary result is
\begin{equation}
\frac{\partial F_j}{\partial \Delta v}
\;=\; \frac{\partial F_j}{\partial x_j}\cdot
\frac{\partial x_j}{\partial \Delta v}
\;=\; \frac{g_j\,x_j\,\iota}{\C\cdot\text{line\_shift}}.
\label{eq:dF_dv}
\end{equation}
%\noindent\textit{Note:} using $1/\C$ in place of
%$1/(\C\cdot\text{line\_shift})$ introduces a systematic error of order $z$
%at all redshifts (e.g.\ 10\% at $z=0.1$) and must be avoided.
\subsection{Line width: \texorpdfstring{$\partial F_j/\partial s$}{dF/ds}}
\label{ssec:dFds}
With $\sigma = s/\C$, we need $\partial F_j/\partial s =
(\partial F_j/\partial \sigma)/\C$. Both the amplitude factor
$\text{amp\_eff} = A\sigma/\seff$ and the exponent depend on $\sigma$.
Using $\partial\seff/\partial\sigma = \sigma/\seff$:
\begin{align}
\frac{\partial}{\partial\sigma}\!\left(\frac{A\sigma}{\seff}\right)
&\;=\;
\frac{A(\seff^2 - \sigma^2)}{\seff^3}
\;=\;
\frac{A\,\sGl^2}{\seff^3},
\\[6pt]
\frac{\partial}{\partial\sigma}\!
\left[\exp\!\left(-\frac{x_j^2}{2\seff^2}\right)\right]
&\;=\;
\exp\!\left(-\frac{x_j^2}{2\seff^2}\right)
\cdot\frac{x_j^2\,\sigma}{\seff^4}.
\end{align}
Combining and using $\sGl^2 = \seff^2 - \sigma^2$:
\begin{align}
\frac{\partial F_j}{\partial\sigma}
&\;=\;
\frac{A}{\seff}\cdot\text{gauss}\cdot
\left(\frac{\sGl^2}{\seff^2} + \frac{\sigma^2 x_j^2}{\seff^4}\right)
\nonumber\\
&\;=\;
\frac{A}{\seff}\cdot\text{gauss}\cdot
\left[1 - \frac{\sigma^2}{\seff^2} + \frac{\sigma^2 x_j^2}{\seff^4}\right]
\nonumber\\
&\;=\;
\frac{A}{\seff}\cdot\text{gauss}\cdot
\Bigl[1 - \sigma^2\bigl(1 - x_j^2\iota\bigr)\iota\Bigr].
\end{align}
Dividing by $\C$:
\begin{equation}
\boxed{
\frac{\partial F_j}{\partial s}
\;=\;
\frac{A}{\seff\,\C}\cdot\text{gauss}\cdot
\Bigl[1 - \sigma^2\bigl(1 - x_j^2\iota\bigr)\iota\Bigr].
}
\label{eq:dF_ds}
\end{equation}
\paragraph{Numerical stability at $\sigma\to 0$.}
When $\sigma = 0$ (a line width fixed to zero), $\seff = \sGl \neq 0$ and
equation~\eqref{eq:dF_ds} evaluates to
\begin{equation}
\left.\frac{\partial F_j}{\partial s}\right|_{\sigma=0}
\;=\;
\frac{A}{\sGl\,\C}
\exp\!\left(-\frac{x_j^2}{2\sGl^2}\right),
\end{equation}
which is finite.
%An earlier equivalent form of \eqref{eq:dF_ds}, $g_j(1/\sigma -
%\sigma\cdots)/\C$, has an explicit $1/\sigma$ that diverges at
%$\sigma=0$ and must \emph{not} be used.
\subsection{Summary}
Table~\ref{tab:jacobian} collects the three Jacobian entries.
\begin{table}[h]
\centering
\renewcommand{\arraystretch}{1.6}
\begin{tabular}{@{}lll@{}}
\toprule
Parameter & Symbol & $\partial F_j/\partial\,\text{param}$ \\
\midrule
Amplitude & $A$ &
$g_j / A$
\\
Velocity shift & $\Delta v$ (km\,s$^{-1}$) &
$g_j\,x_j\,\iota\;/\;(\C\cdot\text{line\_shift})$
\\
Line width & $s$ (km\,s$^{-1}$) &
$(A/\seff\C)\cdot\text{gauss}\cdot
[1 - \sigma^2(1-x_j^2\iota)\iota]$
\\
\bottomrule
\end{tabular}
\caption{Jacobian of the pre-convolved model $F_j$ with respect to the
three per-line parameters. Here $\iota\equiv\seff^{-2}$,
$g_j = (A\sigma/\seff)\,e^{-x_j^2/(2\seff^2)}$, and
$\text{line\_shift}=1+z+v/\C$.}
\label{tab:jacobian}
\end{table}
\section{Implementation Notes}
\label{sec:impl}
\paragraph{Effective width and pixel support.}
The pre-convolution sets a floor on the effective line width:
$\seff \geq \sGl = \sG/\lstar$, so even an unresolved line
($\sigma\to 0$) occupies approximately $2N_\sigma\sGl/\Delta\!\ln\lambda$
pixels, where $\Delta\!\ln\lambda \approx \Delta\lambda/\lambda$ is the
pixel scale in log-$\lambda$. For DESI ($\sG=0.5$\,\AA,
$\Delta\lambda=0.8$\,\AA\ at $\lambda\sim6000$\,\AA), this floor is
$\sGl/(\Delta\ln\lambda) \approx 0.5/0.8 \approx 0.6$\,pixel, so the
pre-convolved profile always spans $\gtrsim 6$ pixels at $5\sigma$ truncation.
This ensures the Riemann sum $\sum_j F_j\,\Delta\lambda_j$ recovers the
analytic flux \eqref{eq:flux} to better than 2\%, independent of the
sub-pixel position of the line center.
\paragraph{Flux independence of resolution matrix.}
The reported line flux $\Phi = \sqrt{2\pi}\,A\,\lstar\,s/\C$
(equation~\ref{eq:flux_phys}) is the integral of the \emph{intrinsic}
profile~\eqref{eq:intrinsic} before any convolution. It is therefore
independent of $\sG$, the pixel grid, and $\W$. This is preferable to
summing the model pixels $\sum_j (\W\mathbf{F})_j\,\Delta\lambda_j$, which
depends on all of these quantities.
\paragraph{Shared parameter constraints.}
In \textsc{FastSpecFit}, lines within a kinematic group share a common $\Delta v$
and $s$. The Jacobian rows for those lines are assembled by the sparse
\texttt{ParamsMapping} layer, which maps the physically constrained parameter
vector to and from the per-line parameter array before calling
the functions described here.
\paragraph{Output for heavily masked lines.}
When more than 30\% of the pixels in the original inverse-variance spectrum within
a line's spectral window are masked, the pixel-level measurements (BOXFLUX, CONT,
CHI2) cannot be computed reliably. For lines whose amplitude, $\Delta v$, and $s$
are all tied to a kinematic anchor, however, the model-derived quantities (AMP,
VSHIFT, SIGMA, MODELAMP, and the analytic flux $\Phi = \sqrt{2\pi}\,A\,\lstar\,s/\C$;
equation~\ref{eq:flux_phys}) are still valid and are reported with the pixel-level
fields set to zero. This primarily benefits the fixed-ratio doublet members such as
[O\,\textsc{iii}]~$\lambda$4959, [N\,\textsc{ii}]~$\lambda$6548, and
[O\,\textsc{ii}]~$\lambda$7330 (Table~\ref{tab:amp_constraints}), whose parameters
are fully determined by their bright reference lines.
\section{Kinematic Groups and Parameter Constraints}
\label{sec:kinematics}
\textsc{FastSpecFit} fits all emission lines simultaneously subject to astrophysically
motivated constraints that reduce the number of free kinematic parameters. Lines within
a \emph{kinematic group} share a common velocity shift $\Delta v$ and line-width $s$,
tied to a single \emph{anchor} line with a fixed multiplicative factor of unity. The
groupings differ between the two models described below. All constraints---kinematic
groups, amplitude ratios, optimizer bounds, and fitting strategy---are read at startup
from the bundled configuration file \texttt{data/emline-constraints.yaml}.
Eight UV and broad AGN lines carry independently free kinematics in both models:
Ly$\alpha$, [N\,v]~$\lambda$1240, O\,\textsc{i}~$\lambda$1304,
Si\,\textsc{iv}~$\lambda$1396, C\,\textsc{iv}~$\lambda$1549,
He\,\textsc{ii}~$\lambda$1640, Al\,\textsc{iii}~$\lambda$1857, and
He\,\textsc{ii}~$\lambda$4686. Two additional global kinematic pairs are applied
regardless of which profile is active: Si\,\textsc{iii}]~$\lambda$1892 is tied to
C\,\textsc{iii}]~$\lambda$1908 (anchor), and Mg\,\textsc{ii}~$\lambda$2796 is tied to
Mg\,\textsc{ii}~$\lambda$2803 (anchor, with the amplitude ratio a free doublet parameter;
Section~\ref{ssec:amp_constraints}). Both global pairs use the broad-line bounds
($1 < s < 10{,}000$~km/s, $|\Delta v| < 2{,}500$~km/s).
\subsection{Narrow-only model (\texttt{linemodel\_nobroad})}
\label{ssec:nobroad}
The narrow-only model is preferred when no significant broad Balmer component is
detected; all broad Balmer amplitudes are fixed to zero. It has two kinematic
groups summarized in Table~\ref{tab:groups_nobroad}.
\begin{table}[h]
\centering
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{@{}llp{8cm}@{}}
\toprule
Group & Anchor & Member lines \\
\midrule
Forbidden & [O\,\textsc{iii}]~$\lambda$5007
& [Ne\,v]~$\lambda\lambda$3346,3426;
[O\,\textsc{ii}]~$\lambda\lambda$3726,3729;
[Ne\,\textsc{iii}]~$\lambda$3869;
[O\,\textsc{iii}]~$\lambda$4363;
[O\,\textsc{iii}]~$\lambda\lambda$4959,5007;
[N\,\textsc{ii}]~$\lambda$5755;
[O\,\textsc{i}]~$\lambda$6300;
[S\,\textsc{iii}]~$\lambda$6312;
[N\,\textsc{ii}]~$\lambda\lambda$6548,6584;
[S\,\textsc{ii}]~$\lambda\lambda$6716,6731;
[Ar\,\textsc{iii}]~$\lambda$7135;
[O\,\textsc{ii}]~$\lambda\lambda$7320,7330;
[S\,\textsc{iii}]~$\lambda\lambda$9069,9532 \\[4pt]
Narrow Balmer + He\,\textsc{i} & H$\alpha$
& H8~($\lambda$3890), H$\epsilon$, H$\delta$, H$\gamma$,
H$\beta$,
He\,\textsc{i}~$\lambda$4471, He\,\textsc{i}~$\lambda$5876 \\
\bottomrule
\end{tabular}
\caption{Kinematic groups in the narrow-only model. All lines within a group share
the anchor's $\Delta v$ and $s$, subject to bounds $1 < s < 750$~km/s and
$|\Delta v| < 500$~km/s. [O\,\textsc{iii}]~$\lambda$4959 is also subject to a
fixed amplitude constraint relative to [O\,\textsc{iii}]~$\lambda$5007
(Table~\ref{tab:amp_constraints}).}
\label{tab:groups_nobroad}
\end{table}
\subsection{Narrow+broad model (\texttt{linemodel\_broad})}
\label{ssec:broad}
The narrow+broad model is preferred when a significant broad Balmer
component is detected. It has three kinematic groups summarized in
Table~\ref{tab:groups_broad}. A notable difference from the
narrow-only model is that all narrow lines---Balmer, He\,\textsc{i},
and forbidden alike---are collapsed into a single kinematic group
anchored to the narrow H$\alpha$ line; the [O\,\textsc{iii}] doublet
retains its own separate kinematics.
\begin{table}[h]
\centering
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{@{}llp{7.5cm}@{}}
\toprule
Group & Anchor & Member lines \\
\midrule
Narrow (all) & H$\alpha$
& All narrow Balmer + He\,\textsc{i} lines listed in
Table~\ref{tab:groups_nobroad}, plus all
forbidden lines except [O\,\textsc{iii}]~$\lambda\lambda$4959,5007 \\[4pt]
[O\,\textsc{iii}] doublet & [O\,\textsc{iii}]~$\lambda$5007
& [O\,\textsc{iii}]~$\lambda$4959, [O\,\textsc{iii}]~$\lambda$5007 \\[4pt]
Broad Balmer & H$\alpha_{\mathrm{broad}}$
& H$\beta_{\mathrm{broad}}$,
H$\gamma_{\mathrm{broad}}$,
H$\delta_{\mathrm{broad}}$,
H$\epsilon_{\mathrm{broad}}$,
H8$_{\mathrm{broad}}$ \\
\bottomrule
\end{tabular}
\caption{Kinematic groups in the narrow+broad model. Narrow groups (\emph{narrow all}
and \emph{[O\,\textsc{iii}] doublet}) are bounded by $1 < s < 750$~km/s and
$|\Delta v| < 500$~km/s; the broad Balmer group by $1 < s < 10{,}000$~km/s and
$|\Delta v| < 2{,}500$~km/s.}
\label{tab:groups_broad}
\end{table}
\subsection{Amplitude constraints}
\label{ssec:amp_constraints}
Several line pairs carry additional constraints on their relative amplitudes,
independent of the kinematic model chosen. Three doublet ratios are fixed to
theoretical values; three others are fitted as free parameters
(Table~\ref{tab:amp_constraints}).
\begin{table}[h]
\centering
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{@{}llll@{}}
\toprule
Constrained line & Reference line & Amplitude factor & Type \\
\midrule
$[$N\,\textsc{ii}$]$~$\lambda$6548 & $[$N\,\textsc{ii}$]$~$\lambda$6584 & $1/3.0326$ & Fixed \\
$[$O\,\textsc{iii}$]$~$\lambda$4959 & $[$O\,\textsc{iii}$]$~$\lambda$5007 & $1/2.9643$ & Fixed \\
$[$O\,\textsc{ii}$]$~$\lambda$7330 & $[$O\,\textsc{ii}$]$~$\lambda$7320 & $1/1.225$ & Fixed \\
$[$O\,\textsc{ii}$]$~$\lambda$3726 & $[$O\,\textsc{ii}$]$~$\lambda$3729 & $r$ (free) & Doublet ratio \\
$[$S\,\textsc{ii}$]$~$\lambda$6731 & $[$S\,\textsc{ii}$]$~$\lambda$6716 & $r$ (free) & Doublet ratio \\
Mg\,\textsc{ii}~$\lambda$2796 & Mg\,\textsc{ii}~$\lambda$2803 & $r$ (free) & Doublet ratio \\
\bottomrule
\end{tabular}
\caption{Amplitude constraints applied in both models. Fixed ratios are derived
from atomic emissivities (see code comments in \texttt{emlines.py}); doublet
ratios are fitted free parameters that encode density-sensitive flux ratios.}
\label{tab:amp_constraints}
\end{table}
\subsection{Final optimization pass}
\label{ssec:final_pass}
After the primary constrained fit \textsc{FastSpecFit} optionally runs a second
optimization pass in which some kinematic ties are relaxed. The pass is controlled at
two levels of granularity, both defined in \texttt{data/emline-constraints.yaml}:
\begin{itemize}
\item \textbf{Per kinematic group}: each group carries \texttt{free\_vshift} and
\texttt{free\_sigma} boolean flags. When a flag is \texttt{true}, the corresponding
parameter type ($\Delta v$ or $s$) is freed for every member of that group in the
relaxed model, with one exception: lines that belong to any amplitude-constrained
doublet pair (Section~\ref{ssec:amp_constraints}) are never freed kinematically,
because releasing them individually would allow transitions originating from the same
upper level to acquire different velocity shifts or line widths. Groups with both
flags \texttt{false} are not relaxed.
\item \textbf{Per profile}: the fields \texttt{enabled}, \texttt{warm\_start},
\texttt{adopt\_if}, and \texttt{inherit\_in\_mc} control whether the pass runs,
how it is initialized, and when its result is adopted.
\end{itemize}
In the default configuration, both kinematic groups of the \emph{narrow-only} profile
have \texttt{free\_vshift: true} and \texttt{free\_sigma: false}: individual velocity
shifts $\Delta v$ are freed so that each line can absorb small wavelength-calibration
offsets, while line widths $s$ remain shared within the group. Doublet-constrained
lines---[O\,\textsc{ii}]~$\lambda\lambda$3726,3729;
[S\,\textsc{ii}]~$\lambda\lambda$6716,6731;
[N\,\textsc{ii}]~$\lambda\lambda$6548,6584;
[O\,\textsc{iii}]~$\lambda\lambda$4959,5007;
[O\,\textsc{ii}]~$\lambda\lambda$7320,7330;
and Mg\,\textsc{ii}~$\lambda\lambda$2796,2803---retain their kinematic ties even when
\texttt{free\_vshift} is \texttt{true}. For the \emph{narrow+broad} profile, all three
groups have both flags set to \texttt{false}; the pass is nominally enabled but produces
no free parameters and is therefore a no-op in the current default configuration.
\paragraph{Warm-start bounds.}
Each freed parameter is initialized at its primary best-fit value (\texttt{warm\_start:
true}) and constrained to remain within a symmetric window of half-width
$\delta_v$\,(km\,s$^{-1}$) for velocity shifts or $\delta_s$\,(km\,s$^{-1}$) for
line widths, both specified per kinematic group. If the warm-start value lies within
1\,km\,s$^{-1}$ of the existing optimizer boundary the tightening is skipped for that
parameter, preventing ill-constrained parameters from being anchored near a wall.
Default values are $\delta_v = 100$\,km\,s$^{-1}$ and $\delta_s = 100$\,km\,s$^{-1}$
for narrow-line groups, and $\delta_v = 500$\,km\,s$^{-1}$ and
$\delta_s = 1{,}000$\,km\,s$^{-1}$ for broad-line groups.
\paragraph{Adoption.}
The relaxed solution is adopted only if the global $\chi^2$ improvement exceeds the
number of additional free parameters (\texttt{chi2\_improves}); otherwise the primary
result is retained. The adoption decision is a single global comparison rather than
per-group, because the total $\chi^2$ is not decomposable by kinematic group when line
profiles overlap spectrally. Monte Carlo realizations use the structure of whichever
model was adopted for the nominal fit and do not independently re-evaluate the adoption
criterion (\texttt{inherit\_in\_mc: true}).
\section*{Acknowledgments}
The deconvolved-resolution-matrix framework follows the implementation
by Sergey Koposov (rvspecfit) and the original bin-integration model
is due to Buhler (2024).
\end{document}