Index: /branches/ccl_branches/ipp-20190806/extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry.asm
===================================================================
--- /branches/ccl_branches/ipp-20190806/extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry.asm	(revision 40917)
+++ /branches/ccl_branches/ipp-20190806/extsrc/gpcsw/gpcsrc/fits/libfh/fh_registry.asm	(revision 40918)
@@ -1,786 +1,786 @@
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 0.0 E \"\ARG\" \"Standard FITS\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 0.0 N \"\ARG\" \"\""
-    ENDM
-DETCOM_X MACRO ARG
-    COBJ "detcom:dheader 1.0 X \"\ARG\" \"Bits per pixel\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 2.0 S \"\ARG\" \"Number of axes\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 2.1 1 \"\ARG\" \"Number of pixel columns\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 2.2 2 \"\ARG\" \"Number of pixel rows\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 2.3 3 \"\ARG\" \"Number of stacked frames (cube)\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 3.0 D \"\ARG\" \"File contains extensions\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 3.1 D \"\ARG\" \"Number of extensions\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 4.0 S \"\ARG\" \"File contains random groups records\""
-    ENDM
-DETCOM_T MACRO ARG
-    COBJ "detcom:dheader 5.0 T \"\ARG\" \"Random parameters before each array in a group\""
-    ENDM
-DETCOM_T MACRO ARG
-    COBJ "detcom:dheader 6.0 T \"\ARG\" \"Number of random groups\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 7.0000 S \"\ARG\" \"Number of fields in a row\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 7.0011 1 \"\ARG\" \"Table format for field 1\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 7.0012 1 \"\ARG\" \"Start Column for field 1\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 7.0021 2 \"\ARG\" \"Table format for field 2\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 7.0022 2 \"\ARG\" \"Start Column for field 2\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 7.0031 3 \"\ARG\" \"Table format for field 3\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 7.0032 3 \"\ARG\" \"Start Column for field 3\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 7.0041 4 \"\ARG\" \"Table format for field 4\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 7.0042 4 \"\ARG\" \"Start Column for field 4\""
-    ENDM
-DETCOM_5 MACRO ARG
-    COBJ "detcom:dheader 7.0051 5 \"\ARG\" \"Table format for field 5\""
-    ENDM
-DETCOM_5 MACRO ARG
-    COBJ "detcom:dheader 7.0052 5 \"\ARG\" \"Start Column for field 5\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 1.0 S \"\ARG\" \"\""
-    ENDM
-DETCOM_Q MACRO ARG
-    COBJ "detcom:dheader 2.0 Q \"\ARG\" \"\""
-    ENDM
-DETCOM_T MACRO ARG
-    COBJ "detcom:dheader 3.0 T \"\ARG\" \"\""
-    ENDM
-DETCOM_R MACRO ARG
-    COBJ "detcom:dheader 4.0 R \"\ARG\" \"\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 5.0 E \"\ARG\" \"\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 6.0 D \"\ARG\" \"\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 1.00 E \"\ARG\" \"Base filename at acquisition\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 1.01 E \"\ARG\" \"Original directory name at acquisition\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 1.10 E \"\ARG\" \"Extension name\""
-    ENDM
-DETCOM_R MACRO ARG
-    COBJ "detcom:dheader 1.20 R \"\ARG\" \"Extension version\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 4.00 E \"\ARG\" \"UTC Date of file creation\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 4.10 E \"\ARG\" \"Local time in Hawaii\""
-    ENDM
-DETCOM_V MACRO ARG
-    COBJ "detcom:dheader 7.00 V \"\ARG\" \"Image creation software version\""
-    ENDM
-DETCOM_R MACRO ARG
-    COBJ "detcom:dheader 1.0 R \"\ARG\" \"Science Detector\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 2.0 E \"\ARG\" \"Instrument Name\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 2.1 E \"\ARG\" \"Instrument Mode\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 2.0 E \"\ARG\" \"Total data pixels in full mosaic\""
-    ENDM
-DETCOM_R MACRO ARG
-    COBJ "detcom:dheader 3.0 R \"\ARG\" \"\""
-    ENDM
-DETCOM_M MACRO ARG
-    COBJ "detcom:dheader 5.0 M \"\ARG\" \"Binning factors\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 5.1 1 \"\ARG\" \"Binning factor along first axis\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 5.2 2 \"\ARG\" \"Binning factor along second axis\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 0.0 3 \"\ARG\" \"Pixel size for both axes (microns)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 1.1 3 \"\ARG\" \"Pixel size for axis 1 (microns)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 1.2 3 \"\ARG\" \"Pixel size for axis 2 (microns)\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 2.1 4 \"\ARG\" \"Pixel scale for axis 1 (arcsec/pixel)\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 2.2 4 \"\ARG\" \"Pixel scale for axis 2 (arcsec/pixel)\""
-    ENDM
-DETCOM_T MACRO ARG
-    COBJ "detcom:dheader 0.0 T \"\ARG\" \"List of amplifiers for this image\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 1.0 E \"\ARG\" \"Amplifier name\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 0.0 E \"\ARG\" \"Detector imaging area size\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 0.1 C \"\ARG\" \"Mosaic area of the detector\""
-    ENDM
-DETCOM_A MACRO ARG
-    COBJ "detcom:dheader 0.11 A \"\ARG\" \"Mosaic area of the detector from Amp A\""
-    ENDM
-DETCOM_B MACRO ARG
-    COBJ "detcom:dheader 0.12 B \"\ARG\" \"Mosaic area of the detector from Amp B\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 0.13 C \"\ARG\" \"Mosaic area of the detector from Amp C\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 0.14 D \"\ARG\" \"Mosaic area of the detector from Amp D\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 0.2 C \"\ARG\" \"Imaging area of the detector\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 0.3 C \"\ARG\" \"Overscan (bias) area of the detector\""
-    ENDM
-DETCOM_A MACRO ARG
-    COBJ "detcom:dheader 1.11 A \"\ARG\" \"Section from Amp A (non-contig. bias excluded)\""
-    ENDM
-DETCOM_B MACRO ARG
-    COBJ "detcom:dheader 1.12 B \"\ARG\" \"Section from Amp B (non-contig. bias excluded)\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 1.13 C \"\ARG\" \"Section from Amp C (non-contig. bias excluded)\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 1.14 D \"\ARG\" \"Section from Amp D (non-contig. bias excluded)\""
-    ENDM
-DETCOM_A MACRO ARG
-    COBJ "detcom:dheader 1.21 A \"\ARG\" \"Overscan (bias) area from Amp A\""
-    ENDM
-DETCOM_B MACRO ARG
-    COBJ "detcom:dheader 1.22 B \"\ARG\" \"Overscan (bias) area from Amp B\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 1.23 C \"\ARG\" \"Overscan (bias) area from Amp C\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 1.24 D \"\ARG\" \"Overscan (bias) area from Amp D\""
-    ENDM
-DETCOM_A MACRO ARG
-    COBJ "detcom:dheader 1.31 A \"\ARG\" \"Section in full CCD for DSECA\""
-    ENDM
-DETCOM_B MACRO ARG
-    COBJ "detcom:dheader 1.32 B \"\ARG\" \"Section in full CCD for DSECB\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 1.33 C \"\ARG\" \"Section in full CCD for DSECC\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 1.34 D \"\ARG\" \"Section in full CCD for DSECD\""
-    ENDM
-DETCOM_A MACRO ARG
-    COBJ "detcom:dheader 1.41 A \"\ARG\" \"Imaging area from Amp A\""
-    ENDM
-DETCOM_B MACRO ARG
-    COBJ "detcom:dheader 1.42 B \"\ARG\" \"Imaging area from Amp B\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 1.43 C \"\ARG\" \"Imaging area from Amp C\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 1.44 D \"\ARG\" \"Imaging area from Amp D\""
-    ENDM
-DETCOM_A MACRO ARG
-    COBJ "detcom:dheader 1.51 A \"\ARG\" \"Trim section for Amp A\""
-    ENDM
-DETCOM_B MACRO ARG
-    COBJ "detcom:dheader 1.52 B \"\ARG\" \"Trim section for Amp B\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 1.53 C \"\ARG\" \"Trim section for Amp C\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 1.54 D \"\ARG\" \"Trim section for Amp D\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 0.1 E \"\ARG\" \"Name of the CCD (manufacturer reference)\""
-    ENDM
-DETCOM_K MACRO ARG
-    COBJ "detcom:dheader 0.2 K \"\ARG\" \"Nickname of the CCD\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 2.0 N \"\ARG\" \"Maximum linearity value (ADU)\""
-    ENDM
-DETCOM_A MACRO ARG
-    COBJ "detcom:dheader 2.01 A \"\ARG\" \"Maximum linearity value for Amp A (ADU)\""
-    ENDM
-DETCOM_B MACRO ARG
-    COBJ "detcom:dheader 2.02 B \"\ARG\" \"Maximum linearity value for Amp B (ADU)\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 2.03 C \"\ARG\" \"Maximum linearity value for Amp C (ADU)\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 2.04 D \"\ARG\" \"Maximum linearity value for Amp D (ADU)\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 2.1 E \"\ARG\" \"Saturation value (ADU)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 5.0 3 \"\ARG\" \"Amplifier gain (electrons/ADU)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 5.01 3 \"\ARG\" \"Amp A gain (electrons/ADU)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 5.02 3 \"\ARG\" \"Amp B gain (electrons/ADU)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 5.03 3 \"\ARG\" \"Amp C gain (electrons/ADU)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 5.04 3 \"\ARG\" \"Amp D gain (electrons/ADU)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 6.0 3 \"\ARG\" \"Read noise (electrons)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 6.01 3 \"\ARG\" \"Amp A read noise (electrons)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 6.02 3 \"\ARG\" \"Amp B read noise (electrons)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 6.03 3 \"\ARG\" \"Amp C read noise (electrons)\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 6.04 3 \"\ARG\" \"Amp D read noise (electrons)\""
-    ENDM
-DETCOM_5 MACRO ARG
-    COBJ "detcom:dheader 7.0 5 \"\ARG\" \"Dark current (ADU/pixel/second)\""
-    ENDM
-DETCOM_5 MACRO ARG
-    COBJ "detcom:dheader 7.1 5 \"\ARG\" \"Dark current (e-/pixel/hour)\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 8.0 S \"\ARG\" \"QE%@wavelength in nm\""
-    ENDM
-DETCOM_V MACRO ARG
-    COBJ "detcom:dheader 0.0 V \"\ARG\" \"Controller software DSPID and SERNO versions\""
-    ENDM
-DETCOM_T MACRO ARG
-    COBJ "detcom:dheader 0.0 T \"\ARG\" \"Detector status\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 0.0 3 \"\ARG\" \"Detector temperature\""
-    ENDM
-DETCOM_P MACRO ARG
-    COBJ "detcom:dheader 1.1 P \"\ARG\" \"\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 1.2 N \"\ARG\" \"Canada-France-Hawaii Telescope\""
-    ENDM
-DETCOM_T MACRO ARG
-    COBJ "detcom:dheader 3.0 T \"\ARG\" \"Telescope Control System status\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 0.0 S \"\ARG\" \"Time System for DATExxxx\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 2.0 E \"\ARG\" \"Time at start of observation (UT)\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 4.0 E \"\ARG\" \"Sidereal time at start of observation\""
-    ENDM
-DETCOM_H MACRO ARG
-    COBJ "detcom:dheader 1.0 H \"\ARG\" \"Equinox of coordinates\""
-    ENDM
-DETCOM_X MACRO ARG
-    COBJ "detcom:dheader 1.1 X \"\ARG\" \"Equinox of coordinates\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 2.0 S \"\ARG\" \"Coordinate system for equinox (FK4/FK5/GAPPT)\""
-    ENDM
-DETCOM_A MACRO ARG
-    COBJ "detcom:dheader 2.1 A \"\ARG\" \"Object right ascension\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 2.2 C \"\ARG\" \"Object declination\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 5.211 1 \"\ARG\" \"WCS Coordinate type\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 5.212 2 \"\ARG\" \"WCS Coordinate type\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 5.411 6 \"\ARG\" \"WCS Coordinate scale matrix\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 5.412 6 \"\ARG\" \"WCS Coordinate scale matrix\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 5.421 6 \"\ARG\" \"WCS Coordinate scale matrix\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 5.422 6 \"\ARG\" \"WCS Coordinate scale matrix\""
-    ENDM
-DETCOM_R MACRO ARG
-    COBJ "detcom:dheader 0.0 R \"\ARG\" \"TCS Number of guiders\""
-    ENDM
-DETCOM_R MACRO ARG
-    COBJ "detcom:dheader 0.01 R \"\ARG\" \"TCS number of guide stars/probes in use\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 0.1 E \"\ARG\" \"TCS guider name\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 0.21 N \"\ARG\" \"TCS guider equinox\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 0.22 C \"\ARG\" \"TCS guider system for equinox\""
-    ENDM
-DETCOM_A MACRO ARG
-    COBJ "detcom:dheader 0.23 A \"\ARG\" \"TCS guider right ascension\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 0.24 C \"\ARG\" \"TCS guider declination\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 0.3 N \"\ARG\" \"TCS guider object name\""
-    ENDM
-DETCOM_X MACRO ARG
-    COBJ "detcom:dheader 0.6 X \"\ARG\" \"TCS guider flux\""
-    ENDM
-DETCOM_X MACRO ARG
-    COBJ "detcom:dheader 0.8 X \"\ARG\" \"TCS total sky flux\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 1.1 1 \"\ARG\" \"TCS guider #1 identification\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 1.21 1 \"\ARG\" \"TCS guider #1 equinox\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 1.22 1 \"\ARG\" \"TCS guider #1 system for equinox\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 1.23 1 \"\ARG\" \"TCS guider #1 right ascension\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 1.24 1 \"\ARG\" \"TCS guider #1 declination\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 1.3 1 \"\ARG\" \"TCS guider #1 object name\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 1.6 1 \"\ARG\" \"TCS guider #1 flux\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 2.1 2 \"\ARG\" \"TCS guider #2 identification\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 2.21 2 \"\ARG\" \"TCS guider #2 equinox\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 2.22 2 \"\ARG\" \"TCS guider #2 system for equinox\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 2.23 2 \"\ARG\" \"TCS guider #2 right ascension\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 2.24 2 \"\ARG\" \"TCS guider #2 declination\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 2.3 2 \"\ARG\" \"TCS guider #2 object name\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 2.6 2 \"\ARG\" \"TCS guider #2 flux\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 3.1 3 \"\ARG\" \"TCS guider #3 identification\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 3.21 3 \"\ARG\" \"TCS guider #3 equinox\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 3.22 3 \"\ARG\" \"TCS guider #3 system for equinox\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 3.23 3 \"\ARG\" \"TCS guider #3 right ascension\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 3.24 3 \"\ARG\" \"TCS guider #3 declination\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 3.3 3 \"\ARG\" \"TCS guider #3 object name\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 3.6 3 \"\ARG\" \"TCS guider #3 flux\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 4.1 4 \"\ARG\" \"TCS guider #4 identification\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 4.21 4 \"\ARG\" \"TCS guider #4 equinox\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 4.22 4 \"\ARG\" \"TCS guider #4 system for equinox\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 4.23 4 \"\ARG\" \"TCS guider #4 right ascension\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 4.24 4 \"\ARG\" \"TCS guider #4 declination\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 4.3 4 \"\ARG\" \"TCS guider #4 object name\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 4.6 4 \"\ARG\" \"TCS guider #4 flux\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 0.0 D \"\ARG\" \"Telescope focus in use\""
-    ENDM
-DETCOM_F MACRO ARG
-    COBJ "detcom:dheader 0.1 F \"\ARG\" \"Telescope focus in use\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 1.0 S \"\ARG\" \"Telescope focus encoder readout\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 1.1 S \"\ARG\" \"Telescope focus encoder readout\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 0.4 E \"\ARG\" \"ISU control state (Off/Only/TCS/Full/Frozen)\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 0.4 E \"\ARG\" \"FSA control state (Off/On/Paused)\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 0.5 E \"\ARG\" \"FSA number of actual moves in last 10 minutes\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 0.11 C \"\ARG\" \"TCS GPS read out in BCD\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 0.13 S \"\ARG\" \"TCS RBUSS clock time\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 0.14 S \"\ARG\" \"TCS EPICS clock time\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 0.15 E \"\ARG\" \"TCS acquisition mode - T/O/G/g for t/o/g coords\""
-    ENDM
-DETCOM_A MACRO ARG
-    COBJ "detcom:dheader 0.51 A \"\ARG\" \"TCS hour angle encoder bits reading\""
-    ENDM
-DETCOM_C MACRO ARG
-    COBJ "detcom:dheader 0.52 C \"\ARG\" \"TCS declination encoder bits reading\""
-    ENDM
-DETCOM_P MACRO ARG
-    COBJ "detcom:dheader 1.0 P \"\ARG\" \"AOB closed loop Open/Closed\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 3.0 S \"\ARG\" \"Loop type \"Nested\"/\"Tip/Tilt\"/\"Single\"\""
-    ENDM
-DETCOM_T MACRO ARG
-    COBJ "detcom:dheader 5.0 T \"\ARG\" \"Optimized loop control True/False\""
-    ENDM
-DETCOM_T MACRO ARG
-    COBJ "detcom:dheader 6.0 T \"\ARG\" \"WFS optical gain\""
-    ENDM
-DETCOM_T MACRO ARG
-    COBJ "detcom:dheader 2.0 T \"\ARG\" \"Total flux count on WFS\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 1.0 S \"\ARG\" \"AOB ADC position In/Out\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 4.0 D \"\ARG\" \"Beam splitter ID\""
-    ENDM
-DETCOM_P MACRO ARG
-    COBJ "detcom:dheader 5.0 P \"\ARG\" \"Beam splitter description\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 6.0 E \"\ARG\" \"AOB mirror slide \"F/20\"/\"F/8\"\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 7.0 D \"\ARG\" \"WFS ND filter position\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 0.0 N \"\ARG\" \"flatfield lamp status ON/OFF\""
-    ENDM
-DETCOM_P MACRO ARG
-    COBJ "detcom:dheader 1.0 P \"\ARG\" \"flatfield lamp intensity\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 0.0 N \"\ARG\" \"comparison lamp 0 status ON/OFF\""
-    ENDM
-DETCOM_0 MACRO ARG
-    COBJ "detcom:dheader 0.1 0 \"\ARG\" \"comparison lamp 0 description\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 1.0 N \"\ARG\" \"comparison lamp 1 status ON/OFF\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 1.1 1 \"\ARG\" \"comparison lamp 1 description\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 2.0 N \"\ARG\" \"comparison lamp 2 status ON/OFF\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 2.1 2 \"\ARG\" \"comparison lamp 2 description\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 3.0 N \"\ARG\" \"comparison lamp 3 status ON/OFF\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 3.1 3 \"\ARG\" \"comparison lamp 3 description\""
-    ENDM
-DETCOM_0 MACRO ARG
-    COBJ "detcom:dheader 0.0 0 \"\ARG\" \"lamp 0 ON/OFF\""
-    ENDM
-DETCOM_1 MACRO ARG
-    COBJ "detcom:dheader 1.0 1 \"\ARG\" \"lamp 1 ON/OFF\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 2.0 2 \"\ARG\" \"lamp 2 ON/OFF\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 3.0 3 \"\ARG\" \"lamp 3 ON/OFF\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 4.0 4 \"\ARG\" \"lamp 4 ON/OFF\""
-    ENDM
-DETCOM_5 MACRO ARG
-    COBJ "detcom:dheader 5.0 5 \"\ARG\" \"lamp 5 ON/OFF\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 6.0 6 \"\ARG\" \"lamp 6 ON/OFF\""
-    ENDM
-DETCOM_7 MACRO ARG
-    COBJ "detcom:dheader 7.0 7 \"\ARG\" \"lamp 7 ON/OFF\""
-    ENDM
-DETCOM_8 MACRO ARG
-    COBJ "detcom:dheader 8.0 8 \"\ARG\" \"lamp 8 ON/OFF\""
-    ENDM
-DETCOM_9 MACRO ARG
-    COBJ "detcom:dheader 9.0 9 \"\ARG\" \"lamp 9 ON/OFF\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 0.1 D \"\ARG\" \"wheel position\""
-    ENDM
-DETCOM_R MACRO ARG
-    COBJ "detcom:dheader 0.2 R \"\ARG\" \"description of filter\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 0.3 3 \"\ARG\" \"filter bandwidth\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 0.4 3 \"\ARG\" \"filter wavelength\""
-    ENDM
-DETCOM_5 MACRO ARG
-    COBJ "detcom:dheader 0.5 5 \"\ARG\" \"lower bound of filter (units/%?)\""
-    ENDM
-DETCOM_5 MACRO ARG
-    COBJ "detcom:dheader 0.6 5 \"\ARG\" \"upper bound of filter (units/%?)\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 0.7 D \"\ARG\" \"filter drawer number\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 0.1 D \"\ARG\" \"'wheel' A position\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 0.2 E \"\ARG\" \"description of filter\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 0.5 4 \"\ARG\" \"lower bound of filter A (units/%?)\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 0.6 4 \"\ARG\" \"upper bound of filter A (units/%?)\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 0.1 D \"\ARG\" \"'wheel' B position\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 0.2 E \"\ARG\" \"description of filter\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 0.5 4 \"\ARG\" \"lower bound of filter B (units/%?)\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 0.6 4 \"\ARG\" \"upper bound of filter B (units/%?)\""
-    ENDM
-DETCOM_7 MACRO ARG
-    COBJ "detcom:dheader 1.0 7 \"\ARG\" \"internal instrument focus value\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 1.0 D \"\ARG\" \"grism position\""
-    ENDM
-DETCOM_M MACRO ARG
-    COBJ "detcom:dheader 2.0 M \"\ARG\" \"grism description\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 3.0 D \"\ARG\" \"grism drawer number\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 1.0 D \"\ARG\" \"mask position\""
-    ENDM
-DETCOM_K MACRO ARG
-    COBJ "detcom:dheader 2.0 K \"\ARG\" \"mask description\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 3.0 D \"\ARG\" \"mask slider number\""
-    ENDM
-DETCOM_L MACRO ARG
-    COBJ "detcom:dheader 1.0 L \"\ARG\" \"grating description\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 2.0 S \"\ARG\" \"dispersion axis (1 or 2)\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 3.0 6 \"\ARG\" \"grating angle in degrees\""
-    ENDM
-DETCOM_0 MACRO ARG
-    COBJ "detcom:dheader 4.0 0 \"\ARG\" \"central wavelength in angstroms\""
-    ENDM
-DETCOM_R MACRO ARG
-    COBJ "detcom:dheader 5.0 R \"\ARG\" \"spectral order\""
-    ENDM
-DETCOM_5 MACRO ARG
-    COBJ "detcom:dheader 6.0 5 \"\ARG\" \"grating setup constant in degrees\""
-    ENDM
-DETCOM_7 MACRO ARG
-    COBJ "detcom:dheader 7.0 7 \"\ARG\" \"setup const in degrees (opening angle / 2)\""
-    ENDM
-DETCOM_5 MACRO ARG
-    COBJ "detcom:dheader 8.0 5 \"\ARG\" \"rel.angle between prisms in degrees\""
-    ENDM
-DETCOM_R MACRO ARG
-    COBJ "detcom:dheader 0.0 R \"\ARG\" \"image slicer in place\""
-    ENDM
-DETCOM_A MACRO ARG
-    COBJ "detcom:dheader 1.0 A \"\ARG\" \"hartman mask 1a position OPEN/CLOSED\""
-    ENDM
-DETCOM_B MACRO ARG
-    COBJ "detcom:dheader 1.1 B \"\ARG\" \"hartman mask 1b position OPEN/CLOSED\""
-    ENDM
-DETCOM_2 MACRO ARG
-    COBJ "detcom:dheader 2.0 2 \"\ARG\" \"hartman mask 2 position OPEN/CLOSED\""
-    ENDM
-DETCOM_3 MACRO ARG
-    COBJ "detcom:dheader 3.0 3 \"\ARG\" \"hartman mask 3 position OPEN/CLOSED\""
-    ENDM
-DETCOM_4 MACRO ARG
-    COBJ "detcom:dheader 4.0 4 \"\ARG\" \"hartman mask 4 position OPEN/CLOSED\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 0.0 N \"\ARG\" \"coude train color UV/RED/CAFE\""
-    ENDM
-DETCOM_R MACRO ARG
-    COBJ "detcom:dheader 0.0 R \"\ARG\" \"exposure meter filter description\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 1.0 S \"\ARG\" \"exposure meter counts at end\""
-    ENDM
-DETCOM_M MACRO ARG
-    COBJ "detcom:dheader 2.0 M \"\ARG\" \"mid-exposure time (seconds)\""
-    ENDM
-DETCOM_E MACRO ARG
-    COBJ "detcom:dheader 0.0 E \"\ARG\" \"CAFE is being used Null/INUSE\""
-    ENDM
-DETCOM_T MACRO ARG
-    COBJ "detcom:dheader 1.0 T \"\ARG\" \"fabry perot etalon description\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 3.0 N \"\ARG\" \"number of channels per scan\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 4.0 N \"\ARG\" \"current channel\""
-    ENDM
-DETCOM_L MACRO ARG
-    COBJ "detcom:dheader 5.0 L \"\ARG\" \"binary control value\""
-    ENDM
-DETCOM_S MACRO ARG
-    COBJ "detcom:dheader 0.0 S \"\ARG\" \"GriF position of FP carriage - In/Out\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 1.1 6 \"\ARG\" \"GriF wavelength of order used to scan\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 1.2 6 \"\ARG\" \"GriF wavelength of calibration spectral line\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 1.3 6 \"\ARG\" \"GriF BCV at calibration line\""
-    ENDM
-DETCOM_Y MACRO ARG
-    COBJ "detcom:dheader 2.0 Y \"\ARG\" \"GriF type of scan - bcv, wave, velocity\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 3.1 6 \"\ARG\" \"GriF wavelength at beginning of scan\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 3.2 6 \"\ARG\" \"GriF wavelength step\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 3.3 6 \"\ARG\" \"GriF current observed wavelength\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 4.1 6 \"\ARG\" \"GriF Binary Contol Value at beginning of scan\""
-    ENDM
-DETCOM_6 MACRO ARG
-    COBJ "detcom:dheader 4.2 6 \"\ARG\" \"GriF BCV step\""
-    ENDM
-DETCOM_R MACRO ARG
-    COBJ "detcom:dheader 4.3 R \"\ARG\" \"GriF applied BCV\""
-    ENDM
-DETCOM_N MACRO ARG
-    COBJ "detcom:dheader 5.1 N \"\ARG\" \"GriF number of channels in scan\""
-    ENDM
-DETCOM_H MACRO ARG
-    COBJ "detcom:dheader 5.2 H \"\ARG\" \"GriF current channel\""
-    ENDM
-DETCOM_X MACRO ARG
-    COBJ "detcom:dheader 6.1 X \"\ARG\" \"GriF X Binary Control Value FP\""
-    ENDM
-DETCOM_Y MACRO ARG
-    COBJ "detcom:dheader 6.2 Y \"\ARG\" \"GriF Y Binary Control Value FP\""
-    ENDM
-DETCOM_D MACRO ARG
-    COBJ "detcom:dheader 1.0 D \"\ARG\" \"Elixir camera run ID\""
-    ENDM
+DETCOM_SIMPLE MACRO ARG
+    COBJ "detcom:dheader 0.0 SIMPLE \"\ARG\" \"Standard FITS\""
+    ENDM
+DETCOM_XTENSION MACRO ARG
+    COBJ "detcom:dheader 0.0 XTENSION \"\ARG\" \"\""
+    ENDM
+DETCOM_BITPIX MACRO ARG
+    COBJ "detcom:dheader 1.0 BITPIX \"\ARG\" \"Bits per pixel\""
+    ENDM
+DETCOM_NAXIS MACRO ARG
+    COBJ "detcom:dheader 2.0 NAXIS \"\ARG\" \"Number of axes\""
+    ENDM
+DETCOM_NAXIS1 MACRO ARG
+    COBJ "detcom:dheader 2.1 NAXIS1 \"\ARG\" \"Number of pixel columns\""
+    ENDM
+DETCOM_NAXIS2 MACRO ARG
+    COBJ "detcom:dheader 2.2 NAXIS2 \"\ARG\" \"Number of pixel rows\""
+    ENDM
+DETCOM_NAXIS3 MACRO ARG
+    COBJ "detcom:dheader 2.3 NAXIS3 \"\ARG\" \"Number of stacked frames (cube)\""
+    ENDM
+DETCOM_EXTEND MACRO ARG
+    COBJ "detcom:dheader 3.0 EXTEND \"\ARG\" \"File contains extensions\""
+    ENDM
+DETCOM_NEXTEND MACRO ARG
+    COBJ "detcom:dheader 3.1 NEXTEND \"\ARG\" \"Number of extensions\""
+    ENDM
+DETCOM_GROUPS MACRO ARG
+    COBJ "detcom:dheader 4.0 GROUPS \"\ARG\" \"File contains random groups records\""
+    ENDM
+DETCOM_PCOUNT MACRO ARG
+    COBJ "detcom:dheader 5.0 PCOUNT \"\ARG\" \"Random parameters before each array in a group\""
+    ENDM
+DETCOM_GCOUNT MACRO ARG
+    COBJ "detcom:dheader 6.0 GCOUNT \"\ARG\" \"Number of random groups\""
+    ENDM
+DETCOM_TFIELDS MACRO ARG
+    COBJ "detcom:dheader 7.0000 TFIELDS \"\ARG\" \"Number of fields in a row\""
+    ENDM
+DETCOM_TFORM1 MACRO ARG
+    COBJ "detcom:dheader 7.0011 TFORM1 \"\ARG\" \"Table format for field 1\""
+    ENDM
+DETCOM_TBCOL1 MACRO ARG
+    COBJ "detcom:dheader 7.0012 TBCOL1 \"\ARG\" \"Start Column for field 1\""
+    ENDM
+DETCOM_TFORM2 MACRO ARG
+    COBJ "detcom:dheader 7.0021 TFORM2 \"\ARG\" \"Table format for field 2\""
+    ENDM
+DETCOM_TBCOL2 MACRO ARG
+    COBJ "detcom:dheader 7.0022 TBCOL2 \"\ARG\" \"Start Column for field 2\""
+    ENDM
+DETCOM_TFORM3 MACRO ARG
+    COBJ "detcom:dheader 7.0031 TFORM3 \"\ARG\" \"Table format for field 3\""
+    ENDM
+DETCOM_TBCOL3 MACRO ARG
+    COBJ "detcom:dheader 7.0032 TBCOL3 \"\ARG\" \"Start Column for field 3\""
+    ENDM
+DETCOM_TFORM4 MACRO ARG
+    COBJ "detcom:dheader 7.0041 TFORM4 \"\ARG\" \"Table format for field 4\""
+    ENDM
+DETCOM_TBCOL4 MACRO ARG
+    COBJ "detcom:dheader 7.0042 TBCOL4 \"\ARG\" \"Start Column for field 4\""
+    ENDM
+DETCOM_TFORM5 MACRO ARG
+    COBJ "detcom:dheader 7.0051 TFORM5 \"\ARG\" \"Table format for field 5\""
+    ENDM
+DETCOM_TBCOL5 MACRO ARG
+    COBJ "detcom:dheader 7.0052 TBCOL5 \"\ARG\" \"Start Column for field 5\""
+    ENDM
+DETCOM_CMMTOBS MACRO ARG
+    COBJ "detcom:dheader 51.0 CMMTOBS \"\ARG\" \"\""
+    ENDM
+DETCOM_CMMTSEQ MACRO ARG
+    COBJ "detcom:dheader 52.0 CMMTSEQ \"\ARG\" \"\""
+    ENDM
+DETCOM_OBJECT MACRO ARG
+    COBJ "detcom:dheader 53.0 OBJECT \"\ARG\" \"\""
+    ENDM
+DETCOM_OBSERVER MACRO ARG
+    COBJ "detcom:dheader 54.0 OBSERVER \"\ARG\" \"\""
+    ENDM
+DETCOM_PI_NAME MACRO ARG
+    COBJ "detcom:dheader 55.0 PI_NAME \"\ARG\" \"\""
+    ENDM
+DETCOM_RUNID MACRO ARG
+    COBJ "detcom:dheader 56.0 RUNID \"\ARG\" \"\""
+    ENDM
+DETCOM_FILENAME MACRO ARG
+    COBJ "detcom:dheader 71.00 FILENAME \"\ARG\" \"Base filename at acquisition\""
+    ENDM
+DETCOM_PATHNAME MACRO ARG
+    COBJ "detcom:dheader 71.01 PATHNAME \"\ARG\" \"Original directory name at acquisition\""
+    ENDM
+DETCOM_EXTNAME MACRO ARG
+    COBJ "detcom:dheader 71.10 EXTNAME \"\ARG\" \"Extension name\""
+    ENDM
+DETCOM_EXTVER MACRO ARG
+    COBJ "detcom:dheader 71.20 EXTVER \"\ARG\" \"Extension version\""
+    ENDM
+DETCOM_DATE MACRO ARG
+    COBJ "detcom:dheader 74.00 DATE \"\ARG\" \"UTC Date of file creation\""
+    ENDM
+DETCOM_HSTTIME MACRO ARG
+    COBJ "detcom:dheader 74.10 HSTTIME \"\ARG\" \"Local time in Hawaii\""
+    ENDM
+DETCOM_IMAGESWV MACRO ARG
+    COBJ "detcom:dheader 77.00 IMAGESWV \"\ARG\" \"Image creation software version\""
+    ENDM
+DETCOM_DETECTOR MACRO ARG
+    COBJ "detcom:dheader 91.0 DETECTOR \"\ARG\" \"Science Detector\""
+    ENDM
+DETCOM_INSTRUME MACRO ARG
+    COBJ "detcom:dheader 92.0 INSTRUME \"\ARG\" \"Instrument Name\""
+    ENDM
+DETCOM_INSTMODE MACRO ARG
+    COBJ "detcom:dheader 92.1 INSTMODE \"\ARG\" \"Instrument Mode\""
+    ENDM
+DETCOM_DETSIZE MACRO ARG
+    COBJ "detcom:dheader 102.0 DETSIZE \"\ARG\" \"Total data pixels in full mosaic\""
+    ENDM
+DETCOM_RASTER MACRO ARG
+    COBJ "detcom:dheader 103.0 RASTER \"\ARG\" \"\""
+    ENDM
+DETCOM_CCDSUM MACRO ARG
+    COBJ "detcom:dheader 105.0 CCDSUM \"\ARG\" \"Binning factors\""
+    ENDM
+DETCOM_CCDBIN1 MACRO ARG
+    COBJ "detcom:dheader 105.1 CCDBIN1 \"\ARG\" \"Binning factor along first axis\""
+    ENDM
+DETCOM_CCDBIN2 MACRO ARG
+    COBJ "detcom:dheader 105.2 CCDBIN2 \"\ARG\" \"Binning factor along second axis\""
+    ENDM
+DETCOM_PIXSIZE MACRO ARG
+    COBJ "detcom:dheader 110.0 PIXSIZE \"\ARG\" \"Pixel size for both axes (microns)\""
+    ENDM
+DETCOM_PIXSIZE1 MACRO ARG
+    COBJ "detcom:dheader 111.1 PIXSIZE1 \"\ARG\" \"Pixel size for axis 1 (microns)\""
+    ENDM
+DETCOM_PIXSIZE2 MACRO ARG
+    COBJ "detcom:dheader 111.2 PIXSIZE2 \"\ARG\" \"Pixel size for axis 2 (microns)\""
+    ENDM
+DETCOM_PIXSCAL1 MACRO ARG
+    COBJ "detcom:dheader 112.1 PIXSCAL1 \"\ARG\" \"Pixel scale for axis 1 (arcsec/pixel)\""
+    ENDM
+DETCOM_PIXSCAL2 MACRO ARG
+    COBJ "detcom:dheader 112.2 PIXSCAL2 \"\ARG\" \"Pixel scale for axis 2 (arcsec/pixel)\""
+    ENDM
+DETCOM_AMPLIST MACRO ARG
+    COBJ "detcom:dheader 130.0 AMPLIST \"\ARG\" \"List of amplifiers for this image\""
+    ENDM
+DETCOM_AMPNAME MACRO ARG
+    COBJ "detcom:dheader 131.0 AMPNAME \"\ARG\" \"Amplifier name\""
+    ENDM
+DETCOM_CCDSIZE MACRO ARG
+    COBJ "detcom:dheader 140.0 CCDSIZE \"\ARG\" \"Detector imaging area size\""
+    ENDM
+DETCOM_DETSEC MACRO ARG
+    COBJ "detcom:dheader 140.1 DETSEC \"\ARG\" \"Mosaic area of the detector\""
+    ENDM
+DETCOM_DETSECA MACRO ARG
+    COBJ "detcom:dheader 140.11 DETSECA \"\ARG\" \"Mosaic area of the detector from Amp A\""
+    ENDM
+DETCOM_DETSECB MACRO ARG
+    COBJ "detcom:dheader 140.12 DETSECB \"\ARG\" \"Mosaic area of the detector from Amp B\""
+    ENDM
+DETCOM_DETSECC MACRO ARG
+    COBJ "detcom:dheader 140.13 DETSECC \"\ARG\" \"Mosaic area of the detector from Amp C\""
+    ENDM
+DETCOM_DETSECD MACRO ARG
+    COBJ "detcom:dheader 140.14 DETSECD \"\ARG\" \"Mosaic area of the detector from Amp D\""
+    ENDM
+DETCOM_DATASEC MACRO ARG
+    COBJ "detcom:dheader 140.2 DATASEC \"\ARG\" \"Imaging area of the detector\""
+    ENDM
+DETCOM_BIASSEC MACRO ARG
+    COBJ "detcom:dheader 140.3 BIASSEC \"\ARG\" \"Overscan (bias) area of the detector\""
+    ENDM
+DETCOM_ASECA MACRO ARG
+    COBJ "detcom:dheader 141.11 ASECA \"\ARG\" \"Section from Amp A (non-contig. bias excluded)\""
+    ENDM
+DETCOM_ASECB MACRO ARG
+    COBJ "detcom:dheader 141.12 ASECB \"\ARG\" \"Section from Amp B (non-contig. bias excluded)\""
+    ENDM
+DETCOM_ASECC MACRO ARG
+    COBJ "detcom:dheader 141.13 ASECC \"\ARG\" \"Section from Amp C (non-contig. bias excluded)\""
+    ENDM
+DETCOM_ASECD MACRO ARG
+    COBJ "detcom:dheader 141.14 ASECD \"\ARG\" \"Section from Amp D (non-contig. bias excluded)\""
+    ENDM
+DETCOM_BSECA MACRO ARG
+    COBJ "detcom:dheader 141.21 BSECA \"\ARG\" \"Overscan (bias) area from Amp A\""
+    ENDM
+DETCOM_BSECB MACRO ARG
+    COBJ "detcom:dheader 141.22 BSECB \"\ARG\" \"Overscan (bias) area from Amp B\""
+    ENDM
+DETCOM_BSECC MACRO ARG
+    COBJ "detcom:dheader 141.23 BSECC \"\ARG\" \"Overscan (bias) area from Amp C\""
+    ENDM
+DETCOM_BSECD MACRO ARG
+    COBJ "detcom:dheader 141.24 BSECD \"\ARG\" \"Overscan (bias) area from Amp D\""
+    ENDM
+DETCOM_CSECA MACRO ARG
+    COBJ "detcom:dheader 141.31 CSECA \"\ARG\" \"Section in full CCD for DSECA\""
+    ENDM
+DETCOM_CSECB MACRO ARG
+    COBJ "detcom:dheader 141.32 CSECB \"\ARG\" \"Section in full CCD for DSECB\""
+    ENDM
+DETCOM_CSECC MACRO ARG
+    COBJ "detcom:dheader 141.33 CSECC \"\ARG\" \"Section in full CCD for DSECC\""
+    ENDM
+DETCOM_CSECD MACRO ARG
+    COBJ "detcom:dheader 141.34 CSECD \"\ARG\" \"Section in full CCD for DSECD\""
+    ENDM
+DETCOM_DSECA MACRO ARG
+    COBJ "detcom:dheader 141.41 DSECA \"\ARG\" \"Imaging area from Amp A\""
+    ENDM
+DETCOM_DSECB MACRO ARG
+    COBJ "detcom:dheader 141.42 DSECB \"\ARG\" \"Imaging area from Amp B\""
+    ENDM
+DETCOM_DSECC MACRO ARG
+    COBJ "detcom:dheader 141.43 DSECC \"\ARG\" \"Imaging area from Amp C\""
+    ENDM
+DETCOM_DSECD MACRO ARG
+    COBJ "detcom:dheader 141.44 DSECD \"\ARG\" \"Imaging area from Amp D\""
+    ENDM
+DETCOM_TSECA MACRO ARG
+    COBJ "detcom:dheader 141.51 TSECA \"\ARG\" \"Trim section for Amp A\""
+    ENDM
+DETCOM_TSECB MACRO ARG
+    COBJ "detcom:dheader 141.52 TSECB \"\ARG\" \"Trim section for Amp B\""
+    ENDM
+DETCOM_TSECC MACRO ARG
+    COBJ "detcom:dheader 141.53 TSECC \"\ARG\" \"Trim section for Amp C\""
+    ENDM
+DETCOM_TSECD MACRO ARG
+    COBJ "detcom:dheader 141.54 TSECD \"\ARG\" \"Trim section for Amp D\""
+    ENDM
+DETCOM_CCDNAME MACRO ARG
+    COBJ "detcom:dheader 150.1 CCDNAME \"\ARG\" \"Name of the CCD (manufacturer reference)\""
+    ENDM
+DETCOM_CCDNICK MACRO ARG
+    COBJ "detcom:dheader 150.2 CCDNICK \"\ARG\" \"Nickname of the CCD\""
+    ENDM
+DETCOM_MAXLIN MACRO ARG
+    COBJ "detcom:dheader 152.0 MAXLIN \"\ARG\" \"Maximum linearity value (ADU)\""
+    ENDM
+DETCOM_MAXLINA MACRO ARG
+    COBJ "detcom:dheader 152.01 MAXLINA \"\ARG\" \"Maximum linearity value for Amp A (ADU)\""
+    ENDM
+DETCOM_MAXLINB MACRO ARG
+    COBJ "detcom:dheader 152.02 MAXLINB \"\ARG\" \"Maximum linearity value for Amp B (ADU)\""
+    ENDM
+DETCOM_MAXLINC MACRO ARG
+    COBJ "detcom:dheader 152.03 MAXLINC \"\ARG\" \"Maximum linearity value for Amp C (ADU)\""
+    ENDM
+DETCOM_MAXLIND MACRO ARG
+    COBJ "detcom:dheader 152.04 MAXLIND \"\ARG\" \"Maximum linearity value for Amp D (ADU)\""
+    ENDM
+DETCOM_SATURATE MACRO ARG
+    COBJ "detcom:dheader 152.1 SATURATE \"\ARG\" \"Saturation value (ADU)\""
+    ENDM
+DETCOM_GAIN MACRO ARG
+    COBJ "detcom:dheader 155.0 GAIN \"\ARG\" \"Amplifier gain (electrons/ADU)\""
+    ENDM
+DETCOM_GAINA MACRO ARG
+    COBJ "detcom:dheader 155.01 GAINA \"\ARG\" \"Amp A gain (electrons/ADU)\""
+    ENDM
+DETCOM_GAINB MACRO ARG
+    COBJ "detcom:dheader 155.02 GAINB \"\ARG\" \"Amp B gain (electrons/ADU)\""
+    ENDM
+DETCOM_GAINC MACRO ARG
+    COBJ "detcom:dheader 155.03 GAINC \"\ARG\" \"Amp C gain (electrons/ADU)\""
+    ENDM
+DETCOM_GAIND MACRO ARG
+    COBJ "detcom:dheader 155.04 GAIND \"\ARG\" \"Amp D gain (electrons/ADU)\""
+    ENDM
+DETCOM_RDNOISE MACRO ARG
+    COBJ "detcom:dheader 156.0 RDNOISE \"\ARG\" \"Read noise (electrons)\""
+    ENDM
+DETCOM_RDNOISEA MACRO ARG
+    COBJ "detcom:dheader 156.01 RDNOISEA \"\ARG\" \"Amp A read noise (electrons)\""
+    ENDM
+DETCOM_RDNOISEB MACRO ARG
+    COBJ "detcom:dheader 156.02 RDNOISEB \"\ARG\" \"Amp B read noise (electrons)\""
+    ENDM
+DETCOM_RDNOISEC MACRO ARG
+    COBJ "detcom:dheader 156.03 RDNOISEC \"\ARG\" \"Amp C read noise (electrons)\""
+    ENDM
+DETCOM_RDNOISED MACRO ARG
+    COBJ "detcom:dheader 156.04 RDNOISED \"\ARG\" \"Amp D read noise (electrons)\""
+    ENDM
+DETCOM_DCURRENT MACRO ARG
+    COBJ "detcom:dheader 157.0 DCURRENT \"\ARG\" \"Dark current (ADU/pixel/second)\""
+    ENDM
+DETCOM_DARKCUR MACRO ARG
+    COBJ "detcom:dheader 157.1 DARKCUR \"\ARG\" \"Dark current (e-/pixel/hour)\""
+    ENDM
+DETCOM_QEPOINTS MACRO ARG
+    COBJ "detcom:dheader 158.0 QEPOINTS \"\ARG\" \"QE%@wavelength in nm\""
+    ENDM
+DETCOM_CONSWV MACRO ARG
+    COBJ "detcom:dheader 170.0 CONSWV \"\ARG\" \"Controller software DSPID and SERNO versions\""
+    ENDM
+DETCOM_DETSTAT MACRO ARG
+    COBJ "detcom:dheader 180.0 DETSTAT \"\ARG\" \"Detector status\""
+    ENDM
+DETCOM_DETTEM MACRO ARG
+    COBJ "detcom:dheader 190.0 DETTEM \"\ARG\" \"Detector temperature\""
+    ENDM
+DETCOM_TELESCOP MACRO ARG
+    COBJ "detcom:dheader 501.1 TELESCOP \"\ARG\" \"\""
+    ENDM
+DETCOM_ORIGIN MACRO ARG
+    COBJ "detcom:dheader 501.2 ORIGIN \"\ARG\" \"Canada-France-Hawaii Telescope\""
+    ENDM
+DETCOM_TELSTAT MACRO ARG
+    COBJ "detcom:dheader 503.0 TELSTAT \"\ARG\" \"Telescope Control System status\""
+    ENDM
+DETCOM_TIMESYS MACRO ARG
+    COBJ "detcom:dheader 510.0 TIMESYS \"\ARG\" \"Time System for DATExxxx\""
+    ENDM
+DETCOM_UTIME MACRO ARG
+    COBJ "detcom:dheader 512.0 UTIME \"\ARG\" \"Time at start of observation (UT)\""
+    ENDM
+DETCOM_SIDTIME MACRO ARG
+    COBJ "detcom:dheader 514.0 SIDTIME \"\ARG\" \"Sidereal time at start of observation\""
+    ENDM
+DETCOM_EPOCH MACRO ARG
+    COBJ "detcom:dheader 521.0 EPOCH \"\ARG\" \"Equinox of coordinates\""
+    ENDM
+DETCOM_EQUINOX MACRO ARG
+    COBJ "detcom:dheader 521.1 EQUINOX \"\ARG\" \"Equinox of coordinates\""
+    ENDM
+DETCOM_RADECSYS MACRO ARG
+    COBJ "detcom:dheader 522.0 RADECSYS \"\ARG\" \"Coordinate system for equinox (FK4/FK5/GAPPT)\""
+    ENDM
+DETCOM_RA MACRO ARG
+    COBJ "detcom:dheader 522.1 RA \"\ARG\" \"Object right ascension\""
+    ENDM
+DETCOM_DEC MACRO ARG
+    COBJ "detcom:dheader 522.2 DEC \"\ARG\" \"Object declination\""
+    ENDM
+DETCOM_CTYPE1 MACRO ARG
+    COBJ "detcom:dheader 525.211 CTYPE1 \"\ARG\" \"WCS Coordinate type\""
+    ENDM
+DETCOM_CTYPE2 MACRO ARG
+    COBJ "detcom:dheader 525.212 CTYPE2 \"\ARG\" \"WCS Coordinate type\""
+    ENDM
+DETCOM_CD1_1 MACRO ARG
+    COBJ "detcom:dheader 525.411 CD1_1 \"\ARG\" \"WCS Coordinate scale matrix\""
+    ENDM
+DETCOM_CD1_2 MACRO ARG
+    COBJ "detcom:dheader 525.412 CD1_2 \"\ARG\" \"WCS Coordinate scale matrix\""
+    ENDM
+DETCOM_CD2_1 MACRO ARG
+    COBJ "detcom:dheader 525.421 CD2_1 \"\ARG\" \"WCS Coordinate scale matrix\""
+    ENDM
+DETCOM_CD2_2 MACRO ARG
+    COBJ "detcom:dheader 525.422 CD2_2 \"\ARG\" \"WCS Coordinate scale matrix\""
+    ENDM
+DETCOM_NGUIDER MACRO ARG
+    COBJ "detcom:dheader 530.0 NGUIDER \"\ARG\" \"TCS Number of guiders\""
+    ENDM
+DETCOM_NGUISTAR MACRO ARG
+    COBJ "detcom:dheader 530.01 NGUISTAR \"\ARG\" \"TCS number of guide stars/probes in use\""
+    ENDM
+DETCOM_GUINAME MACRO ARG
+    COBJ "detcom:dheader 530.1 GUINAME \"\ARG\" \"TCS guider name\""
+    ENDM
+DETCOM_GUIEQUIN MACRO ARG
+    COBJ "detcom:dheader 530.21 GUIEQUIN \"\ARG\" \"TCS guider equinox\""
+    ENDM
+DETCOM_GUIRADEC MACRO ARG
+    COBJ "detcom:dheader 530.22 GUIRADEC \"\ARG\" \"TCS guider system for equinox\""
+    ENDM
+DETCOM_GUIRA MACRO ARG
+    COBJ "detcom:dheader 530.23 GUIRA \"\ARG\" \"TCS guider right ascension\""
+    ENDM
+DETCOM_GUIDEC MACRO ARG
+    COBJ "detcom:dheader 530.24 GUIDEC \"\ARG\" \"TCS guider declination\""
+    ENDM
+DETCOM_GUIOBJN MACRO ARG
+    COBJ "detcom:dheader 530.3 GUIOBJN \"\ARG\" \"TCS guider object name\""
+    ENDM
+DETCOM_GUIFLUX MACRO ARG
+    COBJ "detcom:dheader 530.6 GUIFLUX \"\ARG\" \"TCS guider flux\""
+    ENDM
+DETCOM_SKYFLUX MACRO ARG
+    COBJ "detcom:dheader 530.8 SKYFLUX \"\ARG\" \"TCS total sky flux\""
+    ENDM
+DETCOM_GUINAME1 MACRO ARG
+    COBJ "detcom:dheader 531.1 GUINAME1 \"\ARG\" \"TCS guider #1 identification\""
+    ENDM
+DETCOM_GUIEQUI1 MACRO ARG
+    COBJ "detcom:dheader 531.21 GUIEQUI1 \"\ARG\" \"TCS guider #1 equinox\""
+    ENDM
+DETCOM_GUIRADE1 MACRO ARG
+    COBJ "detcom:dheader 531.22 GUIRADE1 \"\ARG\" \"TCS guider #1 system for equinox\""
+    ENDM
+DETCOM_GUIRA1 MACRO ARG
+    COBJ "detcom:dheader 531.23 GUIRA1 \"\ARG\" \"TCS guider #1 right ascension\""
+    ENDM
+DETCOM_GUIDEC1 MACRO ARG
+    COBJ "detcom:dheader 531.24 GUIDEC1 \"\ARG\" \"TCS guider #1 declination\""
+    ENDM
+DETCOM_GUIOBJN1 MACRO ARG
+    COBJ "detcom:dheader 531.3 GUIOBJN1 \"\ARG\" \"TCS guider #1 object name\""
+    ENDM
+DETCOM_GUIFLUX1 MACRO ARG
+    COBJ "detcom:dheader 531.6 GUIFLUX1 \"\ARG\" \"TCS guider #1 flux\""
+    ENDM
+DETCOM_GUINAME2 MACRO ARG
+    COBJ "detcom:dheader 532.1 GUINAME2 \"\ARG\" \"TCS guider #2 identification\""
+    ENDM
+DETCOM_GUIEQUI2 MACRO ARG
+    COBJ "detcom:dheader 532.21 GUIEQUI2 \"\ARG\" \"TCS guider #2 equinox\""
+    ENDM
+DETCOM_GUIRADE2 MACRO ARG
+    COBJ "detcom:dheader 532.22 GUIRADE2 \"\ARG\" \"TCS guider #2 system for equinox\""
+    ENDM
+DETCOM_GUIRA2 MACRO ARG
+    COBJ "detcom:dheader 532.23 GUIRA2 \"\ARG\" \"TCS guider #2 right ascension\""
+    ENDM
+DETCOM_GUIDEC2 MACRO ARG
+    COBJ "detcom:dheader 532.24 GUIDEC2 \"\ARG\" \"TCS guider #2 declination\""
+    ENDM
+DETCOM_GUIOBJN2 MACRO ARG
+    COBJ "detcom:dheader 532.3 GUIOBJN2 \"\ARG\" \"TCS guider #2 object name\""
+    ENDM
+DETCOM_GUIFLUX2 MACRO ARG
+    COBJ "detcom:dheader 532.6 GUIFLUX2 \"\ARG\" \"TCS guider #2 flux\""
+    ENDM
+DETCOM_GUINAME3 MACRO ARG
+    COBJ "detcom:dheader 533.1 GUINAME3 \"\ARG\" \"TCS guider #3 identification\""
+    ENDM
+DETCOM_GUIEQUI3 MACRO ARG
+    COBJ "detcom:dheader 533.21 GUIEQUI3 \"\ARG\" \"TCS guider #3 equinox\""
+    ENDM
+DETCOM_GUIRADE3 MACRO ARG
+    COBJ "detcom:dheader 533.22 GUIRADE3 \"\ARG\" \"TCS guider #3 system for equinox\""
+    ENDM
+DETCOM_GUIRA3 MACRO ARG
+    COBJ "detcom:dheader 533.23 GUIRA3 \"\ARG\" \"TCS guider #3 right ascension\""
+    ENDM
+DETCOM_GUIDEC3 MACRO ARG
+    COBJ "detcom:dheader 533.24 GUIDEC3 \"\ARG\" \"TCS guider #3 declination\""
+    ENDM
+DETCOM_GUIOBJN3 MACRO ARG
+    COBJ "detcom:dheader 533.3 GUIOBJN3 \"\ARG\" \"TCS guider #3 object name\""
+    ENDM
+DETCOM_GUIFLUX3 MACRO ARG
+    COBJ "detcom:dheader 533.6 GUIFLUX3 \"\ARG\" \"TCS guider #3 flux\""
+    ENDM
+DETCOM_GUINAME4 MACRO ARG
+    COBJ "detcom:dheader 534.1 GUINAME4 \"\ARG\" \"TCS guider #4 identification\""
+    ENDM
+DETCOM_GUIEQUI4 MACRO ARG
+    COBJ "detcom:dheader 534.21 GUIEQUI4 \"\ARG\" \"TCS guider #4 equinox\""
+    ENDM
+DETCOM_GUIRADE4 MACRO ARG
+    COBJ "detcom:dheader 534.22 GUIRADE4 \"\ARG\" \"TCS guider #4 system for equinox\""
+    ENDM
+DETCOM_GUIRA4 MACRO ARG
+    COBJ "detcom:dheader 534.23 GUIRA4 \"\ARG\" \"TCS guider #4 right ascension\""
+    ENDM
+DETCOM_GUIDEC4 MACRO ARG
+    COBJ "detcom:dheader 534.24 GUIDEC4 \"\ARG\" \"TCS guider #4 declination\""
+    ENDM
+DETCOM_GUIOBJN4 MACRO ARG
+    COBJ "detcom:dheader 534.3 GUIOBJN4 \"\ARG\" \"TCS guider #4 object name\""
+    ENDM
+DETCOM_GUIFLUX4 MACRO ARG
+    COBJ "detcom:dheader 534.6 GUIFLUX4 \"\ARG\" \"TCS guider #4 flux\""
+    ENDM
+DETCOM_FOCUSID MACRO ARG
+    COBJ "detcom:dheader 550.0 FOCUSID \"\ARG\" \"Telescope focus in use\""
+    ENDM
+DETCOM_TELCONF MACRO ARG
+    COBJ "detcom:dheader 550.1 TELCONF \"\ARG\" \"Telescope focus in use\""
+    ENDM
+DETCOM_FOCUSPOS MACRO ARG
+    COBJ "detcom:dheader 551.0 FOCUSPOS \"\ARG\" \"Telescope focus encoder readout\""
+    ENDM
+DETCOM_TELFOCUS MACRO ARG
+    COBJ "detcom:dheader 551.1 TELFOCUS \"\ARG\" \"Telescope focus encoder readout\""
+    ENDM
+DETCOM_ISUSTATE MACRO ARG
+    COBJ "detcom:dheader 560.4 ISUSTATE \"\ARG\" \"ISU control state (Off/Only/TCS/Full/Frozen)\""
+    ENDM
+DETCOM_FSASTATE MACRO ARG
+    COBJ "detcom:dheader 570.4 FSASTATE \"\ARG\" \"FSA control state (Off/On/Paused)\""
+    ENDM
+DETCOM_FSANMOVE MACRO ARG
+    COBJ "detcom:dheader 570.5 FSANMOVE \"\ARG\" \"FSA number of actual moves in last 10 minutes\""
+    ENDM
+DETCOM_TCSGPSBC MACRO ARG
+    COBJ "detcom:dheader 580.11 TCSGPSBC \"\ARG\" \"TCS GPS read out in BCD\""
+    ENDM
+DETCOM_TCSRBUSS MACRO ARG
+    COBJ "detcom:dheader 580.13 TCSRBUSS \"\ARG\" \"TCS RBUSS clock time\""
+    ENDM
+DETCOM_TCSEPICS MACRO ARG
+    COBJ "detcom:dheader 580.14 TCSEPICS \"\ARG\" \"TCS EPICS clock time\""
+    ENDM
+DETCOM_TCSAMODE MACRO ARG
+    COBJ "detcom:dheader 580.15 TCSAMODE \"\ARG\" \"TCS acquisition mode - T/O/G/g for t/o/g coords\""
+    ENDM
+DETCOM_TCSENHA MACRO ARG
+    COBJ "detcom:dheader 580.51 TCSENHA \"\ARG\" \"TCS hour angle encoder bits reading\""
+    ENDM
+DETCOM_TCSENDEC MACRO ARG
+    COBJ "detcom:dheader 580.52 TCSENDEC \"\ARG\" \"TCS declination encoder bits reading\""
+    ENDM
+DETCOM_AOBLOOP MACRO ARG
+    COBJ "detcom:dheader 711.0 AOBLOOP \"\ARG\" \"AOB closed loop Open/Closed\""
+    ENDM
+DETCOM_LOOPNES MACRO ARG
+    COBJ "detcom:dheader 713.0 LOOPNES \"\ARG\" \"Loop type \"Nested\"/\"Tip/Tilt\"/\"Single\"\""
+    ENDM
+DETCOM_LOOPOPT MACRO ARG
+    COBJ "detcom:dheader 715.0 LOOPOPT \"\ARG\" \"Optimized loop control True/False\""
+    ENDM
+DETCOM_WFSGOPT MACRO ARG
+    COBJ "detcom:dheader 716.0 WFSGOPT \"\ARG\" \"WFS optical gain\""
+    ENDM
+DETCOM_WFSCOUNT MACRO ARG
+    COBJ "detcom:dheader 722.0 WFSCOUNT \"\ARG\" \"Total flux count on WFS\""
+    ENDM
+DETCOM_ADCPOS MACRO ARG
+    COBJ "detcom:dheader 751.0 ADCPOS \"\ARG\" \"AOB ADC position In/Out\""
+    ENDM
+DETCOM_BEAMSPID MACRO ARG
+    COBJ "detcom:dheader 754.0 BEAMSPID \"\ARG\" \"Beam splitter ID\""
+    ENDM
+DETCOM_BEAMSP MACRO ARG
+    COBJ "detcom:dheader 755.0 BEAMSP \"\ARG\" \"Beam splitter description\""
+    ENDM
+DETCOM_MIRSLIDE MACRO ARG
+    COBJ "detcom:dheader 756.0 MIRSLIDE \"\ARG\" \"AOB mirror slide \"F/20\"/\"F/8\"\""
+    ENDM
+DETCOM_WFSNDID MACRO ARG
+    COBJ "detcom:dheader 757.0 WFSNDID \"\ARG\" \"WFS ND filter position\""
+    ENDM
+DETCOM_FFLAMPON MACRO ARG
+    COBJ "detcom:dheader 910.0 FFLAMPON \"\ARG\" \"flatfield lamp status ON/OFF\""
+    ENDM
+DETCOM_FFLAMP MACRO ARG
+    COBJ "detcom:dheader 911.0 FFLAMP \"\ARG\" \"flatfield lamp intensity\""
+    ENDM
+DETCOM_CLAMP0ON MACRO ARG
+    COBJ "detcom:dheader 920.0 CLAMP0ON \"\ARG\" \"comparison lamp 0 status ON/OFF\""
+    ENDM
+DETCOM_CLAMP0 MACRO ARG
+    COBJ "detcom:dheader 920.1 CLAMP0 \"\ARG\" \"comparison lamp 0 description\""
+    ENDM
+DETCOM_CLAMP1ON MACRO ARG
+    COBJ "detcom:dheader 921.0 CLAMP1ON \"\ARG\" \"comparison lamp 1 status ON/OFF\""
+    ENDM
+DETCOM_CLAMP1 MACRO ARG
+    COBJ "detcom:dheader 921.1 CLAMP1 \"\ARG\" \"comparison lamp 1 description\""
+    ENDM
+DETCOM_CLAMP2ON MACRO ARG
+    COBJ "detcom:dheader 922.0 CLAMP2ON \"\ARG\" \"comparison lamp 2 status ON/OFF\""
+    ENDM
+DETCOM_CLAMP2 MACRO ARG
+    COBJ "detcom:dheader 922.1 CLAMP2 \"\ARG\" \"comparison lamp 2 description\""
+    ENDM
+DETCOM_CLAMP3ON MACRO ARG
+    COBJ "detcom:dheader 923.0 CLAMP3ON \"\ARG\" \"comparison lamp 3 status ON/OFF\""
+    ENDM
+DETCOM_CLAMP3 MACRO ARG
+    COBJ "detcom:dheader 923.1 CLAMP3 \"\ARG\" \"comparison lamp 3 description\""
+    ENDM
+DETCOM_CALIBL0 MACRO ARG
+    COBJ "detcom:dheader 930.0 CALIBL0 \"\ARG\" \"lamp 0 ON/OFF\""
+    ENDM
+DETCOM_CALIBL1 MACRO ARG
+    COBJ "detcom:dheader 931.0 CALIBL1 \"\ARG\" \"lamp 1 ON/OFF\""
+    ENDM
+DETCOM_CALIBL2 MACRO ARG
+    COBJ "detcom:dheader 932.0 CALIBL2 \"\ARG\" \"lamp 2 ON/OFF\""
+    ENDM
+DETCOM_CALIBL3 MACRO ARG
+    COBJ "detcom:dheader 933.0 CALIBL3 \"\ARG\" \"lamp 3 ON/OFF\""
+    ENDM
+DETCOM_CALIBL4 MACRO ARG
+    COBJ "detcom:dheader 934.0 CALIBL4 \"\ARG\" \"lamp 4 ON/OFF\""
+    ENDM
+DETCOM_CALIBL5 MACRO ARG
+    COBJ "detcom:dheader 935.0 CALIBL5 \"\ARG\" \"lamp 5 ON/OFF\""
+    ENDM
+DETCOM_CALIBL6 MACRO ARG
+    COBJ "detcom:dheader 936.0 CALIBL6 \"\ARG\" \"lamp 6 ON/OFF\""
+    ENDM
+DETCOM_CALIBL7 MACRO ARG
+    COBJ "detcom:dheader 937.0 CALIBL7 \"\ARG\" \"lamp 7 ON/OFF\""
+    ENDM
+DETCOM_CALIBL8 MACRO ARG
+    COBJ "detcom:dheader 938.0 CALIBL8 \"\ARG\" \"lamp 8 ON/OFF\""
+    ENDM
+DETCOM_CALIBL9 MACRO ARG
+    COBJ "detcom:dheader 939.0 CALIBL9 \"\ARG\" \"lamp 9 ON/OFF\""
+    ENDM
+DETCOM_FILTERID MACRO ARG
+    COBJ "detcom:dheader 1010.1 FILTERID \"\ARG\" \"wheel position\""
+    ENDM
+DETCOM_FILTER MACRO ARG
+    COBJ "detcom:dheader 1010.2 FILTER \"\ARG\" \"description of filter\""
+    ENDM
+DETCOM_FILTERBW MACRO ARG
+    COBJ "detcom:dheader 1010.3 FILTERBW \"\ARG\" \"filter bandwidth\""
+    ENDM
+DETCOM_FILTERWL MACRO ARG
+    COBJ "detcom:dheader 1010.4 FILTERWL \"\ARG\" \"filter wavelength\""
+    ENDM
+DETCOM_FILTERLB MACRO ARG
+    COBJ "detcom:dheader 1010.5 FILTERLB \"\ARG\" \"lower bound of filter (units/%?)\""
+    ENDM
+DETCOM_FILTERUB MACRO ARG
+    COBJ "detcom:dheader 1010.6 FILTERUB \"\ARG\" \"upper bound of filter (units/%?)\""
+    ENDM
+DETCOM_FILTSLID MACRO ARG
+    COBJ "detcom:dheader 1010.7 FILTSLID \"\ARG\" \"filter drawer number\""
+    ENDM
+DETCOM_WHEELAID MACRO ARG
+    COBJ "detcom:dheader 1020.1 WHEELAID \"\ARG\" \"'wheel' A position\""
+    ENDM
+DETCOM_WHEELADE MACRO ARG
+    COBJ "detcom:dheader 1020.2 WHEELADE \"\ARG\" \"description of filter\""
+    ENDM
+DETCOM_WHEELALB MACRO ARG
+    COBJ "detcom:dheader 1020.5 WHEELALB \"\ARG\" \"lower bound of filter A (units/%?)\""
+    ENDM
+DETCOM_WHEELAUB MACRO ARG
+    COBJ "detcom:dheader 1020.6 WHEELAUB \"\ARG\" \"upper bound of filter A (units/%?)\""
+    ENDM
+DETCOM_WHEELBID MACRO ARG
+    COBJ "detcom:dheader 1030.1 WHEELBID \"\ARG\" \"'wheel' B position\""
+    ENDM
+DETCOM_WHEELBDE MACRO ARG
+    COBJ "detcom:dheader 1030.2 WHEELBDE \"\ARG\" \"description of filter\""
+    ENDM
+DETCOM_WHEELBLB MACRO ARG
+    COBJ "detcom:dheader 1030.5 WHEELBLB \"\ARG\" \"lower bound of filter B (units/%?)\""
+    ENDM
+DETCOM_WHEELBUB MACRO ARG
+    COBJ "detcom:dheader 1030.6 WHEELBUB \"\ARG\" \"upper bound of filter B (units/%?)\""
+    ENDM
+DETCOM_INSTFOC MACRO ARG
+    COBJ "detcom:dheader 1101.0 INSTFOC \"\ARG\" \"internal instrument focus value\""
+    ENDM
+DETCOM_GRISMID MACRO ARG
+    COBJ "detcom:dheader 4101.0 GRISMID \"\ARG\" \"grism position\""
+    ENDM
+DETCOM_GRISM MACRO ARG
+    COBJ "detcom:dheader 4102.0 GRISM \"\ARG\" \"grism description\""
+    ENDM
+DETCOM_GRISSLID MACRO ARG
+    COBJ "detcom:dheader 4103.0 GRISSLID \"\ARG\" \"grism drawer number\""
+    ENDM
+DETCOM_MASKID MACRO ARG
+    COBJ "detcom:dheader 4111.0 MASKID \"\ARG\" \"mask position\""
+    ENDM
+DETCOM_MASK MACRO ARG
+    COBJ "detcom:dheader 4112.0 MASK \"\ARG\" \"mask description\""
+    ENDM
+DETCOM_MASKSLID MACRO ARG
+    COBJ "detcom:dheader 4113.0 MASKSLID \"\ARG\" \"mask slider number\""
+    ENDM
+DETCOM_DISPEL MACRO ARG
+    COBJ "detcom:dheader 4201.0 DISPEL \"\ARG\" \"grating description\""
+    ENDM
+DETCOM_DISPAXIS MACRO ARG
+    COBJ "detcom:dheader 4202.0 DISPAXIS \"\ARG\" \"dispersion axis (1 or 2)\""
+    ENDM
+DETCOM_DISPANG MACRO ARG
+    COBJ "detcom:dheader 4203.0 DISPANG \"\ARG\" \"grating angle in degrees\""
+    ENDM
+DETCOM_WAVELENG MACRO ARG
+    COBJ "detcom:dheader 4204.0 WAVELENG \"\ARG\" \"central wavelength in angstroms\""
+    ENDM
+DETCOM_ORDER MACRO ARG
+    COBJ "detcom:dheader 4205.0 ORDER \"\ARG\" \"spectral order\""
+    ENDM
+DETCOM_GRSETUP MACRO ARG
+    COBJ "detcom:dheader 4206.0 GRSETUP \"\ARG\" \"grating setup constant in degrees\""
+    ENDM
+DETCOM_OPENANG2 MACRO ARG
+    COBJ "detcom:dheader 4207.0 OPENANG2 \"\ARG\" \"setup const in degrees (opening angle / 2)\""
+    ENDM
+DETCOM_GRISMANG MACRO ARG
+    COBJ "detcom:dheader 4208.0 GRISMANG \"\ARG\" \"rel.angle between prisms in degrees\""
+    ENDM
+DETCOM_SLICER MACRO ARG
+    COBJ "detcom:dheader 4210.0 SLICER \"\ARG\" \"image slicer in place\""
+    ENDM
+DETCOM_HART1A MACRO ARG
+    COBJ "detcom:dheader 4221.0 HART1A \"\ARG\" \"hartman mask 1a position OPEN/CLOSED\""
+    ENDM
+DETCOM_HART1B MACRO ARG
+    COBJ "detcom:dheader 4221.1 HART1B \"\ARG\" \"hartman mask 1b position OPEN/CLOSED\""
+    ENDM
+DETCOM_HART2 MACRO ARG
+    COBJ "detcom:dheader 4222.0 HART2 \"\ARG\" \"hartman mask 2 position OPEN/CLOSED\""
+    ENDM
+DETCOM_HART3 MACRO ARG
+    COBJ "detcom:dheader 4223.0 HART3 \"\ARG\" \"hartman mask 3 position OPEN/CLOSED\""
+    ENDM
+DETCOM_HART4 MACRO ARG
+    COBJ "detcom:dheader 4224.0 HART4 \"\ARG\" \"hartman mask 4 position OPEN/CLOSED\""
+    ENDM
+DETCOM_COUDETRN MACRO ARG
+    COBJ "detcom:dheader 4230.0 COUDETRN \"\ARG\" \"coude train color UV/RED/CAFE\""
+    ENDM
+DETCOM_EMFILTER MACRO ARG
+    COBJ "detcom:dheader 4240.0 EMFILTER \"\ARG\" \"exposure meter filter description\""
+    ENDM
+DETCOM_EMCNTS MACRO ARG
+    COBJ "detcom:dheader 4241.0 EMCNTS \"\ARG\" \"exposure meter counts at end\""
+    ENDM
+DETCOM_MIDEXPTM MACRO ARG
+    COBJ "detcom:dheader 4242.0 MIDEXPTM \"\ARG\" \"mid-exposure time (seconds)\""
+    ENDM
+DETCOM_CAFE MACRO ARG
+    COBJ "detcom:dheader 4290.0 CAFE \"\ARG\" \"CAFE is being used Null/INUSE\""
+    ENDM
+DETCOM_AUXINST MACRO ARG
+    COBJ "detcom:dheader 4301.0 AUXINST \"\ARG\" \"fabry perot etalon description\""
+    ENDM
+DETCOM_NUMCHAN MACRO ARG
+    COBJ "detcom:dheader 4303.0 NUMCHAN \"\ARG\" \"number of channels per scan\""
+    ENDM
+DETCOM_CURCHAN MACRO ARG
+    COBJ "detcom:dheader 4304.0 CURCHAN \"\ARG\" \"current channel\""
+    ENDM
+DETCOM_BINVAL MACRO ARG
+    COBJ "detcom:dheader 4305.0 BINVAL \"\ARG\" \"binary control value\""
+    ENDM
+DETCOM_GRFPPOS MACRO ARG
+    COBJ "detcom:dheader 4320.0 GRFPPOS \"\ARG\" \"GriF position of FP carriage - In/Out\""
+    ENDM
+DETCOM_GRWAVORD MACRO ARG
+    COBJ "detcom:dheader 4321.1 GRWAVORD \"\ARG\" \"GriF wavelength of order used to scan\""
+    ENDM
+DETCOM_GRWAVCAL MACRO ARG
+    COBJ "detcom:dheader 4321.2 GRWAVCAL \"\ARG\" \"GriF wavelength of calibration spectral line\""
+    ENDM
+DETCOM_GRBCVCAL MACRO ARG
+    COBJ "detcom:dheader 4321.3 GRBCVCAL \"\ARG\" \"GriF BCV at calibration line\""
+    ENDM
+DETCOM_GRSCANTY MACRO ARG
+    COBJ "detcom:dheader 4322.0 GRSCANTY \"\ARG\" \"GriF type of scan - bcv, wave, velocity\""
+    ENDM
+DETCOM_GRWAVBEG MACRO ARG
+    COBJ "detcom:dheader 4323.1 GRWAVBEG \"\ARG\" \"GriF wavelength at beginning of scan\""
+    ENDM
+DETCOM_GRWAVSTP MACRO ARG
+    COBJ "detcom:dheader 4323.2 GRWAVSTP \"\ARG\" \"GriF wavelength step\""
+    ENDM
+DETCOM_GRWAVCUR MACRO ARG
+    COBJ "detcom:dheader 4323.3 GRWAVCUR \"\ARG\" \"GriF current observed wavelength\""
+    ENDM
+DETCOM_GRBCVBEG MACRO ARG
+    COBJ "detcom:dheader 4324.1 GRBCVBEG \"\ARG\" \"GriF Binary Contol Value at beginning of scan\""
+    ENDM
+DETCOM_GRBCVSTP MACRO ARG
+    COBJ "detcom:dheader 4324.2 GRBCVSTP \"\ARG\" \"GriF BCV step\""
+    ENDM
+DETCOM_GRBCVCUR MACRO ARG
+    COBJ "detcom:dheader 4324.3 GRBCVCUR \"\ARG\" \"GriF applied BCV\""
+    ENDM
+DETCOM_GRNBCHAN MACRO ARG
+    COBJ "detcom:dheader 4325.1 GRNBCHAN \"\ARG\" \"GriF number of channels in scan\""
+    ENDM
+DETCOM_GRCURRCH MACRO ARG
+    COBJ "detcom:dheader 4325.2 GRCURRCH \"\ARG\" \"GriF current channel\""
+    ENDM
+DETCOM_GRBCV_X MACRO ARG
+    COBJ "detcom:dheader 4326.1 GRBCV_X \"\ARG\" \"GriF X Binary Control Value FP\""
+    ENDM
+DETCOM_GRBCV_Y MACRO ARG
+    COBJ "detcom:dheader 4326.2 GRBCV_Y \"\ARG\" \"GriF Y Binary Control Value FP\""
+    ENDM
+DETCOM_CRUNID MACRO ARG
+    COBJ "detcom:dheader 15101.0 CRUNID \"\ARG\" \"Elixir camera run ID\""
+    ENDM
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/Makefile.am
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/Makefile.am	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/Makefile.am	(revision 40918)
@@ -0,0 +1,3 @@
+SUBDIRS = src
+
+CLEANFILES = *~ core core.*
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/autogen.sh
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/autogen.sh	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/autogen.sh	(revision 40918)
@@ -0,0 +1,103 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+PROJECT=ppbgrestore
+TEST_TYPE=-f
+# change this to be a unique filename in the top level dir
+FILE=autogen.sh
+
+DIE=0
+
+LIBTOOLIZE=libtoolize
+ACLOCAL="aclocal $ACLOCAL_FLAGS"
+AUTOHEADER=autoheader
+AUTOMAKE=automake
+AUTOCONF=autoconf
+
+($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $LIBTOOLIZE installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/libtool/"
+        DIE=1
+}
+
+($ACLOCAL --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $ACLOCAL installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
+        DIE=1
+}
+
+($AUTOHEADER --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $AUTOHEADER installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
+        DIE=1
+}
+
+($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $AUTOMAKE installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
+        DIE=1
+}
+
+($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $AUTOCONF installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
+        DIE=1
+}
+
+if test "$DIE" -eq 1; then
+        exit 1
+fi
+
+test $TEST_TYPE $FILE || {
+        echo "You must run this script in the top-level $PROJECT directory"
+        exit 1
+}
+
+if test -z "$*"; then
+        echo "I am going to run ./configure with no arguments - if you wish "
+        echo "to pass any to it, please specify them on the $0 command line."
+fi
+
+$LIBTOOLIZE --copy --force || echo "$LIBTOOLIZE failed"
+$ACLOCAL || echo "$ACLOCAL failed"
+$AUTOHEADER || echo "$AUTOHEADER failed"
+$AUTOMAKE --add-missing --force-missing --copy || echo "$AUTOMAKE failed"
+$AUTOCONF || echo "$AUTOCONF failed"
+
+cd $ORIGDIR
+
+run_configure=true
+for arg in $*; do
+    case $arg in
+        --no-configure)
+            run_configure=false
+            ;;
+        *)
+            ;;
+    esac
+done
+
+if $run_configure; then
+    $srcdir/configure --enable-maintainer-mode "$@"
+    echo
+    echo "Now type 'make' to compile $PROJECT."
+else
+    echo
+    echo "Now run 'configure' and 'make' to compile $PROJECT."
+fi
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/configure.ac
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/configure.ac	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/configure.ac	(revision 40918)
@@ -0,0 +1,46 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_PREREQ(2.61)
+
+AC_INIT([ppbgrestore], [1.0.0], [ipp-support@ifa.hawaii.edu])
+AC_CONFIG_SRCDIR([src])
+
+AM_INIT_AUTOMAKE([1.6 foreign dist-bzip2])
+AM_CONFIG_HEADER([src/config.h])
+AM_MAINTAINER_MODE
+
+IPP_STDLDFLAGS
+
+AC_LANG(C)
+AC_GNU_SOURCE
+AC_PROG_CC_C99
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+AC_SYS_LARGEFILE
+
+dnl ------------------------------------------------------------
+
+AC_PATH_PROG([ERRORCODES], [psParseErrorCodes], [missing])
+if test "$ERRORCODES" = "missing" ; then
+  AC_MSG_ERROR([psParseErrorCodes is required])
+fi
+
+
+PKG_CHECK_MODULES([PSLIB], [pslib >= 1.0.0])
+PKG_CHECK_MODULES([PSMODULE], [psmodules >= 1.0.0])
+PKG_CHECK_MODULES([PSPHOT], [psphot >= 0.9.0])
+
+dnl Set CFLAGS for build
+IPP_STDOPTS
+IPP_STDCFLAGS
+
+IPP_VERSION
+
+AC_SUBST([PPSTAMP_CFLAGS])
+AC_SUBST([PPSTAMP_LIBS])
+
+AC_CONFIG_FILES([
+  Makefile
+  src/Makefile
+])
+
+AC_OUTPUT
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/src/Makefile.am
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/src/Makefile.am	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/src/Makefile.am	(revision 40918)
@@ -0,0 +1,32 @@
+bin_PROGRAMS = ppbgrestore
+
+noinst_HEADERS = \
+	ppbgrestore.h
+
+# Force recompilation of ppbgrestoreVersion.c, since it gets the version information
+ppbgrestoreVersion.c: ppbgrestoreVersionDefinitions.h
+ppbgrestoreVersionDefinitions.h: ppbgrestoreVersionDefinitions.h.in FORCE
+	pslib-setsvnversion.pl PPBGRESTORE ppbgrestoreVersionDefinitions.h.in ppbgrestoreVersionDefinitions.h
+FORCE: ;
+
+
+BUILT_SOURCES = ppbgrestoreVersionDefinitions.h
+
+ppbgrestore_CPPFLAGS = $(PSPHOT_CFLAGS)  $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
+
+ppbgrestore_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS) 
+
+ppbgrestore_SOURCES = \
+	ppbgrestore.c \
+	ppbgrestoreArguments.c \
+	ppbgrestoreCleanup.c \
+	ppbgrestoreLoop.c \
+	ppbgrestoreParseCamera.c \
+	ppbgrestoreVersion.c
+
+clean-local:
+	-rm -f TAGS
+
+# Tags for emacs
+tags:
+	etags `find . -name \*.[ch] -print`
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestore.c
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestore.c	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestore.c	(revision 40918)
@@ -0,0 +1,50 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "ppbgrestore.h"
+
+#define TIMER_TOTAL "PPBGRESTORE_TOTAL"
+
+int main(int argc, char **argv) {
+
+    psLibInit(NULL);
+
+    psTimerStart(TIMER_TOTAL);
+
+    // Parse the configuration and arguments
+    // Open the input image(s)
+    // Determine camera, format from header if not already defined
+    // Construct camera in preparation for reading
+    pmConfig *config = ppbgrestoreArguments(argc, argv);
+    if (config == NULL) {
+        psErrorStackPrint(stderr, "Unable to parse command-line arguments.");
+        ppbgrestoreCleanup(config, NULL);
+        exit(PS_EXIT_CONFIG_ERROR);
+    }
+
+    ppbgrestoreVersionPrint();
+
+    // define recipe options
+    // define the active I/O files
+    ppbgrestoreOptions *options = ppbgrestoreParseCamera(config);
+    if (options == NULL) {
+        psErrorStackPrint(stderr, "Unable to parse camera.");
+        ppbgrestoreCleanup(config, options);
+        exit(PS_EXIT_CONFIG_ERROR);
+    }
+
+    // Image Arithmetic Loop
+    if (!ppbgrestoreLoop(config, options)) {
+        psErrorStackPrint(stderr, "Unable to loop over input");
+        ppbgrestoreCleanup(config, options);
+        exit(PS_EXIT_SYS_ERROR);
+    }
+
+    psLogMsg("ppbgrestore", PS_LOG_INFO, "Complete ppbgrestore run: %f sec\n", psTimerMark(TIMER_TOTAL));
+
+    // Cleaning up
+    ppbgrestoreCleanup(config, options);
+
+    return PS_EXIT_SUCCESS;
+}
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestore.h
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestore.h	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestore.h	(revision 40918)
@@ -0,0 +1,155 @@
+#ifndef PP_BG_RESTORE_H
+#define PP_BG_RESTORE_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <strings.h>  // for strcasecmp
+#include <unistd.h>   // for unlink
+#include "pslib.h"
+#include "psmodules.h"
+#include "psphot.h"
+#include "psastro.h"
+#include "ppStats.h"
+#include "ppbgrestoreVersionDefinitions.h"
+
+// Options for ppbgrestore processing
+typedef struct {
+    // actions which ppbgrestore should perform
+    bool dummy;
+#ifdef notdef
+    bool doMaskBuild;                   // Build internal mask
+    bool doVarianceBuild;               // Build internal variance map
+    bool doMaskBurntool;                // mask potential burntool trails
+    bool doMaskSat;                     // mask saturated pixels
+    bool doMaskLow;                     // mask low pixels
+    bool doMask;                        // Mask bad pixels
+    bool doNonLin;                      // Non-linearity correction
+    bool doOverscan;                    // Overscan subtraction
+    bool doNoiseMap;                    // Bias subtraction
+    bool doBias;                        // Bias subtraction
+    bool doDark;                        // Dark subtraction
+    bool doRemnance;                    // Remnance masking
+    bool doShutter;                     // Shutter correction
+    bool doFlat;                        // Flat-field normalisation
+    bool doPattern;                     // Pattern noise subtraction
+    bool doFringe;                      // Fringe subtraction
+    bool doPhotom;                      // Source identification and photometry
+    bool doBG;                          // Background subtraction
+    bool doAstromChip;                  // per-chip Astrometry
+    bool doAstromMosaic;                // full-mosaic Astrometry
+    bool doStats;                       // call ppStats on the image
+    bool checkCTE;                      // measure pixel-based variance
+    bool applyParity;                   // Apply Cell parities
+
+    bool doCrosstalkMeasure;            // measure crosstalk signal
+    bool doCrosstalkCorrect;            // apply crosstalk correction
+
+    // output files requested
+    bool BaseFITS;
+    bool BaseMaskFITS;
+    bool BaseVarianceFITS;
+
+    bool ChipFITS;
+    bool ChipMaskFITS;
+    bool ChipVarianceFITS;
+
+    bool FPA1FITS;
+    bool FPA2FITS;
+    bool Bin1FITS;
+    bool Bin1JPEG;
+    bool Bin2FITS;
+    bool Bin2JPEG;
+
+    // make values for abstract concepts of masking
+    psImageMaskType maskValue;          // apply this bit-mask to choose masked bits
+    psImageMaskType markValue;          // apply this bit-mask to choose masked bits
+    psImageMaskType satMask;            // Mask value to give saturated pixels
+    psImageMaskType lowMask;            // Mask value to give bad pixels
+    psImageMaskType flatMask;           // Mask value to give bad flat pixels
+    psImageMaskType darkMask;           // Mask value to give bad dark pixels
+    psImageMaskType blankMask;          // Mask value to give blank pixels
+    psImageMaskType burntoolMask;       // Suspect pixels that fall where a burntool trail is expected.
+    // non-linear correction parameters
+    psDataType nonLinearType;
+    psMetadataItem *nonLinearData;
+    void *nonLinearSource;
+
+    // options for the analysis
+    pmOverscanOptions *overscan;        // Overscan options
+    int burntoolTrails;
+    // binning parameters
+    int xBin1;                          // x-binning, scale 1
+    int yBin1;                          // y-binning, scale 1
+    int xBin2;                          // x-binning, scale 2
+    int yBin2;                          // y-binning, scale 2
+
+    // parameters used by the fringe analysis
+    float fringeRej;                    // Fringe rejection limit
+    int fringeIter;                     // Fringe iterations
+    float fringeKeep;                   // Fringe keep fraction
+
+    // Pattern noise subtraction
+    int patternOrder;                   // Polynomial order
+    int patternIter;                    // Clipping iterations
+    float patternRej;                   // Clipping threshold
+    float patternThresh;                // Ignore threshold
+    psStatsOptions patternMean;         // Statistic for mean
+    psStatsOptions patternStdev;        // Statistic for stdev
+
+    int remnanceSize;                   // Size for remnance detection
+    float remnanceThresh;               // Threshold for remnance detection
+
+    char *normClass;                    // class to use for per-class normalization
+#endif
+} ppbgrestoreOptions;
+
+
+ppbgrestoreOptions *ppbgrestoreOptionsAlloc(void);
+
+// Determine the processing options
+ppbgrestoreOptions *ppbgrestoreOptionsParse(pmConfig *config);
+
+// Get the configuration
+pmConfig *ppbgrestoreArguments(int argc, char **argv);
+
+// Determine what type of camera, and initialise
+ppbgrestoreOptions *ppbgrestoreParseCamera(pmConfig *config);
+
+// Loop over the input
+bool ppbgrestoreLoop(pmConfig *config, ppbgrestoreOptions *options);
+
+// free memory, check for leaks
+void ppbgrestoreCleanup (pmConfig *config, ppbgrestoreOptions *options);
+
+// Subtract background from the chip-mosaicked image
+bool ppbgrestoreRestoreBackground(
+    pmConfig *config,                   // Configuration
+    const pmFPAview *view,              // View to chip of interest
+    const ppbgrestoreOptions *options       // Processing options
+    );
+
+
+/// Return short version information
+psString ppbgrestoreVersion(void);
+
+/// Return software source
+psString ppbgrestoreSource(void);
+
+/// Return long version information
+psString ppbgrestoreVersionLong(void);
+
+/// Populate the header with version information for all dependencies
+bool ppbgrestoreVersionHeader(psMetadata *metadata ///< Header to populate
+    );
+
+/// Print version information
+void ppbgrestoreVersionPrint(void);
+
+
+void ppbgrestoreFileCheck(pmConfig *config);
+
+#endif
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreArguments.c
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreArguments.c	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreArguments.c	(revision 40918)
@@ -0,0 +1,47 @@
+#include "ppbgrestore.h"
+
+void usage()
+{
+    fprintf(stderr, "USAGE: ppbgrestore [-file INPUT.fits] | [-list INPUT.txt] [-backmdl BACKMDL.fits] | [-backmdllist BACKMDL.txt] OUTPUT\n\n");
+    exit(2);
+}   
+pmConfig *ppbgrestoreArguments(int argc, char *argv[])
+{
+    int argnum;
+    if (argc == 1) {
+        usage();
+    }
+
+    if (psArgumentGet(argc, argv, "-version")) {
+        ppbgrestoreVersionPrint();
+        exit(0);
+    }
+
+    pmConfig *config = pmConfigRead(&argc, argv, NULL);
+    if (config == NULL) {
+        psErrorStackPrint(stderr, "Can't find site configuration!\n");
+        exit(EXIT_FAILURE);
+    }
+
+    // the input file is a required argument if not found we will exit
+    if (!pmConfigFileSetsMD(config->arguments, &argc, argv, "INPUT", "-file", "-list")) {
+        fprintf(stderr, "input file is required\n");
+        usage();
+    }
+    if (!pmConfigFileSetsMD(config->arguments, &argc, argv, "BACKMDL", "-backmdl", "-backmdllist")) {
+        fprintf(stderr, "backmdl file is required\n");
+        usage();
+    }
+
+    if ((argnum = psArgumentGet(argc, argv, "-savebg"))) {
+        psArgumentRemove(argnum, &argc, argv);
+        psMetadataAddBool(config->arguments, PS_LIST_TAIL, "SAVE_BACKGROUND", 0, "save background innmage", true);
+    }
+
+    if (argc != 2) usage ();
+
+    // Add the input and output images (which remain on the command-line) to the arguments list
+    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[1]);
+
+    return config;
+}
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreCleanup.c
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreCleanup.c	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreCleanup.c	(revision 40918)
@@ -0,0 +1,26 @@
+#include "ppbgrestore.h"
+
+void ppbgrestoreCleanup(pmConfig *config, ppbgrestoreOptions *options)
+{
+    // Free memory used by ppbgrestore
+    psFree(options);
+    psFree(config);
+
+    // Free memory used by psModules
+    pmSourceFitSetDone ();
+    pmConceptsDone();
+    pmConfigDone();
+    pmModelClassCleanup();
+
+    // Free memory used by psLib
+    psLibFinalize();
+
+    // psMemBlock **memblocks;
+    // int Nleaks = psMemCheckLeaks (0, &memblocks, stderr, false);
+    // fprintf (stderr, "Found %d leaks at %s\n", Nleaks, "ppImage");
+
+    // fprintf(stderr, "Found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "ppImage");
+
+//    fprintf(stderr, "Found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "ppbgrestore");
+
+}
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreLoop.c
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreLoop.c	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreLoop.c	(revision 40918)
@@ -0,0 +1,184 @@
+#include "ppbgrestore.h"
+#include "psphot.h"
+
+#define ESCAPE(MESSAGE) { \
+  psError(PS_ERR_UNKNOWN, false, MESSAGE); \
+  psFree(view); \
+  return false; \
+}
+
+
+bool ppbgrestoreLoop(pmConfig *config, ppbgrestoreOptions *options)
+{
+    bool status;                        // Status of MD lookup
+    pmFPAfile *input = psMetadataLookupPtr(&status, config->files, "PPBGRESTORE.INPUT");
+    if (!status) {
+        psErrorStackPrint(stderr, "Can't find input data!\n");
+        ppbgrestoreCleanup(config, options);
+        exit(PS_EXIT_PROG_ERROR);
+    }
+    pmFPAfile *backmdl = psMetadataLookupPtr(&status, config->files, "PPBGRESTORE.BACKMDL");
+    if (!status) {
+        psErrorStackPrint(stderr, "Can't find background model data!\n");
+        ppbgrestoreCleanup(config, options);
+        exit(PS_EXIT_PROG_ERROR);
+    }
+    pmFPAfile *output= psMetadataLookupPtr(&status, config->files, "PPBGRESTORE.OUTPUT");
+    if (!status) {
+        psErrorStackPrint(stderr, "Can't find output data!\n");
+        ppbgrestoreCleanup(config, options);
+        exit(PS_EXIT_PROG_ERROR);
+    }
+    pmFPAfile *background= psMetadataLookupPtr(&status, config->files, "PPBGRESTORE.BACKGROUND");
+    if (!status) {
+        psErrorStackPrint(stderr, "Can't find output data!\n");
+        ppbgrestoreCleanup(config, options);
+        exit(PS_EXIT_PROG_ERROR);
+    }
+    bool save_background = psMetadataLookupBool(&status, config->arguments, "SAVE_BACKGROUND");
+
+    pmFPAview *view = pmFPAviewAlloc(0);// View for level of interest
+//    pmHDU *lastHDU = NULL;              // Last HDU that was updated
+
+    // files associated with the science image
+    if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
+        ESCAPE("load failure for FPA");
+    }
+
+    pmChip *chip;                       // Chip from FPA
+    while ((chip = pmFPAviewNextChip(view, input->fpa, 1)) != NULL) {
+        psLogMsg ("ppbgrestoreLoop", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
+        if (!chip->process || !chip->file_exists) {
+            continue;
+        }
+        if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
+            ESCAPE("load failure for Chip");
+        }
+
+        // much of the following is adapted from ppImageSubtractBackground
+
+        if (chip->cells->n == 0) {
+            psError(PS_ERR_UNKNOWN, true, "Chip has no cells");
+            return false;
+        }
+
+        if (chip->cells->n > 1) {
+            psError(PS_ERR_UNKNOWN, true, "Chip has too many cells: %ld", chip->cells->n);
+            return false;
+        }
+        pmCell *cell = chip->cells->data[0]; // Cell of interest
+        if (!cell || !cell->process || !cell->file_exists) {
+            // Nothing to process
+            return false;
+        }
+        if (cell->readouts->n == 0) {
+            psError(PS_ERR_UNKNOWN, true, "Cell has no readouts");
+            return false;
+        }
+        if (cell->readouts->n > 1) {
+            psWarning("Cell has %ld readouts; only the first will be processed", cell->readouts->n);
+        }
+        pmReadout *ro = cell->readouts->data[0]; // Readout of interest
+        if (!ro || !ro->data_exists) {
+            psError(PS_ERR_UNKNOWN, true, "readout has no data");
+            return false;
+        }
+        psImage *image = ro->image;
+//        psImage *mask = NULL;
+//        psImageMaskType maskVal = 0;
+
+        pmFPAview roView = *view;
+        roView.cell = 0;
+        roView.readout = 0;
+        pmReadout *modelRO = pmFPAviewThisReadout(&roView, backmdl->fpa);
+        if (!modelRO || !modelRO->data_exists) {
+            psError(PS_ERR_UNKNOWN, true, "model readout has no data");
+            return false;
+        }
+        output->save = true;
+        background->save = save_background;
+
+        psImageBinning *binning = psphotBackgroundBinning(image, config);
+        if (!binning) {
+            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find background binning");
+            return false;
+        }
+        pmReadout *backgroundRO;
+#define USE_CELL
+#ifdef USE_CELL
+        pmCell *backgroundCell = pmFPAviewThisCell(&roView, background->fpa);
+        backgroundRO = pmReadoutAlloc(backgroundCell);
+#else
+        backgroundRO = pmFPAviewThisReadout(&roView, background->fpa);
+//        backgroundRO = pmFPAfileDefineInternal (config->files, "PSPHOT.BACKGND", image->numCols, image->numRows, PS_TYPE_F32);
+#endif
+        backgroundRO->image = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32);
+	backgroundRO->data_exists = true;
+	backgroundRO->parent->data_exists = true;
+	backgroundRO->parent->parent->data_exists = true;
+
+        // linear interpolation to full-scale
+        if (!psImageUnbin (backgroundRO->image, modelRO->image, binning)) {
+            psError (PSPHOT_ERR_PROG, true, "inconsistent sizes for unbinning");
+            psFree(binning);
+            return false;
+        }
+        psFree(binning);
+        psF32 **backData = backgroundRO->image->data.F32;
+
+        // Undo the background subtraction
+        int numCols = image->numCols, numRows = image->numRows; // Size of image
+        long nancount = 0;
+        long naninputs = 0;
+        long finitecount = 0;
+        for (int y = 0; y < numRows; y++) {
+            for (int x = 0; x < numCols; x++) {
+                float imageval =  image->data.F32[y][x] ;
+                float bgvalue = backData[y][x];
+                if (!isfinite(bgvalue)) {
+                    // if background is NAN leave the image unchanged
+                    // According to ppImageSubtractBackground pixels where the background is not finite should be NAN
+                    // experimentally
+                    // for breakpoint
+                    nancount++;
+                    if (isfinite(imageval)) {
+                         finitecount++;
+                         //   psWarning("unexpected finite image value %f found at %d %d background is infinite", imageval, x, y);
+                    }
+                    //      Doing this is causes a lot of new NAN pixels to appear.
+                    //      NANS are appearing in the model for some reason.
+                    //      image->data.F32[y][x] = NAN;
+                } else if (isfinite(imageval)) {
+                    // XXX: TODO:following ppImage we should not modify pixels that are masked.
+                    image->data.F32[y][x] = imageval + bgvalue;
+                } else {
+		    naninputs++;
+		}
+            }
+        }
+        if (naninputs) {
+            printf("%ld infinite pixels found in input image\n", naninputs);
+        }
+        if (nancount) {
+            psWarning("%ld infinite pixels found in background %ld pixels were finite\n", nancount, finitecount);
+        }
+//        pmFPAfileDropInternal(config->files, "PSPHOT.BACKGND");
+
+        // Close chip
+        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
+            ESCAPE("save failure for Chip");
+        }
+    }
+
+    if (psTraceGetLevel("ppbgrestore") >= 3) {
+//        ppbgrestoreFileCheck(config);
+    }
+
+    // Output and Close FPA
+    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
+        ESCAPE("save failure for FPA");
+    }
+    psFree(view);
+
+    return true;
+}
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreParseCamera.c
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreParseCamera.c	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreParseCamera.c	(revision 40918)
@@ -0,0 +1,38 @@
+#include "ppbgrestore.h"
+
+ppbgrestoreOptions *ppbgrestoreParseCamera(pmConfig *config)
+{
+    ppbgrestoreOptions *options = psAlloc(sizeof(*options));
+    bool status;
+
+    memset(options, 0, sizeof(*options));
+
+    pmFPAfile *input = pmFPAfileDefineFromArgs(&status, config, "PPBGRESTORE.INPUT", "INPUT");
+    if (!input) {
+        psFree(options);
+        psError(PS_ERR_UNKNOWN, false, "failed to define input file");
+        return NULL;
+    }
+    pmFPAfile *backmdl = pmFPAfileDefineFromArgs(&status, config, "PPBGRESTORE.BACKMDL", "BACKMDL");
+    if (!backmdl) {
+        psFree(options);
+        psError(PS_ERR_UNKNOWN, false, "failed to define background model file");
+        return NULL;
+    }
+    // pmFPAfile *outImage = pmFPAfileDefineOutput(config, input->fpa, "PPBGRESTORE.OUTPUT");
+    pmFPAfile *outImage = pmFPAfileDefineOutput(config, input->fpa, "PPBGRESTORE.OUTPUT");
+    if (!outImage) {
+        psError(PS_ERR_IO, false, _("Unable to generate output file from PPBGRESTORE.OUTPUT"));
+        psFree(options);
+        return NULL;
+    }
+    // pmFPAfile *outBG = pmFPAfileDefineOutput(config, NULL, "PPBGRESTORE.BACKGROUND");
+    pmFPAfile *outBG = pmFPAfileDefineFromFPA(config, input->fpa, 1, 1, "PPBGRESTORE.BACKGROUND");
+    if (!outBG) {
+        psError(PS_ERR_IO, false, _("Unable to generate bacgkround file from PPBGRESTORE.BACKGROUND"));
+        psFree(options);
+        return NULL;
+    }
+
+    return options;
+}
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreVersion.c
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreVersion.c	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreVersion.c	(revision 40918)
@@ -0,0 +1,106 @@
+#include "ppbgrestore.h"
+
+#ifndef PPBGRESTORE_VERSION
+#error "PPBGRESTORE_VERSION is not set"
+#endif
+#ifndef PPBGRESTORE_BRANCH
+#error "PPBGRESTORE_BRANCH is not set"
+#endif
+#ifndef PPBGRESTORE_SOURCE
+#error "PPBGRESTORE_SOURCE is not set"
+#endif
+
+psString ppbgrestoreVersion(void)
+{
+    char *value = NULL;
+    psStringAppend(&value, "%s@%s", PPBGRESTORE_BRANCH, PPBGRESTORE_VERSION);
+    return value;
+}
+
+psString ppbgrestoreSource(void)
+{
+    return psStringCopy(PPBGRESTORE_SOURCE);
+}
+
+psString ppbgrestoreVersionLong(void)
+{
+    psString version = ppbgrestoreVersion();  // Version, to return
+    psString source = ppbgrestoreSource(); // Source
+
+    psStringPrepend(&version, "ppbgrestore ");
+    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
+    psFree(source);
+
+#ifdef __OPTIMIZE__
+    psStringAppend(&version, " optimised");
+#else
+    psStringAppend(&version, " unoptimised");
+#endif
+
+    return version;
+};
+
+bool ppbgrestoreVersionHeader(psMetadata *header)
+{
+#ifdef notyet
+    PS_ASSERT_METADATA_NON_NULL(header, false);
+
+    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
+    psString timeString = psTimeToISO(time); // The time in an ISO string
+    psFree(time);
+    psString history = NULL;               // History string
+    psStringAppend(&history, "ppbgrestore at %s", timeString);
+    psFree(timeString);
+    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, history);
+    psFree(history);
+
+    psLibVersionHeader(header);
+    psModulesVersionHeader(header);
+    psphotVersionHeader(header);
+    psastroVersionHeader(header);
+    ppStatsVersionHeader(header);
+
+    psString version = ppbgrestoreVersion(); // ppbgrestore software version
+    psString source  = ppbgrestoreSource();  // ppbgrestore software source
+
+    psMetadataAddStr(header, PS_LIST_TAIL, "BGREST_V", PS_META_REPLACE, NULL, PPBGRESTORE_VERSION);
+	
+    psStringPrepend(&version, "ppbgrestore version: ");
+    psStringPrepend(&source, "ppbgrestore source: ");
+
+    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, version);
+    psMetadataAddStr(header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, NULL, source);
+
+    psFree(version);
+    psFree(source);
+#endif // notyet
+
+    return true;
+}
+
+
+void ppbgrestoreVersionPrint(void)
+{
+    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now
+    psString timeString = psTimeToISO(time); // The time in an ISO string
+    psFree(time);
+    psLogMsg("ppbgrestore", PS_LOG_INFO, "ppbgrestore at %s", timeString);
+    psFree(timeString);
+
+    psString pslib = psLibVersionLong();// psLib version
+    psString psmodules = psModulesVersionLong(); // psModules version
+    psString psphot = psphotVersionLong(); // psphot version
+    psString ppbgrestore = ppbgrestoreVersionLong(); // ppbgrestore version
+
+    psLogMsg("ppbgrestore", PS_LOG_INFO, "%s", pslib);
+    psLogMsg("ppbgrestore", PS_LOG_INFO, "%s", psmodules);
+    psLogMsg("ppbgrestore", PS_LOG_INFO, "%s", psphot);
+    psLogMsg("ppbgrestore", PS_LOG_INFO, "%s", ppbgrestore);
+
+    psFree(pslib);
+    psFree(psmodules);
+    psFree(psphot);
+    psFree(ppbgrestore);
+
+    return;
+}
Index: /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreVersionDefinitions.h.in
===================================================================
--- /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreVersionDefinitions.h.in	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/ppbgrestore/src/ppbgrestoreVersionDefinitions.h.in	(revision 40918)
@@ -0,0 +1,9 @@
+#ifndef PPBGRESTORE_VERSION_DEFINITIONS_H
+#define PPBGRESTORE_VERSION_DEFINITIONS_H
+
+#define PPBGRESTORE_VERSION @PPBGRESTORE_VERSION@ // SVN version
+#define PPBGRESTORE_BRANCH  @PPBGRESTORE_BRANCH@  // SVN branch
+#define PPBGRESTORE_SOURCE  @PPBGRESTORE_SOURCE@  // SVN source
+
+#endif
+
Index: /branches/ccl_branches/ipp-20190806/simtest/Makefile.am
===================================================================
--- /branches/ccl_branches/ipp-20190806/simtest/Makefile.am	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/simtest/Makefile.am	(revision 40918)
@@ -0,0 +1,15 @@
+
+install_files = \
+	sim.pro \
+	images.pro
+
+installdir = $(datadir)/pantasks/modules
+
+install_DATA = $(install_files)
+
+install-data-hook:
+	chmod 0755 $(installdir) 
+
+EXTRA_DIST = $(install_files)
+
+ACLOCAL_AMFLAGS = -I m4
Index: /branches/ccl_branches/ipp-20190806/simtest/autogen.sh
===================================================================
--- /branches/ccl_branches/ipp-20190806/simtest/autogen.sh	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/simtest/autogen.sh	(revision 40918)
@@ -0,0 +1,103 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+PROJECT=simtest
+TEST_TYPE=-f
+# change this to be a unique filename in the top level dir
+FILE=autogen.sh
+
+DIE=0
+
+LIBTOOLIZE=libtoolize
+ACLOCAL="aclocal $ACLOCAL_FLAGS"
+AUTOHEADER=autoheader
+AUTOMAKE=automake
+AUTOCONF=autoconf
+
+#($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
+#        echo
+#        echo "You must have $LIBTOOLIZE installed to compile $PROJECT."
+#        echo "Download the appropriate package for your distribution,"
+#        echo "or get the source tarball at http://ftp.gnu.org/gnu/libtool/"
+#        DIE=1
+#}
+
+($ACLOCAL --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $ACLOCAL installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
+        DIE=1
+}
+
+#($AUTOHEADER --version) < /dev/null > /dev/null 2>&1 || {
+#        echo
+#        echo "You must have $AUTOHEADER installed to compile $PROJECT."
+#        echo "Download the appropriate package for your distribution,"
+#        echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
+#        DIE=1
+#}
+
+($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $AUTOMAKE installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/automake/"
+        DIE=1
+}
+
+($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have $AUTOCONF installed to compile $PROJECT."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at http://ftp.gnu.org/gnu/autoconf/"
+        DIE=1
+}
+
+if test "$DIE" -eq 1; then
+        exit 1
+fi
+
+test $TEST_TYPE $FILE || {
+        echo "You must run this script in the top-level $PROJECT directory"
+        exit 1
+}
+
+if test -z "$*"; then
+        echo "I am going to run ./configure with no arguments - if you wish "
+        echo "to pass any to it, please specify them on the $0 command line."
+fi
+
+#$LIBTOOLIZE --copy --force || echo "$LIBTOOLIZE failed"
+$ACLOCAL || echo "$ACLOCAL failed"
+#$AUTOHEADER || echo "$AUTOHEADER failed"
+$AUTOMAKE --add-missing --force-missing --copy || echo "$AUTOMAKE failed"
+$AUTOCONF || echo "$AUTOCONF failed"
+
+cd $ORIGDIR
+
+run_configure=true
+for arg in $*; do
+    case $arg in
+        --no-configure)
+            run_configure=false
+            ;;
+        *)
+            ;;
+    esac
+done
+
+if $run_configure; then
+    $srcdir/configure --enable-maintainer-mode "$@"
+    echo
+    echo "Now type 'make' to compile $PROJECT."
+else
+    echo
+    echo "Now run 'configure' and 'make' to compile $PROJECT."
+fi
Index: /branches/ccl_branches/ipp-20190806/simtest/configure.ac
===================================================================
--- /branches/ccl_branches/ipp-20190806/simtest/configure.ac	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/simtest/configure.ac	(revision 40918)
@@ -0,0 +1,17 @@
+AC_PREREQ(2.59)
+
+AC_INIT([simtest], [0.9.0], [ipp-support@ifa.hawaii.edu])
+AC_CONFIG_SRCDIR([sim.pro])
+
+AM_INIT_AUTOMAKE([1.6 foreign dist-bzip2])
+AM_MAINTAINER_MODE
+
+AC_PROG_INSTALL
+
+MODULE_DIR="${datadir}/pantasks/modules"
+AC_SUBST(MODULE_DIR)
+
+AC_CONFIG_FILES([
+  Makefile
+])
+AC_OUTPUT
Index: /branches/ccl_branches/ipp-20190806/simtest/images.pro
===================================================================
--- /branches/ccl_branches/ipp-20190806/simtest/images.pro	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/simtest/images.pro	(revision 40918)
@@ -0,0 +1,210 @@
+
+# set global parameters for the simulations
+macro mkimages.init
+ if ($0 != 7)
+  echo "USAGE: mkimage.empty (Nx) (Ny) (RDNOISE) (SKY) (Nstars) (psfSigma)"
+  break
+ end
+
+ $mkiNx = $1
+ $mkiNy = $2
+ $mkiRD = $3
+ $mkiSKY = $4
+ $mkiPSFsigma = $6
+
+ gaussdev mki_noisev {$mkiNx*$mkiNy} 0.0 1.0
+ dimenup mki_noisev mki_noisei $mkiNx $mkiNy
+ mcreate blank $mkiNx $mkiNy
+end
+
+# generate a fake image with bias and sky, no stars
+macro mkimage.empty
+ if ($0 != 2)
+  echo "USAGE: mkimage.empty (buffer)"
+  break
+ end
+
+ set $1 = blank + $mkiRD*mki_noisei + sqrt($mkiSKY)*mki_noisei + $mkiSKY
+end
+
+# set global parameters for the simulations
+macro mkimages.stars
+ if ($0 != 7)
+  echo "USAGE: mkimage.empty (Nx) (Ny) (RDNOISE) (SKY) (Nstars) (psfSigma)"
+  break
+ end
+
+ $mkiNx = $1
+ $mkiNy = $2
+ $mkiRD = $3
+ $mkiSKY = $4
+ $mkiPSFsigma = $6
+
+ gaussdev mki_noisev {$mkiNx*$mkiNy} 0.0 1.0
+ dimenup mki_noisev mki_noisei $mkiNx $mkiNy
+ mcreate blank $mkiNx $mkiNy
+
+ # mkstars $5 0.6
+ mkstars $5 0.4
+ # mkstars $5 0.3
+end
+
+# generate a fake image with bias, sky, stars, gaussian PFS
+macro mkimage.stars.gauss
+ if ($0 != 2)
+  echo "USAGE: mkimage.stars (buffer)"
+  break
+ end
+
+ set _tmp.stars = mki_stars_image
+
+ mkimage.smooth _tmp.stars _tmp.smooth $mkiPSFsigma mkgauss
+
+ # noise sigma = sqrt (_tmp.smooth + $mkiRD^2 + $mkiSKY)
+ set $1 = _tmp.smooth + $mkiSKY + sqrt(_tmp.smooth + $mkiSKY + $mkiRD^2)*mki_noisei
+end
+
+# generate a fake image with bias, sky, stars, gaussian PFS
+macro mkimage.stars.power
+ if ($0 != 2)
+  echo "USAGE: mkimage.stars (buffer)"
+  break
+ end
+
+ set _tmp.stars = mki_stars_image
+
+ mkimage.smooth _tmp.stars _tmp.smooth $mkiPSFsigma mkpower
+
+ # noise sigma = sqrt (_tmp.smooth + $mkiRD^2 + $mkiSKY)
+ set $1 = _tmp.smooth + $mkiSKY + sqrt(_tmp.smooth + $mkiSKY + $mkiRD^2)*mki_noisei
+end
+
+# generate a fake image with bias, sky, stars, gaussian PFS
+macro mkimage.stars.wing
+ if ($0 != 2)
+  echo "USAGE: mkimage.stars (buffer)"
+  break
+ end
+
+ set _tmp.stars = mki_stars_image
+
+ mkimage.smooth _tmp.stars _tmp.smooth $mkiPSFsigma mkwing
+
+ # noise sigma = sqrt (_tmp.smooth + $mkiRD^2 + $mkiSKY)
+ set $1 = _tmp.smooth + $mkiSKY + sqrt(_tmp.smooth + $mkiSKY + $mkiRD^2)*mki_noisei
+end
+
+# generate the vectors of star coordinates, fluxes and magnitudes
+macro mkstars
+ if ($0 != 3)
+   echo "USAGE: mkstars (Nstars) (alpha)"
+   break
+ end
+
+ local sigma alpha Nstars
+ $Nstars = $1
+ $alpha = $2
+ # alpha is dlogN/dmag = 0.6 for N ~ S^-3/2
+
+ # $sigma is flux of star with S/N = 1 (sigma_sky * 4pi sigma_psf^2)
+ $sigma = sqrt($mkiRD^2 + $mkiSKY) * 4*3.1416*$mkiPSFsigma^2
+ 
+ # faintest magnitudes:
+ # include stars down to 1 sigma
+ $M1 = -2.5*log($sigma)
+
+ # brightest magnitude in sim
+ $M0 = $M1 - log($alpha*$Nstars/0.43)/$alpha
+
+ create _tmp 0 $Nstars
+ set mki_stars_x = $mkiNx * rnd(_tmp)
+ set mki_stars_y = $mkiNy * rnd(_tmp)
+
+ # random variable between 0 and Nstars
+ set _tmpvar = $Nstars * rnd(_tmp)
+
+ # random mags drawn from random variable
+ set mki_stars_mag = $M0 + log(_tmpvar*$alpha/0.43)/$alpha
+
+ set mki_stars_flux = ten(-0.4*mki_stars_mag)
+ sort mki_stars_mag mki_stars_flux mki_stars_x mki_stars_y
+
+ # insert the stars
+ mcreate mki_stars_image $mkiNx $mkiNy
+ for i 0 $Nstars
+   zap mki_stars_image mki_stars_x[$i] mki_stars_y[$i] 1 1 -v mki_stars_flux[$i]
+ end
+end
+
+####
+macro mkimage.smooth
+ if ($0 != 5)
+   echo "USAGE: smooth (in) (out) (sigma) (func)"
+   break
+ end
+ fft2d $1 0 to sm_I_r sm_I_i
+ set sm_g = zero($1)
+ keyword sm_g NAXIS1 SMnx
+ keyword sm_g NAXIS2 SMny
+ $4 sm_g $3 -c 0 0
+ $4 sm_g $3 -c $SMnx 0
+ $4 sm_g $3 -c 0 $SMny
+ $4 sm_g $3 -c $SMnx $SMny
+ stats -q sm_g - - - -
+ set sm_g = sm_g/$TOTAL
+ fft2d sm_g 0 to sm_G_r sm_G_i
+ set sm_r = sm_G_r*sm_I_r - sm_G_i*sm_I_i
+ set sm_i = sm_G_r*sm_I_i + sm_G_i*sm_I_r
+ fft2d -inverse sm_r sm_i to sm_I_r sm_I_i
+
+ set $2 = sm_I_r*$SMnx*$SMny*$SMnx*$SMny
+
+ if (1)
+  delete sm_I_r 
+  delete sm_I_i
+  delete sm_G_r 
+  delete sm_G_i
+  delete sm_r
+  delete sm_i
+  delete sm_g
+ end
+end
+
+macro mkpower
+ if ($0 != 6)
+  echo "USAGE: mkpower (buffer) (sigma) -c X Y"
+  break
+ end
+
+ delete -q tmp
+
+ keyword $1 NAXIS1 tmpnx
+ keyword $1 NAXIS2 tmpny
+ mcreate tmp $tmpnx $tmpny
+ set tmpx = xramp(tmp) - $4
+ set tmpy = yramp(tmp) - $5
+
+# $sigma_y = $2 * $AxisRatio
+# $sigma_xy = dsin(2*$Theta)*(
+
+ set tmpz = tmpx^2 / (2 * $2^2) + tmpy^2 / (2 * $2^2)
+ set $1 = $1 + 1 / (1 + tmpz + tmpz^2.5)
+end
+
+macro mkwing
+ if ($0 != 6)
+  echo "USAGE: mkpower (buffer) (sigma) -c X Y"
+  break
+ end
+
+ delete -q tmp
+
+ keyword $1 NAXIS1 tmpnx
+ keyword $1 NAXIS2 tmpny
+ mcreate tmp $tmpnx $tmpny
+ set tmpx = xramp(tmp) - $4
+ set tmpy = yramp(tmp) - $5
+
+ set tmpz = tmpx^2 / (2 * $2^2) + tmpy^2 / (2 * $2^2)
+ set $1 = $1 + 1 / (1 + tmpz + tmpz^2)
+end
Index: /branches/ccl_branches/ipp-20190806/simtest/sim.pro
===================================================================
--- /branches/ccl_branches/ipp-20190806/simtest/sim.pro	(revision 40918)
+++ /branches/ccl_branches/ipp-20190806/simtest/sim.pro	(revision 40918)
@@ -0,0 +1,262 @@
+### Generate simulated test data for testing the Image Processing Pipeline
+
+module images.pro
+
+$flatlevel = 1000
+$biaslevel = 500
+$skyrate  = 200
+$darkrate = 100
+$shutter = 0.5
+
+macro cleanup
+  exec rm -f *.fit
+  exec rm -f *.jpg
+  exec rm -f *.fits
+  exec rm -rf logs
+end
+
+$simdir = `ipp_datapath.pl path://SIMTEST`
+
+macro init
+  exec pxadmin -delete -dbname simtest
+  exec pxadmin -create -dbname simtest
+  exec mkdir -p $simdir/raw
+  exec mkdir -p $simdir/proc
+  mkbiases
+  mkdarks
+  mkshutter
+  mkflats
+  mkobjects
+  exec ipp_serial_inject.pl $simdir/raw/*.fits --workdir path://SIMTEST/proc --dbname simtest
+end
+
+### create a bias detrun:
+# exec dettool -pretend -definebyquery -inst SIMTEST -filter NONE -det_type bias -select_exp_type bias -workdir path://SIMTEST/mkbias.0 -dbname simtest
+
+### If something goes wrong:
+# exec dettool -updatedetrun -det_id 1 -state stop -dbname simtest
+
+### create a dark detrun:
+# exec dettool -pretend -definebyquery -inst SIMTEST -filter NONE -det_type dark -select_exp_type dark -workdir path://SIMTEST/mkdark.0 -dbname simtest
+
+### create a shutter detrun:
+# exec dettool -pretend -definebyquery -inst SIMTEST -filter NONE -det_type shutter -select_exp_type shutter -workdir path://SIMTEST/mkshutter.0 -dbname simtest
+
+### create a flat detrun:
+# exec dettool -pretend -definebyquery -inst SIMTEST -filter B -det_type flat -select_exp_type flat -select_filter B -workdir path://SIMTEST/mkflat.0 -dbname simtest 
+# exec dettool -pretend -definebyquery -inst SIMTEST -filter V -det_type flat -select_exp_type flat -select_filter V -workdir path://SIMTEST/mkflat.1 -dbname simtest 
+
+# generate a set of fake biases
+macro mkbiases
+  echo "generating 10 bias images"
+  for i 0 10
+    mkimages.init 1024 1024 5 1000 0 2.0
+    set bias = blank + $mkiRD*mki_noisei + $biaslevel
+    keyword bias AIRMASS  -wf {1 + 0.1*$i}
+    keyword bias FILTER   -w NONE
+    keyword bias POSANGLE -wf 0.0
+    keyword bias RA       -wf 0.0
+    keyword bias DEC      -wf 0.0
+    keyword bias EXPTIME  -wf 0.0
+    keyword bias DARKTIME -wf 0.0
+    keyword bias DATE-OBS -w "2006/10/01"
+    sprintf time "00:00:%02d" $i
+    keyword bias UTC-OBS  -w $time
+    keyword bias CCDSUM   -w "1 1"
+    keyword bias TELESCOP -w simscope
+    keyword bias INSTRUME -w SIMTEST
+    keyword bias OBSTYPE  -w BIAS
+    keyword bias OBJECT   -w BIAS
+    sprintf name "$simdir/raw/bias.%02d.fits" $i
+    keyword bias GAIN     -wf 1.0
+    keyword bias RDNOISE  -wf $mkiRD
+    wd bias $name
+  end
+end
+
+macro mkdarks
+  echo "generating 20 dark images"
+  for i 0 20
+    $exptime = 3 * ($i + 1)
+    mkimages.init 1024 1024 5 1000 0 2.0
+    set dark = blank + sqrt($mkiRD*$mkiRD + $darkrate*$exptime)*mki_noisei + $darkrate*$exptime + $biaslevel
+    keyword dark AIRMASS  -wf {1 + 0.1*$i}
+    keyword dark FILTER   -w  NONE
+    keyword dark POSANGLE -wf 0.0
+    keyword dark RA       -wf 0.0
+    keyword dark DEC      -wf 0.0
+    keyword dark EXPTIME  -wf $exptime
+    keyword dark DARKTIME -wf $exptime
+    keyword dark DATE-OBS -w "2006/10/01"
+    sprintf time "00:01:%02d" $i
+    keyword dark UTC-OBS  -w $time
+    keyword dark CCDSUM   -w "1 1"
+    keyword dark TELESCOP -w simscope
+    keyword dark INSTRUME -w SIMTEST
+    keyword dark OBSTYPE  -w DARK
+    keyword dark OBJECT   -w DARK
+    keyword dark GAIN     -wf 1.0
+    keyword dark RDNOISE  -wf $mkiRD
+    sprintf name "$simdir/raw/dark.%02d.fits" $i
+    wd dark $name
+  end  
+end
+
+macro mkshutter
+  echo "generating 10 shutter images"
+  for i 0 10
+    $exptime = 3 * ($i + 1)
+    $opentime = $exptime - $shutter
+    mkimages.init 1024 1024 5 1000 0 2.0
+    set shutter = blank + sqrt($mkiRD*$mkiRD + $darkrate*$exptime + $flatlevel*$opentime)*mki_noisei + $flatlevel*$opentime + $darkrate*$exptime + $biaslevel
+    keyword shutter AIRMASS  -wf 1.0
+    keyword shutter FILTER   -w  NONE
+    keyword shutter POSANGLE -wf 0.0
+    keyword shutter RA       -wf 0.0
+    keyword shutter DEC      -wf 0.0
+    keyword shutter EXPTIME  -wf $exptime
+    keyword shutter DARKTIME -wf $exptime
+    keyword shutter DATE-OBS -w "2006/10/01"
+    sprintf time "00:01:%02d" $i
+    keyword shutter UTC-OBS  -w $time
+    keyword shutter CCDSUM   -w "1 1"
+    keyword shutter TELESCOP -w simscope
+    keyword shutter INSTRUME -w SIMTEST
+    keyword shutter OBSTYPE  -w SHUTTER
+    keyword shutter OBJECT   -w SHUTTER
+    keyword shutter GAIN     -wf 1.0
+    keyword shutter RDNOISE  -wf $mkiRD
+    sprintf name "$simdir/raw/shutter.%02d.fits" $i
+    wd shutter $name
+  end
+end
+
+macro mkflats
+  echo "generating 20 flat images in 2 filters"
+  $exptime = 10.0
+  $opentime = $exptime - $shutter
+  for i 0 10
+    mkimages.init 1024 1024 5 1000 0 2.0
+    set flat = blank + sqrt($mkiRD*$mkiRD + $darkrate*$exptime + $flatlevel*$opentime)*mki_noisei + $darkrate*$exptime + $flatlevel*$opentime + $biaslevel
+    keyword flat AIRMASS  -wf {1 + 0.1*$i}
+    keyword flat FILTER   -w  V
+    keyword flat POSANGLE -wf 0.0
+    keyword flat RA       -wf 0.0
+    keyword flat DEC      -wf 0.0
+    keyword flat EXPTIME  -wf $exptime
+    keyword flat DARKTIME -wf $exptime
+    keyword flat DATE-OBS -w "2006/10/01"
+    sprintf time "00:01:%02d" $i
+    keyword flat UTC-OBS  -w $time
+    keyword flat CCDSUM   -w "1 1"
+    keyword flat TELESCOP -w simscope
+    keyword flat INSTRUME -w SIMTEST
+    keyword flat OBSTYPE  -w FLAT
+    keyword flat OBJECT   -w FLAT
+    keyword flat GAIN     -wf 1.0
+    keyword flat RDNOISE  -wf $mkiRD
+    sprintf name "$simdir/raw/flat.%02d.fits" $i
+    wd flat $name
+  end  
+
+  for i 10 20
+    mkimages.init 1024 1024 5 1000 0 2.0
+    set flat = blank + sqrt($mkiRD*$mkiRD + $darkrate*$exptime + $flatlevel*$opentime)*mki_noisei + $darkrate*$exptime + $flatlevel*$opentime + $biaslevel
+    keyword flat AIRMASS  -wf {1 + 0.1*$i}
+    keyword flat FILTER   -w  B
+    keyword flat POSANGLE -wf 0.0
+    keyword flat RA       -wf 0.0
+    keyword flat DEC      -wf 0.0
+    keyword flat EXPTIME  -wf $exptime
+    keyword flat DARKTIME -wf $exptime
+    keyword flat DATE-OBS -w "2006/10/01"
+    sprintf time "00:02:%02d" $i
+    keyword flat UTC-OBS  -w $time
+    keyword flat CCDSUM   -w "1 1"
+    keyword flat TELESCOP -w simscope
+    keyword flat INSTRUME -w SIMTEST
+    keyword flat OBSTYPE  -w FLAT
+    keyword flat OBJECT   -w FLAT
+    keyword flat GAIN     -wf 1.0
+    keyword flat RDNOISE  -wf $mkiRD
+    sprintf name "$simdir/raw/flat.%02d.fits" $i
+    wd flat $name
+  end  
+end
+
+macro mkobjects
+  echo "generating 10 object images in 2 filters"
+  for i 0 5
+    $exptime = 3 * ($i + 1)
+    $opentime = $exptime - $shutter
+    mkimages.init 1024 1024 5 1000 0 2.0
+    set obj = blank + sqrt($mkiRD*$mkiRD + $darkrate*$exptime + $skyrate*$opentime)*mki_noisei + $darkrate*$exptime + $skyrate*$opentime + $biaslevel
+    keyword obj AIRMASS  -wf {1 + 0.1*$i}
+    keyword obj FILTER   -w  V
+    keyword obj POSANGLE -wf 0.0
+    keyword obj RA       -wf 0.0
+    keyword obj DEC      -wf 0.0
+    keyword obj EXPTIME  -wf $exptime
+    keyword obj DARKTIME -wf $exptime
+    keyword obj DATE-OBS -w "2006/10/01"
+    sprintf time "00:01:%02d" $i
+    keyword obj UTC-OBS  -w $time
+    keyword obj CCDSUM   -w "1 1"
+    keyword obj TELESCOP -w simscope
+    keyword obj INSTRUME -w SIMTEST
+    keyword obj OBSTYPE  -w OBJECT
+    keyword obj OBJECT   -w OBJECT
+    keyword obj GAIN     -wf 1.0
+    keyword obj RDNOISE  -wf $mkiRD
+    sprintf name "$simdir/raw/obj.%02d.fits" $i
+    wd obj $name
+  end  
+
+  for i 5 10
+    $exptime = 3 * ($i - 4)
+    $opentime = $exptime - $shutter
+    mkimages.init 1024 1024 5 1000 0 2.0
+    set obj = blank + sqrt($mkiRD*$mkiRD + $darkrate*$exptime + $skyrate*$opentime)*mki_noisei + $darkrate*$exptime + $skyrate*$opentime + $biaslevel
+    keyword obj AIRMASS  -wf {1 + 0.1*$i}
+    keyword obj FILTER   -w  B
+    keyword obj POSANGLE -wf 0.0
+    keyword obj RA       -wf 0.0
+    keyword obj DEC      -wf 0.0
+    keyword obj EXPTIME  -wf $exptime
+    keyword obj DARKTIME -wf $exptime
+    keyword obj DATE-OBS -w "2006/10/01"
+    sprintf time "00:02:%02d" $i
+    keyword obj UTC-OBS  -w $time
+    keyword obj CCDSUM   -w "1 1"
+    keyword obj TELESCOP -w simscope
+    keyword obj INSTRUME -w SIMTEST
+    keyword obj OBSTYPE  -w OBJECT
+    keyword obj OBJECT   -w OBJECT
+    keyword obj GAIN     -wf 1.0
+    keyword obj RDNOISE  -wf $mkiRD
+    sprintf name "$simdir/raw/obj.%02d.fits" $i
+    wd obj $name
+  end  
+end
+
+macro junk
+-definebyquery Optional arguments, with default values:
+    -det_type          ()                         define the type of detrend run (required)
+    -mode              (master)                   define the mode of this detrend run
+    -exp_type          ()                         search for exp_type
+    -inst              ()                         search for camera
+    -telescope         ()                         search for telescope
+    -filter            ()                         search for filter
+    -uri               ()                         search for uri
+    -set_exp_type      ()                         define exposure type
+    -set_filter        ()                         define filter
+    -set_airmass       (nan)            define airmass
+    -set_exp_time      (nan)            define exposure time
+    -set_ccd_temp      (nan)            define ccd tempature
+    -set_posang        (nan)            define rotator position angle
+    -set_object        ()                         define exposure object
+    -set_registered    (2006-12-13T22:40:18.5)    time detrend run was registered
+    -set_use_begin     ()                         start of detrend run applicable peroid
+    -set_use_end       ()                         end of detrend run applicable peroid
+    -pretend           (FALSE)                    print the exposures that would be included in the detrend run and exit
+end
