Sirilpy Python Module API 0.5.71 Reference
The sirilpy python module supports communication with a running Siril instance. It can request representations of the current loaded image plus its metadata, including details of detected stars, as well as the current loaded sequence and most frame metadata.
This documentation is autogenerated from version 0.5.71 of the python module code.
It can also run Siril commands using the SirilInterface.cmd()
method, and the intent is to provide a capable interface for writing
advanced scripts for Siril to a level not possible with the previous
simple script files.
For example, scripts can now have TKinter front ends using the tkinter and ttkthemes modules, and they can utilise a lot of the ecosystem of Python modules including numpy, scipy, pillow and many more.
Nota
There are some restrictions around modules that require installation of system binary packages for the modules to work.
In the initial module release, most methods relating to the image or
sequence loaded in Siril are read-only. The intent is that the parameters
of the loaded image or sequence can be obtained and used as inputs to
scripts, for example for calculations or input to conditionals, but the
existing mature Siril command set should in most cases be used to act on
the loaded image. Thus header keywords can be set using
cmd("update_key", "key", "value")
, and most built-in image operations
can be carried out using the appropriate Siril command. The main exception
to the rule of python methods providing read-only access is the
set_image_pixeldata()
method, which allows for setting the pixel data in the
loaded image from a numpy array. This means that new pixel processing
algorithms can be added using python, initially getting the pixel data from
the loaded image using get_image_pixeldata()
and setting it on completion
using set_image_pixeldata()
. Similar functions are available for getting
and setting pixel data from sequence frames.
Dependencies
The sirilpy module depends on the following:
numpy >= 1.20.0
packaging >= 21.0
pywin32 >= 300 (only on Windows)
Siril Script Coding Guidance
Unlike most python environments, Siril scripts run directly from Siril and the end user may not typically know how to access or how to use the python venv from outside Siril. This means that some tasks that are fairly trivial in typical python scenarios, such as installing packages, become harder. The user cannot be expected to access the command line and install packages themselves using
python3 -m pip install
.The module therefore provides the
ensure_installed()
method. This uses pip to ensure that modules are installed so that they can be imported.
Siril scripts should always provide the author's name, copyright details / license information and contact details such as a YouTube channel, website or forum where they can be contacted in regard to their script. This is advisory for independently distributed scripts and mandatory for any scripts that are submitted to the scripts repository. If you write a script, you are responsible for supporting it.
As the repository grows and the API develops, not all the scripts published will necessarily always be compatible with all versions of Siril that will be in use:
If your script uses Siril commands, you should use the
requires
Siril command. This can be called directly in a Siril Script File, or it can be called from a Python script usingSirilInterface.cmd("requires", "min_version", {"max_version"})
(max_version is optional) but can be used to ensure scripts designed for older versions of Siril no longer show as applicable to newer versions if the command syntax has changed.If your script uses any features of the Siril python module added since the initial release, you should call the
sirilpy.check_module_version()
method to ensure the installed version meets the requriements of your script. The versions at which features were added will be listed in the API documentation for all features added after the initial public release.The code that populates the Siril view of the scripts repository will automatically filter out scripts whose Siril version or python module version requirements are not met.
If new classes or methods are added to the module after its initial public release the version at which they were introduced will be annotated in the docstring and the online documentation generated from it.
Siril targets Linux, Windows and MacOS. Script writers are encouraged, where possible, to ensure that their scripts run correctly on all three OSes.
Siril Connection
This submodule provides the main SirilInterface class used for communication between Siril and the python script. All its members are made available at the module root level, there is no need to import connection separately.
- class sirilpy.connection.LogColor(value)
Bases:
IntEnum
Defines colors available for use with
SirilInterface.log()
For consistencyLogColor.Default
should be used for normal messages,LogColor.Red
should be used for error messages,LogColor.Salmon
should be used for warning messages, LogColor.Green should be used for completion notifications, andLogColor.Blue
should be used for technical messages such as equations, coefficients etc.- BLUE = 4
- DEFAULT = 0
- GREEN = 3
- RED = 1
- SALMON = 2
- class sirilpy.connection.SirilInterface
Bases:
object
SirilInterface is the main class providing an interface to a running Siril instance and access to methods to interact with it through Siril's inbuilt command system and accessing image and sequence data.
- add_user_polygon(polygon)
Adds a user polygon to the Siril display overlay
- Parámetros:
polyon -- UserPolygon defining the polygon to be added
- Devuelve:
the input updated with the ID assigned by Siril
- Tipo del valor devuelto:
- claim_thread()
Claim the processing thread. This prevents other processes using the processing thread to operate on the current Siril image. The preferred method of thread control is to use the image_lock() context manager rather than using this function manually.
This function must always be called before starting any processing that will end with
SirilInterface.set_image_pixeldata()
. The sequence of operations should be:Call
SirilInterface.claim_thread()
If the result is False, alert the user and await further input: the thread is already in use, or an image processing dialog is open.
If the result is True, you have the thread claimed.
Now you can call
SirilInterface.get_image()
orget_image_pixeldata()
Carry out your image processing
Call
SirilInterface.set_image_pixeldata()
Call
SirilInterface.release_thread()
As a precaution, the thread will be released automatically if it is still held at the point the script process terminates, but that should not be seen as an excuse for failing to call
SirilInterface.release_thread()
Note that the thread should only be claimed when the script itself is operating on the Siril image data. If the script is calling a Siril command to alter the Siril image then the thread must not be claimed or the Siril command will be unable to acquire it, and will fail.
- Devuelve:
True if the processing thread is claimed successfully, or
False if the thread is in use or if an error occured. In either case processing cannot continue, though the script can wait and allow the user to try again once the thread is free.
- Tipo del valor devuelto:
bool
- clear_user_polygons()
Clears all user polygons from the Siril overlay
- Devuelve:
True if the command succeeded, False otherwise
- Tipo del valor devuelto:
bool
- cmd(*args)
Send a command to Siril to be executed. The range of available commands can be found by checking the online documentation. The command and its arguments are provided as a list of strings.
- Parámetros:
*args (
str
) -- Variable number of string arguments to be combined into a command- Muestra:
CommandError -- If the command fails with a specific error code.
SirilError -- If another error occurs during execution.
Ejemplo
- confirm_messagebox(title, message, confirm_label)
Create a modal confirmation message dialog in Siril and wait for the response.
- Parámetros:
title (
str
) -- The title to display in the message box (up to 256 characters)message (
str
) -- The message to display in the message box (up to 1021 characters)confirm_label (
str
) -- The label to display in the message box confirmation button (OK, Yes, Confirm etc.) (Up to 24 characters)
- Devuelve:
True if the message box confirmation button was clicked, False otherwise
- Tipo del valor devuelto:
bool
- Muestra:
RuntimeError -- if an error occurred.
- connect()
Establish a connection to Siril based on the pipe or socket path.
- Tipo del valor devuelto:
Optional
[bool
]- Devuelve:
True if the connection is successful, otherwise False.
- Muestra:
SirilConnectionError -- if a connection error occurred
- delete_user_polygon(polygon_id)
Deletes a single user polygon from the Siril overlay, specified by ID
- Parámetros:
id -- int specifying the polygon ID to be deleted
- Devuelve:
True if the command succeeded, False otherwise
- Tipo del valor devuelto:
bool
- disconnect()
Closes the established socket or pipe connection.
- Devuelve:
True if the connection is closed successfully.
- Muestra:
SirilConnectionError -- if the connection cannot be closed because the pipe / socket cannot be found.
- error_messagebox(my_string, modal=False)
Send an error message to Siril. The maximum message length is 1022 bytes: longer messages will be truncated (but this is more than enough for an error message box). Note that the error message box is not modal by default: this is intended for displaying an error message more prominently than using the Siril log prior to quitting the application.
- Parámetros:
my_string (
str
) -- The message to display in the error message boxmodal (
Optional
[bool
]) -- Sets whether or not the message box should be modal and wait for completion or non-modal and allow the script to continue execution. Note that although a modal message box will block execution of the script, if a TKinter main loop is running events will continue to queue up, so if the message box is triggered by clicking a button then the user may click it while the message box is shown and trigger a second message box which will display immediately the first one is closed.
- Devuelve:
True if the error was successfully displayed, False otherwise
- Tipo del valor devuelto:
bool
- get_image(with_pixels=True)
Request a copy of the current image open in Siril.
- Parámetros:
with_pixels (
Optional
[bool
]) -- optional bool specifying whether to get pixel data as a NumPy array, or only the image metadata. Defaults to True- Tipo del valor devuelto:
Optional
[FFit
]- Devuelve:
FFit object containing the image metadata and (optionally) pixel data, or None if an error occurred
- get_image_bgsamples()
Request background samples data from Siril.
- Tipo del valor devuelto:
Optional
[List
[BGSample
]]- Devuelve:
List of BGSamples background samples, with each set of coordinates expressed as a tuple[float, float], or None if no background samples have been set.
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during data retrieval,
ValueError -- If the received data format is invalid
- get_image_filename()
Request the filename of the loaded image from Siril.
- Tipo del valor devuelto:
Optional
[str
]- Devuelve:
The filename as a string, or None if an error occurred.
- get_image_fits_header()
Retrieve the full FITS header of the current image loaded in Siril.
- Parámetros:
none.
- Devuelve:
The image FITS header as a string.
- Tipo del valor devuelto:
bytes
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during data retrieval,
ValueError -- If the received data format is invalid or shape is invalid
- get_image_history()
Retrieve history entries in the FITS header of the current loaded Siril image using shared memory.
- Parámetros:
none.
- Devuelve:
The history entries in the FITS header as a list of strings.
- Tipo del valor devuelto:
list
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during data retrieval,
ValueError -- If the received data format is invalid or shape is invalid
- get_image_iccprofile()
Retrieve the ICC profile of the current Siril image using shared memory.
Args: none.
- Devuelve:
The image ICC profile as a byte array, or None if the current image has no ICC profile.
- Tipo del valor devuelto:
bytes
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during data retrieval,
ValueError -- If the shared memory data is invalid
- get_image_keywords()
Request FITS keywords data from Siril as a FKeywords object.
- Tipo del valor devuelto:
Optional
[FKeywords
]- Devuelve:
FKeywords object containing the FITS keywords, or None if an error occurred
- get_image_pixeldata(shape=None)
Retrieves the pixel data from the image currently loaded in Siril.
- Parámetros:
shape (
Optional
[list
[int
]]) -- Optional list of [x, y, w, h] specifying the region to retrieve. If provided, gets pixeldata for just that region. If None, gets pixeldata for the entire image.- Devuelve:
The image data as a numpy array
- Tipo del valor devuelto:
numpy.ndarray
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during pixel data retrieval,
ValueError -- If the received data format is invalid or shape is invalid
- get_image_shape()
Request the shape of the image from Siril.
- Tipo del valor devuelto:
Optional
[Tuple
[int
,int
,int
]]- Devuelve:
A tuple (channels, height, width) representing the shape of the image, or None if an error occurred.
- get_image_stars()
Request star model PSF data from Siril.
- Tipo del valor devuelto:
List
[PSFStar
]- Devuelve:
List of PSFStar objects containing the star data, or None if no stars have been detected. (The "findstar" command should be run first to detect stars in the image.)
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during data retrieval,
ValueError -- If the received data format is invalid
- get_image_stats(channel)
Request image statistics from Siril for a specific channel.
- Parámetros:
channel (
int
) -- Integer specifying which channel to get statistics for (typically 0, 1, or 2)- Tipo del valor devuelto:
Optional
[ImageStats
]- Devuelve:
ImageStats object containing the statistics, or None if an error occurred
- get_image_unknown_keys()
Retrieve the unknown key in a FITS header of the current loaded Siril image using shared memory.
- Parámetros:
none.
- Devuelve:
The unknown keys as a string.
- Tipo del valor devuelto:
bytes
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during data retrieval,
ValueError -- If the received data format is invalid or shape is invalid
- get_selection_star(shape=None, channel=None)
Retrieves a PSFStar star model from the current selection in Siril. Only a single PSFStar is returned: if there are more than one in the selection, the first one identified by Siril's internal star detection algorithm is returned.
- Parámetros:
shape (
Optional
[list
[int
]]) -- Optional list of [x, y, w, h] specifying the selection to retrieve from. w x h must not exceed 300 px x 300 px. If provided, looks for a star in the specified selection If None, looks for a star in the selection already made in Siril, if one is made.channel (
Optional
[int
]) -- Optional int specifying the channel to retrieve from. If provided 0 = Red / Mono, 1 = Green, 2 = Blue. If the channel is omitted the current viewport will be used if in GUI mode, or if not in GUI mode the method will fall back to channel 0
- Devuelve:
the PSFStar object representing the star model.
- Tipo del valor devuelto:
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during data retrieval,
ValueError -- If the received data format is invalid or no selection can be determined
- get_selection_stats(shape=None, channel=None)
Retrieves statistics for the current selection in Siril.
- Parámetros:
shape (
Optional
[list
[int
]]) -- Optional list of [x, y, w, h] specifying the selection to retrieve from. If provided, looks for a star in the specified selection If None, looks for a star in the selection already made in Siril, if one is made.channel (
Optional
[int
]) -- Optional int specifying the channel to retrieve from. If provided 0 = Red / Mono, 1 = Green, 2 = Blue. If the channel is omitted the current viewport will be used if in GUI mode, or if not in GUI mode the method will fall back to channel 0
- Devuelve:
the ImageStats object representing the selection statistics.
- Tipo del valor devuelto:
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during data retrieval,
ValueError -- If the received data format is invalid or no selection can be determined
- get_seq()
Request metadata for the current sequence loaded in Siril.
- Tipo del valor devuelto:
Optional
[Sequence
]- Devuelve:
Sequence object containing the current sequence metadata, or None if an error occurred
- get_seq_distodata(channel)
Request sequence distortion data from Siril
channel: Integer specifying which channel to get registration data for (typically 0, 1, or 2)
- Tipo del valor devuelto:
Optional
[DistoData
]- Devuelve:
DistoData object containing the channel distortion parameters, or None if an error occurred
- get_seq_frame(frame, with_pixels=True)
Request sequence frame as a FFit from Siril.
- Parámetros:
frame (default is True) -- Integer specifying which frame in the sequence to retrieve data for
Sequence.number) ((between 0 and)
with_pixels (
Optional
[bool
]) -- bool specifying whether or not to return the pixel data for theframe
- Tipo del valor devuelto:
Optional
[FFit
]- Devuelve:
FFit object containing the frame data, or None if an error occurred
- get_seq_frame_filename(frame)
Request the filename of the specified frame of the loaded sequence from Siril.
- Tipo del valor devuelto:
Optional
[str
]- Devuelve:
The filename as a string, or None if an error occurred.
- get_seq_frame_pixeldata(frame, shape=None)
Retrieves the pixel data from the image currently loaded in Siril.
- Parámetros:
frame (
int
) -- selects the frame to retrieve pixel data from- Devuelve:
The image data as a numpy array
- Tipo del valor devuelto:
numpy.ndarray
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during pixel data retrieval,
ValueError -- If the received data format is invalid or shape is invalid
- get_seq_imgdata(frame)
Request sequence frame metadata from Siril.
- Parámetros:
frame (
int
) -- Integer specifying which frame in the sequence to get image metadata for (between 0 and Sequence.number)- Tipo del valor devuelto:
Optional
[ImgData
]- Devuelve:
ImgData object containing the frame metadata, or None if an error occurred
- get_seq_regdata(frame, channel)
Request sequence frame registration data from Siril.
- Parámetros:
frame (
int
) -- Integer specifying which frame in the sequence to get registration data for (between 0 and Sequence.number),channel (
int
) -- Integer specifying which channel to get registration data for (typically 0, 1, or 2)
- Tipo del valor devuelto:
Optional
[RegData
]- Devuelve:
RegData object containing the registration data, or None if an error occurred
- get_seq_stats(frame, channel)
Request sequence frame statistics from Siril.
- Parámetros:
frame (
int
) -- Integer specifying which frame in the sequence to get statistics data for (between 0 and Sequence.number)channel (
int
) -- Integer specifying which channel to get statistics for (typically 0, 1, or 2)
- Tipo del valor devuelto:
Optional
[ImageStats
]- Devuelve:
ImageStats object containing the statistics, or None if an error occurred
- get_siril_active_vport()
Request the active viewport from Siril.
- Devuelve:
0 = Red (or Mono), 1 = Green, 2 = Blue, 3 = RGB, or None if an error occurred.
- Tipo del valor devuelto:
An int representing the active vport
- get_siril_config(group, key)
Request a configuration value from Siril.
- Parámetros:
group (
str
) -- Configuration group name,key (
str
) -- Configuration key name within the group (Available values for group and key can be determined using the "get -A" command)
- Tipo del valor devuelto:
Union
[bool
,int
,float
,str
,List
[str
],None
]- Devuelve:
The configuration value with appropriate Python type, or None if an error occurred
- Muestra:
RuntimeError -- if an error occurred getting the requested config value
- get_siril_configdir()
Request the user config directory used by Siril.
- Tipo del valor devuelto:
Optional
[str
]- Devuelve:
The user config directory as a string, or None if an error occurred.
- get_siril_selection()
Request the image selection from Siril.
- Tipo del valor devuelto:
Optional
[Tuple
[int
,int
,int
,int
]]- Devuelve:
A tuple (height, width, channels) representing the current selection, or None if an error occurred.
- get_siril_systemdatadir()
Request the system data directory used by Siril.
- Tipo del valor devuelto:
Optional
[str
]- Devuelve:
The system data directory as a string, or None if an error occurred.
- get_siril_userdatadir()
Request the user data directory used by Siril.
- Tipo del valor devuelto:
Optional
[str
]- Devuelve:
The user data directory as a string, or None if an error occurred.
- get_siril_wd()
Request the current working directory from Siril.
- Tipo del valor devuelto:
Optional
[str
]- Devuelve:
The current working directory as a string, or None if an error occurred.
- get_user_polygon(polygon_id)
Gets a single user polygon from the Siril overlay, specified by ID
- Parámetros:
id -- int specifying the polygon ID to be deleted
- Devuelve:
the specified UserPolygon if it exists, None otherwise
- Tipo del valor devuelto:
- Muestra:
RuntimeError -- if an error occurred processing the command
- get_user_polygon_list()
Gets a List of all user polygons from the Siril overlay
- Devuelve:
the list of UserPolygon if some exist, None otherwise
- Tipo del valor devuelto:
List[UserPolygon]
- Muestra:
RuntimeError -- if an error occurred processing the command
- image_lock()
A context manager that handles claiming and releasing the processing thread.
This method is designed to be used with a with statement to ensure that the thread is properly claimed before processing and released after processing, even if an exception occurs during processing. It is preferable to use this context manager rather than manually calling claim_thread() and release_thread() as the context manager will ensure correct cleanup if an exception occurs.
Note that the image_lock() context should only be entered when the script itself is operating on the Siril image data. If the script is calling a Siril command to alter the Siril image then the context must not be entered or the Siril command will be unable to acquire the processing thread and will fail.
Example usage:
with self.image_lock(): # Get image data image_data = self.get_image_pixeldata() # Process image data processed_data = some_processing_function(image_data) # Set the processed image data self.set_image_pixeldata(processed_data)
- Muestra:
RuntimeError -- If the thread cannot be claimed.
- info_messagebox(my_string, modal=False)
Send an information message to Siril. The maximum message length is 1022 bytes: longer messages will be truncated. This is intended for displaying informational messages more prominently than using the Siril log.
- Parámetros:
my_string (
str
) -- The message to display in the info message boxmodal (
Optional
[bool
]) -- Sets whether or not the message box should be modal and wait for completion or non-modal and allow the script to continue execution. Note that although a modal message box will block execution of the script, if a TKinter main loop is running events will continue to queue up, so if the message box is triggered by clicking a button then the user may click it while the message box is shown and trigger a second message box which will display immediately the first one is closed.
- Devuelve:
True if the info was successfully displayed, False otherwise
- Tipo del valor devuelto:
bool
- is_image_loaded()
Check if a single image is loaded in Siril.
- Devuelve:
True if a single image is loaded, False if a single image is not loaded, or None if an error occurred.
- Tipo del valor devuelto:
bool
- is_sequence_loaded()
Check if a sequence is loaded in Siril.
- Devuelve:
True if a sequence is loaded, False if a sequence is not loaded, or None if an error occurred.
- Tipo del valor devuelto:
bool
- log(my_string, color=LogColor.DEFAULT)
Send a log message to Siril. The maximum message length is 1022 bytes: longer messages will be truncated.
- Parámetros:
my_string (
str
) -- The message to logcolor (
LogColor
) -- Defines the text color, defaults to white. See the documentationwhich (for LogColor for an explanation of which colors should be used for)
purposes.
- Devuelve:
True if the message was successfully logged, False otherwise
- Tipo del valor devuelto:
bool
- pix2radec(x, y)
Converts a pair of pixel coordinates into RA and dec coordinates using the WCS of the image loaded in Siril. This requires that an image is loaded in Siril and that it has been platesolved (i.e. it has a WCS solution).
- Parámetros:
x (
float
) -- float: provides the x coordinate to be convertedy (
float
) -- float: provides the y coordinate to be converted
- Devuelve:
[RA, dec] as a Tuple of two floats.
- Tipo del valor devuelto:
Tuple[float, float]
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during pixel data retrieval,
ValueError -- If the received data format is invalid or no WCS is found
- radec2pix(ra, dec)
Converts a pair of RA,dec coordinates into image pixel coordinates using the WCS of the image loaded in Siril. This requires that an image is loaded in Siril and that it has been platesolved (i.e. it has a WCS solution).
- Parámetros:
ra (
float
) -- float: provides the RA coordinate to be converteddec (
float
) -- float: provides the dec coordinate to be converted
- Devuelve:
[x, y] as a Tuple of two floats.
- Tipo del valor devuelto:
Tuple[float, float]
- Muestra:
NoImageError -- If no image is currently loaded,
RuntimeError -- For other errors during pixel data retrieval,
ValueError -- If the received data format is invalid or no WCS is found
- release_thread()
Release the processing thread. This permits other processes to use the processing thread to operate on the current Siril image. The preferred method of thread control is to use the image_lock() context manager rather than using this function manually.
This function must always be called after completing any processing that has updated the image loaded in Siril. The sequence of operations should be:
Call
SirilInterface.claim_thread()
If the result is False, alert the user and await further input: the thread is already in use, or an image processing dialog is open.
If the result is True, you have the thread claimed.
Now you can call
SirilInterface.get_image()
orget_image_pixeldata()
Carry out your image processing
Call
SirilInterface.set_image_pixeldata()
Call
SirilInterface.release_thread()
As a precaution, the thread will be released automatically if it is still held at the point the script process terminates, but that should not be seen as an excuse for failing to call this method.
- Tipo del valor devuelto:
bool
- Devuelve:
True if the thread was successfully released
- Muestra:
SirilError -- if an error occurred in releasing the thread
- reset_progress()
Resets the Siril progress bar.
- Parámetros:
none
- Devuelve:
True if the progress update was successfully sent, False otherwise
- Tipo del valor devuelto:
bool
- set_image_bgsamples(points, show_samples=False, recalculate=True)
Serialize a set of background sample points and send via shared memory. Points can be provided either as: - List of (x,y) Tuples: BGSamples are created with these positions and Siril will automatically compute the statistics. - List of BGSample objects: The complete sample data is sent to Siril. By default Siril will recalculate statistics for the sample points on receipt, but this can be overridden with the argument recalculate=False
- Parámetros:
points (
Union
[List
[Tuple
[float
,float
]],List
[BGSample
]]) -- List of sample points, either as (x,y) tuples or BGSample objectsshow_samples (
bool
) -- Whether to show the sample points in Sirilrecalculate -- Whether to recalculate the sample points once set. This only applies if the sample points are provided as a List of BGSamples, in which case it defaults to True. If the sample points are provided as a List of (x,y) Tuples then the parameter has no effect. Setting recalculate=False is usually a bad idea but the option is provided to support potential advanced uses where the values are adjusted in python code to manipulate the background fit.
- set_image_metadata_from_header_string(header)
- Tipo del valor devuelto:
bool
Send image metadata to Siril from a FITS header. The header can be obtained from a sirilpy FFit.header or alternatively from a FITS file obened from disk using astropy.fits.
Example: .. code-block:: python
hdul = fits.open('your_fits_file.fits') # Get the header from the primary HDU (or any other HDU you want) header = hdul[0].header # Convert the header to string header_string = header.tostring(sep='
- ')
# Send the metadata to Siril siril.set_image_metadata_from_header_string(header_string)
- Args:
header: string containing the FITS header data
- Returns:
bool: True if successful, False otherwise
- set_image_pixeldata(image_data)
Send image data to Siril using shared memory.
- Parámetros:
image_data (
ndarray
) -- numpy.ndarray containing the image data. Must be 2D (single channel) or 3D (multi-channel) array with dtype either np.float32 or np.uint16.- Devuelve:
True if successful, False otherwise
- Tipo del valor devuelto:
bool
- set_seq_frame_incl(index, incl)
Set whether a given frame is included in the currently loaded sequence in Siril. This method is intended for use in creating custom sequence filters.
- Parámetros:
index (
int
) -- integer specifying which frame to set the pixeldata for.incl (
bool
) -- bool specifying whether the frame is included or not.
- Devuelve:
True if successful, False otherwise
- Tipo del valor devuelto:
bool
- set_seq_frame_pixeldata(index, image_data)
Send image data to Siril using shared memory.
- Parámetros:
index (
int
) -- integer specifying which frame to set the pixeldata for.image_data (
ndarray
) -- numpy.ndarray containing the image data. Must be 2D (single channel) or 3D (multi-channel) array with dtype either np.float32 or np.uint16.
- Devuelve:
True if successful, False otherwise
- Tipo del valor devuelto:
bool
- set_siril_selection(x, y, w, h)
Set the image selection in Siril using the provided coordinates and dimensions.
- Parámetros:
x (
int
) -- X-coordinate of the selection's top-left cornery (
int
) -- Y-coordinate of the selection's top-left cornerw (
int
) -- Width of the selectionh (
int
) -- Height of the selection
- Devuelve:
True if the selection was successfully set, False otherwise
- Tipo del valor devuelto:
bool
- undo_save_state(my_string)
Saves an undo state. The maximum message length is 70 bytes: longer messages will be truncated.
- Parámetros:
my_string (
str
) -- The message to log in FITS HISTORY- Devuelve:
True if the message was successfully logged, False otherwise
- Tipo del valor devuelto:
bool
- update_progress(message, progress)
Send a progress update to Siril with a message and completion percentage.
- Parámetros:
message (
str
) -- Status message to display,progress (
float
) -- Progress value in the range 0.0 to 1.0
- Devuelve:
True if the progress update was successfully sent, False otherwise
- Tipo del valor devuelto:
bool
- warning_messagebox(my_string, modal=False)
Send a warning message to Siril. The maximum message length is 1022 bytes: longer messages will be truncated. This is intended for displaying warning messages more prominently than using the Siril log.
- Parámetros:
my_string (
str
) -- The message to display in the warning message boxmodal (
Optional
[bool
]) -- Sets whether or not the message box should be modal and wait for completion or non-modal and allow the script to continue execution. Note that although a modal message box will block execution of the script, if a TKinter main loop is running events will continue to queue up, so if the message box is triggered by clicking a button then the user may click it while the message box is shown and trigger a second message box which will display immediately the first one is closed.
- Devuelve:
True if the warning was successfully displayed, False otherwise
- Tipo del valor devuelto:
bool
- xy_plot(plot_data)
Serialize plot data and send via shared memory. See the sirilpy.plot submodule documentation for how to configure a PlotData object for use with SirilInterface.xy_plot()
- Parámetros:
plot_metadata -- PlotMetadata object containing plot configuration
Siril Data Models
This submodule provides dataclasses and IntEnums to represent the main Siril data structures. All its members are made available at the module root level, there is no need to import models separately.
- class sirilpy.models.BGSample(*args, x=None, y=None, position=None, size=25, **kwargs)
Bases:
object
Python equivalent of the Siril background_sample struct. Used to hold background sample data obtained from Siril, or to generate or modify background sample data to set in Siril. A BGSample can be constructed as: - s1 = BGSample(x=1.0, y=2.0) - s2 = BGSample(position=(1.0, 2.0)) - s3 = BGSample(x=1.0, y=2.0, mean=0.5, size=31)
-
max:
float
= 0.0
-
mean:
float
= 0.0
-
median:
Tuple
[float
,float
,float
] = (0.0, 0.0, 0.0) Median values for R, G and B channels. For mono images only median[0] is used.
-
min:
float
= 0.0
-
position:
Optional
[Tuple
[float
,float
]] = None Position in (x, y) image coordinates
-
size:
int
= 25 The default size matches the size of Siril bg samples.
-
valid:
bool
= True Samples default to being valid
-
max:
- class sirilpy.models.DataType(value)
Bases:
IntEnum
Mimics the Siril data_type enum. Note that although Siril can handle opening FITS files of any data type, internally it processes images only as USHORT_IMG (uint16) or FLOAT_IMG (float32).
- BYTE_IMG = 8
- DOUBLE_IMG = 64
- FLOAT_IMG = 32
- LONG_IMG = 32
- SHORT_IMG = 16
- USHORT_IMG = 16
- class sirilpy.models.DistoData(index=DistoType.DISTO_UNDEF, filename='', velocity=(0, 0))
Bases:
object
Python equivalent of Siril disto_params structure
-
filename:
str
= '' filename if DISTO_FILE or DISTO_MASTER (and optional for DISTO_FILE_COMET)
-
velocity:
Tuple
[float
,float
] = (0, 0) shift velocity if DISTO_FILE_COMET
-
filename:
- class sirilpy.models.DistoType(value)
Bases:
IntEnum
Python equivalent of the Siril disto_source enum
- DISTO_FILE = 2
Distortion from given file
- DISTO_FILES = 4
Distortion stored in each file (true only from seq platesolve, even with no distortion, it will be checked upon reloading)
- DISTO_FILE_COMET = 5
special for cometary alignement, to be detected by apply reg
- DISTO_IMAGE = 1
Distortion from current image
- DISTO_MASTER = 3
Distortion from master files
- DISTO_UNDEF = 0
No distortion
- class sirilpy.models.FFit(bitpix=0, orig_bitpix=0, naxis=0, _naxes=(0, 0, 0), keywords=<factory>, checksum=False, header=None, unknown_keys=None, stats=<factory>, mini=0.0, maxi=0.0, neg_ratio=0.0, type=DataType.LONG_IMG, _data=None, top_down=False, _focalkey=False, _pixelkey=False, history=<factory>, color_managed=False, _icc_profile=None)
Bases:
object
Python equivalent of Siril ffit (FITS) structure, holding image pixel data and metadata.
- allocate_data()
Allocate memory for image data with appropriate type. self.width, self.height, self.naxis, self.naxes and self.dtype must be set before calling this method.
- ensure_data_type(target_type=None)
Ensure data is in the correct type with proper scaling
- Parámetros:
target_type -- Optional type to convert to. Can be either DataType or np.dtype. If None, uses self.type
- Muestra:
ValueError -- if the conversion is between data types that are not internally used by Siril for calculation
- get_channel(channel)
Get a specific channel of the pixel data. Note that this does not pull pixel data directly from the image loaded in Siril: that must previously have been obtained using get_image_pixeldata() or get_image()
- Tipo del valor devuelto:
ndarray
- update_stats()
Update image statistics for all channels. Note that this only updates the statistics based on the NumPy array representing pixel data in the python FFit object, it does not update the statistics of the image in Siril.
-
bitpix:
int
= 0 Bits per pixel
- property channels: int
Image channels
-
checksum:
bool
= False Whether Siril will write FITS data checksums for this file.
-
color_managed:
bool
= False Specifies whether the image is color managed or not.
- property data: ndarray | None
The pixel data of the current image loaded in Siril, stored as a NumPy array
- property dtype: dtype
The NumPy dtype based on the current type
-
header:
Optional
[str
] = None The FITS header as a string.
- property height: int
Image height
-
history:
list
[str
] Contains a list of strings holding the HISTORY entries for this image.
- property icc_profile: bytes | None
The ICC profile as raw bytes data. This may be converted for use by modules such as pillow which can handle ICC profiles.
-
maxi:
float
= 0.0 The maximum value across all image channels.
-
mini:
float
= 0.0 The minimum value across all image channels.
- property naxes: Tuple[int, int, int]
The naxes tuple holds the image dimensions as width x height x channels. Note that the axis ordering differs between Siril representation as held in naxes and numpy representation as held in _data.shape (which is channels x height x width)
-
naxis:
int
= 0 The number of axes (2 for a mono image, 3 for a RGB image). Corresponds to the FITS kwyword NAXIS.
-
neg_ratio:
float32
= 0.0 The ratio of negative pixels to the total pixels.
-
orig_bitpix:
int
= 0 Original bits per pixel (accounts for changes from original file).
-
stats:
List
[Optional
[ImageStats
]] A list of ImageStats objects, one for each channel.
-
top_down:
bool
= False Specifies the ROWORDER for this image. The FITS specification directs that FITS should be stored bottom-up, but many CMOS sensors are natively TOP_DOWN and capture software tends to save FITS images captured by these sensors as TOP_DOWN.
-
unknown_keys:
Optional
[str
] = None All unknown FITS header keys as a string. This gives access to header cards that Siril does not use internally.
- property width: int
Image width
- class sirilpy.models.FKeywords(bscale=1.0, bzero=0.0, lo=0, hi=0, flo=0.0, fhi=0.0, program='', filename='', row_order='', filter='', image_type='', object='', instrume='', telescop='', observer='', bayer_pattern='', sitelat_str='', sitelong_str='', focname='', date=None, date_obs=None, data_max=0.0, data_min=0.0, pixel_size_x=0.0, pixel_size_y=0.0, binning_x=1, binning_y=1, expstart=0.0, expend=0.0, bayer_xoffset=0, bayer_yoffset=0, airmass=1.0, focal_length=0.0, flength=0.0, iso_speed=0.0, exposure=0.0, aperture=0.0, ccd_temp=0.0, set_temp=0.0, livetime=0.0, stackcnt=0, cvf=0.0, gain=0, offset=0, focuspos=0, focussz=0, foctemp=0.0, centalt=0.0, centaz=0.0, sitelat=0.0, sitelong=0.0, siteelev=0.0)
Bases:
object
Python equivalent of Siril fkeywords structure. Contains the FITS header keyword values converted to suitable datatypes.
-
airmass:
float
= 1.0 Airmass at frame center (Gueymard 1993)
-
aperture:
float
= 0.0 Aperture value as a float
-
bayer_pattern:
str
= '' Bayer color pattern
-
bayer_xoffset:
int
= 0 X offset of the Bayer pattern
-
bayer_yoffset:
int
= 0 Y offset of the Bayer pattern
-
binning_x:
int
= 1 XBINNING FITS header card as an int
-
binning_y:
int
= 1 YBINNING FITS header card as an int
-
bscale:
float
= 1.0 Offset data range to that of unsigned short
-
bzero:
float
= 0.0 Default scaling factor
-
ccd_temp:
float
= 0.0 CCD temperature as a float
-
centalt:
float
= 0.0 [deg] Altitude of telescope
-
centaz:
float
= 0.0 [deg] Azimuth of telescope
-
cvf:
float
= 0.0 Conversion factor (e- / ADU)
-
data_max:
float
= 0.0 used to check if 32b float is in the [0, 1] range
-
data_min:
float
= 0.0 used to check if 32b float is in the [0, 1] range
-
date:
Optional
[datetime
] = None UTC date that FITS file was created
-
date_obs:
Optional
[datetime
] = None ss observation start, UT
- Type:
YYYY-MM-DDThh
- Type:
mm
-
expend:
float
= 0.0 Exposure end as a Julian date
-
exposure:
float
= 0.0 Exposure time as a float (s)
-
expstart:
float
= 0.0 Exposure start as a Julian date
-
fhi:
float32
= 0.0 MIPS-Hi key in FITS file, "Upper visualization cutoff (float)"
-
filename:
str
= '' Original Filename
-
filter:
str
= '' Active filter name
-
flength:
float
= 0.0 [mm] Focal length
-
flo:
float32
= 0.0 MIPS-LO key in FITS file, "Lower visualization cutoff (float)"
-
focal_length:
float
= 0.0 [mm] Focal length
-
focname:
str
= '' Focusing equipment name
-
foctemp:
float
= 0.0 Focuser temperature
-
focuspos:
int
= 0 Focuser position
-
focussz:
int
= 0 [um] Focuser step size
-
gain:
int
= 0 Gain factor read in camera
-
hi:
int
= 0 MIPS-HI key in FITS file, "Upper visualization cutoff"
-
image_type:
str
= '' Type of image
-
instrume:
str
= '' Instrument name
-
iso_speed:
float
= 0.0 ISO speed value as a float
-
livetime:
float
= 0.0 Sum of exposure times (s)
-
lo:
int
= 0 MIPS-LO key in FITS file, "Lower visualization cutoff"
-
object:
str
= '' Name of the object of interest
-
observer:
str
= '' Observer name
-
offset:
int
= 0 Offset value read in camera
-
pixel_size_x:
float
= 0.0 XPIXSZ FITS header card as a float
-
pixel_size_y:
float
= 0.0 YPIXSZ FITS header card as a float
-
program:
str
= '' Software that created this HDU
-
row_order:
str
= '' Order of the rows in image array
-
set_temp:
float
= 0.0 CCD set temperature as a float
-
siteelev:
float
= 0.0 [m] Observation site elevation
-
sitelat:
float
= 0.0
-
sitelat_str:
str
= ''
-
sitelong:
float
= 0.0 [deg] Observation site longitude
-
sitelong_str:
str
= ''
-
stackcnt:
int
= 0 Number of stacked frames
-
telescop:
str
= '' Telescope used to acquire this image
-
airmass:
- class sirilpy.models.Homography(h00=0.0, h01=0.0, h02=0.0, h10=0.0, h11=0.0, h12=0.0, h20=0.0, h21=0.0, h22=0.0, pair_matched=0, Inliers=0)
Bases:
object
Python equivalent of the Siril Homography structure. Contains coefficients for the Homography matrix that maps a sequence frame onto the reference frame.
-
Inliers:
int
= 0 number of inliers kept after RANSAC step
-
h00:
float
= 0.0 Homography matrix H00
-
h01:
float
= 0.0 Homography matrix H01
-
h02:
float
= 0.0 Homography matrix H02
-
h10:
float
= 0.0 Homography matrix H10
-
h11:
float
= 0.0 Homography matrix H11
-
h12:
float
= 0.0 Homography matrix H12
-
h20:
float
= 0.0 Homography matrix H20
-
h21:
float
= 0.0 Homography matrix H21
-
h22:
float
= 0.0 Homography matrix H22
-
pair_matched:
int
= 0 number of pairs matched
-
Inliers:
- class sirilpy.models.ImageStats(total=0, ngoodpix=0, mean=0.0, median=0.0, sigma=0.0, avgDev=0.0, mad=0.0, sqrtbwmv=0.0, location=0.0, scale=0.0, min=0.0, max=0.0, normValue=0.0, bgnoise=0.0)
Bases:
object
Python equivalent of Siril imstats structure. Contains statistics for a particular channel of a Siril image.
-
avgDev:
float
= 0.0 average deviation of pixels
-
bgnoise:
float
= 0.0 RMS background noise
-
location:
float
= 0.0 location of pixel values
-
mad:
float
= 0.0 mean average deviation of pixels
-
max:
float
= 0.0 maximum pixel value
-
mean:
float
= 0.0 mean value of pixels
-
median:
float
= 0.0 median value of pixels
-
min:
float
= 0.0 minimum pixel value
-
ngoodpix:
int
= 0 number of non-zero pixels
-
normValue:
float
= 0.0 norm value of the pixels
-
scale:
float
= 0.0 scale value of the pixels
-
sigma:
float
= 0.0 standard deviation of pixels
-
sqrtbwmv:
float
= 0.0 square root of the biweight midvariance of pixel values
-
total:
int
= 0 total number of pixels
-
avgDev:
- class sirilpy.models.ImgData(filenum=0, incl=False, date_obs=None, airmass=0.0, rx=0, ry=0)
Bases:
object
Python equivalent of Siril imgdata structure
-
airmass:
float
= 0.0 airmass of the image
-
date_obs:
Optional
[datetime
] = None date of the observation
-
filenum:
int
= 0 real file index in the sequence
-
incl:
bool
= False selected in the sequence
-
rx:
int
= 0 width
-
ry:
int
= 0 height
-
airmass:
- class sirilpy.models.PSFStar(star_name=None, B=0.0, A=0.0, x0=0.0, y0=0.0, sx=0.0, sy=0.0, fwhmx=0.0, fwhmy=0.0, fwhmx_arcsec=0.0, fwhmy_arcsec=0.0, angle=0.0, rmse=0.0, sat=0.0, R=0, has_saturated=False, beta=0.0, profile=StarProfile.GAUSSIAN, xpos=0.0, ypos=0.0, mag=0.0, Bmag=0.0, s_mag=999.99, s_Bmag=999.99, SNR=0.0, BV=0.0, B_err=0.0, A_err=0.0, x_err=0.0, y_err=0.0, sx_err=0.0, sy_err=0.0, ang_err=0.0, beta_err=0.0, layer=0, units=None, ra=0.0, dec=0.0)
Bases:
object
Python equivalent of the Siril fwhm_struct structure. Contains data on a modelled fit to a star identified in the image.
-
A:
float
= 0.0 amplitude
-
A_err:
float
= 0.0 error in A
-
B:
float
= 0.0 average sky background value
-
BV:
float
= 0.0 only used to pass data in photometric color calibration
-
B_err:
float
= 0.0 error in B
-
Bmag:
float
= 0.0 B magnitude
-
R:
int
= 0 Optimized box size to enclose sufficient pixels in the background
-
SNR:
float
= 0.0 SNR of the star
-
ang_err:
float
= 0.0 error in angle
-
angle:
float
= 0.0 angle of the x and yaxes with respect to the image x and y axes
-
beta:
float
= 0.0 Moffat equation beta parameter
-
beta_err:
float
= 0.0 error in beta
-
dec:
float
= 0.0 Declination
-
fwhmx:
float
= 0.0 FWHM in x axis in pixels
-
fwhmx_arcsec:
float
= 0.0 FWHM in x axis in arc seconds
-
fwhmy:
float
= 0.0 FWHM in y axis in pixels
-
fwhmy_arcsec:
float
= 0.0 FWHM in y axis in arc seconds
-
has_saturated:
bool
= False Shows whether the star is saturated or not
-
layer:
int
= 0 image channel on which the star modelling was carried out
-
mag:
float
= 0.0 magnitude, approximate or accurate
-
profile:
StarProfile
= 0
-
ra:
float
= 0.0 Right Ascension
-
rmse:
float
= 0.0 RMSE of the minimization
-
s_Bmag:
float
= 999.99 error on the B magnitude
-
s_mag:
float
= 999.99 error on the (V) magnitude
-
sat:
float
= 0.0 Level above which pixels have satured
-
star_name:
Optional
[str
] = None
-
sx:
float
= 0.0 Size of the fitted function on the x axis in PSF coordinates
-
sx_err:
float
= 0.0 error in sx
-
sy:
float
= 0.0 Size of the fitted function on the y axis in PSF coordinates
-
sy_err:
float
= 0.0 error in sy
-
units:
Optional
[str
] = None Units
-
x0:
float
= 0.0 x coordinate of the peak
-
x_err:
float
= 0.0 error in x
-
xpos:
float
= 0.0 x position of the star in the image
-
y0:
float
= 0.0 y coordinate of the peak
-
y_err:
float
= 0.0 error in y
-
ypos:
float
= 0.0 y position of the star in the image
-
A:
- class sirilpy.models.RegData(fwhm=0.0, weighted_fwhm=0.0, roundness=0.0, quality=0.0, background_lvl=0.0, number_of_stars=0, H=<factory>)
Bases:
object
Python equivalent of Siril regdata structure
-
H:
Homography
Stores a homography matrix describing the affine transform from this frame to the reference frame
-
background_lvl:
float32
= 0.0 background level
-
fwhm:
float
= 0.0 copy of fwhm->fwhmx, used as quality indicator
-
number_of_stars:
int
= 0 number of stars detected in the image
-
quality:
float
= 0.0 measure of image quality
-
roundness:
float32
= 0.0 fwhm->fwhmy / fwhm->fwhmx, 0 when uninit, ]0, 1] when set
-
weighted_fwhm:
float32
= 0.0 used to exclude spurious images
-
H:
- class sirilpy.models.Sequence(seqname='', number=0, selnum=0, fixed=0, nb_layers=-1, rx=0, ry=0, is_variable=False, bitpix=0, reference_image=0, imgparam=None, regparam=None, stats=None, distoparam=None, beg=0, end=0, exposure=0.0, fz=False, type=None, cfa_opened_monochrome=False, current=0)
Bases:
object
Python equivalent of Siril sequ structure
-
beg:
int
= 0 imgparam[0]->filenum
-
bitpix:
int
= 0 image pixel format, from fits
-
cfa_opened_monochrome:
bool
= False CFA SER opened in monochrome mode
-
current:
int
= 0 file number currently loaded
-
end:
int
= 0 imgparam[number-1]->filenum
-
exposure:
float
= 0.0 exposure of frames
-
fixed:
int
= 0 fixed length of image index in filename
-
fz:
bool
= False whether the file is compressed
-
is_variable:
bool
= False sequence has images of different sizes
-
nb_layers:
int
= -1 number of layers embedded in each image file
-
number:
int
= 0 number of images in the sequence
-
reference_image:
int
= 0 reference image for registration
-
rx:
int
= 0 first image width
-
ry:
int
= 0 first image height
-
selnum:
int
= 0 number of selected images
-
seqname:
str
= '' name of the sequence
-
stats:
List
[List
[ImageStats
]] = None statistics of the images for each layer [nb_layers][number]
-
type:
SequenceType
= None the type of sequence
-
beg:
- class sirilpy.models.SequenceType(value)
Bases:
IntEnum
Python equivalent of the Siril sequence_type enum
- SEQ_AVI = 3
- SEQ_FITSEQ = 2
- SEQ_INTERNAL = 4
- SEQ_REGULAR = 0
- SEQ_SER = 1
- class sirilpy.models.SirilPoint(x, y)
Bases:
object
Represents a 2D point in the Siril image with x and y coordinates.
-
x:
float
x co-ordinate
-
y:
float
y co-ordinate
-
x:
- class sirilpy.models.StarProfile(value)
Bases:
IntEnum
Python equivalent of the Siril starprofile enum. Used to identify the type of fit used to model a star in the image. Note that MOFFAT_FIXED is currently not used in Siril, but is reserved for future use for Moffat stars modelled with a fixed beta parameter
- GAUSSIAN = 0
- MOFFAT = 1
- MOFFAT_FIXED = 2
- class sirilpy.models.UserPolygon(points, polygon_id=0, color=4294967295, fill=False, legend=None)
Bases:
object
Represents a user-defined polygon for display in the image overlay. These can be filled or outline-only, and can have any color and transparency (alpha) value. They can also have an optional label which is displayed centred on the polygon.
Note that UserPolygons should be considered transitory - they can be used to display information to the user but they may be cleared at any time if the user toggles the overlay button in the main Siril interface to clear the overlay.
- polygon_id
A unique identifier for the polygon.
- Type:
int
- points
List of points defining the polygon's shape.
- Type:
List[Point]
- color
Packed RGBA color (32-bit integer).
- Type:
int
- fill
If True, the polygon should be filled when drawn.
- Type:
bool
- legend
Optional legend for the polygon.
- Type:
str
- classmethod deserialize_polygon(data)
Creates a UserPolygon object by deserializing a byte array.
- Devuelve:
- A UserPolygon object and any remaining bytes in the byte
array. (The remaining bytes are for use in deserialize_polygon_list and can be safely ignored if deserializing a single polygon.)
- Tipo del valor devuelto:
Tuple
- Muestra:
ValueError -- If there is insufficient data to deserialize.
- classmethod deserialize_polygon_list(data)
Creates a List of UserPolygon objects by deserializing a byte array.
- Devuelve:
A List of UserPolygon objects.
- Tipo del valor devuelto:
List
- Muestra:
ValueError -- If there is invalid data to deserialize.
- serialize()
Serializes a single UserPolygon object into a byte array.
- Devuelve:
A byte array representing the serialized polygon data.
- Tipo del valor devuelto:
bytes
- Muestra:
ValueError -- If the number of points exceeds the allowed limit.
-
color:
int
= 4294967295 32-bit RGBA color (packed, uint_8 per component. Default value is 0xFFFFFFFF)
-
fill:
bool
= False whether or not the polygon should be filled when drawn
-
legend:
str
= None an optional legend
-
points:
List
[SirilPoint
] List of points defining the polygon's shape
-
polygon_id:
int
= 0 unique identifier
Siril Plotting
This submodule provides classes and method to access the native Siril plotting functionality. Of course, you can also use matplotlib but this submodule provides access to the same plotting capabilities as used internally within Siril for a more seamless result. All its members are made available at the module root level, there is no need to import models separately.
Once populated, the PlotData object can be plotted using SirilInterface.xy_plot()
.
Plot module for Siril, providing classes for plot data representation and serialization. This module enables users to create and configure various types of plots with customizable appearance and error bars.
- class sirilpy.plot.PlotData(title='Data Plot', xlabel='X', ylabel='Y', savename='plot', show_legend=True, datamin=None, datamax=None)
Bases:
object
Metadata container for plot configuration. The actual series data are held in SeriesData objects and can be added using the Class methods add_series or add_series_obj after initialization of the PlotData.
- Members:
title: Plot title
xlabel: X-axis label
ylabel: Y-axis label
savename: Save filename (extension is added automatically)
show_legend: bool indicating whether to show legend
datamin: List [xmin, ymin] forcing the bottom left coordinate to show. If omitted, the range is set to the data range.
datamax: List [xmax, ymax] forcing the top right coordinate to show. If omitted, the range is set to the data range.
- add_series(x_coords, y_coords, label=None, plot_type=PlotType.LINES, n_error=None, p_error=None)
Add a new series to the plot metadata.
- Devuelve:
the created SeriesData object for further manipulation if needed.
- Tipo del valor devuelto:
- add_series_obj(series)
Add a pre-created SeriesData object to the plot metadata.
Returns: None
- Tipo del valor devuelto:
None
- class sirilpy.plot.PlotType(value)
Bases:
IntEnum
Enumeration of available plot types for visualizing data series.
- HYPHENS = 2
- LINES = 3
- LINESHYPHENS = 6
- LINESMARKS = 5
- LINESPOINTS = 4
- MARKS = 1
- POINTS = 0
- class sirilpy.plot.SeriesData(x_coords, y_coords, label=None, plot_type=PlotType.LINES, n_error=None, p_error=None)
Bases:
object
Represents a single data series for plotting.
- Members:
x_coords: Either a List[float] or a np.ndarray containing the values for the x coordinates for this series
y_coords: Either a List[float] or a np.ndarray containing the values for the y coordinates for this series
label: A str containing a label for the series (shown in the plot legend)
plot_type: a PlotType setting the type of marks to use
n_error: Either a List[float] or a np.ndarray containing values for the y-axis negative errors for this series
p_error: Either a List[float] or a np.ndarray containing values for the y-axis positive errors for this series
Siril Utility Methods
This submodule provides utility methods for use in Siril python scripts.
The most important is ensure_installed()
but there are also methods
such as download_with_progress()
which provides a highly robust method
for downloading large files with good error recovery through a retries and
resume mechanism.
Utility module for Siril Python interface providing helper functions for file operations, package management, and standard I/O control to support Siril's scripting capabilities.
- class sirilpy.utility.SuppressedStderr
Bases:
object
This class allows suppression of the script's stderr, which can be useful if you are using module functions that are known to produce warnings that you want to avoid distracting the user with, such as FutureWarnings of features that have become deprecated but are in a dependency rather than your own code. The class should be used sparingly and should not be used to hide evidence of bad code.
- class sirilpy.utility.SuppressedStdout
Bases:
object
This class allows suppression of the script's stdout, which can be useful to avoid flooding the log with stdout messages from an excessively verbose module used in the script.
Ejemplo
siril = sirilpy.SirilInterface() print("This message will appear in the Siril log") with siril.SuppressedStdout(): print("This message will not appear") print("This message will appear again")
- sirilpy.utility.check_module_version(requires=None)
Check the version of the Siril module is sufficient to support the script. This is not mandatory if you are only using classes, methods etc. that are provided in the initial public release, but if you rely on methods that are noted int he API documentation as having been added at a particular version of the module then you must check the running sirilpy module supports your script by calling this function.
- Parámetros:
requires (str) -- A version format specifier string following the same format used by pip, i.e. it may contain '==1.2', '!=3.4', '>5.6', '>=7.8', or a combination such as '>=1.2,<3.4'
- Devuelve:
True if requires = None or if the available sirilpy module version satisfies the version specifier, otherwise False
- Muestra:
ValueError -- if requires is an invalid version specifier.
- sirilpy.utility.download_with_progress(siril, url, file_path, max_retries=3, retry_delay=5, resume=True)
Robust file download method with native Siril progress tracking and error handling using retries and a resume mechanism.
- Parámetros:
siril (SirilInterface) -- SirilInterface to use to update the progress bar
url (str) -- URL of the file to download
file_path (str) -- Local path to save the downloaded file
max_retries (int) -- Number of download retry attempts
retry_delay (int) -- Delay between retry attempts in seconds
resume (bool) -- Whether or not to resume a partially downloaded file or start again
- Devuelve:
True if download successful, False otherwise
- Tipo del valor devuelto:
bool
- sirilpy.utility.ensure_installed(*packages, version_constraints=None)
Ensures that the specified package(s) are installed and meet optional version constraints.
- Parámetros:
*packages (str or List[str]) -- Name(s) of the package(s) to ensure are installed.
version_constraints (str or List[str], optional) -- Version constraint string(s) (e.g. ">=1.5", "==2.0"). Can be a single constraint or a list matching packages.
- Devuelve:
True if all packages are successfully installed or already meet constraints.
- Tipo del valor devuelto:
bool
- Muestra:
RuntimeError -- If package installation fails.
- sirilpy.utility.human_readable_size(bytes_size)
Convert bytes to human-readable format.
- Parámetros:
bytes_size (int) -- Size in bytes
- Devuelve:
Formatted size with appropriate unit (B, KB, MB, GB, TB)
- Tipo del valor devuelto:
str
Siril TK GUI
This submodule provides some helper functions to support consistent
GUI implementation using tkinter
. It must be explicitly imported in
order to be used. Note that when writing TKinter GUIs you should import
ThemedTK from the ttkthemes module, because the bare TKinter UI shows up
poorly on MacOS. ThemedTK and the methods available in the tksiril
module help to provide a consistent look for Siril script GUIs on all
platforms.
from sirilpy import tksiril
- sirilpy.tksiril.create_tooltip(widget, text, wrap_length=250)
Create a tooltip for a given Tkinter widget.
- Parámetros:
widget (tk.Widget) -- The widget to attach the tooltip to
text (str) -- The tooltip text to display
max_width (int, optional) -- Maximum width of the tooltip. Defaults to 300.
wrap_length (int, optional) -- Length at which text wraps. Defaults to 250.
- Muestra:
RuntimeError -- If the provided widget is not a valid Tkinter widget
TypeError -- If text is not a string
- sirilpy.tksiril.match_theme_to_siril(themed_tk, s)
Match the Tkinter theme to the Siril configuration and set the script dialog to have topmost status, meaning that it will remain in front of other non-topmost windows.
- Parámetros:
s (SirilInterface) -- sirilpy.SirilInterface class to provide the Siril theme (light or dark) to match
themed_tk (ThemedTk) -- ThemedTk instance to apply the theme to
- Muestra:
TypeError -- If input arguments are of incorrect type
ValueError -- If the theme configuration is not 0 or 1
AttributeError -- If required methods are not available
- sirilpy.tksiril.standard_style()
Provide a standardised ttk style to allow consistent visual appearance between different Siril python scripts.
- Parámetros:
none
- Muestra:
RuntimeError -- If the style creation or configuration fails
Siril Exceptions
This submodule provides some customized exceptions to support Siril-specific error handling. All its members are made available at the module root level, there is no need to import it separately.
- exception sirilpy.exceptions.CommandError(message='Command execution failed', status_code=_CommandStatus.CMD_GENERIC_ERROR)
Bases:
SirilError
Raised when a command sent to Siril fails to execute properly. (Note: 'command' in this case refers to internal commands sent from the python module to the Siril python handler, not Siril commands of the type that might be entered in the Siril command entry.) This includes cases like:
Invalid command parameters
Command execution failures
Unexpected command responses
Command timeout
- exception sirilpy.exceptions.DataError(message='Error handling data')
Bases:
SirilError
Raised when there are problems with data handling. This includes cases like:
Invalid image data
Data conversion errors
Memory allocation failures
Buffer overflows
- exception sirilpy.exceptions.NoImageError(message='No Siril image loaded')
Bases:
SirilError
Raised when a method requires an image to be loaded but no image is loaded.
- exception sirilpy.exceptions.NoSequenceError(message='No Siril sequence loaded')
Bases:
SirilError
Raised when a method requires a sequence to be loaded but no sequence is loaded.
- exception sirilpy.exceptions.SirilConnectionError(message='Failed to connect to Siril')
Bases:
SirilError
Raised when there are problems connecting to or communicating with Siril. This includes cases like:
Siril not running
Socket connection failures
Communication protocol errors
Unexpected disconnections
- exception sirilpy.exceptions.SirilError(message='An error occurred')
Bases:
Exception
Base exception class for all Siril-related errors.
All other Siril exceptions inherit from this class, making it easy to catch any Siril-related error with a single except clause.