Messager Céleste

Journal

PixInsight on autopilot: from raw frames to final image with scripts

Translated from French.

A night in Texas produces a few dozen exposures; a finished target often has several hundred, sometimes more than a thousand for a mosaic. Processing them in PixInsight means a long series of nearly identical operations: calibrate, align, stack, combine colours, remove noise, stretch. For a few weeks now, that series has been handed to a chain of scripts, launched and monitored by an artificial intelligence agent (Claude Code). The Texas equipment mostly belongs to Renaud Venne-Landry; I take care of acquisition and automation.

Four-panel mosaic of the Heart and Soul nebulae in the SHO palette
The Heart and Soul: a four-panel mosaic, 1,200 exposures of 600 s, processed end to end by the script chain.

How it is wired

PixInsight runs on a Mac; the agent works on a small Linux server at home. The two machines share a network folder: scripts, settings files, logs and JPEG previews go through it. The large files (calibrated and aligned frames, masters, intermediate images) stay on the Mac's disk and never cross the network.

The scripts are written in PixInsight's scripting language (PJSR, a form of JavaScript). They call the usual processes directly — ImageCalibration, StarAlignment, ImageIntegration, BlurXTerminator, NoiseXTerminator, StarXTerminator — without opening any dialog. To launch a script, the agent types a run command in the PixInsight console, then follows the log from the server. The original raw frames and masters are never modified, and the scripts only close the windows they opened: PixInsight remains usable at the same time.

Five steps

ScriptDurationRole
Preprocessing15 min to 1 hMissing calibration masters, calibration, alignment, local normalization, stacking, plate solving
Panelsa few secondsColour combination, BlurXTerminator in correct-only mode, gradient correction, colour calibration, common crop
Mosaic1 to 2 minAssembling the panels by their astrometry, matching sky backgrounds
Linearabout 1 minDeconvolution, noise reduction, separation of stars and nebulae
Non-linearabout 30 sContinuum-free Ha, stretch, curves, dark structures, stars added back, export

Each image is described by a small settings file: the raw frame folders, the palette (LRGB, SHO, HOO), the chosen calibration masters and the rendering parameters. A planner prepares it from the image headers: for each batch (filter, exposure time, temperature), it looks for the matching dark and flat in the master library, or plans to build them. That plan is reviewed before preprocessing starts: choosing flats remains an astrophotographer's decision.

The chart below details the whole workflow, from the first question to delivery.

Workflow of the automated processing in PixInsightEight steps, from plan to delivery: four scripts in PixInsight, framed by planning, preview review and delivery handled from the server.PixInsight, on the MacAgent, from the serverQuestions and planServer · a few minutes• Target, single image or mosaic, palette• Planner: darks and flats picked, or to be built• Plan reviewed and accepted before launchPreprocessingPixInsight · 15 min to 1 h per target• Missing masters, calibration, alignment• Local normalization, stacking, plate solving• Resumes after a stop, intermediates deletedPanelsPixInsight · about twelve seconds per panel• Colour combination (LRGB, SHO, HOO)• BXT correct-only, then gradients (SPFC, MGC, MARS)• Colour calibration on the starsMosaicPixInsight · 1 to 2 min · mosaics only• Reprojection by each panel's astrometry• Normalization on stars, backgrounds matched• Blending, second gradient pass, final cropLinear processingPixInsight · about 1 min• Deconvolution (BlurXTerminator)• Noise reduction (NoiseXTerminator)• Star separation (StarXTerminator)Non-linear processingPixInsight · about 30 s• Continuum-free Ha, stretch, luminance, curves• Dark structures, stars added back• Final autostretch, XISF and JPEG exportPreview reviewServer · after each step• Logs: "FIN OK" or "FIN ERREUR"• Previews and crops: seams, colour casts, trails• Rendering to redo: new version in 20 sDeliveryServer · a few minutes• JPEG and sheet in the final images folder• Website: close-ups, annotated image, finder chart• Clean-up: the shared folder keeps only scriptssingleimagenewversion

Looking, not just reading logs

A script can finish without error on a failed image. After each step, the agent therefore opens the previews and looks at them. That is how, for example, these were caught:

  • on the Crescent mosaic, a hole of 1 × 11 pixels that were exactly zero at the junction of two panels, which became a black spot after deconvolution; the mosaic script now fills such pixels;
  • around galaxies, an artificial dark halo created by the dark-structure enhancement; it is turned off for galaxies;
  • burnt-out galaxy cores: two successive passes of HDRMultiscaleTransform, followed by a saturation boost limited to bright areas, give much better results than a single one.
Mosaic of the Crescent Nebula NGC 6888 in the SHO palette
NGC 6888, the Crescent: a four-panel mosaic, 1,160 exposures, preprocessed in 48 minutes.

