Signal Normalization
====================

After :doc:`scan aggregation <scan_aggregation>`, the resulting spectrum can be
normalized so that its overall scale is comparable across measurements recorded
under different conditions.  The :meth:`~daxs.measurements.Measurement1D.normalize`
method of 1D measurements supports two strategies, selected via the ``mode``
argument.

Normalization to area
---------------------

.. math::

   y_\text{norm}(E) = \frac{y(E)}{\left|\int y(E)\,dE\right|}

The spectrum is divided by the absolute value of its integral, computed with
the trapezoidal rule over the current energy axis.

**When to use:** The most common choice for spectroscopy.  It preserves the
shape of the spectrum and makes the integrated intensity equal to 1 (or −1 if
the spectrum is inverted), which is natural for comparing spectra of the same
edge from different samples::

    measurement.normalize()                  # default
    measurement.normalize(mode="area")       # explicit

Normalization to maximum
------------------------

.. math::

   y_\text{norm}(E) = \frac{y(E)}{\left|\max_E y(E)\right|}

The spectrum is divided by the absolute value of its highest point.

**When to use:** Handy for quickly overlaying spectra to compare peak positions
and relative feature intensities, without worrying about integrated intensity.
Keep in mind that any noise spike at the top of the spectrum will dominate the
denominator::

    measurement.normalize(mode="maximum")

API reference
-------------

See :meth:`~daxs.measurements.Measurement1D.normalize`.
