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,
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 private:
108 // Used to initialize the StarCorrespondence object, which ultimately finds
109 // the guidestar using the geometry between it and the other stars detected.
110 void setupStarCorrespondence(const QList<Edge> &neighbors, int guideIndex);
111
112 // Evaluates which stars are desirable as guide stars and reference stars.
113 void evaluateSEPStars(const QList<Edge *> &starCenters, QVector<double> *scores,
114 const QRect *roi, const double maxHFR) const;
115
116 // Prepares parameters for evaluateSEPStars().
117 SSolver::Parameters getStarExtractionParameters(int num);
118
119 // Returns the top num stars according to the evaluateSEPStars criteria.
120 void findTopStars(const QSharedPointer<FITSData> &imageData, int num, QList<Edge> *stars,
121 const double maxHFR,
122 const QRect *roi = nullptr,
123 QList<double> *outputScores = nullptr,
124 QList<double> *minDistances = nullptr);
125 // The interface to the SEP star detection algoritms.
126 int findAllSEPStars(const QSharedPointer<FITSData> &imageData, QList<Edge*> *sepStars, int num);
127
128 // Convert from input image coordinates to output RA and DEC coordinates.
129 GuiderUtils::Vector point2arcsec(const GuiderUtils::Vector &p) const;
130
131 // Returns the RA and DEC distance between the star and the reference star.
132 void computeStarDrift(const Edge &star, const Edge &reference,
133 double *driftRA, double *driftDEC) const;
134 // Selects the guide star given the star detections and score generated
135 // by evaluateSEPStars().
136 QVector3D selectGuideStar(const QList<Edge> &detectedStars,
138 int maxX, int maxY,
140
141 // Computes the distance from stars[i] to its closest neighbor.
142 double findMinDistance(int index, const QList<Edge*> &stars);
143
144 // Plot the positions of the neighbor stars on the guideView display.
145 void plotStars(QSharedPointer<GuideView> &guideView, const QRect &trackingBox);
146
147 // These three methods are useful for testing.
148 void setDetectedStars(const QList<Edge> &stars)
149 {
150 detectedStars = stars;
151 }
152 void setSkyBackground(const SkyBackground &background)
153 {
154 skyBackground = background;
155 }
156 void setStarMap(const QVector<int> &map)
157 {
158 starMap = map;
159 }
160 int getStarMap(int index);
161
162 // Sky background value generated by the SEP processing.
163 // Used to calculate star SNR values.
164 SkyBackground skyBackground;
165
166 // Used to find the guide star in a new set of image detections.
167 StarCorrespondence starCorrespondence;
168
169 // These are set when the guide star is detected, and can be queried, e.g.
170 // for logging.
171 double guideStarMass = 0;
172 double guideStarSNR = 0;
173
174 // The newly detected stars.
175 QVector<int> starMap;
176 // This maps between the newly detected stars and the reference stars.
177 QList<Edge> detectedStars;
178
179 Calibration calibration;
180 bool calibrationInitialized {false};
181
182 // Find guide star will allow robust star correspondence.
183 bool allowMissingGuideStar { true };
184
185 int unreliableDectionCounter { 0 };
186
187 int m_NumStarsDetected { 0 };
188
189 friend class TestGuideStars;
190};
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 May 24 2024 11:49:21 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.