Skip to content

Target Model, Take 2

Rob Norris edited this page Dec 2, 2015 · 34 revisions
  // XXX FIXME: Temporary, until nonsidereal support is implemented

            — A. Brighton, 7-Nov-2005

Plan A (the violent and monolithic switchover from ITarget to Target) didn't go that well because I made some bad assumptions and didn't understand how a lot of things worked. This is old and terrible code. So now I have a much better idea of the order in which things should happen, so we can do it incrementally. Each of the bullet points below will end up being a distinct JIRA task, or at least a distinct PR.

The old issue is OCSADV-154 but we need to make this more fine-grained and update the old PRs.

1. Initial OCS Prep

These are largely mechanical changes that can be done quickly using refactoring tools. I have worked through most of this already so I know what to expect. These changes can be applied directly to develop and can ship in 15B regardless; nothing here commits us to the new model, and all are things that need to been done anyway.

Trivial API Footprint Reductions

We can immediately simplify the target API simply by running inspections and removing unused code, and redundant "convenience" methods.

  • PR Remove unused sidereal type DegDegTarget.
  • PR Remove unused methods on SPTarget, as well as ITarget and its subtypes, make things private/protected when possible, and inline methods when appropriate; the intent is to reduce the number of entry points in the API.

Remove "brightness" Property

There is an old and useless brightness property that we should simply remove. It is sent to the TCC but cannot possibly be used because it's an unstructured string.

  • PR Remove brightness from model, and remove associated editors. Add To2015B program updater to populate structured magnitudes based on brightness property when possible, and leave notes behind explaining what happened.
  • PR Add an AP band for apparent magnitude, for ephemeris-based targets coming from Phase I. Update SpTargetFactory to push this into Phase II target.
  • PR Update TooTarget to have a proper magnitude table and push it into the created Phase II targets. Will need to change servlet protocol and notify the authorities.

Remove support for non-J2000 coordinate systems.

There are now five coordinate systems supported in OCS, but J2000 is the only one that is actually supported (and it is used by literally 99.999% of our targets ... we have enough for that many digits of precision).

I have not worked through this stuff yet. Initially I was going to continue supporting B1950, but it turns out that everything is converted to/from J2000 in the TPE and elsewhere and there's simply no point maintaining the complexity if it has no impact on the user.

Convert uses of deprecated coordinate systems
  • PR Add conversion to change JNNNN and APPARENT to J2000 on import. Each is used only once, the former for engineering in GN-ENG20110920 and the latter for commissioning in GS-2007B-Q-235.
  • PR Add conversions to precess B1950 coordinates and proper motion to J2000. Precession code exists in old model but results should be spot-checked by scientists to verify.
Remove unused coordinate systems
  • PR Remove reference frames entirely; FK5/J2000 is the only one now. Remove equinox-specific methods in SPTarget and ITarget hierarchy.

Remove unsupported conic target systems.

Five of seven conic target types are unsupported, and are simply rendered into one of the two remaining types via UI trickery in the OT.

  • PR Add upgrade conversions to remove these types from the science programs; conversion logic lives in NonSiderealTargetSupport. Remove unsupported types from the model and associated hacks from the OT.

Push Magnitudes into the Target model

  • PR Add magnitude table to ITarget (perhaps by just making it into a class) and add delegates for SPTarget methods.
  • PR Inline SPTarget delegate methods so client code is using the target directly, and remove now-unused methods from SPTarget. (Done for getters, not for mutators).
  • PR Finish change for mutators above by externalizing change event propagation.

Simplify ITarget Hierarchy

Lots of code at this point is bifurcated as sidereal/non-sidereal but we want to discourage this specialization. So let's remove the NonSiderealTarget superclass and make code explicitly handle each of the three target types (since there will be two more when the new model arrives).

  • PR Merge IHorizonsTarget methods into INonSiderealTarget. Merge INonSiderealTarget into NonSiderealTarget.
  • PR Clean up redundant methods in ITarget hierarchy.
  • Push NonSiderealTarget down into ConicTarget and NamedTarget. This will require each instanceof check for NonSiderealTarget be inspected and fixed.
  • PR Remove CoordinateSystem superclass. Remove SystemName and SystemOption notions from the target model. With the exception of the conic target, which still needs a discriminant, these will all be constants.

