!*************************************************************************
!  
!-----------------------------------------------------------------------------
! modification history:
!
!   date    opr     who	    reason
! -------- -----  --------  --------------------------------------	
! 06/07/02        Rose      Initial Version
! 04/05/04 50879  J.Baum    Change ALL to GEN or ASN in "CLASS" field, change
!                           CENTBODY keyword from OMS to new ORB class,
!                           force OMS to ignore shp_data table
! 04/15/04 50879  MSwam     Add CCDCHIP for ACS HRC,fix NIC PHOTTAB
! 05/06/04 50879  MSwam     Comment out OMS settings of optional keywords,
!                           Fix t_SYNONM for WFPC-2 and t_CATARG for NIC,STI
! 06/15/04 51071  MSwam     Add WFPC-2 IDCTAB,OFFTAB
! 09/17/04 50683  MSwam     Trim WFC3 EXPNAME at 9 chars
! 10/06/04 52157  MSwam     Change ASNTBL to load for all asns (FUSE needs)
! 09/30/04 48984  MSwam     Remove STIS WBIAFILE
! 10/18/04 51963  MSwam     Add NICMOS IDCTAB 
! 09/31/04 51427  J.Baum    Use new WFPC2 commands for GCOUNT, t_WF2PR, and
!                           multichip keywords or keyword values moving to or
!                           from load group specified in t_WF2PR.  Describe 
!                           command syntax. Describe special DEBUG_KW rule.
! 11/01/04 52183  J.Baum    Add IGNORE rule for ACS and NICMOS when ASNTBL is
!                           set to LOAD. Add new ACS and NICMOS commands for
!                           t_ISORPH and use the new keywords for PRODEXP
!                           rules.
! 11/19/04 51455  J.Baum    Add CCDCHIP for ACS SBC (See 50879 above)
! 01/28/05 51419  J.Baum    Create t_OBSNUM keywords for moving_targets
! 02/15/05 47831  J.Baum    Use new NIC <galactic> command to recompute
!                           GLON_REF,GLAT_REF,ELON_REF and ELAT_REF.
! 05/05/05 52861  J.Baum    Use new NIC <actual_dur> command to recompute
!                           exposure time for NIC products.
! 07/13/05 53869  J.Baum    For WFPC2, set CALIBRAT values for all groups so
!                           that <setcount> command works properly.
! 07/15/05 53869  MSwam     Removed 52861 effects so 53869 could be quickfix
! 07/15/05 52861  MSwam     Added 52861 + 53869 to resolve branch
! 07/22/05 54036  J.Baum    Add new MTP load keyword t_MTLOAD and add GEN rule
!                           for t_OBSNUM using t_MTLOAD value 
! 07/26/05 54087  J.Baum    Set GEN TARGCAT to either TARGCAT or TARGCAT2 
!                           depending on which TARKEYn is not blank.
! 08/04/05 54078  J.Baum    Use <mergeraw> for uncalibrated WFPC2
! 09/09/05 53526  MSwam     STIS GACTAB entry removed (no "used" db field)
! 09/26/06 56376  MSwam     NICMOS SAADFILE
! 05/21/07 57618  MSwam     NICMOS ZPRATTAB,RNLCORTB
! 05/21/07 57852  MSwam     WFPC-2 WF4TFILE
! 12/12/07 48945  MSwam     Add F5DN and PUPIL rules for t_WAVLEN,t_BANDWD
!                             (and rearrange rules by instrument, remove
!                              many commented-out rules)
! 12/12/07 58280  MSwam     Set COSTAR = F for all SIs except HRS
! 12/21/07 58997  MSwam     WFPC-2 DGEOFILE
! 04/09/08 58278  Sherbert  Add CCDCHIP to WFC3 IR 
! 04/23/08 58278  Sherbert  Attempt COS rules
! 07/08/08 60293  Sherbert  COS ACQs should be treated as singletons
! 10/09/08 60598  MSwam     add NIC PMODFILE,PMSKFILE
! 10/20/08 60598  MSwam     add NIC SAACNTAB, PEDSBTAB
! 11/12/08 55050  Sherbert  no longer need t_ACTDUR/actual_dur override for NIC products 
! 11/13/08 61211  MSwam     Add BIASEVNU,BIASODDU grps for WFPC-2
! 11/24/08 61236  Sherbert  Totally mess w/ WFPC2 to prefer cal, remove t_WF2PR
! 01/05/09 61474  MSwam     Add NICMOS TDFFILE
! 01/05/09 61421  Sherbert  Remove COS SEGEXP rules
! 01/21/09 61586  Sherbert  Remove NIC <galactic> commands 
! 05/13/09 60563  Sherbert  Record launch of STS-125 for SM4
! 07/10/09 62511  Sherbert  Add more used reffile mods, simplify others
! 09/10/09 62767  Sherbert  Fix WFC3 sci_spec_1234 when no filter commanded
! 09/10/09 62408  Sherbert  Remove COS SEGMENT rules
! 09/16/09 63219  Sherbert  do not want sci_asn_id filled for ACQs
! 09/22/09 54677  Sherbert  Add sci_aec rules for new SIs
! 08/30/10 59963  Sherbert  rm fuse
! 10/18/10 66275  MSwam     Add COS SPWCSTAB
! 02/17/11 67560  Sherbert  WFC3 can now have orphans
! 07/07/11 68298  MSwam     Add ACS IMPHTTAB
!
!-----------------------------------------------------------------------------

