Optics math — pixel size, sampling, focal length
getSampling(): the one conversion every pixel-based measurement needs
Any module measuring something in pixels (star HFR, drift, centering error) needs it in arcseconds to mean anything independent of the camera/optic combination in use. getSampling() is that conversion, called from Focus, Guider, Inspector, Navigator, Polar and Sequencer alike — by far the most used helper in this whole chapter:
// src/modules/guider/guider.cpp
_dRAvector.push_back(_driftRA * getSampling());
_dDEvector.push_back(_driftDE * getSampling());// src/modules/focus/focus.cpp
onLoopFrameMeasured(_solver.HFRavg * getSampling());// src/modules/sequencer/sequencer.cpp, OnSucessSEP()
double ech = getSampling();
dta.HFRavg = _solver.HFRavg * ech;Internally it combines pixel size and optical setup, and refuses to guess for a module that isn’t actually an imager:
// libs/indimodule.cpp
double IndiModule::getSampling()
{
if (!isImager())
{
logWarning("%1 - module is not defined as an imager - defaults to 1", {QString("getSampling")});
return 1;
}
return 206 * getPixelSize(getString("devices", "camera")) / (getFloat("optic", "fl") * getFloat("optic", "red"));
}isImager() here is the read side of defineMeAsImager() (Ready-made families) — every module listed above reaches it through defineMeAsFocuser()/defineMeAsGuider()/defineMeAsSequencer(), which all bundle defineMeAsImager() in turn.
getPixelSize(deviceName) is the piece that actually reads CCD_PIXEL_SIZE off the device — no core module calls it directly, getSampling() is the only caller.
setFocalLengthAndDiameter(): push the optic’s numbers to the device
Some drivers (plate solvers, simulators) need to know the telescope’s focal length and aperture themselves, via the standard SCOPE_INFO vector. Navigator, Allsky and Inspector all call it right before anything that depends on correct optics, and abort if it fails:
// src/modules/navigator/navigator.cpp
if (!setFocalLengthAndDiameter())
{
setStateEvent(OST::Error, "error", "badopticparams", "Invalid optic parameters");
...
return;
}Guider calls the same no-argument overload unconditionally, with a one-line reason why it can’t be skipped even outside a real optics-dependent step:
// src/modules/guider/guider.cpp
setFocalLengthAndDiameter(); // Mandatory for simulators to work
The no-argument form is a thin convenience that reads optic.fl/optic.diam/devices.camera and delegates to a second overload taking them explicitly — no core module calls that one directly, but it’s where the actual SCOPE_INFO round-trip and the validation (focal length/diameter both >= 1) happen:
// libs/indimodule.cpp
bool IndiModule::setFocalLengthAndDiameter()
{
double fl = getFloat("optic", "fl");
double diam = getFloat("optic", "diam");
QString dev = getString("devices", "camera");
return setFocalLengthAndDiameter(dev, fl, diam);
}