== General notes ==

Though efforts have been made to avoid this from occurring, where
header keyword names are longer than the usual 8 character maximum,
the HIERARCH convention will be used.

Celestial coordinates are in ICRS.

Magnitudes are AB magnitudes (flux zero point is 3631 Jy).

Unless otherwise noted, error values are statistical only, and include
no contribution by systematic errors.

== Primary header ==

The primary header will not contain any information beyond that
written automatically by cfitsio, and is present only for compliance
with the FITS standard.

== FITS table ==

The FITS table will include all detections within an exposure.

Duplicates from overlapping skycells will have been filtered out by
IPP, with the measurements from the source closest to the centre of a
skycell included (and all others discarded).

=== Header ===

The header will contain information relevant to the exposure as a whole.

 * Version information
  * SWSOURCE (string): source of software (e.g., "60eb6cdc-a59c-4636-a4e0-dba66a9721fd")
  * SWVERSN (string): version of software (e.g., "trunk/ppMops@24658")

 * Provenance information
  * EXP_NAME (string): Exposure name (e.g., "o1234g5678")
  * EXP_ID (S64): Exposure identifier
  * CHIP_ID (S64): Chip stage identifier
  * CAM_ID (S64): Camera stage identifier
  * FAKE_ID (S64): Fake stage identifier
  * WARP_ID (S64): Warp stage identifier
  * DIFF_ID (S64): Diff stage identifier
  * DIFF_POS (boolean): Sense of subtraction; T for forward, F for backward

 * Exposure details
  * MJD-OBS (F64): TAI MJD of exposure mid-point
  * RA (string): Reported Right Ascension of telescope boresight, sexagesimal hours (e.g., "12:34:56.789")
  * DEC (string): Reported Declination of telescope boresight, sexagesimal degrees (e.g., "-12:34:56.78")
  * TEL_ALT (F64): Reported telescope altitude, degrees
  * TEL_AZ (F64): Reported telescope azimuth, degrees
  * EXPTIME (F32): Exposure time, seconds
  * ROTANGLE (F64): Rotator angle, degrees
  * FILTER (string): Filter name (e.g., "r.00000")
  * AIRMASS (F32): Airmass for exposure
  * OBSCODE (string): IAU observatory code (i.e., "F51" for PS1)
  * SEEING (F32): Measured seeing at diff stage, arcsec
  * MAGZP (F32): Magnitude zero point
  * MAGZPERR (F32): Error in magnitude zero point
  * ASTRORMS (F32): RMS of astrometric fit, arcsec

 * Detection efficiency
  * DE_MAGnn (F32): Magnitude (calibrated) for detection efficiency
  * DE_EFFnn (F32): Detection efficiency (0..1)

==== Current limitations ====

The IPP is not yet calculating detection efficiencies (it is still
being developed).  Further, it is not yet clear how to merge the
detection efficiency measurements for different skycells.  Until these
issues are resolved, the detection efficiency values will be fake.

==== Differences from original ICD ====

 * SWSOURCE, SWVERSN has replaced TABLEVER which was never defined
 * All of the "Provenance information" has replaced FPA_ID, for better tracking of the source of each detection
 * SEEING and MAGZP added as indicators of the quality of the exposure
 * MAGZPERR added to make absolute (i.e., across exposures) magnitude errors more accurate
 * ASTRORMS added to make absolute (i.e., across exposures) astrometry errors more accurate
 * DE_MAGnn and DE_EFFnn replace DE1 through DE10, which were never well defined

=== Table ===

The table will contain information relevant to the individual
detections within the exposure.

 * RA (F64): Right Ascension of detection centre, degrees
 * RA_ERR (F64): Error in RA, degrees
 * DEC (F64): Declination of detection centre, degrees
 * DEC_ERR (F64): Error in DEC, degrees
 * MAG (F32): Calibrated magnitude of detection
 * MAG_ERR (F32): Error in MAG
 * STARPSF (F32): A PSF/extended source separator
 * ANGLE (F64): Angle of trail fit to source, degrees E of N
 * ANGLE_ERR (F64): Error in ANGLE, degrees
 * LENGTH (F32): Length of trail fit to source, degrees
 * LENGTH_ERR (F32): Error in LENGTH, degrees
 * FLAGS (S32): IPP detection flags, bit mask
 * DIFF_SKYFILE_ID (S64): IPP diff_skyfile_id for source

==== Current limitations ====

The IPP is not yet fitting trails to sources in the difference images.
Until this is being done, the ANGLE, ANGLE_ERR, LENGTH and LENGTH_ERR
values will be zero.

The value being written as STARPSF is EXT_NSIGMA from the IPP CMF
files; it is not clear that this is what MOPS wants, but this is
probably irrelevant until the trail fitting has been implemented.

==== Differences from original ICD ====

 * RA_DEG, DEC_DEG renamed RA, DEC to match apparent naming policy
 * *_SIG renamed *_ERR to be more clear
 * ANG, ANG_SIG, LEN, LEN_SIG spelled out as ANGLE, ANGLE_ERR, LENGTH, LENGTH_ERR
 * FLUX, FLUX_SIG renamed MAG, MAG_ERR since IPP writes magnitudes
 * FLAGS added to allow additional weeding out of bad detections
 * DIFF_SKYFILE_ID added to allow trace back to IPP diff skyfile, for postage stamps




                            Table 3: IPP-MOPS Transient Detection Keywords
FITS Keyword      Precision                     Description
FPA ID            char(20)                      IPP-assigned identifier that can be used to trace back to this FPA
MJD-OBS           F64                           midpoint time of the exposure as a MJD and day fraction
RA                HH:MM:SS.SSS                 field center RA at exposure midpoint, string
DEC               sDD:MM:SS (s is + or -) field center declination at exposure midpoint, string
EXPTIME           F64                          exposure time in seconds
ROTANGLE          F64                          image rotation of the y-axis in degrees, from local N toward E
FILTER            char(3)                       effective filter used for the exposure, one of g, r, i, z, y, B, V, w
AIRMASS           F64                          airmass at exposure midpoint
LIMITMAG          F64                           limiting magnitude of detections for this FPA
DE1 through DE10  F64                           detection efficiency coefficients
OBSCODE           char(5)                       MPC three-character observatory code
TEL ALT           F64                          telescope altitude at exposure midpoint, in degrees
TEL AZ            F64                          telescope azimuth at exposure midpoint, in degrees
                         Table 4: IPP-MOPS Transient Detection Table Columns
             Column       Precision Description
             RA DEG       F64          detection center coordinates in degrees
             RA SIG       F64          error in the detection center, in degrees
             DEC DEG      F64          detection center coordinates in degrees
             DEC SIG      F64          error in the detection center, in degrees
             FLUX         F64          flux
             FLUX SIG     F64          error in the flux value
             STARPSF      F64          probability that the PSF matches a starlike PSF
             ANG          F64          detection’s elongation angle in degrees, local N toward E
             ANG SIG      F64          error in the angle, in degrees
             LEN          F64          elongation length of the detection in degrees
             LEN SIG      F64          error in the length, in degrees