!-----------------------------------------------------------------------------
!
!  File: CATALOG_RULES.LIS
!
!  Purpose:  This file provides the inputs to the KR_rules_pkg for cataloging.
!    This package should be designed around a table which contains, for
!    each instrument, a set of rules for determining the value of a particular
!    keyword.  
!
!  Conventions:
!
!	A comment line begins with a '!' character.  These are ignored by
!	the rules package.
!
!	The lines are freely formatted, but white-space is significant
!
!	The fields are:
!
!	CLASS:		The rule class (e.g. STI, WF2, STS, W2S, etc.)
!	NAME:		Keyword to be set
!	DEFAULT:	Value to set the keyword to if....
!	KEYWORD:	this keyword..
!	COMPARE:	has this relation..
!			(The allowable operators in the 'COMPARE' field are:
!	    		=, !=, >, <)
!	VALUE:		to this value.  (Use BLANK for testing against "")
!
!	TEST:		The order of the individual tests
!			If you want to join two tests with an AND
!			give them the same test number.  If you
!			want to join two tests with an OR, do not give
!			them the same test number.
!
!  Indirection:
!
!	In either the DEFAULT or the VALUE field, if you want to refer
!	to the dynamic value of a keyword rather than a constant, enclose
!	the keyword name in curly brackets {}.  For example:
!		if (OOPTMODE != OPTVALUE) OOPTMODE = OPTTYPE
! 	would be entered:
!
!INST 	NAME  =   DEFAULT  if TEST  KEYWORD   COMPARE	VALUE
!----	--------  ----------  ----  --------  -------	-------
!STI 	OPTMODE   {OPTTYPE}	1   OOPTMODE  =		{OPTVALUE}
!
!
!  Wildcarding:
!
!	A constant in the VALUE field may be wildcarded with the '?' symbol.
!
!	For example the following VALUE matches MIR1, MIR2, MIR3, MIRUVL
!
!INST 	NAME  =   DEFAULT  if TEST  KEYWORD   COMPARE	VALUE
!----	--------  ----------  ----  --------  -------	-------
!STI	OBSTYPE   IMAGING       1   MIRROR    =        MIR?
!STI    OBSTYPE   SPECTROSCOPIC 2   T         =        T
!
!
!  Forcing a value:
!  ----------------
!
!	In the last line above, OBSTYPE is given the value SPECTROSCOPIC
!	if no previous test succeeded.  
!
!  Getting and setting group-specific values:
!  ------------------------------------------
!
!       In the NAME, KEYWORD, DEFAULT, or VALUE field, if the latter
!       two refer to a dynamic value of a keyword, you can specify which
!       group of data to get or set:
!
!INST 	NAME  =   DEFAULT  if TEST  KEYWORD   COMPARE	VALUE
!----	--------  ----------  ----  --------  -------	-------
!STI 	OPTMODE(1) {OPTTYPE(1)}	 1   OOPTMODE    =	{OPTVALUE}
!WFPC2  LPKTTIM   {LPKTTIME(3)}  1       T       =      T
!COS    P1_PTM    FIXED          1   P2_AWF(2)   =      UNKNOWN
!
!       The default group number if not specified will be group zero
!       which normally contains the primary header and the header of
!       the first extension.  Group 1 is actually the keyword values
!       in the second extension.
!
!  Setting all the groups of a keyword:
!  ------------------------------------
!
!       Of course this depends on the definition of "all".  In the
!       syntax below keyword TARGCAT stands as a model for the
!       extension of PROGRMID: the number of groups for the keyword
!       PROGRMID will be the same as for TARGCAT.  The action taken
!       in this rule is:
!               for (i=1; i<=number_of_TARGCAT_groups; ++i) {
!                   PROGRMID(*) = PROGRMID(0);
!               }
!
!ACS    PROGRMID(*) {PROGRMID}   1   TARGCAT     =     {TARGCAT}
!
!       Note that the symbol 'i' above can be any non-numeric character,
!       and that the model keyword must appear on both sides of the '='
!
!  Substrings:
!  -----------
!
!       The default value can be a substring expression of the form (n:m).
!       For example, if you want to remove the IRAF file preface from a
!       reference file name (eg: OTAB$M9A16591O_APD.FITS), you would specify:
!
!INST 	NAME  =   DEFAULT  if TEST  KEYWORD   COMPARE	VALUE
!----	--------  ----------  ----  --------  -------	-------
!STIS    APDESTAB  {APDESTAB(5:)}  1 APDESTAB   =        OTAB$?
!
!
!  Arithmetic equations:
!  ---------------------
!
!	Both the DEFAULT and VALUE fields may contain an arithmetic
!	equation. Equations must be surrounded by square brackets and
!	may contain a dynamic keyword value (see Indirection above).
!	The equation must not contain spaces unless the whole field,
!	including square brackets, is quoted. Supported operators, in
!	highest to lowest precedence order and followed by examples, are
!	listed below ("a" and "b" below are operands):
!
!	Round up to nearest integer   CEIL(a)   (Ex. CEIL(3.2) = 4)
!	Round down to nearest integer FLOOR(a)  (Ex. FLOOR(-2.4) = -3)
!	Involution (exponentiation)   a^b       (Ex. 3.0^2 = 9)
!	Division                      a/b       (Ex. 10/3 = 3)
!	                                        (Ex. 10.0/3 = 3.333333)
!	Multiplication                a*b       (Ex. 2*3 = 6)
!	Modulo                        a%b       (Ex. 10%3 = 1)
!	Addition                      a+b       (Ex. 23+1= 24)
!	Subtraction                   a-b       (Ex. -4--5 = 1)
!	Bit-wise AND                  a&b       (Ex. 3&1 = 1)
!	Bit-wise exclusive-OR         a~b       (Ex. 2~3 = 1)
!	Bit-wise OR                   a|b       (Ex. 2|3 = 3)
!
!	Parentheses can be used to modify the order of evaluation and
!	care should be taken to ensure proper evaluation order in
!	complicated equations. The equation solver distinguishes between
!	integer and floating-point arithmetic (see the examples above for
!	division) and the usual cautions apply when using = with
!	floating-point results. 
!
!	For example, to express the rule:
!		if (PATTERN == "BOX") P1_PSPAC = 0.559 * BOXSCALE
!	you would write:
!
!INST 	NAME  =   DEFAULT  if TEST  KEYWORD   COMPARE	VALUE
!----	--------  ----------  ----  --------  -------	-------
!STI 	P1_PSPAC [.559*{BOXSCALE}] 1 PATTERN  =		BOX
!
!
!	
!  Commands in the DEFAULT field:
!  ------------------------------ 
!
!	Only the DEFAULT field may contain a command name. The command must
!       not include any white space and it must be surrounded by angle brackets.
!       The command names are not case sensitive but lowercase names are
!       more obvious. Command names are qualified by the INST value so the same
!       command name used for different INST values may be different functions.
!       The command is passed the value of the NAME field which is usually
!       a keyword name but the command can update the value of multiple 
!       keywords not just the keyword referenced in the NAME field. The
!       implemention of a command is performed by function pointers passed 
!       by the application using the keyword rules software, so before a 
!       command is used in this file, there should be extra comment lines that
!       describe the action of the command. 
!
!
!       For example, WFPC2 needs a method to determine the number of
!       CCD images (from CCD Chips) taken in an exposure. In the following
!       example, the keyword GCOUNT will be updated with this value using
!       the command "setcount".
! 
!INST 	NAME  =   DEFAULT  if TEST  KEYWORD   COMPARE	VALUE
!----	--------  ----------  ----  --------  -------	-------
!WFPC2 	GCOUNT   <setcount>   1       T        =         T
! 
!       Definitions of Commands in the DEFAULT field can be found in
!       Cat_KR_Commands.cpp.
!
!  Special CATALOG rules
!  ------------------------------ 
!
!       Comments from Cat_DB_Tree.cpp:
!       If the selector keyword != LOAD, don't write this relation.
!
!       Ordinarily you would want all groups to be loaded, but there
!       are cases in which you might want only a specific group.
!       You can specify which group to load by using LOADn as the
!       value of the selector.  LOAD0 would load only group 0,
!       and LOAD4 would load only group number 4
!
!       Internal keywords and overrides
!       can be set up to avoid creating entries in the relation tree
!       when fieldname = none or where special_process like "IGNORE%"
!
! 
!
!
!  Temporary Rule Variables (t_):
!  ------------------------------
!
!        A rule-writer can ask for the creation of a temporary
!        rule variable by using a keyword named "t_XXXXXX" as the
!        destination of a rule result.  The XXXXXX can be any characters,
!        (all 6 do not need to be filled) but the "t_" must be in lowercase.  
!        Once a variable with such a name is written to once, it can be 
!        used anywhere else in later rules.  These variables are temporary
!        in the sense that a predefined keyword does not need to exist
!        in the instrument header for these variable names.
!        They are created and filled as the rules are evaluated.
!        This capability can be used to conveniently
!        reduce a set of complex tests to a single result, which can
!        be used to make later rules simpler to read and write.
!
!        For example,
!
! slitless = [F25?|50?|F28?|25?|6X6]
!
!STS     t_SLITLS  T             1       APERTURE  = F25?
!STS     t_SLITLS  T             2       APERTURE  = 50?
!STS     t_SLITLS  T             3       APERTURE  = F28?
!STS     t_SLITLS  T             4       APERTURE  = 25?
!STS     t_SLITLS  T             5       APERTURE  = 6X6
!STS     t_SLITLS  F             6       T = T
!
!        can be used to define a subset of apertures, and the temporary
!        rule variable "t_SLITLS" can then be used in later rules:
!STS     FLATCORR  OMIT          10      OBSTYPE   =     SPECT?
!STS     FLATCORR  OMIT          10      t_SLITLS  =     T
!
!
!  Special diagnotic rule:
!  -----------------------
! 
!        During rules development the behavior of new rules can be unexpected.
!        The special DEBUG_KW rule can be used to increase the number of
!        debug (level -D-) messages during the KW_apply_rules function. This
!        special rule ignores the test conditions, so it should be written as a
!        T = T test to avoid confusion. The default value of this rule is the
!        value of a rule NAME field for which the special debug messages
!        should be generated. If the default value ALL is used then every 
!        rule gets the extra debug messages.  
!     
!        For example, to check the tests for WFPC2 keyword t_WAVLEN use::
!
!INST 	NAME  =   DEFAULT  if TEST  KEYWORD   COMPARE	VALUE
!----	--------  ----------  ----  --------  -------	-------
!WFPC2  DEBUG_KW  t_WAVLEN     1       T        =         T
!ALL 	DEBUG_KW  ALL          1       T        =         T
!
!===========================================================================