The rendering is then tuned by iteration: each version carries a tag (v1, v2…), and a new pass of the last step takes about twenty seconds. Two or three tries are usually enough. The default finish — two passes of DarkStructureEnhance, a rather bright sky background, a little more contrast — comes from preferences expressed along the way.

Colour

Two colour calibration methods were compared. SPCC (spectrophotometric calibration, based on a star catalogue and the filter curves) gave images that were too orange; on M31, the galaxy's red/blue ratio went from 1.21 to 1.48. The default method is therefore the simplest one: background neutralization, then white taken from the stars in the field. It has its limits: in a very dusty field such as Rho Ophiuchi, the stars are reddened by dust, their average is no longer white and the whole image turns blue. SPCC is then the right choice.

Mosaics and batches

To assemble the panels, the scripts invent nothing: they drive, without their window, the engines of the registration scripts that ship with PixInsight. Each panel is reprojected according to its own astrometric solution, normalized on the stars they share, and sky backgrounds are matched in the overlap areas. On the Pleiades as on the Heart and Soul, no seam is visible.

Several targets can also run one after another from a single launch: eight targets, from raw frames to final image, in about two hours. A trap appeared with the first batch: the calibrated and aligned frames weigh about a hundred gigabytes per target, and the disk filled up. They are now deleted as soon as the masters are done.

An image redone: the Pleiades

The Pleiades mosaic was the first one assembled by the script chain. Its first version showed the cluster and its reflection nebulae well, but the large dust cloud filling the field was barely visible, drowned in a greenish background; a later version kept a teal cast and a large-scale colour gradient.

First version of the Pleiades mosaic: dark, greenish background, dust barely visible
First version (November 25): the cluster stands out, the dust hardly at all.

Two changes transformed it. First, gradients are now removed on each panel, still linear, before colour calibration and before assembly. The tool is MultiscaleGradientCorrection, which compares the sky background of the image with MARS, an all-sky photometric survey, and removes only what does not belong to the sky. It requires a prior flux calibration (SpectrophotometricFluxCalibration), done with the curves of the Antlia filters and of the sensor. An attempt on the already assembled mosaic did not succeed: it really has to be done panel by panel. Second, a final histogram transformation, equivalent to PixInsight's automatic display stretch (ScreenTransferFunction), is applied to the finished image: it brings out the faint structures.

A last revision came from PixInsight's own documentation: tutorials, examples, the starter guide, the process reference pages and the team's posts on the forum. The recommended order is clear: first BlurXTerminator in correct-only mode, which restores clean star shapes and makes the flux calibration more accurate; then gradient correction on each panel, with a scale chosen by PixInsight's rule (4096 pixels here instead of 1024, so as not to erase large structures); then a second pass on the assembled mosaic, with edge correction. This is the current version: a more neutral background without the grey-green veil, and finer stars.

Current version of the Pleiades mosaic: neutral background, dust veils visible across the whole field
Current version (November 28): neutral background, and the dust veils appear across the whole width of the field.

The whole gallery redone

The lessons learned on the Pleiades were then applied to every image on the site, reprocessed in one evening through chained batches. Three changes apply throughout. Gradient correction is now done on each filter, including Ha and OIII, which the MARS database also covers; SII, which the database lacks, goes through GradientCorrection, and a field outside MARS coverage automatically switches to that tool. The Ha of colour images is no longer blended into the red as is: the continuum light, measured in the red channel, is subtracted first, as recommended by the M31 example published by PixInsight. The HII regions of the galaxies then stand out as small, sharp pink spots, and tiny jets from newborn stars, the Herbig-Haro objects, appear in NGC 1333. Finally, the galaxies are calibrated with SPCC.

M81 and M82, previous version on the left and current version on the right
M81 and M82: previous version (left) and current version (right), with the galactic dust surrounding both galaxies.

The rendering of the galaxies went through a series of trials: eight variants of core compression (HDRMultiscaleTransform) and saturation, compared on full-resolution crops. The one kept preserves the detail of M81's core while warming up the colours, which were too beige before.

This reprocessing also revealed two automation traps. A script had left in PixInsight's memory a function named like a system function; every following script used it unknowingly, and plate solving failed with incomprehensible errors. The scripts now run in the V8 JavaScript engine, which starts from a clean environment on every run. The second trap affected mosaics: gradient correction filled the empty areas around the panels, which the crop no longer recognized, and a black rectangle remained in the image.

What is still done by hand

Automation replaces hours of clicking, not judgement. Choosing the targets, the calibration masters and the palette, assessing a rendering, and the final touch-ups of some images are still done by hand. The images published in the gallery are sometimes those touched-up versions.