Teareduce: a Python package with utilities for teaching reduction techniques in Astronomy

Nicolás Cardiel, Sergio Pascual, María Chillarón-Víctor, Cristina Cabello, Jesús Gallego, Jaime Zamorano, María Teresa Ceballos · 2026

Read Teareduce: a Python package with utilities for teaching reduction techniques in Astronomy by Nicolás Cardiel, Sergio Pascual, María Chillarón-Víctor, Cristina Cabello, Jesús Gallego, Jaime Zamorano, María Teresa Ceballos (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2601-20914.txt.

Introduction

Nicolás Cardiel and six co-authors built a Python package to teach a core astronomy skill. Their 2026 paper presents teareduce. The package supports teaching the reduction of astronomical data. Reduction is the step that turns raw telescope output into clean, usable images. The package serves students in practical classes. Their courses process images from various instruments and telescopes.

Good teaching tools must be simple but honest. Teareduce gives students utilities that mirror real workflows. They can learn calibration and cleaning steps on actual data. The authors are astronomers and educators sharing their classroom material. Open teaching code helps other schools run the same practicals. The paper is a resource note for anyone who trains new observers.

Catalog record

CREATORNicolás Cardiel, Sergio Pascual, María Chillarón-Víctor, Cristina Cabello, Jesús Gallego, Jaime Zamorano, María Teresa Ceballos
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE7 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2601-20914

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Teareduce: a Python package with utilities for teaching reduction techniques in Astronomy
Nicolás Cardiel, Sergio Pascual, María Chillarón-Víctor, Cristina Cabello, Jesús Gallego, Jaime Zamorano, María Teresa Ceballos

Abstract
The Python package teareduce has been developed to support teaching activities related to the reduction of astronomical data. Specifically, it serves as instructional material for students participating in practical classes on the processing of astronomical images acquired with various instruments and telescopes. These classes are part of the course Experimental Techniques in Astrophysics, which belongs to the Master’s Degree in Astrophysics at the Complutense University of Madrid. The code is publicly available on GitHub, accompanied by a documentation page that includes Jupyter notebooks demonstrating the use of its various classes and functions.



1
Departamento de Física de la Tierra y Astrofísica,
Facultad CC. Físicas, Universidad Complutense de Madrid, E-28040 Madrid, Spain;

[email protected]

2
Instituto de Física de Partículas y del Cosmos, IPARCOS,
Facultad CC. Físicas, Universidad Complutense de Madrid, E-28040 Madrid, Spain

3
Instituto de Física de Cantabria, CSIC-Universidad de
Cantabria, E-39005 Santander, Spain

1
Introduction

Python is widely used in the scientific community and offers a powerful
ecosystem for astronomical data processing.
Astropy
and affiliated
packages provide ready-to-use tools for tasks like handling FITS files,
performing calibrations, and analyzing photometric data, which significantly
simplifies the image reduction workflow. Additionally, Python integrates
seamlessly with other scientific packages (e.g.,
NumPy
,

SciPy
,
Matplotlib
) to enhance data manipulation and
visualization. Its cross-platform compatibility with Windows, macOS, and Linux
further ensures flexibility and accessibility for researchers working in
different computing environments, making Python an ideal choice for
astronomical image reduction.

2
Teaching reduction techniques in the classroom

As part of the course
Técnicas Experimentales en Astrofísica

(TEA; Experimental Techniques in Astrophysics), included in the Master’s Degree
in Astrophysics at the Universidad Complutense de Madrid (Spain), students
prepare observing proposals, carry out astronomical observations using the
CAFOS instrument installed on the 2.2 m telescope at the Calar Alto Observatory
(Almería, Spain; see Fig.
1
), reduce the acquired images, and
analyse the results.

Figure 1.
:
Left:
the 2.2m Telescope at the
Calar Alto Observatory.
Center:
students listening to explanations
from the observatory staff on the use of the CAFOS instrument.

Right:
students and faculty of the Master’s program conducting
observations from the control room of the 2.2m Telescope.

To support the data reduction and analysis process, we have developed the
Python package
teareduce
1
1

1

https://nicocardiel.github.io/teareduce-cookbook/intro.html
.
Its main goal of is to serve as an educational tool.

Teareduce
is not intended as a general-purpose image reduction tool.
Rather, it includes a set of specific operations needed for certain steps in
the traditional astronomical image reduction workflow. At the time of its
creation, these features were not available in more established packages such
as
ccdproc
. Students can examine the Python code and introduce modifications in
order to gain a deeper understanding of the operations performed during the
astronomical image reduction process. The package also introduces alternative
approaches to some tasks, which have proven to be more practical for use in
Master’s-level instruction. Some examples are shown below.

2.1
Auxiliary classes for image slicing

Working with astronomical images in FITS (Flexible Image Transport System)
format is a fundamental task in modern astronomy. However, one of the most
common and persistent sources of programming errors when handling FITS files in
Python stems from the different indexing and slicing conventions used across
various systems. These differences, rooted in historical computing decisions,
continue to confuse astronomers and programmers alike, leading to subtle bugs
that can compromise scientific results.

The
teareduce
classes

SliceRegion1D
,
SliceRegion2D
, and
SliceRegion3D

allow the users to explicitly define the slice region following either FITS or
Python indexing convention. Once an object is instantiated, it can also be used
with either the FITS or Python convention by simply accessing the
corresponding attribute:
.fits
or
.python
.

2.2
Wavelength calibration

The C-distortion correction and the wavelength calibration of astronomical
spectra are very important steps in the reduction of astronomical spectra. The

teareduce
package provides the
TeaWaveCalibration
class,
which enables the following steps to be performed: interactive identification
of arc lines, automatic detection of line peaks across all spectra in a 2D
image, and computation of polynomial corrections to perform the C-distortion
correction and the wavelength calibration (see Fig.
2
). The resulting
calibration can be applied both to
Numpy
arrays and to

CCDData
2
2

2

https://docs.astropy.org/en/stable/nddata/ccddata.html
objects.

Figure 2.
:
Different steps carried out
by the
TeaWaveCalibration
class.

2.3
Adaptive spline fit

There are many situations in which it is useful to perform a smooth fit to a
series of points, but a polynomial fit does not provide the necessary
flexibility. In such cases, spline fitting is often used.

To facilitate this task, the class
AdaptiveLSQUnivariateSpline
allows
performing this type of fit without having to predefine the locations of the
knots (the points where the different polynomial segments join to create a
continuous and smooth curve), requiring only the specification of the number of
intermediate knots to use
(
Cardiel 2009
, see e.g.,)
. Applying a
numerical minimisation process allows the fit to automatically adjust the knot
positions in order to achieve a good match to the data.

2.4
Cosmic ray removal

The
teareduce
package includes an auxiliary program called

tea-cleanest
, which enables the interactive cleaning of cosmic rays in
individual exposures (see Fig.
3
). This code is inspired by the

cleanest
code

(
Cardiel 2020
)
3
3

3

https://cleanest.readthedocs.io/
, although
the approach to detecting cosmic rays differs. In particular, this program uses
the L.A. Cosmic algorithm
(
van Dokkum 2001
)
to identify pixels suspected of
being affected by cosmic-ray hits.

At the time of writing, other algorithms, such as PyCosmic

(
Husemann et al. 2012
)
, deepCR
(
Zhang & Bloom 2020
)
and Cosmic-CoNN
(
Xu et al. 2023
)
,
are being incorporated into this tool.

Figure 3.
:
Example of cosmic ray
detection and correction: original image with multiple cosmic-ray hits
(
left
), identification of a specific cosmic ray with pre-flagged
pixels marked by red x’s allowing manual selection/deselection
(
center
), and corrected image after interpolation with interpolated
pixels marked by x’s and pixels used for interpolation indicated by magenta
dots (
right
).

Teareduce
also provides an alternative method, the function

cr2images
, for automatically removing cosmic rays in cases where two
equivalent exposures are available. In such situations, the cosmic-ray pixels
in each exposure can be replaced with the signal from the other exposure. This
function also allows the users to define regions to be cleaned or regions to be

Read the complete text