14.2.4 XP mean spectra
In this section we describe some tests aiming for internal validation of the XP mean spectra in the catalogue. The tests look at some general properties (Section 14.2.4), the coefficients to the basis functions (Section 14.2.4), the shape of the spectra (Section 14.2.4), the integrated fluxes (Section 14.2.4), and the sampled spectra (Section 14.2.4).
General XP tests
Empty spectra: There is (only) one source with an RP spectrum but no BP spectrum. This source is source_id. It is a red and faint source (, and mag). Although integrated photometry for BP could be calculated (using 11 observations), it is not surprising that no spectrum could be produced, given the faintness of the source.
Number of transits: As can be seen in Figure 14.9, the number of transits used for building the mean BP spectra is lower than for the mean RP spectra, although the number of observations used to derive the mean photometry is more balanced. This is a known issue, resulting from the fact that BP spectra from the first ten months of mission were rejected due to contamination of the mirrors, cf. Section 1.3.3.
Tests on source coefficients
XP source coefficients absolute value: The absolute value of the XP source coefficients should be smaller (or of the same order of magnitude) than the integrated flux. If we define the XP (either BP or RP) mean spectra coefficients as and the XP flux derived from the photometric calibration (phot_bp_mean_flux or phot_rp_mean_flux), we flag sources with
with being a proportionality factor, adopted here as . The index is running over all coefficients, i.e. .
There is only one source failing the test for BP (none for RP), with source_id. There are two coefficients of its BP spectrum not fulfilling and failing the test. They are coefficients 33 and 37, having and respectively. This source is a blue and faint object ( mag, mag and mag). As it has very small total flux in BP ( e/s), its mean internal sampled BP spectrum is quite unrealistic (Figure 14.10). In fact, considering the error in the coefficients, they are compatible with zero.
XP source coefficients decreasing: The values of the optimised XP source coefficients () should in general be decreasing with the order of the coefficient (), see Figure 17.58. We consider the first coefficients and test the difference
Let be a vector of length whose entries at position are if and else. We have to adjust the signs in the covariance matrix of the coefficients, , by computing . The error on is then given by
The test is passed for a source if
The suitable choice of the index depends on the basis in which the coefficients are analysed. For the optimised Hermite basis used in the spectra, a value of was adopted. For the limit, was used.
In Table 14.1 we show the results of the test.
|Coefficients||% Passed||% Failed||Passed||Failed|
|BP||199.99%||0.01%||219 171 605||26 037|
|RP||100.00%||0.00%||219 192 173||15 470|
In Figure 14.11 we show the percentage of sources failing in a colour-magnitude diagram. Faint sources with extreme colours are the ones that fail the most, specially red sources for the BP test and vice versa.
Truncation of the number of coefficients: We check with this test that proposed truncation of the XP mean spectrum coefficients (according to bp_n_relevant_bases and rp_n_relevant_bases) produce good results.
We derive residuals as a function of the pseudo-wavelength of the sampled spectra derived using the full set of mean spectrum coefficients () and the truncated set of coefficients (). We then compare this residual with the uncertainty in the sampled spectra using the full set of coefficients ().
with the values of and being the maximum number of standard deviations a spectrum in full representation and truncated representation is accepted to differ in mean and in maximum (we adopted and ).
In the wings, very large relative changes might be acceptable, as the count numbers are very small. The test is therefore done on two ranges of pseudo-wavelengths, one including the wings, and one without the wings. The sampling in the ranges for the two versions of the test is chosen as and in pseudo-wavelength space, using a sampling in 0.5 steps.
The test is passed for a source if it satisfies (14.5).
About – of the sources are considered failing this test when considering the whole XP spectrum and about –% when excluding the wings (see Table 14.2). The location of the failing sources in the sky show some correlation with the scanning law. The high numbers of failing sources is caused by the low threshold applied in this test. Comparing the failure rates with results from simulated data and the theoretical case of normally distributed data, the failure rate is about as expected.
|Band||% Passed||% Failed||Passed||Failed|
|BP||38.82%||61.18%||185 054 925||134 065 408|
|RP||45.84%||54.16%||100 440 777||118 679 557|
|BP||64.01%||35.99%||140 256 920||178 863 413|
|RP||60.46%||39.54%||132 473 460||186 646 874|
Looking at the number of relevant basis functions for all the spectra, we find:
112 348 sources with bp_n_relevant_bases=1
0 sources with bp_n_relevant_bases=54
22 721 sources with bp_n_relevant_bases=55
75 430 sources with rp_n_relevant_bases=1
0 sources with rp_n_relevant_bases=54
5 sources with rp_n_relevant_bases=55
The first thing to notice is that there are no sources with relevant number of bases equal to 54. This is due a minor oversight and of little consequence. Another thing to notice is that there are very few sources (only 5) with relevant number of bases equal to 55 for RP. In fact, the spectra of sources with 55 relevant bases were checked to be pure noise and they have mostly mag. They have no significant coefficients and then the default value (55) is maintained.
Tests on the shape of the spectra
Beta angle: This test defines a set of representative sources located at different wide regions in the HR diagram and determines similarities in the XP spectrum for a given source with those in each of these regions. We use here the concept of ‘ angle’, which describes in a single parameter how well a spectrum can be represented as a linear combination of spectra in a set of reference spectra. This angle is thus always with respect to a certain set of reference spectra, and this set may change with application and purpose.
The test consists of selecting different sets of reference spectra, selected from different regions of the HR diagram. For all sources, the beta angle with respect to all selected reference were computed. Sources in the same region of the HR diagram as defined by a reference set should have small beta angles. Sources from different regions should have large beta angles. Non-stellar sources should have very large angles.
The integrated photometry and the parallax can be used to determine the position of sources in the HR diagram, and identify the reference sets for which the beta angle should be small. It is therefore necessary to apply the same selection criterion used for the selection of the reference sets to all test sources, and to classify them with respect to the reference sets.
Assume we have a set of XP spectra we use as the reference set. Each spectrum is represented by a vector , . To compensate for differences in brightness, we may normalise the spectra. A natural choice for the normalisation is the L2-norm. We denote the normalised vectors , with
We then arrange the normalised vectors into the matrix and perform a Singular Value Decomposition on it, e.g.
We then use the matrix from this decomposition to construct a new basis for the XP spectra. Since this matrix is orthogonal by construction, i.e. , we can multiply any spectrum with , and if the sampled basis functions are multiplied with , then the sampled spectra remain identical for any sampling ,
We are thus free to use an orthogonal matrix to transform both the coefficients and the basis functions, without changing the representation of the spectra. The use of from a SVD has the additional advantage that the new basis functions are sorted according to the singular values of the matrix , ensuring that the basis functions are sorted according to their relevance in representing the set of reference spectra. We may therefore consider a truncation of the representation of the set of reference sources. We denote the number of transformed basis functions required to represent all spectra in the set of reference spectra to a satisfactory degree by , with . For the reference spectra we thus set coefficients for indices larger than to zero. For a source not within the set of reference spectra, its coefficients for indices larger than in comparison to all the coefficients provides a measure for how well the the spectrum can be represented by linear combinations of the spectra in the reference set.
We denote a coefficient vector in the transformed basis by , i.e.
and the truncated vector resulting from setting all coefficients in for indices larger than to zero we denote . The scalar product of and can be expressed by the cosine of the angle between the two vectors, and we have
This is the quantity we are interested in. We may take the inverse cosine to obtain an angle directly. However, this is not strictly necessary and the non-linear transformation might have unfavourable effects in the computation of the error on for very noisy spectra. We therefore may prefer to use the cosine of instead of .
(14.11) simplifies further if we take into consideration that the first elements of and are identical, and the remaining elements with indices are identical zero. Therefore, , and
Graphically, this means the cosine beta is the ratio of the length of the coefficient vector containing only the coefficients required to describe the reference set of spectra, over the total length of the coefficient vector.
A suitable number of basis functions, , needs to be chosen for this test. To get this number, first, for all spectra in the reference set the value of can be computed as a function of the number of basis functions used, . Then, three different criteria may be applied to select :
The lowest in the set should be smaller than .
The highest in the set should be smaller than .
The median in the set should be smaller than .
The number of basis functions used is the smallest number that satisfies all three conditions together. The values chosen for the three thresholds are , , and .
We selected sources with good parallax (parallax_over_error) and computed the median angle of all sources within a cell in colour-magnitude grid with respect to several predefined populations.
The smaller the angle is, it means that a given source has a more similar spectrum with respect to those of the population.
In general lines, all populations can more or less be distinguished from the others based on their XP spectra. Some populations are better detected in one of the bands. For example, MSK and MSM are clearly better detected in the RP spectrum, as only with the BP information one can only say that it is a red source, but not distinguish among different types of red source.
This feature is more exaggerated in the Ultra-cool case (Figure 14.14), which is completely non-discriminant in the BP case (with very low values as they are simply confused by faint sources at any colour interval) and improves considerably in the RP one, where low values are only present in the expected ultra-cool stars region. XP spectra alone cannot distinguish very well between main sequence and giants, as it can be seen with the vertical structures in the HR diagrams. Nevertheless, RP is more useful to distinguish Red Clump and subgiants.
The same procedure was also carried out for White Dwarfs (WD). However, due to their faintness and the fact that they have a similar spectral shape with respect to other kinds of stellar sources, the angle is not enough to distinguish the subtle spectral differences to detect WDs correctly (Figure 14.15).
Small wings: Values at the wings of the spectra should be smaller than in the central parts corresponding the wavelengths with significant response. To evaluate the behaviour of the spectra at the wings at both sides, we may consider the integrals over the spectra over finite intervals in pseudo-wavelength. We consider the expressions:
And analogously on the other side of the spectrum:
One should find if the wings are decreasing. The integral tests the behaviour outside the range for which the basis functions have been constructed, and is sensitive to possible overshooting effects. The other side of the spectrum is in analogy, i.e. one should see , with testing the overshooting. We therefore consider the differences between pairs of these integrals, normalised to the uncertainty of the difference,
Here, denotes the covariance matrix for the integrals. If we assume that the index refers to the outer interval, and to the inner one, then should in general be smaller than and we can chose a limit about what is acceptable for , say
with the value adopted in the test.
This same test was repeated using truncated coefficients and the comparison is provided in Figure 14.16.
The failing sources are not specially faint. In general the number of failing sources decrease when considering the truncated case. But it is surprising that for very red ( mag) and bright ( mag) sources in RP the amount of failing sources increase when using truncated spectra.
Tests on integrated fluxes
Coherence between photometry and spectra: Integrated flux from XP spectra should be similar to the calibrated mean flux derived from the photometric calibration. See also Section 5.4.2.
Figure 14.17 shows the comparison of integrated photometry from XP spectra in the wavelength/pseudo-wavelength ranges [680 nm; 330 nm] = [14.223398; 51.402673] for BP and [680 nm; 1050 nm] = [11.228237; 48.919845] for RP (converted to magnitudes with the same zero points as in Gaia EDR3) and the mean photometry as a function of colour and magnitude. The samples for BP and RP contain about 1.0 and 1.7 million random sources brighter than mag and mag, respectively, and with good phot_bp_rp_excess_factor. Differences in zero points and dependencies with colour are expected (as shown in the top panels) because of the difference of the mean instruments in photometry and spectra. We notice, however, a dip in the RP comparison at about mag for the red sources (; bottom right panel), which is not explained.
The dip at mag in even deeper in Figure 14.18, where the same difference is shown but now versus the colour and for a larger sample ( mag). For between 4 and 5 mag the dip reaches 0.04 mag, but fading away for bluer colours and turning into an excess for very red sources. The plot also shows a population with excess for sources of normal colours. As shown in Figure 14.19, for the same sample, this is predominantly sources disturbed by another source closeby.
In order to do this comparison for all sources in the catalogue with XP spectra, we define as the XP flux (either BP or RP) derived from the photometric passband calibration and the flux derived from the XP calibrated mean spectra. We now compute the ratio
for all sources.
In Figure 14.20 we show the obtained distribution: both bands show a peak in , but in the BP case the tail to larger values (larger photometric flux than the spectral one) is wider than in the RP case.
The origin of this plateau at large values for BP could be related with the minimum values for BP fluxes (1 e) imposed in Gaia DR3 photometry (see van Leeuwen 2021; Riello et al. 2021). When plotting the distribution of BP photometric fluxes for those sources having , (Figure 14.21) it can be seen that it peaks around e instead. This correspond to the mean value expected when you cut half of the distribution when rejecting observations with fluxes smaller than 1 e (, obtaining e).
Uncertainty of the integrated flux: In this test the integrated flux uncertainty from XP spectra is compared with the uncertainty in the flux derived from the integrated passband calibration.
For this end, we compare the uncertainty in the integrated flux derived from the photometric calibration () with the uncertainty in the integrated flux derived from the spectra ().
In Figure 14.22 we show the obtained distribution showing a peak near , although a bit deviated to positive values (larger photometric uncertainties). Besides, the widths of the distributions are a bit wide. Taking into account that we plot the logarithm of , we find excessive to have a ratio between the two flux errors of a factor larger or smaller.
Negative integrated fluxes in the spectra: Spectra should not have negative fluxes, with the exception of noise for sufficiently faint sources.
We may quantify the degree of ‘negativity’ of a spectrum be the quantity
is the –norm of the spectrum. If there are no negative fluxes within the spectrum, this value should be zero. If there are only negative values, it gives one. The more negative values there are in a spectrum, the larger this number should get.
Unusual values of can be identified by looking at a plot of against the –norm. The sources with very high values of may be affected by an over-subtraction of the sky background. We expect the negativity to follow a logarithmic relation with the norm of the spectrum . We approximated this relation by and marked as failed any spectrum above this function. Moreover, any spectrum with more than 90% of negativity is also flagged.
Only 2438 and 550 sources are failing this test, in BP and RP respectively. Figure 14.23 shows the distribution of the spectra in a negativity-flux diagram.
Excess flux: This test compares excess flux from the spectra with excess flux from the photometry. The criterion for a failing source is that , being and the photometric and spectrophotometric excess fluxes, respectively. Only 82 sources are failing this test, being mostly the faintest sources in the sample.
Mean sampled spectra
This test checks that the mean sampled spectra dataset is correctly built from the source coefficients with differences compatible with floating point accuracy. If there is an error in the computation, then it should show in basically all sources. We derive an independent set of sampled spectra and compute their relative difference with respect to the published (sampled) spectra. The maximum absolute value of this relative difference for a source is the quantity of interest. Figure 14.24 shows that value of the discrepancy is very small, concluding that the mean spectra have been correctly built from the coefficients.