Kstars

guidestars.h
1/*
2 SPDX-FileCopyrightText: 2020 Hy Murveit <hy@murveit.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QObject>
10#include <QList>
11#include <QVector3D>
12
13#include "starcorrespondence.h"
14#include "vect.h"
15#include "calibration.h"
16
17class GuideView;
18
19namespace SSolver
20{
21class Parameters;
22}
23
24/*
25 * This class manages selecting a guide star, finding that star in a new image
26 * and calculating the drift of the new star image.
27 * The major methods are:
28 *
29 * GuideStars guideStars();
30 * guideStars.selectGuideStar(QSharedPointer<FITSdata>);
31 * Selects a guide star, given the input image. This can be done at the start of
32 * calibration, when guiding starts, or when the guide star is lost.
33 *
34 * Vector xy = guideStars.findGuideStar(QSharedPointer<FITSdata>, QRect trackingBox)
35 * Finds the guide star that was previously selected. xy will contain the pixel coordinates
36 * {x,y,0}. The tracking box is not enforced if the multi-star star-finding algorithm
37 * is used, however, if that fails, it backs off to the star with the best score
38 * (basically the brightest star) in the tracking box.
39 *
40 * bool success = guideStars.getDrift(guideStarDrift, reticle_x, reticle_y, RADrift, DECDrift)
41 * Returns the star movement in RA and DEC. The reticle can be input indicating
42 * that the desired position for the original guide star and reference stars has
43 * shifted (e.g. dithering).
44 */
45
46class GuideStars
47{
48 public:
49 GuideStars();
50 ~GuideStars() {}
51
52 // Select a guide star, given the image.
53 // Performs a SEP processing to detect stars, then finds the
54 // most desirable guide star.
55 QVector3D selectGuideStar(const QSharedPointer<FITSData> &imageData);
56
57 // Finds the guide star previously selected with selectGuideStar()
58 // in a new image. This sets up internal structures for getDrift().
59 GuiderUtils::Vector findGuideStar(const QSharedPointer<FITSData> &imageData, const QRect &trackingBox,
60 QSharedPointer<GuideView> &guideView, bool firstFrame);
61
62 // Finds the drift of the star positions in arc-seconds for RA and DEC.
63 // Must be called after findGuideStar().
64 // Returns false if this can't be calculated.
65 // setCalibration must have been called once before this (so that pixel
66 // positions can be converted to RA and DEC).
67 bool getDrift(double oneStarDrift, double reticle_x, double reticle_y,
68 double *RADrift, double *DECDrift);
69
70 // Use this calibration object for conversions to arcseconds and RA/DEC.
71 void setCalibration(const Calibration &calibration);
72
73 // Returns the sky background object that was obtained from SEP analysis.
74 const SkyBackground &skybackground() const
75 {
76 return skyBackground;
77 }
78 double getGuideStarMass() const
79 {
80 return guideStarMass;
81 }
82 double getGuideStarSNR() const
83 {
84 return guideStarSNR;
85 }
86
87 int getNumStarsDetected() const
88 {
89 return m_NumStarsDetected;
90 }
91
92 int getNumReferencesFound() const
93 {
94 return starCorrespondence.getNumReferencesFound();
95 }
96
97 int getNumReferences() const
98 {
99 return starCorrespondence.size();
100 }
101
102 void reset()
103 {
104 starCorrespondence.reset();
105 }
106
107 // Used to initialize the StarCorrespondence object, which ultimately finds
108 // the guidestar using the geometry between it and the other stars detected.
109 // Would be private, except for testing
110 void setupStarCorrespondence(const QList<Edge> &neighbors, int guideIndex);
111
112private:
113 // Evaluates which stars are desirable as guide stars and reference stars.
114 void evaluateSEPStars(const QList<Edge *> &starCenters, QVector<double> *scores,
115 const QRect *roi, const double maxHFR) const;
116
117 // Prepares parameters for evaluateSEPStars().
118 SSolver::Parameters getStarExtractionParameters(int num);
119
120 // Returns the top num stars according to the evaluateSEPStars criteria.
121 void findTopStars(const QSharedPointer<FITSData> &imageData, int num, QList<Edge> *stars,
122 const double maxHFR,
123 const QRect *roi = nullptr,
124 QList<double> *outputScores = nullptr,
125 QList<double> *minDistances = nullptr);
126 // The interface to the SEP star detection algoritms.
127 int findAllSEPStars(const QSharedPointer<FITSData> &imageData, QList<Edge*> *sepStars, int num);
128
129 // Convert from input image coordinates to output RA and DEC coordinates.
130 GuiderUtils::Vector point2arcsec(const GuiderUtils::Vector &p) const;
131
132 // Returns the RA and DEC distance between the star and the reference star.
133 void computeStarDrift(const Edge &star, const Edge &reference,
134 double *driftRA, double *driftDEC) const;
135 // Selects the guide star given the star detections and score generated
136 // by evaluateSEPStars().
137 QVector3D selectGuideStar(const QList<Edge> &detectedStars,
138 const QList<double> &sepScores,
139 int maxX, int maxY,
140 const QList<double> &minDistances);
141
142 // Computes the distance from stars[i] to its closest neighbor.
143 double findMinDistance(int index, const QList<Edge*> &stars);
144
145 // Plot the positions of the neighbor stars on the guideView display.
146 void plotStars(QSharedPointer<GuideView> &guideView, const QRect &trackingBox);
147
148 // These three methods are useful for testing.
149 void setDetectedStars(const QList<Edge> &stars)
150 {
151 detectedStars = stars;
152 }
153 void setSkyBackground(const SkyBackground &background)
154 {
155 skyBackground = background;
156 }
157 void setStarMap(const QVector<int> &map)
158 {
159 starMap = map;
160 }
161 int getStarMap(int index);
162
163 // Sky background value generated by the SEP processing.
164 // Used to calculate star SNR values.
165 SkyBackground skyBackground;
166
167 // Used to find the guide star in a new set of image detections.
168 StarCorrespondence starCorrespondence;
169
170 // These are set when the guide star is detected, and can be queried, e.g.
171 // for logging.
172 double guideStarMass = 0;
173 double guideStarSNR = 0;
174
175 // The newly detected stars.
176 QVector<int> starMap;
177 // This maps between the newly detected stars and the reference stars.
178 QList<Edge> detectedStars;
179
180 Calibration calibration;
181 bool calibrationInitialized {false};
182
183 // Find guide star will allow robust star correspondence.
184 bool allowMissingGuideStar { true };
185
186 int unreliableDectionCounter { 0 };
187
188 int m_NumStarsDetected { 0 };
189
190 friend class TestGuideStars;
191};
The main change relative to fitsview is to add the capability of displaying the 'neighbor guide stars...
Definition guideview.h:22
QFuture< void > map(Iterator begin, Iterator end, MapFunctor &&function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:51:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.