Clean up proper motion and clean out of SPTarget

These operations are defined only for HmsDegTarget and otherwise fail in various ways.

  • PR Remove tracking effective wavelength. It is unused.
  • PR Get rid of stringly PM operations on SPTarget; change to Double.
  • PR Push proper motion into HmsDegTarget. Remove all calls to proper-motion operations from SPTarget; instead force client code to ensure that it is dealing with an HmsDmsTarget.

Document In/Out String Formats

  • For all methods on SPTarget, ITarget and subtypes that consume or produce strings, add comments documenting the format of these strings, and especially which (if any) are ultimately sent to the TCC.

Clean up Target Editor

The target editor is going to need a lot of work, so we need to get it in a state where it can be understood a little better. We may end up rewriting the whole thing; this remains unclear. But we can certainly make small improvements now.

  • PR Remove index-based tables in NonSiderealTargetSupport (and elsewhere, if any) by using enum and maps rather than index-aligned arrays.

Prepare target editor for new types

  • PR Change editor UI to make sidereal, named, comet, and minor planet modes distinct, rather than the latter three being "flavors" of nonsidereal target. It will probably make sense to get rid of the generic and stupid nonsidereal editor since there are only three cases now.

2. Advanced OCS Prep

These items are more involved. In the new model everything is immutable and coordinates are always time-varying, so we need to prepare for this.

Prepare for Immutable Targets

  • PR Remove public mutators from ITarget; move them to SPTarget, where the implementation will eventually swap targets out rather than mutate in-place.

Promote SchedulingBlock

The SchedulingBlock on SPObservation will be the basis for most time-based coordinate lookups, so we need to make it available.

  • PR Make an Option[SchedulingBlock] available in common contexts where coordinates are used.

Prepare for Unavailable Coordinates

  • Many PRs Add ITarget API calls to require an Option[SPObservation] and return optional coordinate information. Update existing calls to use new API, coping with missing coordinates in each case.

Prepare for TOO Target Type

  • Add .isTOO to ITarget and factor out code that looks for an empty HmsDegTarget.

4. Finish Core Target Model

  • PR Remove ConicTarget types; we are dropping support. Existing ones will become 1-point ephemeris targets.
  • PR Remove NamedTarget .. will need to covert existing ones to nonsidereal with empty ephemeris.
  • PR Update ephemeris model to allow easy slicing and comparison. Prototype here.
  • PR PIO serializers for new model.
  • TargetConfig for new model.
  • PR add spectral distribution, spatial profile

5. The Big Switch

These changes will need to happen on a branch that is kept up to date with develop, which gets harder and harder as time goes on. So this work should be completed quickly. Some parts may be doable in isolation, like new target editors (which can go into the trunk but will not be visible to users yet).

Update SPTarget/ITarget

  • add new Target member
  • turn ITarget back into an interface and make a wrapper for new model.
  • update methods on TransitionalSPTarget to swap out immutable targets

Update Skeleton Generation

  • P1/P2 target conversion (if PIT has not yet moved to core model)
  • Assign default scheduling block

Import Conversions

  • Conic ~> Nonsidereal (+ assign scheduling block)
  • HMS ~> TOO or Sidereal
  • Named ~> Named

OT Updates

  • Make scheduling block visible always
  • Update target editor. Borrow ephemermis editor/upload from PIT?
  • Some kind of menu item to write .eph files to TCS install dir

New P2 Checks

  • scheduling block must be defined for nonsidereal targets
  • ephemeris must be defined for entire scheduling block

Ephemeris Robot

  • add cron task to write .eph files to TCS