!===========================================================================
!                   START RULES
!---------------------------------------------------------------------------
!
!
!INST 	NAME  =   DEFAULT  if TEST  KEYWORD   COMPARE	VALUE
!----	--------  ----------  ----  --------  -------	-------
!  These rules are used for association tables
ASN     ASNTBL    LOAD        1     ASN_STAT       =    COMPLETE
ASN     ASNTBL    LOAD        2     ASN_STAT       =    INCOMPLETE
ASN     ASNTBL    IGNORE      3           T        =    T
!
! ACS rules:-------------------------------------------------------------
!
! The ACS <testorph> command sets the designated keyword to T if the dataset
! is an exposure member that is an orphan, otherwise the value is F.
!
ACS     t_ISORPH  F           1     ASNTBL         =    LOAD
ACS     t_ISORPH  F           2     ASN_ID         =    NONE
ACS     t_ISORPH  <testorph>  3          T         =    T
!
ACS     PRODEXP   IGNORE      1     ASNTBL         =    LOAD
ACS     PRODEXP   LOAD        2     ASN_ID         =    NONE
ACS     PRODEXP   LOAD        3     t_ISORPH       =    T
ACS     PRODEXP   LOAD        4     ASN_MTYP       =    PROD?
ACS     PRODEXP   IGNORE      5           T        =    T
!
ACS     MEMBEXP   IGNORE      1     ASNTBL         =    LOAD
ACS     MEMBEXP   LOAD        2     ASN_ID         =    NONE
ACS     MEMBEXP   LOAD        3     ASN_MTYP       =    EXP?
ACS     MEMBEXP   IGNORE      4           T        =    T
!
ACS     GRANDMA   LOAD        1     FILETYPE       =    ACC
ACS     GRANDMA   IGNORE      2           T        =    T
!
ACS     ARCHCLAS  ACM         1     FILETYPE       =    ACC 
!
! This one is so that the acs_chip table loads for HRC (normally it
!   would not, since CCDCHIP is a key field and the HRC headers don't
!   have this keyword). And also do it for SBC.
!
ACS     CCDCHIP   0           1     DETECTOR       =    HRC
ACS     CCDCHIP   0           2     DETECTOR       =    SBC
!
! Need to trim the used reference file fields
! PR 62511 simplify by changing nref$? or [nm]tab$? to ?$? like other SIs
ACS     BIASFILE  {BIASFILE(5:)}  1   BIASFILE   =  ?$?
ACS     CFLTFILE  {CFLTFILE(5:)}  1   CFLTFILE   =  ?$?
ACS     DARKFILE  {DARKFILE(5:)}  1   DARKFILE   =  ?$?
ACS     DFLTFILE  {DFLTFILE(5:)}  1   DFLTFILE   =  ?$?
ACS     DGEOFILE  {DGEOFILE(5:)}  1   DGEOFILE   =  ?$?
ACS     FLSHFILE  {FLSHFILE(5:)}  1   FLSHFILE   =  ?$?
ACS     LFLTFILE  {LFLTFILE(5:)}  1   LFLTFILE   =  ?$?
ACS     PFLTFILE  {PFLTFILE(5:)}  1   PFLTFILE   =  ?$?
ACS     SHADFILE  {SHADFILE(5:)}  1   SHADFILE   =  ?$?
ACS     ATODTAB   {ATODTAB(5:)}   1   ATODTAB    =  ?$?
ACS     BPIXTAB   {BPIXTAB(5:)}   1   BPIXTAB    =  ?$?
ACS     CCDTAB    {CCDTAB(5:)}    1   CCDTAB     =  ?$?
ACS     COMPTAB   {COMPTAB(5:)}   1   COMPTAB    =  ?$?
ACS     CRREJTAB  {CRREJTAB(5:)}  1   CRREJTAB   =  ?$?
ACS     GRAPHTAB  {GRAPHTAB(5:)}  1   GRAPHTAB   =  ?$?
ACS     IDCTAB    {IDCTAB(5:)}    1   IDCTAB     =  ?$?
ACS     MDRIZTAB  {MDRIZTAB(5:)}  1   MDRIZTAB   =  ?$?
ACS     MLINTAB   {MLINTAB(5:)}   1   MLINTAB    =  ?$?
ACS     OSCNTAB   {OSCNTAB(5:)}   1   OSCNTAB    =  ?$?
ACS     PHOTTAB   {PHOTTAB(5:)}   1   PHOTTAB    =  ?$?
ACS     SPOTTAB   {SPOTTAB(5:)}   1   SPOTTAB    =  ?$?
ACS     IMPHTTAB  {IMPHTTAB(5:)}  1   IMPHTTAB   =  ?$?

!
!
! COS TV rules: ------------  maybe  ------------------------------------
!
! Problem with COS TV data which has lqdopzer=2376176032
! which is bigger than an integer value in sybase
TVL     LQDOPZER  0	      1     LQDOPZER > 2147483647
!
!==== THESE 2 ARE HARD-CODED TO PRODUCE THERMAL VAC CATLOGUING
TVL     PRODEXP   IGNORE      1           T        =    T
TVL     TVEXP     LOAD        1           T        =    T

!
! COS rules:-------------------------------------------------------------
!
! PR 65745
! COS CCI files
COS     GRANDMA   LOAD            1   FILETYPE   =    COS_CUMULATIVE_IMAGE
COS     GRANDMA   LOAD            1   INSTRUME   =    COS
COS     GRANDMA   IGNORE          2     T        =    T
!
COS     ARCHCLAS  CSI             1     FILETYPE =    COS_CUMULATIVE_IMAGE
!
! ......assoc_member...assoc_status...assoc_orphan...
! The <testorph> command sets the designated keyword to T if the dataset
! is an exposure member that is an orphan, otherwise the value is F.
! Copied from ACS and NICMOS for COS and WFC3
!
! WAVECALs are being called orphans when they are NOT.
! Until code is changed, set this selector to F.
COS      t_ISORPH  F           1          T         =    T
!
! PR 63219 CATALOG needs ASN_ID to be NONE for uncollected members of ASNs...
!INST 	NAME  =   DEFAULT  if TEST  KEYWORD   COMPARE	VALUE
!----	--------  ----------  ----  --------  -------	-------
COS     t_UNCOLL   T           1     ASN_MTYP       =    EXP-ACQ?
COS     t_UNCOLL   F           2        T           =       T    
COS     ASN_ID     NONE        1     t_UNCOLL       =       T    
!
! ......PRODUCT level tables (products, singletons)
! Copied from nicmos because stis is a class unto itself
! Not sure they were all that different from ACS which are 
! easier to understand...
COS     PRODEXP   IGNORE      1     ASNTBL         =    LOAD
COS     PRODEXP   LOAD        2     t_ISORPH       =    T
! COS considers ACQs to be uncollected members of associations BUT
! we want to treat them as singletons so they go into Product and
! Exposure Level tables.
COS     PRODEXP   LOAD        3     ASN_MTYP       =    EXP-ACQ?
COS     PRODEXP   IGNORE      4     ASN_MTYP       =    EXP?
COS     PRODEXP   IGNORE      5     FILETYPE       =    ASN_TABLE
COS     PRODEXP   IGNORE      6     FILETYPE       =    COS_CUMULATIVE_IMAGE
COS     PRODEXP   LOAD        7           T        =    T
!
! ......EXPOSURE level tables (members, singletons)
! Singletons get both PRODEXP and MEMBEXP set to LOAD :)
COS     MEMBEXP   IGNORE      1     ASNTBL         =    LOAD
COS     MEMBEXP   IGNORE      2     ASN_MTYP       =    PROD?
COS     MEMBEXP   IGNORE      3     FILETYPE       =    ASN_TABLE
COS     MEMBEXP   IGNORE      4     FILETYPE       =    COS_CUMULATIVE_IMAGE
COS     MEMBEXP   LOAD        5           T        =    T
!
! PR 62408 calcos should be setting SEGMENT therefore remove rules
!
! Need to trim the used reference file fields
! PR 62511 simplify by changing nref$? or [nm]tab$? to ?$? like other SIs
COS     FLATFILE  {FLATFILE(5:)}  1   FLATFILE   =  ?$?
COS     GEOFILE   {GEOFILE(5:)}   1   GEOFILE    =  ?$?
COS     BADTTAB   {BADTTAB(5:)}   1   BADTTAB    =  ?$?
COS     BPIXTAB   {BPIXTAB(5:)}   1   BPIXTAB    =  ?$?
COS     BRFTAB    {BRFTAB(5:)}    1   BRFTAB     =  ?$?
COS     BRSTTAB   {BRSTTAB(5:)}   1   BRSTTAB    =  ?$?
COS     DEADTAB   {DEADTAB(5:)}   1   DEADTAB    =  ?$?
COS     DISPTAB   {DISPTAB(5:)}   1   DISPTAB    =  ?$?
COS     FLUXTAB   {FLUXTAB(5:)}   1   FLUXTAB    =  ?$?
COS     IMPHTTAB  {IMPHTTAB(5:)}  1   IMPHTTAB   =  ?$?
COS     LAMPTAB   {LAMPTAB(5:)}   1   LAMPTAB    =  ?$?
COS     PHATAB    {PHATAB(5:)}    1   PHATAB     =  ?$?
COS     PHOTTAB   {PHOTTAB(5:)}   1   PHOTTAB    =  ?$?
COS     TDSTAB    {TDSTAB(5:)}    1   TDSTAB     =  ?$?
COS     WCPTAB    {WCPTAB(5:)}    1   WCPTAB     =  ?$?
COS     XTRACTAB  {XTRACTAB(5:)}  1   XTRACTAB   =  ?$?
COS     SPWCSTAB  {SPWCSTAB(5:)}  1   SPWCSTAB   =  ?$?

