Skip to content

Target Model, Take 2

Rob Norris edited this page Feb 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. Oops, can't finish this because SPTarget has property change list that responds to the setters. Will add another PR at some point.

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 Remove mutators unrelated to proper motion.
  • Remove all calls to proper-motion operations from SPTarget; instead force client code to ensure that it is dealing with an HmsDmsTarget.
  • Remove the now-unused methods from SPTarget.

Same as above; this work can be committed to develop and ship with 15B

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.
  • Run inspections on EdCompTargetList; remove unused code; and aggressively repair things that are stupid.

Prepare target editor for new types

  • 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 coordinates are always time-varying, so we need to prepare for this.

Proper Support for Conic Targets

We can't stop supporting conic targets because there are simply too many in the database, but our "support" is nonsensical. We have the conic parameters but don't have code to solve the equations, so instead we just ask the PI to supply one point for use in the TPE, which also displays ephemeris elements, if it can find the target in horizons. There is nothing that ensures the conic parameters are consistent with either horizons or the validAt point.

Originally I was going to leave this as-is, but I would prefer to fix it properly. I don't want special-case code for legacy conic targets.

  • Write scala code to solve the conic equations; we will reuse this in the new model. Kepler figured this out in 1609 so it seems like we should be able to do it.
  • Leave validAt date for now, but compute its value. Remove coordinate setters.
  • Replace Horizons stuff in editor/TPE with computed values.
  • Remove horizons-related information and methods from ConicTarget.

Prepare for time-varying coordinates

This one is rough.

  • Add time-varying variants of all coordinate getters that return an Option.
  • Change all client code to use time-varying getters and to handle the possibility of empty coordinates. This is potentially complex because we need to decide which time to pass, and OCS has been using zero for missing coordinates up until now (and special-casing zero in places, probably). We may want to add something to the target that specifies how the default date should be computed. Needs some thought. We originally considered using (a) the validAt date if any, then (b) the start of the schedulingBlock, if any, then (c) the midpoint of the program semester, then (d) the epoch of the target, then (e) J2000.0 ... but this seems too complicated to me. I think we might want something in the TPE that indicates the date range(s) where we know the coordinates, and a way to select a point.
  • Remove now-unused methods.
  • Remove validAt date for conic targets.

3. Prepare the PIT

Mutable ⟷ Immutable Translation

  • Create a typeclass for translation between schema-generated and immutable types. Due to the unfortunate need to pass a Namer this can't just be scalaz.Iso.
  • Create instances for all pairs of types, and change serializing code to use these instances rather than factory and .mutable methods in the model.
  • Remove now-unused methods.

4. Construct Core Target Model

The PIT model isn't quite adequate but it's close. So we need to make some updates there. Much of this work is done.

Extract Core Target Model

Copy the PIT model in to spModel.core and then update as follows:

  • Remove references to mutable structures (this will be replaced with a typeclass in PIT).
  • Expand Coordinates to support distinct RA and Dec with shared underlying Angle type, with parsing and formatting.
  • Property-based tests for the above; there are a lot of corner cases with sexigesimal formats.
  • Add conic target types.
  • Make magnitude table a property of all targets (not just sidereal). Chad verified that this is what we want; they need not be time-varying for nonsidereal targets.
  • Remove HorizonsInfo from SiderealTarget; this was an over-generalization.

PIO serializers for new model

  • Conversions from old model serial structure.
  • Serializers for new model.

TCC serializer

  • Implement TargetConfig for new target model.
  • Test that configs for converted targets are identical to originals.
Clone this wiki locally