astrocook.core.resolution module#
The spectral resolution: one source, the resol column (#526).
The resol column of a spectrum holds the resolution of each pixel. Its
unit says what it is: dimensionless for the resolving power R, km/s
for the FWHM in velocity. A component of a system list can override it
with its own value (always R).
Before #526 the resolution could also live in the SpectrumData.resol
attribute and in the meta keys resol (R), RESOL (R, V1 archives)
and resol_fwhm (km/s), and its unit was guessed from its value (below
500: FWHM in km/s). These legacy sources are migrated into the column when
a spectrum is built (migrate_resolution()), and no longer read
anywhere else; the guess of the unit survives only there, for data saved
before #526. Since #526 (PR 4) nothing writes them: the attribute is
cleared by the migration, the meta keys are left as they came (they may be
keywords of the original file).
- astrocook.core.resolution.LEGACY_KMS_THRESHOLD = 500.0#
a resolution below this value was taken as a FWHM in km/s, above as R. Used only to migrate data saved before #526.
- Type:
Legacy rule
- astrocook.core.resolution.STAMPED_RTOL = 0.01#
A component resolution within this fraction of the resolution of the spectrum at its position was stamped by the fitter before #526 (it wrote the resolution it used into every fitted component), not set by the user: it is cleared at load, so that the component follows the column.
- astrocook.core.resolution.column_to_resolving_power(values: ndarray, unit) ndarray[source]#
Resolving power R from the values of a
resolcolumn.- Parameters:
values (np.ndarray) – The values of the column.
unit (astropy.units.Unit) – Their unit: dimensionless (R) or a velocity (FWHM).
- Returns:
R for each pixel, NaN where the value is missing or not positive.
- Return type:
np.ndarray
- astrocook.core.resolution.legacy_resolution(data) Tuple[float | None, str][source]#
Resolving power from the legacy sources of a spectrum, in the order the fitter read them before #526: attribute, meta
resol, metaRESOL, metaresol_fwhm. Returns(None, '')if none is set.
- astrocook.core.resolution.migrate_resolution(data)[source]#
Move the resolution of a
SpectrumDatainto itsresolcolumn.A column with at least one valid value is kept (a dimensionless column with median below
LEGACY_KMS_THRESHOLDwas a FWHM in km/s before #526, and gets that unit). Otherwise the column is created, flat, from the legacy sources (legacy_resolution()), if any. The attribute is cleared either way, so that it cannot come back later (e.g. after the column is deleted).- Returns:
The same object if nothing changes, a new one otherwise.
- Return type:
- astrocook.core.resolution.resolution_at(spec, x_values: ndarray) ndarray[source]#
Resolving power of a spectrum at the given x (same unit as its x), interpolated; NaN where the spectrum has none.
- astrocook.core.resolution.migrate_component_resolutions(systs, spec)[source]#
Component resolutions of a system list saved before #526.
Legacy values below
LEGACY_KMS_THRESHOLDwere FWHM in km/s and are converted to R. Values withinSTAMPED_RTOLof the resolution of the spectrum at the component (its first transition) were stamped by the fitter and are cleared, so that the component follows the column; other values are kept as deliberate overrides.- Returns:
The same object if nothing changes, a new one otherwise.
- Return type: