diff --git a/desktop/src/app/image/image.component.ts b/desktop/src/app/image/image.component.ts index e66504012..3e7841167 100644 --- a/desktop/src/app/image/image.component.ts +++ b/desktop/src/app/image/image.component.ts @@ -921,8 +921,8 @@ export class ImageComponent implements AfterViewInit, OnDestroy { } } - this.solver.focalLength ||= imagePreference.solverFocalLength || 0 - this.solver.pixelSize ||= imagePreference.solverPixelSize || 0 + this.solver.focalLength ||= imagePreference.solver?.focalLength || 0 + this.solver.pixelSize ||= imagePreference.solver?.pixelSize || 0 } imageClicked(event: MouseEvent, contextMenu: boolean) { @@ -1275,8 +1275,10 @@ export class ImageComponent implements AfterViewInit, OnDestroy { private loadPreference() { const preference = this.preference.imagePreference.get() - this.solver.radius = preference.solverRadius ?? this.solver.radius - this.solver.type = preference.solverType ?? 'ASTAP' + this.solver.radius = preference.solver?.radius ?? this.solver.radius + this.solver.type = preference.solver?.type ?? 'ASTAP' + this.solver.focalLength = preference.solver?.focalLength ?? 0 + this.solver.pixelSize = preference.solver?.pixelSize ?? 0 this.starDetection.type = preference.starDetection?.type ?? this.starDetection.type this.starDetection.minSNR = preference.starDetection?.minSNR ?? this.preference.starDetectionRequest(this.starDetection.type).get().minSNR ?? this.starDetection.minSNR this.starDetection.maxStars = preference.starDetection?.maxStars ?? this.starDetection.maxStars @@ -1287,11 +1289,19 @@ export class ImageComponent implements AfterViewInit, OnDestroy { private savePreference() { const preference = this.preference.imagePreference.get() - preference.solverRadius = this.solver.radius - preference.solverType = this.solver.type - preference.solverPixelSize = this.solver.pixelSize - preference.solverFocalLength = this.solver.focalLength - preference.starDetection = this.starDetection + + preference.solver = { + type: this.solver.type, + focalLength: this.solver.focalLength, + pixelSize: this.solver.pixelSize, + radius: this.solver.radius, + } + preference.starDetection = { + type: this.starDetection.type, + maxStars: this.starDetection.maxStars, + minSNR: this.starDetection.minSNR, + } + this.preference.imagePreference.set(preference) } diff --git a/desktop/src/shared/types/image.types.ts b/desktop/src/shared/types/image.types.ts index 6f9b0aed7..f7bb8688d 100644 --- a/desktop/src/shared/types/image.types.ts +++ b/desktop/src/shared/types/image.types.ts @@ -1,7 +1,7 @@ import { Point, Size } from 'electron' import { Angle, AstronomicalObject, DeepSkyObject, EquatorialCoordinateJ2000, Star } from './atlas.types' import { Camera, CameraStartCapture } from './camera.types' -import { PlateSolverType, StarDetectionRequest, StarDetectorType } from './settings.types' +import { PlateSolverRequest, StarDetectionRequest } from './settings.types' export type ImageChannel = 'RED' | 'GREEN' | 'BLUE' | 'GRAY' @@ -111,18 +111,28 @@ export interface ImageStatistics { maximum: number } +export interface StarDetectionImagePreference extends Pick { +} + +export interface PlateSolverImagePreference extends Pick { + radius: number + focalLength: number + pixelSize: number +} + export interface ImagePreference { - solverRadius?: number - solverType?: PlateSolverType - solverFocalLength?: number - solverPixelSize?: number savePath?: string - starDetection?: Pick + solver?: PlateSolverImagePreference + starDetection?: StarDetectionImagePreference } export const EMPTY_IMAGE_PREFERENCE: ImagePreference = { - solverRadius: 4, - solverType: 'ASTAP', + solver: { + type: 'ASTAP', + radius: 4, + focalLength: 0, + pixelSize: 0, + }, starDetection: { type: 'ASTAP', minSNR: 0, @@ -213,17 +223,13 @@ export interface ImageStretchDialog { midtone: number } -export interface ImageSolverDialog { +export interface ImageSolverDialog extends PlateSolverImagePreference { showDialog: boolean running: boolean blind: boolean centerRA: Angle centerDEC: Angle - radius: number - focalLength: number - pixelSize: number readonly solved: ImageSolved - type: PlateSolverType } export interface ImageFOVDialog extends FOV { @@ -284,12 +290,9 @@ export interface ROISelected { height: number } -export interface StarDetectionDialog { +export interface StarDetectionDialog extends StarDetectionImagePreference { showDialog: boolean running: boolean - type: StarDetectorType - minSNR: number - maxStars: number visible: boolean stars: DetectedStar[] computed: Omit & { minFlux: number, maxFlux: number } diff --git a/nebulosa-common/src/main/kotlin/nebulosa/common/exec/CommandLine.kt b/nebulosa-common/src/main/kotlin/nebulosa/common/exec/CommandLine.kt index ec0912b99..73a923280 100644 --- a/nebulosa-common/src/main/kotlin/nebulosa/common/exec/CommandLine.kt +++ b/nebulosa-common/src/main/kotlin/nebulosa/common/exec/CommandLine.kt @@ -178,9 +178,9 @@ data class CommandLine internal constructor( } } } catch (e: InterruptedException) { - LOG.error("command line interrupted") + LOG.warn("command line interrupted") } catch (e: Throwable) { - LOG.error("command line failed: {}", e.message) + LOG.warn("command line exited: {}", e.message) } finally { completable.complete(Unit) reader.close() diff --git a/nebulosa-siril/src/main/kotlin/nebulosa/siril/command/FindStar.kt b/nebulosa-siril/src/main/kotlin/nebulosa/siril/command/FindStar.kt index cdcf1fd5c..5f2fc4e50 100644 --- a/nebulosa-siril/src/main/kotlin/nebulosa/siril/command/FindStar.kt +++ b/nebulosa-siril/src/main/kotlin/nebulosa/siril/command/FindStar.kt @@ -94,14 +94,16 @@ data class FindStar( if (line.startsWith('#')) continue val columns = line.split('\t') - val x = columns[5].trim().toDouble() - val y = columns[6].trim().toDouble() - val fwhmx = columns[7].trim().toDouble() - val fwhmy = columns[8].trim().toDouble() + val flux = columns[3].trim().toDouble() // A ??? + val x = columns[5].trim().toDouble() // X + val y = columns[6].trim().toDouble() // Y + val fwhmx = columns[7].trim().toDouble() // FWHMx [px] + val fwhmy = columns[8].trim().toDouble() // FWHMy [px] + val snr = columns[12].trim().toDouble() // RMSE ??? val fwhm = (fwhmx + fwhmy) / 2.0 val hfd = fwhm / FWHM - stars.add(Star(x, height - y, hfd, 0.0, 0.0)) + stars.add(Star(x, height - y, hfd, snr, flux)) } } diff --git a/nebulosa-siril/src/main/kotlin/nebulosa/siril/command/SirilCommand.kt b/nebulosa-siril/src/main/kotlin/nebulosa/siril/command/SirilCommand.kt index a7b25f10d..ad6bf8b7a 100644 --- a/nebulosa-siril/src/main/kotlin/nebulosa/siril/command/SirilCommand.kt +++ b/nebulosa-siril/src/main/kotlin/nebulosa/siril/command/SirilCommand.kt @@ -1,5 +1,8 @@ package nebulosa.siril.command +/** + * @see Commands + */ sealed interface SirilCommand { fun write(commandLine: SirilCommandLine): T diff --git a/nebulosa-siril/src/main/kotlin/nebulosa/siril/stardetector/SirilStarDetector.kt b/nebulosa-siril/src/main/kotlin/nebulosa/siril/stardetector/SirilStarDetector.kt index 0aa2bee55..78880f873 100644 --- a/nebulosa-siril/src/main/kotlin/nebulosa/siril/stardetector/SirilStarDetector.kt +++ b/nebulosa-siril/src/main/kotlin/nebulosa/siril/stardetector/SirilStarDetector.kt @@ -6,6 +6,8 @@ import nebulosa.stardetector.StarDetector import nebulosa.stardetector.StarPoint import java.nio.file.Path +// https://gitlab.com/free-astro/siril/-/blob/master/src/algos/star_finder.c + data class SirilStarDetector( private val executablePath: Path, private val maxStars: Int = 0, diff --git a/nebulosa-siril/src/test/kotlin/SirilLiveStackerTest.kt b/nebulosa-siril/src/test/kotlin/SirilTest.kt similarity index 81% rename from nebulosa-siril/src/test/kotlin/SirilLiveStackerTest.kt rename to nebulosa-siril/src/test/kotlin/SirilTest.kt index 6cafb84aa..7da243822 100644 --- a/nebulosa-siril/src/test/kotlin/SirilLiveStackerTest.kt +++ b/nebulosa-siril/src/test/kotlin/SirilTest.kt @@ -18,7 +18,7 @@ import kotlin.io.path.copyTo import kotlin.io.path.listDirectoryEntries @EnabledIf(NonGitHubOnlyCondition::class) -class SirilLiveStackerTest : AbstractFitsAndXisfTest() { +class SirilTest : AbstractFitsAndXisfTest() { init { val executablePath = Path.of("siril-cli") @@ -62,9 +62,21 @@ class SirilLiveStackerTest : AbstractFitsAndXisfTest() { } "star detector" { val detector = SirilStarDetector(executablePath) - val stars = detector.detect(PI_01_LIGHT) - stars shouldHaveSize 126 - println(stars) + + with(detector.detect(PI_FOCUS_0)) { + this shouldHaveSize 307 + map { it.hfd }.average() shouldBe (7.9 plusOrMinus 1e-1) + } + + with(detector.detect(PI_FOCUS_30000)) { + this shouldHaveSize 258 + map { it.hfd }.average() shouldBe (1.1 plusOrMinus 1e-1) + } + + with(detector.detect(PI_FOCUS_100000)) { + this shouldHaveSize 82 + map { it.hfd }.average() shouldBe (22.4 plusOrMinus 1e-1) + } } } }