Skip to content

Commit

Permalink
Merge pull request #4150 from gemini-hlsw/sc-3493-make-ags-work-prope…
Browse files Browse the repository at this point in the history
…rly-for-calibrations

Handle AGS differently for different types of calibrations
  • Loading branch information
cquiroz authored Sep 16, 2024
2 parents 00dd7f9 + b9da518 commit eca9f0d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
3 changes: 2 additions & 1 deletion common/src/main/scala/explore/model/ObsConfiguration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ case class ObsConfiguration(
scienceOffsets: Option[NonEmptyList[Offset]],
acquisitionOffsets: Option[NonEmptyList[Offset]],
averagePA: Option[AveragePABasis],
obsDuration: Option[Duration]
obsDuration: Option[Duration],
needGuideStar: Boolean
) derives Eq:
// In case there is no guide star we still want to have a posAngle equivalent
// To draw visualization
Expand Down
3 changes: 2 additions & 1 deletion explore/src/main/scala/explore/tabs/ObsTabTiles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ object ObsTabTiles:
sequenceOffsets.toOption.flatMap(_.science),
sequenceOffsets.toOption.flatMap(_.acquisition),
averagePA,
obsDuration.map(_.toDuration)
obsDuration.map(_.toDuration),
props.observation.get.needsAGS
)

def getObsInfo(obsId: Observation.Id)(targetId: Target.Id): TargetEditObsInfo =
Expand Down
8 changes: 5 additions & 3 deletions explore/src/main/scala/explore/tabs/TargetTabContents.scala
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ object TargetTabContents extends TwoPanels:
case Some(id) =>
props.programSummaries.get.observations.values
.collect:
case Observation(
case o @ Observation(
obsId,
_,
_,
Expand All @@ -421,14 +421,15 @@ object TargetTabContents extends TwoPanels:
_,
_
) if obsId === id =>
(const, conf.toBasicConfiguration, posAngle, wavelength)
(const, conf.toBasicConfiguration, posAngle, wavelength, o.needsAGS)
.headOption
case _ => None
}

val constraints = obsConf.map(_._1)
val configuration: Option[BasicConfiguration] = obsConf.map(_._2)
val wavelength = obsConf.map(_._4)
val needsAGS = obsConf.exists(_._5)

def setCurrentTarget(oids: Option[ObsIdSet])(
tid: Option[Target.Id],
Expand Down Expand Up @@ -520,7 +521,8 @@ object TargetTabContents extends TwoPanels:
none,
none,
none,
none
none,
needsAGS
),
none,
props.focused.target,
Expand Down
15 changes: 10 additions & 5 deletions explore/src/main/scala/explore/targeteditor/AladinCell.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ case class AladinCell(
fullScreen: View[AladinFullScreen],
globalPreferences: View[GlobalPreferences]
) extends ReactFnProps(AladinCell.component):
val needsAGS: Boolean =
obsConf.exists(_.needGuideStar)

val anglesToTest: Option[NonEmptyList[Angle]] =
for {
conf <- obsConf
Expand Down Expand Up @@ -244,9 +247,11 @@ object AladinCell extends ModelOptics with AladinCommon:
CatalogMessage.GSRequest(baseTracking, vizTime)
)
_ <- gs.setStateAsync(candidates)
} yield ()).guarantee(
props.obsConf.flatMap(_.agsState).foldMap(_.async.set(AgsState.Idle))
)
} yield ())
.guarantee(
props.obsConf.flatMap(_.agsState).foldMap(_.async.set(AgsState.Idle))
)
.whenA(props.needsAGS)
}
// Reference to root
.useMemo(())(_ => domRoot)
Expand Down Expand Up @@ -309,7 +314,7 @@ object AladinCell extends ModelOptics with AladinCommon:
vizTime,
observingMode,
candidates
) =>
) if props.needsAGS =>
import ctx.given

val runAgs = (positions,
Expand Down Expand Up @@ -478,7 +483,7 @@ object AladinCell extends ModelOptics with AladinCommon:

val renderAgsOverlay: AsterismVisualOptions => VdomNode =
(t: AsterismVisualOptions) =>
if (props.globalPreferences.get.agsOverlay.isVisible) {
if (props.needsAGS && props.globalPreferences.get.agsOverlay.isVisible) {
props.obsConf
.flatMap(_.agsState)
.map(agsState =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ object AladinContainer extends AladinCommon {

def includeSvg(v: JsAladin): Callback =
v.onZoom(onZoom) *> // re render on zoom
v.onPositionChanged(u => onPositionChanged(u)) *>
v.onPositionChanged(onPositionChanged) *>
v.onMouseMove(s =>
props
.updateMouseCoordinates(Coordinates(s.ra, s.dec))
Expand Down
3 changes: 3 additions & 0 deletions model/shared/src/main/scala/explore/model/Observation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import cats.syntax.all.*
import eu.timepit.refined.cats.*
import eu.timepit.refined.types.numeric.NonNegShort
import eu.timepit.refined.types.string.NonEmptyString
import explore.model.syntax.all.*
import explore.modes.GmosSpectroscopyOverrides
import explore.modes.InstrumentOverrides
import io.circe.Decoder
Expand Down Expand Up @@ -79,6 +80,8 @@ case class Observation(
case _ =>
none

val needsAGS: Boolean = calibrationRole.forall(_.needsAGS)

val toModeOverride: Option[InstrumentOverrides] = observingMode.map {
case ObservingMode.GmosNorthLongSlit(
_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import eu.timepit.refined.types.numeric.NonNegInt
import eu.timepit.refined.types.numeric.NonNegShort
import explore.model.*
import explore.model.enums.PosAngleOptions
import lucuma.core.enums.CalibrationRole
import lucuma.core.enums.Site
import lucuma.core.math.Angle
import lucuma.core.math.Declination
Expand Down Expand Up @@ -125,3 +126,9 @@ object all:
extension (e: GroupTree.Value) def id: GroupTree.Key = e.bimap(_.id, _.id)

extension (e: NonNegShort) def toNonNegInt: NonNegInt = NonNegInt.unsafeFrom(e.value)

extension (cr: CalibrationRole)
def needsAGS: Boolean = cr match
case CalibrationRole.SpectroPhotometric => true
case CalibrationRole.Twilight => false
case _ => true

0 comments on commit eca9f0d

Please sign in to comment.