Journey's End

Jul 04
2026

Siril Script to Calculate Total Sequence Exposure Time

When stacking sub-exposures of different durations while also disabling images based on FWHM and visual inspection the question of "what is the total exposure time" can be difficult to answer. The following python script should answer the question.

from collections import Counter

import sirilpy as s

siril = s.SirilInterface()
siril.connect()

seq = siril.get_seq()

print(f'Computing exposure time for sequence {seq.seqname}')
print(f'Sequence has {seq.number} images, {seq.selnum} selected/enabled')

exp_time_table = Counter()

for idx, imparam in enumerate(seq.imgparam):
    if not imparam.incl:
        continue

    header = siril.get_seq_frame_header(idx, return_as='dict')
    exp_time_table[header['EXPTIME']] += 1

total_exp_time_s = 0
for exp_time, count in exp_time_table.items():
    print(f'Exposure time: {count:4d} x {exp_time:4.0f} secs')
    total_exp_time_s += exp_time * count

total_exp_time_min = total_exp_time_s / 60
total_exp_time_hr = total_exp_time_s / 3600

print(f'Total exposure time: {total_exp_time_s:.0f} secs (={total_exp_time_min:.1f} mins '
      f'={total_exp_time_hr:.1f} hrs)')

Example output:

14:06:45: Computing exposure time for sequence r_ngc_6188_combined_
14:06:45: Sequence has 606 images, 566 selected/enabled
14:06:46: Exposure time:  293 x   60 secs
14:06:46: Exposure time:  248 x   30 secs
14:06:46: Exposure time:   25 x  120 secs
14:06:46: Total exposure time: 28020 secs (=467.0 mins =7.8 hrs)

Apr 20
2026

Datetime Display in Django

Suppose you have instruments in different timezones taking readings. You might have the following Django data model:

class Instrument(models.Model):
    timezone_utc_offset_hours = models.FloatField(...)
    ...

class Reading(models.Model):
    instrument = models.ForeignKey(Instrument, ...)
    timestamp = models.DateTimeField(auto_now_add=True)
    ...

Furthermore suppose settings.py contains the following:

...
USE_TZ = True
TIME_ZONE = "Europe/Paris"
...

It …

May 24
2025

Adventures in Compressed DNG

I have been working with industrial cameras and frame-grabbers that simply gives me a dump of their sensor data. To make that data useful it needs to undergo demosaicing, ideally using one of the modern demosaic algorithms like RCD rather than simple interpolation or the rather outdated VNG. Unfortunately the …

Apr 10
2025

Python One-liner for Local QR Code Decoding

Because KeepassXC lacks the ability to decode QR code for TOTP setup and not all MFA implementations show the required secret in text format, I use the following snipet to read the QR code information locally:

  python -c 'from cv2 import QRCodeDetector; from PIL.ImageGrab import grabclipboard; import numpy as …
ts=03:07 tags=[python,software,oss]

Feb 04
2023

Aug 05
2018

IPython Notebook on GPS Timing and CDMA

In \[1\]:
%matplotlib inline import matplotlib import numpy as np import matplotlib.pyplot as plt
# GPS Timing Carrier-phase detection is suppose to yield better timing information than tracking the pseudorandom code stream. The reason for this is supposedly that the higher frequency carrier allows for more accurate measurements of the …

May 07
2016

Sep 12
2014

Sep 12
2014

Adventures in Python Optimisation

Recently I found myself looking at the following piece of code and trying to optimise it:

from __future__ import division

import numpy as np

MagneticPermeability = 4*np.pi*1e-7
MagneticPermeabilityOver4Pi = MagneticPermeability / (4*np.pi)

def fieldfunc_py(p, q, moment):
  r = p - q 
  rmag = np.sqrt(r.dot(r))

  rdash3 = rmag …
ts=14:41 tags=[python,c,code,software]

Jul 21
2012

GNU readline with System Python (OS X 10.7)

By default system python loads "fake" readline (fake because it actually uses libedit) from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so. Even if you install readline (which goes into /Library/Python/2.7/site-packages), it will still load it, even if you fiddle …

ts=01:46 tags=[python,software,osx]

Jan 27
2011

iPhone 4 layer export script for Gimp

I often mockup iPhone interfaces on the Gimp, then exporting each layer for use as backgrounds. For iOS 4 each image needs to be exported twice: one at full resolution with @2x in its filename, and once at half-resolution without the @2x. e.g. nav_bg@2x.png and nav_bg.png …

Oct 11
2009

qrbackup

I generated a gpg keypair for myself today, and I was looking for a fairly safe way to back it up. I don't particularly trust DVD/CDs, and keeping it on flash is even more worrying. I wanted a means of backup I can see and touch.

Paperbak would be …

Oct 09
2008

Jul 16
2008

Apr 28
2008

{} I <3 thee

Firstly, I am the kind of guy who likes tabs over spaces, because I don't like forcing my particular preferences on to other people. To wax poetic, I like to give other people the freedom of choosing how they want their code indented. This of course brings me into the …

Dec 31
2007

html2pml

I was tired of converting all my HTML ebooks to rtf, then to pdb using Palm Doc Converter only to lose all the nice touches like bold, italics and headings. Since there didn't seem to be a HTML to PML converter for OS X, I wrote one to get more …

ts=10:15 tags=[python,code,palm]