!
! FGS rules:-------------------------------------------------------------
!
!
FGS     FGSDATA   LOAD        1     FILETYPE       =    AST
FGS     FGSDATA   IGNORE      2           T        =    T
FGS     PRODEXP   LOAD        1           T        =    T
FGS     MEMBEXP   LOAD        1           T        =    T
!
FGS    t_WAVLEN  5500	 1 CAST_FLT = F550W
FGS    t_WAVLEN  5830	 2 CAST_FLT = F583W
FGS    t_WAVLEN  5830	 3 CAST_FLT = F5ND
FGS    t_WAVLEN  5830	 4 CAST_FLT = PUPIL
FGS    t_WAVLEN  6050	 5 CAST_FLT = F605W
FGS    t_WAVLEN  6500	 6 CAST_FLT = F650W
!
FGS    t_BANDWD  750	 1 CAST_FLT = F550W
FGS    t_BANDWD  2340	 2 CAST_FLT = F583W
FGS    t_BANDWD  2340	 3 CAST_FLT = F5ND
FGS    t_BANDWD  2340	 4 CAST_FLT = PUPIL
FGS    t_BANDWD  1900	 5 CAST_FLT = F605W
FGS    t_BANDWD  750	 6 CAST_FLT = F650W
!
FGS    t_PIXRES  .003	 1 OPMODE = POS
FGS    t_PIXRES  .003	 2 OPMODE = TRANS
FGS    t_PIXRES  .003	 3 OPMODE = SCAN
FGS    t_PIXRES  .003	 4 OPMODE = WALKDOWN
FGS    t_PIXRES  .002	 5 OPMODE = LOS
FGS    t_PIXRES  .002	 6 OPMODE = MAP
!
! While TEMPk1 is used to load fgs_tempK, the value which should
! be used depends on the FGSID active at the time.
!
FGS    TEMP21  {TEMP22}  1 FGSID  = 2
FGS    TEMP21  {TEMP23}  2 FGSID  = 3
FGS    TEMP31  {TEMP32}  1 FGSID  = 2
FGS    TEMP31  {TEMP33}  2 FGSID  = 3
FGS    TEMP41  {TEMP42}  1 FGSID  = 2
FGS    TEMP41  {TEMP43}  2 FGSID  = 3
FGS    TEMP61  {TEMP62}  1 FGSID  = 2
FGS    TEMP61  {TEMP63}  2 FGSID  = 3
FGS    TEMP71  {TEMP72}  1 FGSID  = 2
FGS    TEMP71  {TEMP73}  2 FGSID  = 3
FGS    TEMP91  {TEMP92}  1 FGSID  = 2
FGS    TEMP91  {TEMP93}  2 FGSID  = 3

!
! OMS rules:-------------------------------------------------------------
!
OMS     OMSDATA   LOAD        1     FILETYPE       =    JIM
OMS     OMSDATA   LOAD        2     FILETYPE       =    JTB
OMS     OMSDATA   IGNORE      3           T        =    T
OMS     OMSSUM    IGNORE      1     ASN_MTYP       =    ?WAVECAL
OMS     OMSSUM    LOAD        2           T        =    T
OMS     MEMBEXP   IGNORE      1           T        =    T

!
! ORB rules:--------------------------------------------------------------
!
ORB     CENTBODY(*)   EARTH          1   CENTBODY   = BLANK

!
!
! NICMOS rules:-------------------------------------------------------------
!
! The NICMOS <testorph> command sets the designated keyword to T if the dataset
! is an exposure member that is an orphan, otherwise the value is F.
!
NICMOS  t_ISORPH  F           1     ASNTBL         =    LOAD
NICMOS  t_ISORPH  F           2     ASN_ID         =    NONE
NICMOS  t_ISORPH  <testorph>  3          T         =    T
!
! The NICMOS GLON_REF,GLAT_REF,ELON_REF, and ELAT_REF association products 
! (PROD-TARG) keywords are now recalculated in the after calibration stage.
!
NICMOS  PRODEXP   IGNORE      1     ASNTBL         =    LOAD
NICMOS  PRODEXP   LOAD        2     t_ISORPH       =    T
NICMOS  PRODEXP   IGNORE      3     ASN_MTYP       =    EXP?
NICMOS  PRODEXP   IGNORE      4     FILETYPE       =    ASN_TABLE
NICMOS  PRODEXP   LOAD        5           T        =    T
!
NICMOS  MEMBEXP   IGNORE      1     ASNTBL         =    LOAD
NICMOS  MEMBEXP   IGNORE      2     ASN_MTYP       =    PROD?
NICMOS  MEMBEXP   IGNORE      3     FILETYPE       =    ASN_TABLE
NICMOS  MEMBEXP   LOAD        4           T        =    T
!
NICMOS  ARCHCLAS  CAL         1           T        =    T
!
! Need to trim the used reference file fields
! PR 62511 simplify by changing nref$? or [nm]tab$? to ?$? like other SIs
NICMOS  DARKFILE  {DARKFILE(5:)}  1   DARKFILE   =  ?$?
NICMOS  MASKFILE  {MASKFILE(5:)}  1   MASKFILE   =  ?$?
NICMOS  FLATFILE  {FLATFILE(5:)}  1   FLATFILE   =  ?$?
NICMOS  ILLMFILE  {ILLMFILE(5:)}  1   ILLMFILE   =  ?$?
NICMOS  NLINFILE  {NLINFILE(5:)}  1   NLINFILE   =  ?$?
NICMOS  NOISFILE  {NOISFILE(5:)}  1   NOISFILE   =  ?$?
NICMOS  SAADFILE  {SAADFILE(5:)}  1   SAADFILE   =  ?$?
NICMOS  PMODFILE  {PMODFILE(5:)}  1   PMODFILE   =  ?$?
NICMOS  PMSKFILE  {PMSKFILE(5:)}  1   PMSKFILE   =  ?$?
NICMOS  TEMPFILE  {TEMPFILE(5:)}  1   TEMPFILE   =  ?$?
NICMOS  TDFFILE   {TDFFILE(5:)}   1   TDFFILE    =  ?$?
NICMOS  PHOTTAB   {PHOTTAB(5:)}   1   PHOTTAB    =  ?$?
NICMOS  IDCTAB    {IDCTAB(5:)}    1   IDCTAB     =  ?$?
NICMOS  ZPRATTAB  {ZPRATTAB(5:)}  1   ZPRATTAB   =  ?$?
NICMOS  RNLCORTB  {RNLCORTB(5:)}  1   RNLCORTB   =  ?$?
NICMOS  SAACNTAB  {SAACNTAB(5:)}  1   SAACNTAB   =  ?$?
NICMOS  PEDSBTAB  {PEDSBTAB(5:)}  1   PEDSBTAB   =  ?$?

