The importance of refocusing as ambient temperature changes
Astrophotography is an activity where seemingly trivial details can have a disproportionately large effect on the outcome. One of these factors, which will be explored in this article, is the impact of minor shifts in focus caused by changes in the ambient temperature.
Going back to basics is helpful when thinking about focus. A telescope is essentially a tube with an objective lens at the front and an eyepiece (or camera) at the rear. For an image to be in focus, there must be a precise distance between these two elements. As ambient temperature changes, the material the tube is made from will expand or contract, which changes this distance and therefore also the focus. This is illustrated in the images below, borrowed from Liverpool Astronomical Society's excellent article Buying a Telescope by Steve Southern.


Those of us not yet blessed with backyard observatories normally keep telescopes and other equipment inside our homes, for obvious reasons. Because the indoor and outdoor temperatures are rarely equal, telescopes generally require an adjustment period after being set up, in order to reach thermal equilibrium. Observatories largely avoid this problem because this temperature difference is usually much smaller.
Focusing too soon after setting up is often a waste of time, as the focus will inevitably shift slightly once the telescope has adjusted. On top of this, the ambient temperature will usually change gradually during an imaging session. Below is a comparison of two images of the galaxy M33 in Triangulum, showing the impact which being even slightly out of focus can have on the quality of the final image.


When the frames for the right image were taken, I had neglected to properly refocus since setting up, and the ambient temperature had changed, causing the focus to shift ever so slightly. This results in a noticeably blurry image, particularly when compared side-by-side with the properly-focused equivalent. The solution is simply to check focus at regular intervals (typically every 30 to 60 minutes). I am sure I must be far from the only beginner who has made this error, and had it cost them hours of precious clear-sky time!
The Bahtinov mask

It's often surprisingly difficult to tell when an image is perfectly in focus, particularly with other factors like seeing affecting the apparent clarity and stability of the image. One beautifully simple but effective tool to resolve this is the Bahtinov mask. This is simply a sheet or board of opaque material large enough to cover the objective lens of the telescope, with a series of evenly-spaced slits cut into it in a specific pattern, as seen below.

When placed at the front of the telescope, the slits create diffraction spikes. These are visual artifacts caused by diffraction of light around obstructions in the light path. Good examples of these are seen in images from the Hubble or James Webb space telescopes, where bright stars appear to be surrounded by a cross or star-shaped arrangement of spikes, caused by the different arrangement of the secondary mirror supports in each telescope.

The secret is in how the spike pattern created by the bahtinov mask changes as the telescope moves in and out of focus. Each spike moves on its perpendicular axis. When the telescope is out of focus, the spikes are misaligned and overlap in different places. The better focus becomes, the closer together the intersection points of the spikes. When the telescope is perfectly focused, the spikes align and all intersect perfectly in the centre of the light source. This is shown in the gif below (from Wikipedia).

The Bahtinov mask is an ingenious piece of technology. It's so simple you could make one yourself without much trouble, and costs almost nothing, yet it works so well it's become a near-indispensable tool in astronomy (at least for me personally). In terms of cost to benefit ratio, this has to be the best money I've ever spent in the hobby. Even with an automatic focuser, it's still useful for verifying (and if necessary, manually fine-tuning) focus.