gess.common
helpers
- gess.common.helpers.checkcalibexists(calibtype, calibfolder, calibfmt, workdir, frames, ext, app=None)
Checks if a calibration library of a folder containing calibration frames to stack exists
- Parameters:
calibtype (str) – the name of calibration frames, i.e. dark,flat or bias
calibfolder (str) – either the path to the calibration frames library or the subfolder name containing calibration frames to stack
calibfmt (str) – the string to parse master frame name, containing str and FITS header keys with format specifier e.g: “BIAS_O[OFFSET:d]_bin[XBINNING:d].fit”
workdir (str) – the path to the working directory containing the session
frames (str) – the string to identify the frames to be calibrated, typ. “light” or “flat”
ext (str) – the extension of the frames to be calibrated
app (Siril, optional) – a Siril class instance that can be used to call pySiril functions. Pass None if it needs to be started, defaults to None
- Returns:
(True if successful,True if the masters are in a library/False if they need to be stacked from the session,full path to the masterframe if found in a library)
- Return type:
(bool,bool,str)
- gess.common.helpers.checklocalcalibexists(calibtype, calibfolder, calibfmt, frames, ext, app=None)
Checks if a local copy of the master exists in the working directory (in the masters subfolder)
- Parameters:
calibtype (str) – the name of calibration frames, i.e. dark,flat or bias
calibfolder (str) – the path to the local calibration frames library
calibfmt (str) – the string to parse master frame name, containing str and FITS header keys with format specifier e.g: “BIAS_O[OFFSET:d]_bin[XBINNING:d].fit”
frames (str) – the string to identify the frames to be calibrated, typ. “light” or “flat”
ext (str) – the extension of the frames to be calibrated
app (Siril, optional) – a Siril class instance that can be used to call pySiril functions. Pass None if it needs to be started, defaults to None
- Returns:
(True if master exists, full path to the masterframe if found)
- Return type:
(bool,str)
- gess.common.helpers.getfirstfile(folder)
Finds the first file of a folder with given extension
- Parameters:
folder (str) – the path to search
- Returns:
the path to the first file of the folder if one was found, an empty string otherwise
- Return type:
str
- gess.common.helpers.parsemasterformat(masterfmt, hdr, refframe, mode='r', rmspace=True)
Parses the name of a master based on its formatting string and the header of the frame to calibrate
- Parameters:
masterfmt (str) – a string containing the format specification to parse the name.
All the string tokens between brackets will be parsed. The tokens are formed with: - HEADERKEY: a valid key of the FITS header - fmt: a format specifier. Most of the time d, f or s should do.
You can have a look at https://docs.python.org/3/library/string.html#formatstrings
Special wildcard “*” character before HEADERKEY: If a HEADERKEY is suffixed with a wildcard character, the string returned will change, depending on mode value:
If mode=’r’: [*HEADERKEY:fmt] is replaced by *
If mode=’w’: HEADERKEY is parsed
- Parameters:
hdr (dict) – A dictionnary of refframe header keys, as returned by pySiril.Addons::ReadFITSHeader
refframe (str) – the name of the reference frame
mode (str, optional) – either ‘r’ or ‘w’. Flag to handle behavior with wildcards, defaults to ‘r’
mode – Flag to remove spaces in the output string, defaults to True
- Returns:
the name of the file with header keys parsed as per specification.
- Return type:
str
- gess.common.helpers.findmaster(workdir, master, masterfmt, refframe, app=None)
Looks for a suitable master for a given reference frame
- Parameters:
workdir (str) – the path to the working directory containing the session
master (str) – either the full path to the masters library or subfolder string wrt. workdir
masterfmt (str) – check-out spec in parsemasterformat
refframe (str) – the name of the reference frame
app (Siril, optional) – a Siril class instance that can be used to call pySiril functions. Pass None if it needs to be started, defaults to None
- Returns:
(True if the master was found,the full path to the master if one was found)
- Return type:
(bool,str)
- gess.common.helpers.pathhasspace(folder)
Returns True if the path has spaces
- Parameters:
folder (str) – a path
- Returns:
True if the path has spaces
- Return type:
bool
- gess.common.helpers.checksubfolder(workdir, subfolder)
Checks if a subfolder exists
- Parameters:
workdir (str) – the path to the root folder to be searched
subfolder (str) – the subfolder name to be found
- Returns:
(True if the subfolder exists,The full path to the subfolder)
- Return type:
(bool,str)
- gess.common.helpers.relativizepath(refframe, workdir)
Returns the path of a file relative to a given directory
- Parameters:
refframe (str) – the path to a file
workdir (str) – the path to a folder
- Returns:
the path of refframe relative to workdir, with all separators replaced with “/”
- Return type:
str
- gess.common.helpers.fast_scandir(dirname)
Returns all the subfolders of a given path
- Parameters:
dirname (str) – the path to a folder
- Returns:
the list of all subpaths of dirname (full paths)
- Return type:
list(str)
- gess.common.helpers.checkmastersubs(mastertype, masters, opt, subbydate, app=None, findsubsets=True, follownaming='')
Returns all the subsets of masters in a path
- Parameters:
mastertype (str) – a name to be used in print outs, giving the type of files being searched
masters (str) – the last part of a path corresponding to these masters
opt (DictX) – options member of an Options instance, with optiontype=’gess’
subbydate (list(str)) – a set of folders to search
app (Siril, optional) – a Siril class instance that can be used to call pySiril functions. Pass None if it needs to be started, defaults to None
findsubsets (bool, optional) – True if the headers of the files need to be verified to identify unique sets of frames, defaults to True
follownaming (str, optional) – the naming convention to be used to name the subsets, defaults to ‘’
- Returns:
the list of all the subsets paths
- Return type:
list(str)
- gess.common.helpers.checkmastersconfiguration(mastertype, opt, loop)
Checks the masters configuration as per loop spec
- Parameters:
- Returns:
(True if the check succeeded,True if the masters need to be stacked and copied to a library,the final pathbit of the masters,the format to parse the masters names)
- Return type:
(bool,bool,str,str,str)
- gess.common.helpers.masterstackingoptions(opt, mastertype, library=False)
Returns gess options with only one type of masters to be stacked
- Parameters:
opt (DictX) – options member of an Options instance, with optiontype=’gess’
mastertype (str) – the type of masters to be activated
library (bool, optional) – True if the masters will be copied to a library. Activates 16b with no compression. Defaults to False
- Returns:
options member of an Options instance, with optiontype=’gess’, with preprocessing and compression options set to only stack one type of masters
- Return type:
- gess.common.helpers.returninifolder(inifile, boxtitle=None)
Returns the last session working directory
- Parameters:
inifile (str) – the path to gess.ini file
boxtitle (str, optional) – The message to be displayed at the top of the folder chooser, defaults to None
- Returns:
the path to the selected session folder. gess.ini is updated with the new path
- Return type:
str
- gess.common.helpers.ReadSirilPrefs(app=None)
Reads Siril Preferences file
- Parameters:
app (Siril, optional) – a Siril class instance that can be used to call pySiril functions. Pass None if it needs to be started, defaults to None, defaults to None
- Returns:
a dictionnary with Siril configuration
- Return type:
dict
- gess.common.helpers.ParseSirilBDC(prefs=None, app=None)
Parses Siril bitdepth and compression settings
- Parameters:
prefs (dict, optional) – a dictionnary containong Siril preferences. If None, pySiril Addons::GetSirilPrefs() is called.
app (Siril, optional) – a Siril class instance that can be used to call pySiril functions. Pass None if it needs to be started, defaults to None, defaults to None
- Returns:
a DictX with compression and bitdepth commands
- Return type:
- gess.common.helpers.GetSirilBitDepth(prefs=None, app=None)
Returns Siril bitdepth preferences
- Parameters:
prefs (dict, optional) – a dictionnary containong Siril preferences. If None, pySiril Addons::GetSirilPrefs() is called.
app (Siril, optional) – a Siril class instance that can be used to call pySiril functions. Pass None if it needs to be started, defaults to None
- Returns:
“16” or “32”
- Return type:
str
- gess.common.helpers.GetSirilRawExt()
Returns Siril list of RAW extensions
- Returns:
a list of valid extensions for raw format as returned by siril -f
- Return type:
list(str)
- gess.common.helpers.ReadRawHeader(filename, validrawexts=None)
Read raw exif and returns a dictionnary with the following keys:
INSTRUMEN: the name of the camera
ISOSPEED: the iso setting of the shot
EXPTIME: the exposure time in s
DATE-LOC: the date and time of the exposure
- Parameters:
filename (str) – full path to the raw file to read headers from.
validrawexts (list(str)) – a list of valid raw files extensions, defaults to None
- Returns:
a dictionnary with keys listed above
- Return type:
dict
DictX
- class gess.common.DictX.DictX
A overload of dict class that accepts dot assignment
- Parameters:
dict (dict) – a dictionnary
options
- class gess.common.options.options(optiontype='gess', addcfgfile=None, dictcfg={}, updatedefault=False, returnclean=False)
Class to handle options passed to gessengine, gessloop and copyback.
Default cfg file are stored in your user folder at ./gess/
This class is called at initialization of the package to create default cfg files if none is present:
gess.cfg: the options for your typical worflow
loop.cfg: additional options to use gessloop module
copyback.cfg : additional options to use copyback module
- Parameters:
optiontype (str, optional) – the type of options, either ‘gess’, ‘loop’ or ‘copyback’, defaults to ‘gess’
addcfgfile (str, optional) – an additional cfg file to read more options from on top of default values, defaults to None
dictcfg (dict, optional) – a dictionnary to read more options from on top of default values, defaults to {}
updatedefault (bool, optional) – Flag to update default cfg with the values passed, defaults to False
returnclean (bool, optional) – Flag to return a clean version of the options attribute with all values to default, defaults to False
- updateoptions_fromdict(optdict)
method to update the options attribute with values from a dictionnary. Checks the type of the entries to make sure they match the types defined in the constructor.
- Parameters:
optdict (dict) – a dictionnary with values to update the options attribute
- Returns:
True if the update was successful
- Return type:
bool
- updateoptions_fromfile(addcfg)
method to update the options attribute with values from a file.
- Parameters:
addcfg (str) – the path to a cfg file. Can be either a full path or a filename. If filename, it is assummed to be located in the dame folder as the default cfgfile.
- Returns:
True if the update was successful
- Return type:
bool
- printoptions()
Print out all the keys and values of the options attribute
- getoptions()
Return the options attribute
- exportcfgfile(cfgfile='')
Export options attribute to a cfg file, selected by the user
- Parameters:
cfgfile (str, optional) – optional path to save the cfgfile. If empty, will open a SaveAs window, defaults to ‘’
- Returns:
True if sucessfull
- Return type:
bool
- importcfgfile(update=True)
Import options attribute from a cfg file, selected by the user
- Parameters:
update (bool, optional) – If True, the default cfg file is updated, defaults to True
- Returns:
True if sucessfull
- Return type:
bool
Logger
- class gess.common.Logger.Logger(caller='gess_')
Class to log both to terminal and to .log file
- Parameters:
object (object) – object