!
!
! STIS rules:-------------------------------------------------------------
!
! PR 65747
! Run GRANDMA rules for new CCI files, but just in case anyone tries to 
! send in old MAMA lifetime accums (ACC), make sure they are ignored.
!
STIS    GRANDMA   LOAD        1     FILETYPE       =    STIS_CUMULATIVE_IMAGE
STIS    GRANDMA   LOAD        1     INSTRUME       =    STIS
STIS    GRANDMA   IGNORE      2           T        =    T
!
STIS    PRODEXP   IGNORE      1     FILETYPE       =    ACC
STIS    PRODEXP   IGNORE      2     FILETYPE       =    STIS_CUMULATIVE_IMAGE
STIS    PRODEXP   IGNORE      3     FILETYPE       =    ASN_TABLE
STIS    PRODEXP   LOAD0       4           T        =    T
STIS    MEMBEXP   IGNORE      1     FILETYPE       =    ACC
STIS    MEMBEXP   IGNORE      2     FILETYPE       =    STIS_CUMULATIVE_IMAGE
STIS    MEMBEXP   IGNORE      3     FILETYPE       =    ASN_TABLE
STIS    MEMBEXP   LOAD        4           T        =    T
!
! Tighten this up
STIS    ARCHCLAS(*) SSI       1     FILETYPE       =    STIS_CUMULATIVE_IMAGE
STIS    ARCHCLAS(*) CAL       2     TARGNAME       =    {TARGNAME}
!
! Need to trim the used reference file fields
! PR 62511 simplify by changing oref$? or otab$? to ?$? like other SIs
! 10/02/09 PR 62511  Sherbert  Add missing reffile keywords, reorder
STIS    APDESTAB  {APDESTAB(5:)}  1   APDESTAB   =  ?$?
STIS    APERTAB   {APERTAB(5:)}   1   APERTAB    =  ?$?
STIS    ATODTAB   {ATODTAB(5:)}   1   ATODTAB    =  ?$?
STIS    BIASFILE  {BIASFILE(5:)}  1   BIASFILE   =  ?$?
STIS    BPIXTAB   {BPIXTAB(5:)}   1   BPIXTAB    =  ?$?
STIS    CCDTAB    {CCDTAB(5:)}    1   CCDTAB     =  ?$?
STIS    CDSTAB    {CDSTAB(5:)}    1   CDSTAB     =  ?$?
STIS    CRREJTAB  {CRREJTAB(5:)}  1   CRREJTAB   =  ?$?
STIS    DARKFILE  {DARKFILE(5:)}  1   DARKFILE   =  ?$?
STIS    DFLTFILE  {DFLTFILE(5:)}  1   DFLTFILE   =  ?$?
STIS    DISPTAB   {DISPTAB(5:)}   1   DISPTAB    =  ?$?
STIS    ECHSCTAB  {ECHSCTAB(5:)}  1   ECHSCTAB   =  ?$?
STIS    EXSTAB    {EXSTAB(5:)}    1   EXSTAB     =  ?$?
STIS    GACTAB    {GACTAB(5:)}    1   GACTAB     =  ?$?
STIS    HALOTAB   {HALOTAB(5:)}   1   HALOTAB    =  ?$?
STIS    IDCTAB    {IDCTAB(5:)}    1   IDCTAB     =  ?$?
STIS    INANGTAB  {INANGTAB(5:)}  1   INANGTAB   =  ?$?
STIS    LAMPTAB   {LAMPTAB(5:)}   1   LAMPTAB    =  ?$?
STIS    LFLTFILE  {LFLTFILE(5:)}  1   LFLTFILE   =  ?$?
STIS    MLINTAB   {MLINTAB(5:)}   1   MLINTAB    =  ?$?
STIS    MOFFTAB   {MOFFTAB(5:)}   1   MOFFTAB    =  ?$?
STIS    PCTAB     {PCTAB(5:)}     1   PCTAB      =  ?$?
STIS    PFLTFILE  {PFLTFILE(5:)}  1   PFLTFILE   =  ?$?
STIS    PHOTTAB   {PHOTTAB(5:)}   1   PHOTTAB    =  ?$?
STIS    RIPTAB    {RIPTAB(5:)}    1   RIPTAB     =  ?$?
STIS    SDCTAB    {SDCTAB(5:)}    1   SDCTAB     =  ?$?
STIS    SDSTFILE  {SDSTFILE(5:)}  1   SDSTFILE   =  ?$?
STIS    SHADFILE  {SHADFILE(5:)}  1   SHADFILE   =  ?$?
STIS    SPTRCTAB  {SPTRCTAB(5:)}  1   SPTRCTAB   =  ?$?
STIS    SRWTAB    {SRWTAB(5:)}    1   SRWTAB     =  ?$?
STIS    TDCTAB    {TDCTAB(5:)}    1   TDCTAB     =  ?$?
STIS    TDSTAB    {TDSTAB(5:)}    1   TDSTAB     =  ?$?
STIS    TELTAB    {TELTAB(5:)}    1   TELTAB     =  ?$?
STIS    WCPTAB    {WCPTAB(5:)}    1   WCPTAB     =  ?$?
STIS    XTRACTAB  {XTRACTAB(5:)}  1   XTRACTAB   =  ?$?
!
STIS	BANDWID   {PHOTBW}	  1   OBSTYPE    =  IMAGING
STIS    CENTRWV   {PHOTPLAM}      1   OBSTYPE    =  IMAGING

!
!
!-----------------------------------------------------------------------------
! 12/21/07 58278  Sherbert     Attempt to affect a change in WFC3 catalogs
!-----------------------------------------------------------------------------
!! Not sure I can change these from WFC3 to TVI to do what I want
!! but need to do something.   58278
!-----------------------------------------------------------------------------
! TVI rules:-------------------------------------------------------------
!
!==== THESE ARE HARD-CODED TO PRODUCE THERMAL VAC CATLOGUING
TVI    PRODEXP   IGNORE      1           T        =    T
TVI    TVEXP     LOAD        1           T        =    T
!===========================================================
!
! trimming off the timestamp for TV data
TVI    EXPNAME   {EXPNAME(:10)}  1         T        =    T

!
!===========================================================
! PR 67560
! The WFC3 <testorph> command sets the designated keyword to T if the dataset
! is an exposure member that is an orphan, otherwise the value is F.
!
WFC3    t_ISORPH  F           1     ASNTBL         =    LOAD
WFC3    t_ISORPH  F           2     ASN_ID         =    NONE
WFC3    t_ISORPH  <testorph>  3          T         =    T
!
WFC3    PRODEXP   IGNORE      1     ASNTBL         =    LOAD
WFC3    PRODEXP   LOAD        2     ASN_ID         =    NONE
WFC3    PRODEXP   LOAD        3     t_ISORPH       =    T
WFC3    PRODEXP   LOAD        4     ASN_MTYP       =    PROD?
WFC3    PRODEXP   IGNORE      5           T        =    T
WFC3    MEMBEXP   IGNORE      1     ASNTBL         =    LOAD
WFC3    MEMBEXP   LOAD        2     ASN_ID         =    NONE
WFC3    MEMBEXP   LOAD        3     ASN_MTYP       =    EXP?
WFC3    MEMBEXP   IGNORE      4           T        =    T
WFC3    CCDCHIP   0           1     DETECTOR       =    IR
!
! Need to trim the used reference file fields
! PR 62511 simplify by changing nref$? or [nm]tab$? to ?$? like other SIs
WFC3    BIASFILE  {BIASFILE(5:)}  1   BIASFILE   =  ?$?
WFC3    DARKFILE  {DARKFILE(5:)}  1   DARKFILE   =  ?$?
WFC3    DFLTFILE  {DFLTFILE(5:)}  1   DFLTFILE   =  ?$?
WFC3    DGEOFILE  {DGEOFILE(5:)}  1   DGEOFILE   =  ?$?
WFC3    FLSHFILE  {FLSHFILE(5:)}  1   FLSHFILE   =  ?$?
WFC3    LFLTFILE  {LFLTFILE(5:)}  1   LFLTFILE   =  ?$?
WFC3    NLINFILE  {NLINFILE(5:)}  1   NLINFILE   =  ?$?
WFC3    PFLTFILE  {PFLTFILE(5:)}  1   PFLTFILE   =  ?$?
WFC3    SHADFILE  {SHADFILE(5:)}  1   SHADFILE   =  ?$?
WFC3    ATODTAB   {ATODTAB(5:)}   1   ATODTAB    =  ?$?
WFC3    BPIXTAB   {BPIXTAB(5:)}   1   BPIXTAB    =  ?$?
WFC3    CCDTAB    {CCDTAB(5:)}    1   CCDTAB     =  ?$?
WFC3    COMPTAB   {COMPTAB(5:)}   1   COMPTAB    =  ?$?
WFC3    CRREJTAB  {CRREJTAB(5:)}  1   CRREJTAB   =  ?$?
WFC3    GRAPHTAB  {GRAPHTAB(5:)}  1   GRAPHTAB   =  ?$?
WFC3    IDCTAB    {IDCTAB(5:)}    1   IDCTAB     =  ?$?
WFC3    MDRIZTAB  {MDRIZTAB(5:)}  1   MDRIZTAB   =  ?$?
WFC3    OSCNTAB   {OSCNTAB(5:)}   1   OSCNTAB    =  ?$?
!
! PR 62767 Fill sci_spec_1234 when no filter commanded
WFC3    SPEC_1    {FILTER}     1    SPEC_1     =       BLANK

