Python to generate Siril script for cooled OSC

Edit: I had let a few bugs in this version, I’m posting an update below

Hi folks,

First contribution to this forum. I’m sharing even though it does not cover a very general case. But as long as I’ve written this bit of code that fits my use, I figured out it might be of help to others.

Just a few notes before I start:

  • This is not a replacement of Sirilic which I also know and really helped me when I started. It 's just about being lazy and loving anything that is fully automated: no clicks to select files and folders, no workflow being defined everytime while you’re doing exactly the same over and over again.
  • I use APT as imaging software. And it handles organizing my pics and neatly arranging them in folders as I image. If that’s not your case (with APT, SGP or other), it won’t help much. You should definitely turn to Sirilic, which generates Siril scripts AND handles organizing/copying your files in a Siril-compatible manner.
  • “cooled OSC” means you want to use a darks library
  • I started with a DSLR and I really loved launching one of the builtin scripts before going to bed without having to move stuff around. When I turned to dedicated camera, it was not possible anymore. This code is an attempt at replicating this way of working.

You will need Python 3.x and astropy module (Astropy Documentation — Astropy v4.2.1)

This python script takes as entry a workfolder name (where all the Lights/flats/biases subfolders are stored) and writes a .ssf script in a folder of your liking. You just then open Siril (after having set that this “folder of your liking” contains scripts). The new script is listed with the others, you just run it. You won’t even need to change the workfolder in the GUI, the script does it for you (told you I was lazy!)

But what does it do:

  • for the 3 subfolders Lights/Flats/Biases, it renames all the .fit files to a naming format adequate to automatically generate a valid Siril sequence. It also saves in each folder a log saving the old/new filenames.
  • it creates a folder result one-up wrt to the workfolder to store the results.
  • it finds the dark in the darks library matching temperature, exposure length, gain and binning (reads the fits header of the lights to find all this)
    it creates a Siril script with a classical workflow: stack of biases, preprocess of flats with masterbias and stacking, preprocess the lights with masterdark and masterflat, registering and stacking. No cosmetic correction but that’s an easy change if required.
  • the result will be saved to “result” folder with the object name and date.

My files are organized as follows:
Pictures->ObjectName->Date->Lights/flats/Biases (that’s what APT can automatically organize for you if setup accordingly)
The result is saved at Pictures->ObjectName->result->

For this first version, passing some parameters is a bit quick and dirty, you need to modify the following at the start of the file:

lights=‘Lights’ #Name of the lights subfolder
biases=‘Biases’ #Name of the biases subfolder
flats=‘Flats’ #Name of the flats subfolder
darks=’…/…/Libraries/Darks/’ #darks library wrt to work folder
scripts=R’C:\SirilScripts’ #path to store scripts
ext=‘fit’ #extension of the fits files as saved by imaging software
flip=True #same as GUI option “Debayer fits file in up-bottom direction” (True if checked, False if unchecked)

The last parameter flip is important for APT users as the files are written with up-bottom convention.

In a next version, all this could be passed with an option files.

All my darks are named as: Again, this could be made more flexible if required.

For your first use, I would suggest you duplicate an existing session in a test folder as the files are renamed (nothing irreversible, the names are saved in logs).

If you want to run it without even typing any line, you just create a .bat file on your desktop (Windows) with this single line:
python “the path where this py file is stored\” %1
You then just drag the workfolder on the .bat icon and you’re done!

Voila, I’m opened to suggestions if you see any other changes that can be implemented. As said, it does not intend to cover the general case. You can also modify as you like to suit your specific needs.

Thanks for reading and clear skies,

Cecile (4.2 KB)


Hi again,

here-below the log of modifications (corrections and additions):


  • bug correction with the dark path file
  • corrected calling bias instead of flat in the preprocessing of the lights


  • Possibility to specify dark library path as absolute or relative - the path written in the script is always absolute (cannot have spaces yet!)

  • Added flexible darkfile name format (darkfmt) based on FITS header keys and format spec:

  • Example: ‘darks_G[GAIN:d][SET-TEMP:d]C_bin[XBINNING:d][EXPTIME:03d]’

  • Checks that the FITS header keys specified in darkfmt are all present in the lights

  • Checks for existence of dark library and correct dark file before starting the process

  • Does not rename the files if they already have the right name format (avoid overwriting logs if this code is run a second time)

Clear skies, (6.7 KB)