1 #pragma once
2
3 #include <QObject>
4 #include "structuredefinitions.h"
5
6 namespace SSolver
7 {
8
9 //This is the shape used for source extration in sextractor
10 enum Shape
11 {
12 SHAPE_AUTO,
13 SHAPE_CIRCLE,
14 SHAPE_ELLIPSE
15 };
16
17 //This gets a string for the Sextractor setting for calculating Flux using ellipses or circles
getShapeString(SSolver::Shape shape)18 static QString getShapeString(SSolver::Shape shape)
19
20 {
21 switch(shape)
22 {
23 case SHAPE_AUTO:
24 return "Auto";
25 break;
26
27 case SHAPE_CIRCLE:
28 return "Circle";
29 break;
30
31 case SHAPE_ELLIPSE:
32 return "Ellipse";
33 break;
34 default:
35 return "";
36 break;
37 }
38 }
39
40 //This is a structure to hold the paths to the external programs for solving.
41 //This makes the paths easier to access and set
42 typedef struct
43 {
44 QString confPath; //Path to the Astrometry Config File
45 QString sextractorBinaryPath; //Path to the Sextractor Program binary
46 QString solverPath; //Path to the Astrometry Solver binary
47 QString astapBinaryPath; //Path to the ASTAP Program binary
48 QString wcsPath; //Path to the WCSInfo binary
49 } ExternalProgramPaths;
50
51 // This is the units used by astrometry.net for the scale for plate solving
52 typedef enum {DEG_WIDTH,
53 ARCMIN_WIDTH,
54 ARCSEC_PER_PIX,
55 FOCAL_MM
56 } ScaleUnits;
57
58 // This gets the scale unit string for astrometry.net input
59 // This should NOT be translated
getScaleUnitString(SSolver::ScaleUnits scaleunit)60 static QString getScaleUnitString(SSolver::ScaleUnits scaleunit)
61 {
62 switch(scaleunit)
63 {
64 case DEG_WIDTH:
65 return "degwidth";
66 break;
67 case ARCMIN_WIDTH:
68 return "arcminwidth";
69 break;
70 case ARCSEC_PER_PIX:
71 return "arcsecperpix";
72 break;
73 case FOCAL_MM:
74 return "focalmm";
75 break;
76 default:
77 return "";
78 break;
79 }
80 }
81
82 // This is the list of operations that the Stellarsolver can do.
83 // You need to set this either directly or using a method before starting the process.
84 typedef enum { EXTRACT, //This just sextracts the sources
85 EXTRACT_WITH_HFR, //This sextracts the sources and finds the HFR
86 SOLVE //This solves the image
87 } ProcessType;
88
89 typedef enum { EXTRACTOR_INTERNAL, //This uses internal SEP to Sextract Sources
90 EXTRACTOR_EXTERNAL, //This uses the external sextractor to Sextract Sources.
91 EXTRACTOR_BUILTIN //This uses whatever default sextraction method the selected solver uses
92 } ExtractorType;
93
94 typedef enum { SOLVER_STELLARSOLVER, //This uses the internal build of astrometry.net
95 SOLVER_LOCALASTROMETRY, //This uses an astrometry.net or ANSVR locally on this computer
96 SOLVER_ASTAP, //This uses a local installation of ASTAP
97 SOLVER_ONLINEASTROMETRY //This uses the online astrometry.net or ASTAP
98 } SolverType;
99
100 //This gets the processType as a string explaining the command StellarSolver is Running
getCommandString(SSolver::ProcessType processType,SSolver::ExtractorType m_ExtractorType,SSolver::SolverType solverType)101 static QString getCommandString(SSolver::ProcessType processType, SSolver::ExtractorType m_ExtractorType,
102 SSolver::SolverType solverType)
103 {
104 QString commandString = "";
105
106 switch(m_ExtractorType)
107 {
108 case EXTRACTOR_INTERNAL:
109 commandString += "Internal ";
110 break;
111
112 case EXTRACTOR_EXTERNAL:
113 commandString += "External ";
114 break;
115
116 case EXTRACTOR_BUILTIN:
117 commandString += "Built In ";
118 break;
119 }
120
121 switch(processType)
122 {
123 case EXTRACT:
124 commandString += "Extractor ";
125 break;
126
127 case EXTRACT_WITH_HFR:
128 commandString += "Extractor w/HFR ";
129 break;
130
131 case SOLVE:
132 commandString += "Extractor w/ ";
133 break;
134 }
135
136 if(processType == SOLVE)
137 {
138 switch(solverType)
139 {
140 case SOLVER_STELLARSOLVER:
141 commandString += "StellarSolver ";
142 break;
143
144 case SOLVER_LOCALASTROMETRY:
145 commandString += "local solver ";
146 break;
147
148 case SOLVER_ASTAP:
149 commandString += "local ASTAP ";
150 break;
151
152 case SOLVER_ONLINEASTROMETRY:
153 commandString += "online solver ";
154 break;
155 }
156 }
157 return commandString;
158 };
159
160
161 // These are the algorithms used for patallel solving
162 // When solving an image, this is one of the Parameters
163 typedef enum {NOT_MULTI, // This option does not use parallel solving
164 MULTI_SCALES, // This option generates multiple threads based on different image scales
165 MULTI_DEPTHS, // This option generates multiple threads based on different image "depths"
166 MULTI_AUTO // This option generates multiple threads (or not) automatically based on the algorithm that is best
167 } MultiAlgo;
168
169 //This gets a string for which Parallel Solving Algorithm we are using
getMultiAlgoString(SSolver::MultiAlgo multi)170 static QString getMultiAlgoString(SSolver::MultiAlgo multi)
171 {
172 switch(multi)
173 {
174 case NOT_MULTI:
175 return "None";
176 break;
177
178 case MULTI_SCALES:
179 return "Scales";
180 break;
181
182 case MULTI_DEPTHS:
183 return "Depths";
184 break;
185 default:
186 return "";
187 break;
188 }
189 }
190
191 // Astrometry.net struct for defining the log level
192 // It is defined both here and in log.h so that we can set the log level here without including all of log.h.
193 typedef enum
194 {
195 LOG_OFF,
196 LOG_NORMAL,
197 LOG_VERBOSE
198 } SSolverLogLevel;
199
200 // Astrometry.net struct for defining the log level
201 // It is defined both here and in log.h so that we can set the log level here without including all of log.h.
202 enum logging_level
203 {
204 LOG_NONE,
205 LOG_ERROR,
206 LOG_MSG,
207 LOG_VERB,
208 LOG_ALL
209 };
210
getLogLevelString(SSolver::logging_level logLevel)211 static QString getLogLevelString(SSolver::logging_level logLevel)
212 {
213 switch(logLevel)
214 {
215 case LOG_NONE:
216 return "None";
217 break;
218
219 case LOG_ERROR:
220 return "Error";
221 break;
222
223 case LOG_MSG:
224 return "Message";
225 break;
226
227 case LOG_VERB:
228 return "Verbose";
229 break;
230
231 case LOG_ALL:
232 return "All";
233 break;
234
235 default:
236 return "";
237 break;
238 }
239 }
240
241 //STELLARSOLVER PARAMETERS
242 //These are the parameters used by the StellarSolver for both Sextracting and Solving
243 //The values here are the defaults unless they get changed.
244 //If you are fine with those defaults, you don't need to set any of them.
245
246 class Parameters
247 {
248 public:
249
250 // These are the available parameter profiles that are built into StellarSolver.
251 // You can just use them without having to set any parameters yourself.
252 typedef enum
253 {
254 FAST_SOLVING,
255 PARALLEL_SOLVING,
256 PARALLEL_LARGESCALE,
257 PARALLEL_SMALLSCALE,
258 ALL_STARS,
259 SMALL_STARS,
260 MID_STARS,
261 BIG_STARS
262 } ParametersProfile;
263
264 // This is the name of this particular profile of options for StellarSolver
265 QString listName = "Default";
266 // This is a description of the Profile, what it is intended for, anything that sets it apart
267 QString description;
268
269 //Sextractor Photometry Parameters
270 Shape apertureShape = SHAPE_CIRCLE; // Whether to use the SEP_SUM_ELLIPSE method or the SEP_SUM_CIRCLE method
271 double kron_fact = 2.5; // This sets the Kron Factor for use with the kron radius for flux calculations.
272 int subpix = 5; // The subpix setting. The instructions say to make it 5
273 double r_min = 3.5; // The minimum radius for stars for flux calculations.
274 short inflags = 0; // Note sure if we need them?
275
276 //Sextractor Extraction Parameters
277 // This is the 'zero' magnitude used for settting the magnitude scale for the stars in the image during sextraction.
278 double magzero = 20;
279 // This is the minimum area in pixels for a star detection, smaller stars are ignored.
280 double minarea = 10;
281 int deblend_thresh = 32; // The number of thresholds the intensity range is divided up into.
282 double deblend_contrast =
283 0.005; // The percentage of flux a separate peak must # have to be considered a separate object.
284 int clean = 1; // Attempts to 'clean' the image to remove artifacts caused by bright objects
285 double clean_param = 1; // The cleaning parameter, not sure what it does.
286 // A variable to store the fwhm used to generate the conv filter, changing this WILL NOT change the conv filter, you can use the method below to create the conv filter based on the fwhm
287 double fwhm = 2;
288 // Automatically partition the image to several threads to speed it up.
289 bool partition = true;
290
291 //This is the filter used for convolution. You can create this directly or use the convenience method below.
292 QVector<float> convFilter = {0.260856, 0.483068, 0.260856,
293 0.483068, 0.894573, 0.483068,
294 0.260856, 0.483068, 0.260856
295 };
296
297 //Star Filter Parameters
298 double maxSize =
299 0; // The maximum size of stars to include in the final list in pixels based on semi-major and semi-minor axes
300 double minSize =
301 0; // The minimum size of stars to include in the final list in pixels based on semi-major and semi-minor axes
302 double maxEllipse =
303 0; // The maximum ratio between the semi-major and semi-minor axes for stars to include (a/b)
304 int initialKeep = 1000000; // Number of stars to keep in the list before HFR. This is based on star size. This is most useful for SEP operations involving HFR like Focusing images, Guiding, and monitoring image HFR over time. It is important to reduce the number of stars prior to doing HFR calculations
305 int keepNum = 0; // The number of brightest stars to keep in the list. This is based on magnitude. This is most useful for Solving because limiting the number of stars to the brightest ones greatly speeds up the solver.
306 double removeBrightest = 0; // The percentage of brightest stars to remove from the list
307 double removeDimmest = 0; // The percentage of dimmest stars to remove from the list
308 double saturationLimit = 0; // Remove all stars above a certain threshhold percentage of saturation
309
310 //Astrometry Config/Engine Parameters
311 MultiAlgo multiAlgorithm = MULTI_AUTO;// Algorithm for running multiple threads on possibly multiple cores to solve faster
312 bool inParallel =
313 true; // Check the indices in parallel? if the indices you are using take less than 2 GB of space, and you have at least as much physical memory as indices, you want this enabled,
314 int solverTimeLimit = 600; // Give up solving after the specified number of seconds of CPU time
315 double minwidth =
316 0.1; // If no scale estimate is given, this is the limit on the minimum field width in degrees.
317 double maxwidth =
318 180; // If no scale estimate is given, this is the limit on the maximum field width in degrees.
319
320 //Astrometry Basic Parameters
321 bool resort =
322 true; // Whether to resort the stars based on magnitude NOTE: This is REQUIRED to be true for the filters above
323 bool autoDownsample = // Whether or not to automatically determine the downsample size based on the image size.
324 true;
325 int downsample =
326 1; // Factor to use for downsampling the image before SEP for plate solving. Can speed it up. This is not used for Source Extraction
327 int search_parity = 2; // Only check for matches with positive/negative parity (default: try both)
328 double search_radius = 15; // Only search in indexes within 'radius' of the field center given by RA and DEC
329
330 //LogOdds Settings
331 double logratio_tosolve = log(1e9); // Odds ratio at which to consider a field solved (default: 1e9)
332 double logratio_tokeep = log(1e9); // Odds ratio at which to keep a solution (default: 1e9)
333 double logratio_totune = log(
334 1e6); // Odds ratio at which to try tuning up a match that isn't good enough to solve (default: 1e6)
335
336 bool operator==(const Parameters &o);
337
338 static QMap<QString, QVariant> convertToMap(Parameters params);
339 static Parameters convertFromMap(QMap<QString, QVariant> settingsMap);
340
341 signals:
342
343 }; // Parameters
344
345 } // namespace SSolver
346
347