!
! 
! WFPC2 rules:-------------------------------------------------------------
! 
! PR 61236 Dec 2008 Explanation of WF2 cataloging and changes made
!                   for this PR.
! The current set up in ingest_files_mapping ALWAYS prefers (for 4 chips)
!     c0f into groups 0, 1, 2, 3      
! and d0f into groups 4, 5, 6, and 7  
! where groups 0 (c0h) and 4 (d0h) are a combination of the keywords in the 
!       PRIMARY and first SCI extension headers.
! Let me note that the majority of WFPC2 keyword values are essentially 
! the same in the raw and cal headers, so this switch in preference 
! (PR 60995) has only affected a subset of keywords, most, if not all, 
! of which require special rules to get into the catalog.
!
! Table selectors (from ingest_tables) are given a value containing the
! string "LOAD".  The rules package understands when to load from a
! specific group, because the group number can be appended to the string
! "LOAD".  In the past, the WF2 logic was set to prefer the raw data: the 
! raw data were always the first set of groups and the cal data started at
! the group number matching the sum of GCOUNT from the raw.  Therefore,
! in the past, the strings LOAD0 meant catalog from the raw data, and
! LOADN (for N chip data) meant catalog from the calibrated data.
! "LOADN" could be "LOAD4" or "LOAD2", etc., depending on the number of
! chips used for the observation.   Some keywords values were copied from
! their default group to the one that was to be loaded.  This logic
! worked because the content of the groups was predictable, but now, with
! the more logical "prefer cal data" setup, if there are NO cal data,
! then raw data will be in the groups the cal data usually occupy.  Now
! we prefer to load from group 0, which is usually cal data, but reverts
! to raw when that is all that is available.  Thus we decreased the
! number of commands needed because we no longer need the <move*>
! commands.  
! 
! However, there are a large number of keywords with different values
! in the Multi-Extension Format (MEF) extensions that go into the catalog
! as values in "suffixed fields".  In other words, instead of having N
! rows for the N different chip values, there are instead N fields.  The
! same keyword fills each field, except that the keyword values come
! from the different extensions.  So, fake "suffixed keywords" are
! created by a set of entries in dads_keywords, ingest_overrides, and
! filled by a set of rule commands so that the value from the correct
! extension will get into the correct "suffixed field".  This also means 
! that the WFPC2 catalog will _always_ contain some NULLs because 4
! "suffixed fields" exist to accommodate the maximum number of chips that 
! could be observed with, but some observations use fewer.  
!
! Lastly, there are a set of these "suffixed keywords" that must always
! come from raw headers, even if cal data is available; and another set
! which must always be filled from the cal headers unless only raw data
! are available.  These commands, the right logic in the rules, and a
! preference for loading from group 0.
! 
! The original names of these commands (<merge*>) did not seem to me to
! make much sense.  Therefore, they were renamed.
!        mergeraw became realloc_0_to_0
!        mergecal became realloc_N_to_N (and is no longer used)
!       mergephot became realloc_N_to_0
!
! Also, instead of using the enigmatic t_WF2PR selector for the 
! wfpc2_primary_data relation, we now use MEMBEXP like the other 
! WFPC2-specific tables.  
!-----------------------
!
WFPC2   CALIBRAT(*) {CALIBRAT} 1          TARGNAME =    {TARGNAME}
!
WFPC2   PRODEXP   LOAD0        1          T        =    T
WFPC2   MEMBEXP   LOAD0        1          T        =    T
!
! We need a rule to tell us when we have only raw data available, 
! because how we fill the suffixed keywords may differ when there 
! is only raw data.  <setcount> now sets t_USERAW.
!
! When cal data are present,     group 0 is cal, "load group" is raw
! When cal data are NOT present, group 0 is raw, "load group" is NON-existent
! mergecal          mergeraw          mergephot
! realloc_N_to_N    realloc_0_to_0    realloc_N_to_0
! LoadN -> LoadN    Load0 -> Load0    LoadN -> Load0
!     4 -> _1(4)        0 -> _1(0)    4 -> _1(0)
!     5 -> _2(4)        1 -> _2(0)    5 -> _2(0)
!     6 -> _3(4)        2 -> _3(0)    6 -> _3(0)
!     7 -> _4(4)        3 -> _4(0)    7 -> _4(0)
! 
! The WFPC2 <setcount> command sets the value for t_USERAW and sets up some 
! constants needed by later calls to the other commands (see above).  The 
! <setcount> command depends on a non-null value of CALIBRAT for every group 
! so every CALIBRAT value is set explicitly.
!
WFPC2   t_USERAW   <setcount>        1          T        =    T
! 
! Use t_USERAW to indicate when keywords should be cataloged from the RAW data 
! specifically.  t_USERAW will have T/F values spelled out.
! 
! Remove the iraf directory variable before loading the catalog
!
WFPC2   BIASDFIL  {BIASDFIL(5:)}  1   BIASDFIL   =  uref$?
WFPC2   BLEVDFIL  {BLEVDFIL(5:)}  1   BLEVDFIL   =  uref$?
WFPC2   BLEVDFIL  {BLEVDFIL(5:)}  2   BLEVDFIL   =  ucal$?
WFPC2   DARKDFIL  {DARKDFIL(5:)}  1   DARKDFIL   =  uref$?
WFPC2   FLATDFIL  {FLATDFIL(5:)}  1   FLATDFIL   =  uref$?
WFPC2   ATODFILE  {ATODFILE(5:)}  1   ATODFILE   =  uref$?
WFPC2   BIASFILE  {BIASFILE(5:)}  1   BIASFILE   =  uref$?
WFPC2   BLEVFILE  {BLEVFILE(5:)}  1   BLEVFILE   =  ucal$?
WFPC2   DARKFILE  {DARKFILE(5:)}  1   DARKFILE   =  uref$?
WFPC2   FLATFILE  {FLATFILE(5:)}  1   FLATFILE   =  uref$?
WFPC2   IDCTAB    {IDCTAB(5:)}    1   IDCTAB     =  uref$?
WFPC2   OFFTAB    {OFFTAB(5:)}    1   OFFTAB     =  uref$?
WFPC2   MASKFILE  {MASKFILE(5:)}  1   MASKFILE   =  uref$?
WFPC2   SHADFILE  {SHADFILE(5:)}  1   SHADFILE   =  uref$?
WFPC2   WF4TFILE  {WF4TFILE(5:)}  1   WF4TFILE   =  uref$?
WFPC2   DGEOFILE  {DGEOFILE(5:)}  1   DGEOFILE   =  uref$?
WFPC2   COMPTAB   {COMPTAB(5:)}   1   COMPTAB    =  mtab$?
WFPC2   GRAPHTAB  {GRAPHTAB(5:)}  1   GRAPHTAB   =  mtab$?
! 
!--------------------------------------------------------------
! The <realloc_0_to_0> command populates suffixed keywords in group 0 for
! WFPC2 datasets. The suffixes are _1, _2 etc. The number of keywords to 
! reallocate and the the load group are determined by the setcount 
! command but basically they match the NEXTEND value. 
!
! These keyword values go into wfpc2_primary_data and we want cal values
!
WFPC2   ATODSAT         <realloc_0_to_0>  1	         T   =   T
WFPC2   BADPIXEL        <realloc_0_to_0>  1	         T   =   T
WFPC2   BIASEVEN        <realloc_0_to_0>  1	         T   =   T
WFPC2   BIASEVNU        <realloc_0_to_0>  1	         T   =   T
WFPC2   BIASODD         <realloc_0_to_0>  1	         T   =   T
WFPC2   BIASODDU        <realloc_0_to_0>  1	         T   =   T
WFPC2   CALIBDEF        <realloc_0_to_0>  1	         T   =   T
WFPC2   CD1_1           <realloc_0_to_0>  1	         T   =   T
WFPC2   CD1_2           <realloc_0_to_0>  1	         T   =   T
WFPC2   CD2_1           <realloc_0_to_0>  1	         T   =   T
WFPC2   CD2_2           <realloc_0_to_0>  1	         T   =   T
WFPC2   CRPIX1          <realloc_0_to_0>  1	         T   =   T
WFPC2   CRPIX2          <realloc_0_to_0>  1	         T   =   T
WFPC2   CRVAL1          <realloc_0_to_0>  1	         T   =   T
WFPC2   CRVAL2          <realloc_0_to_0>  1	         T   =   T
WFPC2   CTE_1E2         <realloc_0_to_0>  1              T   =   T
WFPC2   CTE_1E3         <realloc_0_to_0>  1              T   =   T
WFPC2   CTE_1E4         <realloc_0_to_0>  1              T   =   T
WFPC2   CTYPE1          <realloc_0_to_0>  1	         T   =   T
WFPC2   CTYPE2          <realloc_0_to_0>  1	         T   =   T
WFPC2   DATALOST        <realloc_0_to_0>  1	         T   =   T
WFPC2   DATAMAX         <realloc_0_to_0>  1	         T   =   T
WFPC2   DATAMEAN        <realloc_0_to_0>  1	         T   =   T
WFPC2   DATAMIN         <realloc_0_to_0>  1	         T   =   T
WFPC2   DETECTOR        <realloc_0_to_0>  1	         T   =   T
WFPC2   DEZERO          <realloc_0_to_0>  1	         T   =   T
WFPC2   ERRCNT          <realloc_0_to_0>  1	         T   =   T
WFPC2   FILLCNT         <realloc_0_to_0>  1	         T   =   T
WFPC2   FPKTTIME        <realloc_0_to_0>  1	         T   =   T
WFPC2   GOODMAX         <realloc_0_to_0>  1	         T   =   T
WFPC2   GOODMIN         <realloc_0_to_0>  1	         T   =   T
WFPC2   GPIXELS         <realloc_0_to_0>  1	         T   =   T
WFPC2   LPKTTIME        <realloc_0_to_0>  1	         T   =   T
WFPC2   MIR_REVR        <realloc_0_to_0>  1	         T   =   T
WFPC2   OVERLAP         <realloc_0_to_0>  1	         T   =   T
WFPC2   SOFTERRS        <realloc_0_to_0>  1	         T   =   T
WFPC2   STATICD         <realloc_0_to_0>  1	         T   =   T
WFPC2   VAFACTOR        <realloc_0_to_0>  1              T   =   T
!------------------------------------------------------------------
!
! These data populate wfpc2_secondary_data with RAW header values
! on purpose.  That means that when cal data are present, we want 
! values from the the 2nd set of data starting at the group number 
! matching NEXTEND BUT when only raw data are available, we 
! will use the values from groups starting at 0.  Therefore, we 
! need a way to know when only raw data area available.  This is 
! where <setcount> and t_USERAW come in. 
!
!INST     NAME  =           DEFAULT  if TEST  KEYWORD   COMPARE    VALUE
!----    --------          ----------  ----  --------  -------    -------
WFPC2   ORIENTAT    <realloc_0_to_0>      1   t_USERAW      =      TRUE          ! raw only, load0 
WFPC2   ORIENTAT    <realloc_N_to_0>      2           T     =   T                ! cal avail, loadN
WFPC2   BACKGRND    <realloc_0_to_0>      1   t_USERAW      =      TRUE
WFPC2   BACKGRND    <realloc_N_to_0>      2           T     =   T
WFPC2   HISTWIDE    <realloc_0_to_0>      1   t_USERAW      =      TRUE
WFPC2   HISTWIDE    <realloc_N_to_0>      2           T     =   T
WFPC2   MEANC100    <realloc_0_to_0>      1   t_USERAW      =      TRUE
WFPC2   MEANC100    <realloc_N_to_0>      2           T     =   T
WFPC2   MEANC10     <realloc_0_to_0>      1   t_USERAW      =      TRUE
WFPC2   MEANC10     <realloc_N_to_0>      2           T     =   T
WFPC2   MEANC200    <realloc_0_to_0>      1   t_USERAW      =      TRUE
WFPC2   MEANC200    <realloc_N_to_0>      2           T     =   T
WFPC2   MEANC25     <realloc_0_to_0>      1   t_USERAW      =      TRUE
WFPC2   MEANC25     <realloc_N_to_0>      2           T     =   T
WFPC2   MEANC300    <realloc_0_to_0>      1   t_USERAW      =      TRUE
WFPC2   MEANC300    <realloc_N_to_0>      2           T     =   T
WFPC2   MEANC50     <realloc_0_to_0>      1   t_USERAW      =      TRUE
WFPC2   MEANC50     <realloc_N_to_0>      2           T     =   T
WFPC2   MEDIAN      <realloc_0_to_0>      1   t_USERAW      =      TRUE
WFPC2   MEDIAN      <realloc_N_to_0>      2           T     =   T
WFPC2   MEDSHADO    <realloc_0_to_0>      1   t_USERAW      =      TRUE
WFPC2   MEDSHADO    <realloc_N_to_0>      2           T     =   T
WFPC2   SKEWNESS    <realloc_0_to_0>      1   t_USERAW      =      TRUE
WFPC2   SKEWNESS    <realloc_N_to_0>      2           T     =   T
!
! The PHOT keywords are yet another twist on top of the already awkward 
! rules.  They also go into the relation wfpc2_secondary_data, but 
! we always want the calibrated value unless only raw is available.  
! With cal data preferred, that means always take the values from group 0.
!
WFPC2   PHOTBW          <realloc_0_to_0>  1            T   =       T
WFPC2   PHOTFLAM        <realloc_0_to_0>  1            T   =       T
WFPC2   PHOTMODE        <realloc_0_to_0>  1            T   =       T
WFPC2   PHOTPLAM        <realloc_0_to_0>  1            T   =       T
WFPC2   PHOTZPT         <realloc_0_to_0>  1            T   =       T
WFPC2   ZP_CORR         <realloc_0_to_0>  1            T   =       T
!
! There was NO need to have WFPC2 rules for t_WAVLEN and t_BANDWD.
! Evidently the following value for science table is a constant.
!
WFPC2  t_PIXRES   .1       1     T =  T
!
!
! End of WFPC2 rules:-------------------------------------------------------------

