Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/align/offlineastrometryparser.cpp
Show First 20 Lines • Show All 212 Lines • ▼ Show 20 Line(s) | 207 | { | |||
---|---|---|---|---|---|
213 | if (Options::astrometryDetectParity() && (parity.isEmpty() == false) && (args.contains("parity") == false) && | 213 | if (Options::astrometryDetectParity() && (parity.isEmpty() == false) && (args.contains("parity") == false) && | ||
214 | (args.contains("-3") || args.contains("-L"))) | 214 | (args.contains("-3") || args.contains("-L"))) | ||
215 | solverArgs << "--parity" << parity; | 215 | solverArgs << "--parity" << parity; | ||
216 | 216 | | |||
217 | QString confPath = KSUtils::getAstrometryConfFilePath(); | 217 | QString confPath = KSUtils::getAstrometryConfFilePath(); | ||
218 | solverArgs << "--config" << confPath; | 218 | solverArgs << "--config" << confPath; | ||
219 | 219 | | |||
220 | QString solutionFile = QDir::tempPath() + "/solution.wcs"; | 220 | QString solutionFile = QDir::tempPath() + "/solution.wcs"; | ||
221 | solverArgs << "-W" << solutionFile << filename; | 221 | solverArgs << "-W" << solutionFile; | ||
222 | | ||||
223 | fitsFile = filename; | | |||
224 | 222 | | |||
225 | solver.clear(); | 223 | solver.clear(); | ||
226 | solver = new QProcess(this); | 224 | solver = new QProcess(this); | ||
227 | 225 | | |||
226 | sextractorProcess.clear(); | ||||
227 | sextractorProcess = new QProcess(this); | ||||
228 | | ||||
229 | QString sextractorBinaryPath=Options::sextractorBinary(); | ||||
230 | | ||||
228 | #ifdef Q_OS_OSX | 231 | #ifdef Q_OS_OSX | ||
229 | QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); | 232 | QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); | ||
230 | QString path = env.value("PATH", ""); | 233 | QString path = env.value("PATH", ""); | ||
231 | QString pythonExecPath = "/usr/local/opt/python/libexec/bin"; | 234 | QString pythonExecPath = "/usr/local/opt/python/libexec/bin"; | ||
232 | if(!Options::useDefaultPython()) | 235 | if(!Options::useDefaultPython()) | ||
233 | pythonExecPath = Options::pythonExecPath(); | 236 | pythonExecPath = Options::pythonExecPath(); | ||
234 | if (Options::astrometrySolverIsInternal()) | 237 | if (Options::astrometrySolverIsInternal()) | ||
235 | { | 238 | { | ||
236 | env.insert("PATH", QCoreApplication::applicationDirPath() + "/netpbm/bin:" + pythonExecPath + ":/usr/local/bin:" + path); | 239 | env.insert("PATH", QCoreApplication::applicationDirPath() + "/netpbm/bin:" + pythonExecPath + ":/usr/local/bin:" + path); | ||
237 | } | 240 | } | ||
238 | else | 241 | else | ||
239 | { | 242 | { | ||
240 | env.insert("PATH", pythonExecPath + ":/usr/local/bin:" + path); | 243 | env.insert("PATH", pythonExecPath + ":/usr/local/bin:" + path); | ||
241 | } | 244 | } | ||
245 | if(Options::sextractorIsInternal()) | ||||
246 | sextractorBinaryPath=QCoreApplication::applicationDirPath() + "/astrometry/bin/sex"; | ||||
242 | solver->setProcessEnvironment(env); | 247 | solver->setProcessEnvironment(env); | ||
248 | sextractorProcess->setProcessEnvironment(env); | ||||
243 | 249 | | |||
244 | if (Options::alignmentLogging()) | 250 | if (Options::alignmentLogging()) | ||
245 | { | 251 | { | ||
246 | align->appendLogText("export PATH=" + env.value("PATH", "")); | 252 | align->appendLogText("export PATH=" + env.value("PATH", "")); | ||
247 | } | 253 | } | ||
248 | 254 | | |||
249 | #endif | 255 | #endif | ||
250 | 256 | | |||
257 | fitsFile = filename; | ||||
258 | | ||||
259 | //These commands use sextractor to make a list of stars to feed into astrometry.net | ||||
260 | if(Options::useSextractor()) | ||||
261 | { | ||||
262 | //Sets up the Temp file for the xy list of stars | ||||
263 | QString sextractorFilePath = QDir::tempPath() + "/SextractorList.xyls"; | ||||
264 | QFile sextractorFile(sextractorFilePath); | ||||
265 | if(sextractorFile.exists()) | ||||
266 | sextractorFile.remove(); | ||||
267 | | ||||
268 | //Configuration arguments for sextractor | ||||
269 | QStringList sextractorArgs; | ||||
270 | sextractorArgs << "-CATALOG_NAME" << sextractorFilePath; | ||||
271 | sextractorArgs << "-CATALOG_TYPE" << "FITS_1.0"; | ||||
272 | sextractorArgs << filename; | ||||
273 | | ||||
274 | //sextractor needs a default.param file in the working directory | ||||
275 | //This creates that file with the options we need for astrometry.net | ||||
276 | | ||||
277 | QString paramPath = QDir::tempPath() + "/default.param"; | ||||
278 | QFile paramFile(paramPath); | ||||
279 | if(!paramFile.exists()) | ||||
280 | { | ||||
281 | if (paramFile.open(QIODevice::WriteOnly) == false) | ||||
282 | KSNotification::error(i18n("Sextractor file write error.")); | ||||
283 | else | ||||
284 | { | ||||
285 | QTextStream out(¶mFile); | ||||
286 | out << "MAG_AUTO Kron-like elliptical aperture magnitude [mag]\n"; | ||||
287 | out << "X_IMAGE Object position along x [pixel]\n"; | ||||
288 | out << "Y_IMAGE Object position along y [pixel]\n"; | ||||
289 | paramFile.close(); | ||||
290 | } | ||||
291 | } | ||||
292 | | ||||
293 | //sextractor needs a default.conv file in the working directory | ||||
294 | //This creates the default one | ||||
295 | | ||||
296 | QString convPath = QDir::tempPath() + "/default.conv"; | ||||
297 | QFile convFile(convPath); | ||||
298 | if(!convFile.exists()) | ||||
299 | { | ||||
300 | if (convFile.open(QIODevice::WriteOnly) == false) | ||||
301 | KSNotification::error(i18n("Sextractor file write error.")); | ||||
302 | else | ||||
303 | { | ||||
304 | QTextStream out(&convFile); | ||||
305 | out << "CONV NORM\n"; | ||||
306 | out << "1 2 1\n"; | ||||
307 | out << "2 4 2\n"; | ||||
308 | out << "1 2 1\n"; | ||||
309 | convFile.close(); | ||||
310 | } | ||||
311 | } | ||||
312 | sextractorProcess->setWorkingDirectory(QDir::tempPath()); | ||||
313 | sextractorProcess->start(sextractorBinaryPath, sextractorArgs); | ||||
314 | align->appendLogText(i18n("Starting sextractor...")); | ||||
315 | align->appendLogText(sextractorBinaryPath + " " + sextractorArgs.join(' ')); | ||||
316 | sextractorProcess->waitForFinished(); | ||||
317 | if (Options::alignmentLogging()) | ||||
318 | align->appendLogText(sextractorProcess->readAllStandardError().trimmed()); | ||||
319 | solverArgs << sextractorFilePath; | ||||
320 | } | ||||
321 | else | ||||
322 | { | ||||
323 | solverArgs << fitsFile; | ||||
324 | } | ||||
325 | | ||||
251 | connect(solver, SIGNAL(finished(int)), this, SLOT(solverComplete(int))); | 326 | connect(solver, SIGNAL(finished(int)), this, SLOT(solverComplete(int))); | ||
252 | solver->setProcessChannelMode(QProcess::MergedChannels); | 327 | solver->setProcessChannelMode(QProcess::MergedChannels); | ||
253 | connect(solver, SIGNAL(readyReadStandardOutput()), this, SLOT(logSolver())); | 328 | connect(solver, SIGNAL(readyReadStandardOutput()), this, SLOT(logSolver())); | ||
254 | 329 | | |||
255 | #if QT_VERSION > QT_VERSION_CHECK(5, 6, 0) | 330 | #if QT_VERSION > QT_VERSION_CHECK(5, 6, 0) | ||
256 | connect(solver.data(), &QProcess::errorOccurred, this, [&]() | 331 | connect(solver.data(), &QProcess::errorOccurred, this, [&]() | ||
257 | { | 332 | { | ||
258 | align->appendLogText(i18n("Error starting solver: %1", solver->errorString())); | 333 | align->appendLogText(i18n("Error starting solver: %1", solver->errorString())); | ||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |