Fits manager#

from prose import FitsManager, Telescope
from prose import simulations

Astronomical observations often generate highly disorganised fits images folders. To know the content of these files, file names can be used but have their limitations. At the end it is not rare to start opening these files to acces the information in their headers.

To solve this issue, prose features the FitsManager object, a conveniant tool to ease the sorting process.

Generating fake fits#

To demonstrate the use of the FITS manager, lets’ generate a set of fake data from telescope A and B, defined with

_ = Telescope(name="A", save=True)
_ = Telescope(name="B", save=True)
Telescope 'a' saved
Telescope 'b' saved

Images will be located in a single folder, featuring different sizes, filters and associated calibration files, with no way to distinguish them from their file names

destination = "./fake_observations"

The Fits Manager object#

To dig into these disorganised folder, let’s instantiate a FitsManager object

fm = FitsManager(destination)
date telescope filter type target width height files
5 2023-06-15 A dark prose 10 10 2
6 2023-06-15 A a light prose 10 10 5
3 2023-06-15 A ab light prose 10 10 5
2 2023-06-15 A b flat prose 10 10 2
1 2023-06-15 A b light prose 10 10 5
8 2023-06-15 A c dark prose 10 10 2
7 2023-06-15 A c flat prose 10 10 2
4 2023-06-15 B b light prose 10 20 5

The keywords of all images have been parsed and associated with different telescopes. The advantage is that specific keywords from specific telescopes are recognized and standardized to common namings. This is useful to define telescope agnostic pipelines.

Picking an observation#

From there let say we want to keep the files from an observation using its id

files = fm.observation_files(1)
date telescope filter type target width height exposure files
1 2023-06-15 A b light prose 10 10 1.0 5
5 2023-06-15 A dark prose 10 10 1.0 2
8 2023-06-15 A c dark prose 10 10 8.0 2
2 2023-06-15 A b flat prose 10 10 1.0 2

flats with the right filter have been kept, as well as darks

Telescope specific keywords#

The information retained by FitsManager was taken from images headers. To know which keywords to use, we had to register telescopes A and B with a dictionary. Whenever their names appear in a fits header, their dictionary is loaded to read their header keywords.

Since we just specified the telescope names all the rest is default. For example the filter is taken from the keyword FILTER and the image type from IMAGETYP, knowing that IMAGETYP=light is a light (a.k.a science) frame. These keywords can be set in more details when registering the telescope.

For more details, chcek the Telescope object

Hide code cell content
# hidden
from shutil import rmtree