!
! Generic (all instrument) rules:-----------------------------------------
!
! The following rules control whether certain relations are being loaded
! ......moving_target_position...
GEN     t_MOVER   LOAD        1     MTFLAG         =    T
GEN     t_MOVER   IGNORE      2           T        =    T
!
GEN	t_FIXED   IGNORE      1     MTFLAG         =    T
GEN     t_FIXED   IGNORE      2     ASN_MTYP       =    EXP?
GEN     t_FIXED   IGNORE      3     ASN_MTYP       =    BLANK
GEN     t_FIXED   IGNORE      4     FILETYPE       =    ASN_TABLE
GEN     t_FIXED   IGNORE      5     FILETYPE       =    JIM
GEN     t_FIXED   LOAD        6           T        =    T
! ......scan_parameters
GEN     t_SCANER  LOAD        1     SCAN_TYP       =    C
GEN     t_SCANER  LOAD        1     ASN_MTYP       =    PROD?
GEN     t_SCANER  LOAD        2     SCAN_TYP       =    D
GEN     t_SCANER  LOAD        2     ASN_MTYP       =    PROD?
GEN     t_SCANER  LOAD        3     SCAN_TYP       =    C
GEN     t_SCANER  LOAD        3     INSTRUME       =    WFPC2
GEN     t_SCANER  LOAD        4     SCAN_TYP       =    D
GEN     t_SCANER  LOAD        4     INSTRUME       =    WFPC2
GEN     t_SCANER  IGNORE      5           T        =    T
! ......target_keyword
GEN     t_CATARG  IGNORE      1     TARGCAT        =    BLANK
GEN     t_CATARG  LOAD        2     PRODEXP        =    LOAD?
GEN     t_CATARG  IGNORE      3           T        =    T
!.......target_synonym
GEN	t_SYNONM  IGNORE      1     TARGNAME     =    BLANK
GEN	t_SYNONM  IGNORE      2     TARGNAME     =    WAVELINE
GEN     t_SYNONM  LOAD        3     PRODEXP      =    LOAD?
GEN	t_SYNONM  IGNORE      4           T      =    T
!
! PR 54677 Add some rules for SM4 instruments 
GEN     AEC       C           1     TARGNAME     =    ANTISUN
GEN     AEC       C           2     TARGNAME     =    ASLAG
GEN     AEC       C           3     TARGNAME     =    BIAS
GEN     AEC       C           4     TARGNAME     =    DARK
GEN     AEC       C           5     TARGNAME     =    EARTH-CALIB
GEN     AEC       C           6     TARGNAME     =    FGS.CHAR1
GEN     AEC       C           7     TARGNAME     =    GLOW-TAR
GEN     AEC       C           8     TARGNAME     =    INTFLAT
GEN     AEC       C           9     TARGNAME     =    ION
GEN     AEC       C           10    TARGNAME     =    KSPOTS
GEN     AEC       C           11    TARGNAME     =    SKY-2
GEN     AEC       C           12    TARGNAME     =    SKY-5
GEN     AEC       C           13    TARGNAME     =    PMT-DARK-SKY
GEN     AEC       C           14    TARGNAME     =    TALED
GEN     AEC       C           15    TARGNAME     =    UVFLAT
GEN     AEC       C           16    TARGNAME     =    VISFLAT
GEN     AEC       C           17    TARGNAME     =    WAVE?
GEN     AEC       C           18    TARGNAME     =    NONE
GEN     AEC       C           19    IMAGETYP     =    LAMP?
GEN     AEC       C           19    INSTRUME     =    NICMOS
GEN     AEC       C           20    TARGNAME     =    TUNGSTEN
GEN     AEC       C           21    TARGNAME     =    DEUTERIUM
GEN     AEC       C           22    TARGNAME     =    POST-SAA-DARK 
GEN     AEC       C           23    TARGNAME     =    ORBIT-POLE
GEN     AEC       C           24    TARGNAME     =    NORTH-POLE-SKY
GEN     AEC       C           25    INSTRUME     =    WFC3
GEN     AEC       C           25    DETECTOR     =    IR
GEN     AEC       C           25    FILTER       =    BLANK
GEN     AEC       C           25    IMAGETYP     =    DARK
GEN     AEC       S           40        T        =    T
!
GEN     COSTAR    T            1    INSTRUME     =    HRS
GEN     COSTAR    F            2        T        =    T
!
! Modified to make more sense via PR 60563
GEN     FOV_CNFG  SM-1         1   EXPSTART      < [0.0+50499.0] !20 FEB 1997
GEN     FOV_CNFG  SM-2         2   EXPSTART      < [0.0+52336.0] !03 MAR 2002
GEN     FOV_CNFG  SM-3         3   EXPSTART      < [0.0+54964.0] !13 MAY 2009
GEN     FOV_CNFG  SM-4         4       T         =    T
!
!
! ...make multiple keys, multiple groups for target_synonym.  Need to
!    propogate the other keys from group zero too.
!
GEN     TARGNAME(1) {ALIAS1}    1   ALIAS1      !=    BLANK
GEN     TARGNAME(2) {ALIAS2}    1   ALIAS2      !=    BLANK
GEN     PROGRMID(*) {PROGRMID}  1   TARGNAME     =    {TARGNAME}
GEN     OBSET_ID(*) {OBSET_ID}  1   TARGNAME     =    {TARGNAME}
GEN     OBSERVTN(*) {OBSERVTN}  1   TARGNAME     =    {TARGNAME}
GEN     OBSID(*)    {OBSID}  1   TARGNAME     =    {TARGNAME}
!
GEN     TARKEY1     NULL        1   TARKEY1      =    BLANK
GEN     TARKEY1(1)  {TARKEY2}   1   TARKEY2     !=    BLANK
GEN     TARGCAT(1)  {TARGCAT}   1   TARKEY2     !=    BLANK
GEN     TARKEY1(2)  {TARKEY3}   1   TARKEY3     !=    BLANK
GEN     TARGCAT(2)  {TARGCAT}   1   TARKEY3     !=    BLANK
GEN     TARKEY1(3)  {TARKEY4}   1   TARKEY4     !=    BLANK
GEN     TARGCAT(3)  {TARGCAT}   1   TARKEY4     !=    BLANK
GEN     TARKEY1(4)  {TARKEY5}   1   TARKEY5     !=    BLANK
GEN     TARGCAT(4)  {TARGCAT}   1   TARKEY5     !=    BLANK
GEN     TARKEY1(5)  {TARKEY6}   1   TARKEY6     !=    BLANK
GEN     TARGCAT(5)  {TARGCAT2}  1   TARKEY6     !=    BLANK
GEN     TARKEY1(6)  {TARKEY7}   1   TARKEY7     !=    BLANK
GEN     TARGCAT(6)  {TARGCAT2}  1   TARKEY7     !=    BLANK
GEN     TARKEY1(7)  {TARKEY8}   1   TARKEY8     !=    BLANK
GEN     TARGCAT(7)  {TARGCAT2}  1   TARKEY8     !=    BLANK
GEN     TARKEY1(8)  {TARKEY9}   1   TARKEY9     !=    BLANK
GEN     TARGCAT(8)  {TARGCAT2}  1   TARKEY9     !=    BLANK
GEN     TARKEY1(9)  {TARKEY10}  1   TARKEY10    !=    BLANK
GEN     TARGCAT(9)  {TARGCAT2}  1   TARKEY10    !=    BLANK
GEN     PROGRMID(*) {PROGRMID}  1   TARKEY1     =    {TARKEY1}
GEN     OBSET_ID(*) {OBSET_ID}  1   TARKEY1     =    {TARKEY1}
GEN     OBSERVTN(*) {OBSERVTN}  1   TARKEY1     =    {TARKEY1}
!
GEN     MTP_TEXT     {MT_LV1_1} 1   MT_LV1_1    !=    BLANK
GEN     MTP_LEVL     1          1   MT_LV1_1    !=    BLANK
GEN     MTP_LINE     1          1   MT_LV1_1    !=    BLANK
GEN     MTP_TEXT(1)  {MT_LV1_2} 1   MT_LV1_2    !=    BLANK
GEN     MTP_LEVL(1)  1          1   T = T
GEN     MTP_LINE(1)  2          1   MT_LV1_2    !=    BLANK
GEN     MTP_TEXT(2)  {MT_LV1_3} 1   MT_LV1_3    !=    BLANK
GEN     MTP_LEVL(2)  1          1   T = T
GEN     MTP_LINE(2)  3          1   MT_LV1_3    !=    BLANK
GEN     MTP_TEXT(3)  {MT_LV1_4} 1   MT_LV1_4    !=    BLANK
GEN     MTP_LEVL(3)  1          1   T = T
GEN     MTP_LINE(3)  4          1   MT_LV1_4    !=    BLANK
GEN     MTP_TEXT(4)  {MT_LV1_5} 1   MT_LV1_5    !=    BLANK
GEN     MTP_LEVL(4)  1          1   T = T
GEN     MTP_LINE(4)  5          1   MT_LV1_5    !=    BLANK
GEN     MTP_TEXT(5)  {MT_LV2_1} 1   MT_LV2_1    !=    BLANK
GEN     MTP_LEVL(5)  2          1   MT_LV2_1    !=    BLANK
GEN     MTP_LINE(5)  1          1   MT_LV2_1    !=    BLANK
GEN     MTP_TEXT(6)  {MT_LV2_2} 1   MT_LV2_2    !=    BLANK
GEN     MTP_LEVL(6)  2          1   MT_LV2_2    !=    BLANK
GEN     MTP_LINE(6)  2          1   MT_LV2_2    !=    BLANK
GEN     MTP_TEXT(7)  {MT_LV2_3} 1   MT_LV2_3    !=    BLANK
GEN     MTP_LEVL(7)  2          1   MT_LV2_3    !=    BLANK
GEN     MTP_LINE(7)  3          1   MT_LV2_3    !=    BLANK
GEN     MTP_TEXT(8)  {MT_LV2_4} 1   MT_LV2_4    !=    BLANK
GEN     MTP_LEVL(8)  2          1   MT_LV2_4    !=    BLANK
GEN     MTP_LINE(8)  4          1   MT_LV2_4    !=    BLANK
GEN     MTP_TEXT(9)  {MT_LV2_5} 1   MT_LV2_5    !=    BLANK
GEN     MTP_LEVL(9)  2          1   MT_LV2_5    !=    BLANK
GEN     MTP_LINE(9)  5          1   MT_LV2_5    !=    BLANK
GEN     MTP_TEXT(10)  {MT_LV3_1} 1   MT_LV3_1    !=    BLANK
GEN     MTP_LEVL(10)  3          1   MT_LV3_1    !=    BLANK
GEN     MTP_LINE(10)  1          1   MT_LV3_1    !=    BLANK
GEN     MTP_TEXT(11)  {MT_LV3_2} 1   MT_LV3_2    !=    BLANK
GEN     MTP_LEVL(11)  3          1   MT_LV3_2    !=    BLANK
GEN     MTP_LINE(11)  2          1   MT_LV3_2    !=    BLANK
GEN     MTP_TEXT(12)  {MT_LV3_3} 1   MT_LV3_3    !=    BLANK
GEN     MTP_LEVL(12)  3          1   MT_LV3_3    !=    BLANK
GEN     MTP_LINE(12)  3          1   MT_LV3_3    !=    BLANK
GEN     MTP_TEXT(13)  {MT_LV3_4} 1   MT_LV3_4    !=    BLANK
GEN     MTP_LEVL(13)  3          1   MT_LV3_4    !=    BLANK
GEN     MTP_LINE(13)  4          1   MT_LV3_4    !=    BLANK
GEN     MTP_TEXT(14)  {MT_LV3_5} 1   MT_LV3_5    !=    BLANK
GEN     MTP_LEVL(14)  3          1   MT_LV3_5    !=    BLANK
GEN     MTP_LINE(14)  5          1   MT_LV3_5    !=    BLANK
GEN     PROGRMID(*)  {PROGRMID}  1   MTP_TEXT      =   {MTP_TEXT}
GEN     OBSET_ID(*)  {OBSET_ID}  1   MTP_TEXT      =   {MTP_TEXT}
GEN     t_MTLOAD(*)  {PRODEXP}   1   MTP_TEXT      =   {MTP_TEXT}
GEN     t_OBSNUM(*)  {OBSNUM}    1   MTP_TEXT      =   {MTP_TEXT}
GEN     t_OBSNUM(*)  {OBSNUM}    1   t_MTLOAD      =   LOAD?
