Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PixInsight Stacker #462

Merged
merged 5 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import nebulosa.api.cameras.CameraStartCaptureRequest
import nebulosa.guiding.GuideDirection

data class DARVStartRequest(
val capture: CameraStartCaptureRequest = CameraStartCaptureRequest.EMPTY,
val direction: GuideDirection = GuideDirection.NORTH,
val reversed: Boolean = false,
@JvmField val capture: CameraStartCaptureRequest = CameraStartCaptureRequest.EMPTY,
@JvmField val direction: GuideDirection = GuideDirection.NORTH,
@JvmField val reversed: Boolean = false,
)
26 changes: 13 additions & 13 deletions api/src/main/kotlin/nebulosa/api/atlas/BodyPosition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ import nebulosa.nova.astrometry.Constellation
import nebulosa.skycatalog.SkyObject

data class BodyPosition(
@field:JsonSerialize(using = RightAscensionSerializer::class) val rightAscensionJ2000: Angle,
@field:JsonSerialize(using = DeclinationSerializer::class) val declinationJ2000: Angle,
@field:JsonSerialize(using = RightAscensionSerializer::class) val rightAscension: Angle,
@field:JsonSerialize(using = DeclinationSerializer::class) val declination: Angle,
@field:JsonSerialize(using = AzimuthSerializer::class) val azimuth: Angle,
@field:JsonSerialize(using = DeclinationSerializer::class) val altitude: Angle,
val magnitude: Double,
val constellation: Constellation,
val distance: Double,
val distanceUnit: String,
val illuminated: Double,
@field:JsonSerialize(using = DegreesSerializer::class) val elongation: Angle,
val leading: Boolean, // true = rises and sets BEFORE Sun.
@field:JsonSerialize(using = RightAscensionSerializer::class) @JvmField val rightAscensionJ2000: Angle,
@field:JsonSerialize(using = DeclinationSerializer::class) @JvmField val declinationJ2000: Angle,
@field:JsonSerialize(using = RightAscensionSerializer::class) @JvmField val rightAscension: Angle,
@field:JsonSerialize(using = DeclinationSerializer::class) @JvmField val declination: Angle,
@field:JsonSerialize(using = AzimuthSerializer::class) @JvmField val azimuth: Angle,
@field:JsonSerialize(using = DeclinationSerializer::class) @JvmField val altitude: Angle,
@JvmField val magnitude: Double,
@JvmField val constellation: Constellation,
@JvmField val distance: Double,
@JvmField val distanceUnit: String,
@JvmField val illuminated: Double,
@field:JsonSerialize(using = DegreesSerializer::class) @JvmField val elongation: Angle,
@JvmField val leading: Boolean, // true = rises and sets BEFORE Sun.
) {

companion object {
Expand Down
10 changes: 5 additions & 5 deletions api/src/main/kotlin/nebulosa/api/atlas/CloseApproach.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import java.time.format.DateTimeFormatter
import java.util.*

data class CloseApproach(
val name: String = "",
val designation: String = "",
val dateTime: Long = 0,
val distance: Double = 0.0,
val absoluteMagnitude: Double = 0.0,
@JvmField val name: String = "",
@JvmField val designation: String = "",
@JvmField val dateTime: Long = 0,
@JvmField val distance: Double = 0.0,
@JvmField val absoluteMagnitude: Double = 0.0,
) {

companion object {
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/kotlin/nebulosa/api/atlas/Location.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data class Location(
@field:JsonSerialize(using = DegreesSerializer::class) @field:JsonDeserialize(using = DegreesDeserializer::class) override val latitude: Angle = 0.0,
@field:JsonSerialize(using = DegreesSerializer::class) @field:JsonDeserialize(using = DegreesDeserializer::class) override val longitude: Angle = 0.0,
@field:JsonSerialize(using = MetersSerializer::class) @field:JsonDeserialize(using = MetersDeserializer::class) override val elevation: Distance = 0.0,
val offsetInMinutes: Int = 0,
@JvmField val offsetInMinutes: Int = 0,
) : GeographicCoordinate, TimeZonedInSeconds {

override val offsetInSeconds = offsetInMinutes * 60
Expand Down
27 changes: 14 additions & 13 deletions api/src/main/kotlin/nebulosa/api/atlas/MinorPlanet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ package nebulosa.api.atlas
import nebulosa.sbd.SmallBody

data class MinorPlanet(
val found: Boolean = false,
val name: String = "",
val spkId: Int = -1,
val kind: SmallBody.BodyKind? = null,
val pha: Boolean = false, val neo: Boolean = false,
val orbitType: String = "",
val parameters: List<OrbitalPhysicalParameter> = emptyList(),
val searchItems: List<SearchItem> = emptyList(),
@JvmField val found: Boolean = false,
@JvmField val name: String = "",
@JvmField val spkId: Int = -1,
@JvmField val kind: SmallBody.BodyKind? = null,
@JvmField val pha: Boolean = false,
@JvmField val neo: Boolean = false,
@JvmField val orbitType: String = "",
@JvmField val parameters: List<OrbitalPhysicalParameter> = emptyList(),
@JvmField val searchItems: List<SearchItem> = emptyList(),
) {

data class OrbitalPhysicalParameter(
val name: String,
val description: String,
val value: String,
@JvmField val name: String,
@JvmField val description: String,
@JvmField val value: String,
) {

constructor(param: SmallBody.OrbitElement) : this(
Expand All @@ -31,8 +32,8 @@ data class MinorPlanet(
}

data class SearchItem(
val name: String,
val pdes: String,
@JvmField val name: String,
@JvmField val pdes: String,
)

companion object {
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/kotlin/nebulosa/api/atlas/SatelliteEntity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import nebulosa.api.database.BoxEntity
@Entity
data class SatelliteEntity(
@Id(assignable = true) override var id: Long = 0L,
var name: String = "",
var tle: String = "",
var groups: MutableList<String> = ArrayList(0),
@JvmField var name: String = "",
@JvmField var tle: String = "",
@JvmField var groups: MutableList<String> = ArrayList(0),
) : BoxEntity
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import kotlin.math.cos
import kotlin.math.sin

data class SkyObjectInsideCoordinate(
private val rightAscension: Angle,
private val declination: Angle,
private val radius: Angle,
@JvmField val rightAscension: Angle,
@JvmField val declination: Angle,
@JvmField val radius: Angle,
) : QueryFilter<SimbadEntity> {

private val sinDEC = declination.sin
Expand Down
14 changes: 7 additions & 7 deletions api/src/main/kotlin/nebulosa/api/atlas/Twilight.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package nebulosa.api.atlas

@Suppress("ArrayInDataClass")
data class Twilight(
val civilDusk: DoubleArray,
val nauticalDusk: DoubleArray,
val astronomicalDusk: DoubleArray,
val night: DoubleArray,
val astronomicalDawn: DoubleArray,
val nauticalDawn: DoubleArray,
val civilDawn: DoubleArray,
@JvmField val civilDusk: DoubleArray,
@JvmField val nauticalDusk: DoubleArray,
@JvmField val astronomicalDusk: DoubleArray,
@JvmField val night: DoubleArray,
@JvmField val astronomicalDawn: DoubleArray,
@JvmField val nauticalDawn: DoubleArray,
@JvmField val civilDawn: DoubleArray,
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import java.nio.file.Path
@Entity
data class CalibrationFrameEntity(
@Id override var id: Long = 0L,
@Index @Convert(converter = FrameTypePropertyConverter::class, dbType = Int::class) var type: FrameType = FrameType.LIGHT,
@Index var name: String = "",
var filter: String? = null,
var exposureTime: Long = 0L,
var temperature: Double = 0.0,
var width: Int = 0,
var height: Int = 0,
var binX: Int = 0,
var binY: Int = 0,
var gain: Double = 0.0,
@Convert(converter = PathPropertyConverter::class, dbType = String::class) var path: Path? = null,
var enabled: Boolean = true,
@JvmField @Index @Convert(converter = FrameTypePropertyConverter::class, dbType = Int::class) var type: FrameType = FrameType.LIGHT,
@JvmField @Index var name: String = "",
@JvmField var filter: String? = null,
@JvmField var exposureTime: Long = 0L,
@JvmField var temperature: Double = 0.0,
@JvmField var width: Int = 0,
@JvmField var height: Int = 0,
@JvmField var binX: Int = 0,
@JvmField var binY: Int = 0,
@JvmField var gain: Double = 0.0,
@JvmField @Convert(converter = PathPropertyConverter::class, dbType = String::class) var path: Path? = null,
@JvmField var enabled: Boolean = true,
) : BoxEntity
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package nebulosa.api.calibration

data class CalibrationFrameGroup(
val id: Int,
val name: String,
val key: CalibrationGroupKey,
val frames: List<CalibrationFrameEntity>,
@JvmField val id: Int,
@JvmField val name: String,
@JvmField val key: CalibrationGroupKey,
@JvmField val frames: List<CalibrationFrameEntity>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import nebulosa.image.algorithms.transformation.correction.BiasSubtraction
import nebulosa.image.algorithms.transformation.correction.DarkSubtraction
import nebulosa.image.algorithms.transformation.correction.FlatCorrection
import nebulosa.image.format.ImageHdu
import nebulosa.image.format.ReadableHeader
import nebulosa.indi.device.camera.FrameType
import nebulosa.indi.device.camera.FrameType.Companion.frameType
import nebulosa.log.loggerFor
import nebulosa.xisf.isXisf
import nebulosa.xisf.xisf
Expand Down Expand Up @@ -100,7 +100,7 @@ class CalibrationFrameService(
}

fun upload(name: String, path: Path): List<CalibrationFrameEntity> {
val files = if (path.isRegularFile() && path.isFits) listOf(path)
val files = if (path.isRegularFile()) listOf(path)
else if (path.isDirectory()) path.listDirectoryEntries("*.{fits,fit,xisf}").filter { it.isRegularFile() }
else return emptyList()

Expand Down Expand Up @@ -220,17 +220,5 @@ class CalibrationFrameService(
companion object {

@JvmStatic private val LOG = loggerFor<CalibrationFrameService>()

@JvmStatic val ReadableHeader.frameType
get() = frame?.let {
if (it.contains("LIGHT", true)) FrameType.LIGHT
else if (it.contains("DARK", true)) FrameType.DARK
else if (it.contains("FLAT", true)) FrameType.FLAT
else if (it.contains("BIAS", true)) FrameType.BIAS
else null
}

inline val Path.isFits
get() = "$this".let { it.endsWith(".fits") || it.endsWith(".fit") }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ import nebulosa.indi.device.camera.FrameType
import kotlin.math.roundToInt

data class CalibrationGroupKey(
val type: FrameType, val filter: String?,
val width: Int, val height: Int,
val binX: Int, val binY: Int,
val exposureTime: Long,
val temperature: Int, val gain: Double,
@JvmField val type: FrameType,
@JvmField val filter: String?,
@JvmField val width: Int,
@JvmField val height: Int,
@JvmField val binX: Int,
@JvmField val binY: Int,
@JvmField val exposureTime: Long,
@JvmField val temperature: Int,
@JvmField val gain: Double,
) {

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package nebulosa.api.cameras

import nebulosa.api.calibration.CalibrationFrameService.Companion.frameType
import nebulosa.common.concurrency.atomic.Incrementer
import nebulosa.fits.*
import nebulosa.image.format.ReadableHeader
import nebulosa.indi.device.camera.Camera
import nebulosa.indi.device.camera.FrameType
import nebulosa.indi.device.camera.FrameType.Companion.frameType
import nebulosa.indi.device.filterwheel.FilterWheel
import nebulosa.indi.device.focuser.Focuser
import nebulosa.indi.device.mount.Mount
Expand Down
18 changes: 11 additions & 7 deletions api/src/main/kotlin/nebulosa/api/cameras/CameraCaptureTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import java.util.concurrent.Executor
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.io.path.copyTo
import kotlin.io.path.exists
import kotlin.io.path.extension

data class CameraCaptureTask(
@JvmField val camera: Camera,
Expand Down Expand Up @@ -100,7 +101,7 @@ data class CameraCaptureTask(

private fun LiveStackingRequest.processCalibrationGroup(): LiveStackingRequest {
return if (calibrationFrameProvider != null && enabled &&
!request.calibrationGroup.isNullOrBlank() && (dark == null || flat == null || bias == null)
!request.calibrationGroup.isNullOrBlank() && (darkPath == null || flatPath == null || biasPath == null)
) {
val calibrationGroup = request.calibrationGroup
val temperature = camera.temperature
Expand All @@ -119,24 +120,27 @@ data class CameraCaptureTask(
calibrationGroup, temperature, binX, binY, width, height, exposureTime, gain, filter
)

val newDark = dark?.takeIf { it.exists() } ?: calibrationFrameProvider
val newDarkPath = darkPath?.takeIf { it.exists() } ?: calibrationFrameProvider
.findBestDarkFrames(calibrationGroup, temperature, width, height, binX, binY, exposureTime, gain)
.firstOrNull()
?.path

val newFlat = flat?.takeIf { it.exists() } ?: calibrationFrameProvider
val newFlatPath = flatPath?.takeIf { it.exists() } ?: calibrationFrameProvider
.findBestFlatFrames(calibrationGroup, width, height, binX, binY, filter)
.firstOrNull()
?.path

val newBias = if (newDark != null) null else bias?.takeIf { it.exists() } ?: calibrationFrameProvider
val newBiasPath = if (newDarkPath != null) null else biasPath?.takeIf { it.exists() } ?: calibrationFrameProvider
.findBestBiasFrames(calibrationGroup, width, height, binX, binY)
.firstOrNull()
?.path

LOG.info("live stacking will use calibration frames. group={}, dark={}, flat={}, bias={}", calibrationGroup, newDark, newFlat, newBias)
LOG.info(
"live stacking will use calibration frames. group={}, dark={}, flat={}, bias={}",
calibrationGroup, newDarkPath, newFlatPath, newBiasPath
)

copy(dark = newDark, flat = newFlat, bias = newBias)
copy(darkPath = newDarkPath, flatPath = newFlatPath, biasPath = newBiasPath)
} else {
this
}
Expand Down Expand Up @@ -334,7 +338,7 @@ data class CameraCaptureTask(
sendEvent(CameraCaptureState.STACKING)

liveStacker!!.add(path)?.let {
val stackedPath = Path.of("${path.parent}", "STACKED.fits")
val stackedPath = Path.of("${path.parent}", "STACKED.${it.extension}")
it.copyTo(stackedPath, true)
stackedPath
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package nebulosa.api.connection

data class ConnectionStatus(
val id: String,
val type: ConnectionType,
val host: String, val port: Int,
val ip: String? = null,
@JvmField val id: String,
@JvmField val type: ConnectionType,
@JvmField val host: String,
@JvmField val port: Int,
@JvmField val ip: String? = null,
)
8 changes: 4 additions & 4 deletions api/src/main/kotlin/nebulosa/api/guiding/GuiderInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package nebulosa.api.guiding
import nebulosa.guiding.GuideState

data class GuiderInfo(
val connected: Boolean = false,
val state: GuideState = GuideState.STOPPED,
val settling: Boolean = false,
val pixelScale: Double = 1.0,
@JvmField val connected: Boolean = false,
@JvmField val state: GuideState = GuideState.STOPPED,
@JvmField val settling: Boolean = false,
@JvmField val pixelScale: Double = 1.0,
) {

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package nebulosa.api.guiding

import nebulosa.api.message.MessageEvent

data class GuiderMessageEvent(override val eventName: String, val data: Any? = null) : MessageEvent
data class GuiderMessageEvent(override val eventName: String, @JvmField val data: Any? = null) : MessageEvent
14 changes: 7 additions & 7 deletions api/src/main/kotlin/nebulosa/api/guiding/HistoryStep.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package nebulosa.api.guiding
import nebulosa.guiding.GuideStep

data class HistoryStep(
val id: Long = 0L,
val rmsRA: Double = 0.0,
val rmsDEC: Double = 0.0,
val rmsTotal: Double = 0.0,
val guideStep: GuideStep? = null,
val ditherX: Double = 0.0,
val ditherY: Double = 0.0,
@JvmField val id: Long = 0L,
@JvmField val rmsRA: Double = 0.0,
@JvmField val rmsDEC: Double = 0.0,
@JvmField val rmsTotal: Double = 0.0,
@JvmField val guideStep: GuideStep? = null,
@JvmField val ditherX: Double = 0.0,
@JvmField val ditherY: Double = 0.0,
)
6 changes: 3 additions & 3 deletions api/src/main/kotlin/nebulosa/api/guiding/SettleInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import nebulosa.guiding.Guider
import org.hibernate.validator.constraints.Range

data class SettleInfo(
@Range(min = 1, max = 25) val amount: Double = 1.5,
@Range(min = 1, max = 60) val time: Long = 10,
@Range(min = 1, max = 60) val timeout: Long = 30,
@Range(min = 1, max = 25) @JvmField val amount: Double = 1.5,
@Range(min = 1, max = 60) @JvmField val time: Long = 10,
@Range(min = 1, max = 60) @JvmField val timeout: Long = 30,
) {

companion object {
Expand Down
Loading