Automating Image Processing Using Siril Scripts…

Siril is a powerful freeware astronomical image processing tool. One of the features of Siril which I find very useful (and fun to tinker with) is the ability to automate image pre-processing and processing tasks using scripts. Automating things like creating master calibration frames(biases, darks, and flats), applying calibration frames to lights, and stacking calibrated lights allows you to make your image processing workflow easily repeatable which leads to quicker processing, fewer issues, and better images. Siril provides a number of pre-packaged scripts for Mono and One Shot Color (OSC) images but you can also create and use your own custom scripts.

A Siril Script is a simple text file with the extension .ssf (ie image_stacking.ssf). The commands in the text file are executed in order, as if you typed the commands on the command line one at a time, the same way Linux shell and Windows batch scripts work. The Siril Documentation covers the scripting here. There is Command Reference Appendix of the Siril Docs which provides details on usage of commands which can be called from within a script.

I have a created a few custom Siril scripts which can be found on my raspastro github. Nothing too fancy, just some adjustments to the scripts which are packaged with Siril to make them fit better into the workflow I use to process images.

My script [HSC] CreateMasters_NoBias.ssf saves me a ton of time with processing by creating masters from my dark and flat frames. These masters can then be used for calibrating light frames during stacking. To run the script I set my current working directory in Siril, in that directory I create 3 directories: darks – this is where I place the dark frame files, flats – this is where I place the flat frame files, and masters – this is where the script will save the master dark and master flat. A fourth directory, process, is created by the script to use a temporary directory to process files. The script is run from the Scripts dropdown menu and status is displayed in the Siril Console.

Here is a quick walk through of the [HSC] CreateMasters_NoBias.ssf script:
Lines starting with a hash-tag (#) are comments. Comments lines are not executed but these lines are displayed in the Siril console when the script is run. Comments are useful for documenting the script.
############################################
# Hersey - http://www.suffolksky.com/
# January 2024
#############################################
# Script to create master flat and master dark
# master flat is created with out bias frames
#
# Place flat frames in the following working directory
# flats/
#
# Place dark frames in the following working directory
# darks/
#
# Saves masters to ./masters/
############################################

The requires command sets the minimum version of Siril required to run the script, in this case 1.2.0.
# Requires at least Siril 1.2.0
requires 1.2.0

The script changes to the flats directory and runs the convert command which renames and places the flat frames into the process directory. If the process directory does not exist it is created. The script then changes to the process directory and calibrates the flat files (I don’t think calibrate is necessary since I am not using bias frames, but I left it here to add offset calibration in the future). The calibrated flats are stacked and the master flat (pp_flat_stacked.fit) is saved in the masters directory.
# Convert Flat Frames to Siril .fit files
cd flats
convert flat -out=../process
cd ../process
# Calibrate Flat Frames
calibrate flat
# Stack Flat Frames to pp_flat_stacked.fit
stack pp_flat rej 3 3 -norm=mul -out=../masters/pp_flat_stacked
cd ..

Now the script moves on to the darks. The script changes to the darks directory and runs convert to put the darks in the process directory. The script changes to the process directory. The darks are stacked and the resulting master dark (dark_stacked.fit) is saved to the masters directory.
# Convert Dark Frames to Siril .fit files
cd darks
convert dark -out=../process
cd ../process
# Stack Dark Frames to dark_stacked.fit
stack dark rej 3 3 -nonorm -out=../masters/dark_stacked
cd ..

The script closes any images, files, or sequences which were opened.
close
Any errors will be reported in the Siril console. If the script completes successfully there will be a master flat and a master dark located in the masters directory. The process directory should be cleaned up (delete the directory or the files in the directory) before running the script again (this has to be done manually, unless you use Sirilic… but that’s another post).

I created scripts to calibrate and stack my light frames using the master dark and master flat instead of having to recreate them each run. It speeds the processing up considerably. Examples of scripts which use the masters when stacking light frames are [HSC] OSC_Extract_HaOIII_Masters.ssf, for Duo-Band captures, and [HSC] OSC_Preprocessing_Masters.ssf, for no filter or UV/IR filter captures.

These are just a couple examples of how you can create or modify scripts to use when processing images.

The official Siril external script repository which contains scripts to automate Image Pre-processing and Image Processing tasks can be found here Free-Astro Siril Scripts. Two scripts from the repository which I like to use in my processing are the DSA-HubbleMatic.ssf, which simulates the Hubble color palette using One Shot Color (OSC) data, and DSA-Star_Reduction-MTF.ssf, which uses the StarNet++ cli to reduce the number of stars in an image.

I may look to adding some of my custom scripts into the official script repository.

How to Install Custom Siril Scripts
You should place any custom/downloaded Siril scripts in a separate directory so the scripts are not deleted or overwritten when updating Siril. Just create a new directory to store the scripts. I have a directory structure for Siril on my NAS with a directory, SirilScripts, where I store custom scripts.
Custom Siril Scripts stored in directory on NAS
To configure the script directory in Siril, launch Siril and select the Burger icon and then Preferences.

Navigate to the Scripts menu in Preferences. Then add the directory where your custom scripts are stored to the Script Storage Directories. In my case the full path for the directory is N:\Astronomy\Siril\SirilScripts. Just enter the full directory path on a new line and hit Apply.
Siril Script Storage Directories
The refresh button below the Scripts Storage Directories text box re-reads the configured directories for Siril scripts (files with the .ssf extension). So if you create a new script, you can come here while and refresh, Siril will check the directories for new scripts, and the new scripts will be available for use without needing to restart Siril.

The Scripts menu contains the list of available scripts. This is also where scripts can be executed. The script progress, including warnings and errors, can be monitored in the Console widget.
Siril Scripts and Console

Sirilic
Another great Siril automation tool is Sirilic. Sirilic is an interactive graphical software tool for automating the pre-processing of astronomical images using the Siril software. Sirilic provides a graphical user interface for creating the working directories, organizing the image and calibration frames, and calibrating and stacking images. Sirilic generates automation scripts based on user point-and-click inputs. Scripts can then be saved as projects. I’ll dive a bit deeper in Sirilic in another post…

If you have any Siril tips or tricks or your own custom scripts, drop a note in the comments.

Hoping for clear skies soon.

Leave a Reply

Your email address will not be published. Required fields are marked *

three × one =