kr_test


This is a utility to test the keyword_rules to determine if the rules still behave as they have in the past.

There are four input files which are required:

  1. The cgg1 format file which defines the fields in your private cgg1_keyword file and the name of that file.
  2. The cgg1_keyword file which is named in the format file. During development we used a subset of the operational cgg1_keyword.dat file used to load the cgg1_keyword relation in the database. This was the easiest route since the format file (above) had already been defined and tested.
  3. Your test keyword_rules file. This allows you to construct new tests of the rules.
  4. Your test values file where you can change the input values of the keywords. This file is formatted as a keyword=value file just like the .dvx or .dcx or .dgx files used in OPUS.

 
Usage:
Context:


Inputs Initial examples of all the input files can be found in the share/dat CVS library.

{cgg1_file}

The cgg1 format file defines the name of your private cgg1_keyword.dat file as well as the fields in that private file. For example:

!--------------------------------------------------------------------
!
!      KEYWORD NAMES FILE
!
!
! This file defines the order and size of the fields in the keyword
! names file.  It is assumed that this file will be resident
! in the opus_definitions_dir along with other resource and data files.
!
! Note that the filename and the offset and size of any of the fields
! may change; but the names of the fields on the left of the "=" must
! remain.
!
!--------------------------------------------------------------------
!                          REVISION HISTORY
!--------------------------------------------------------------------
!  MOD             PR
! LEVEL   DATE   NUMBER  User  Description
! ----- -------- ------  ------ -------------------------------------
!  000  05/09/97 34299   Rose   Created
!
!--------------------------------------------------------------------

!FILENAME = OPUS_DBMS_LOAD:cgg1_keyword.dat
FILENAME  = kr_test_cgg1.dat

INSTRUMENT.OFFSET = 0		!Name of the instrument
INSTRUMENT.SIZE   = 3		!INSTRUMENT/GROUP/ORDER must be first fields

GROUP.OFFSET  	  = 4		!Name of the group of keywords
GROUP.SIZE        = 3

ORDER.OFFSET      = 14		!Order in which keyword appears in header
ORDER.SIZE        =  3		!within this group.

NAME.OFFSET       = 18		!Keyword name.  FITS limits these to
NAME.SIZE         =  8		!eight characters.

TYPE.OFFSET       = 27		!L1, I4, R4, R8, Cnn, CHR, COM=comment
TYPE.SIZE         =  3		!nn=number of characters, CHR=C20

DEFAULT.OFFSET    = 31		!default value.  note that strings are left
DEFAULT.SIZE      = 20		!justified, numeric is right justified.

COMMENT.OFFSET    = 52		!any string.
COMMENT.SIZE      = 68

OPTIONAL.OFFSET   = 127		!Y/N: if N, then if keyword is blank,
OPTIONAL.SIZE     =   1		!omit the keyword from the header

{rules_file}

Your test keyword_rules file. This allows you to construct new tests of the rules. The structure and syntax of the rules file can be found in the operational keyword_rules.lis file. Your test rules file can (should) include some tests which fail. For example:
!
! Test undelimited substring (This is OK)
ALL     BIASDFIL  {BIASDFIL(5:)}  1   BIASDFIL   =  uref$?
!
! Test illegal substring limits
ALL     DARKFILE  {DARKFILE(A:H)}  1   T = T
!
! Test arithmetic with bogus value ( = 12)
ALL     SURF_V    [12+VVV]      1       T  = T
! 
! Test a null number
ALL     SURF_U    {SURF_V()}   1       T  = T
! 
! Test a negative index
ALL     MAG_U     {MAG_B(-1)}   1       T  = T
! 
! Test an illegal number
ALL     MAG_B     {MAG_B(A)}   1       T  = T
! 
! Test illegal wildcard on condition
ALL     SURF_B    {SURF_R}     1    EXPSTART = {SUN_ALT(*)}
ALL     SURF_U    {SURF_R}     1    MOONANGLE(*) =  BLANK
! 
! Confused syntax in group notation
ALL     SURF_R    {SURF_B(*:2)} 1    T = T
! 
! Missing close parens
ALL     SURF_V    {SURF_U(3:4}  1    T = T
! 
! Test negative group number
ALL     TARGNAME(-4) {ALIAS2}    1   ALIAS2      !=    BLANK
!
! ...make multiple keys, multiple groups for target_synonym.  Need to
!    propogate the other keys from group zero too.
!
ALL     TARGNAME(1) {ALIAS1}    1   ALIAS1      !=    BLANK
ALL     TARGNAME(2) {ALIAS2}    1   ALIAS2      !=    BLANK
!

{values_file}

Your test values file where you can change the input values of the keywords. This file is formatted as a keyword=value file just like the .dvx or .dcx or .dgx files used in OPUS. For example:

------------- j8a602a1q 2001/07/17 07:17:58 ----------
------------- file_type WCS, frame 1 -----------------
CRVAL1  =   3.095607457200E+02 / WCS SCI
CRVAL2  =   6.150131629327E+01 / WCS SCI
CRPIX1  =                 2072 / WCS SCI
CRPIX2  =                 1044 / WCS SCI
CD1_1   =         -6.92045E-06 / WCS SCI
CD1_2   =          1.10248E-05 / WCS SCI
CD2_1   =          1.17985E-05 / WCS SCI
CD2_2   =          7.85754E-06 / WCS SCI
CTYPE1  = RA---TAN             / WCS SCI
CTYPE2  = DEC--TAN             / WCS SCI
RA_APER =   3.095607457200E+02 / WCS SCI
DEC_APER=   6.150131629327E+01 / WCS SCI
MIR_REVR=                    T / WCS SCI
ORIENTAT=              54.5219 / WCS SCI
LTV1    =                   24 / WCS SCI
LTV2    =                   20 / WCS SCI
LTM1_1  =                    1 / WCS SCI
LTM2_2  =                    1 / WCS SCI
PA_APER =   5.452186203003E+01 / WCS SCI
CENTERA1=                 2073 / WCS SCI
CENTERA2=                 1035 / WCS SCI
SIZAXIS1=                 4144 / WCS SCI
SIZAXIS2=                 2068 / WCS SCI
FILTNAM1= F122M                / WCS SCI
TARKEY1 = target key 1         / WCS SCI
TARKEY2 = say something        / WCS SCI
TARKEY4 = nice                 / WCS SCI
EXPSTART= 51000.0              / WCS SCI
ATODSAT = 10000                / WCS SCI
TARGNAME= Big Star             / WCS SCI
TARGCAT = Top Notch Category   / WCS SCI
ASN_MTYP= PRODUCE GALORE       / WCS SCI
ALIAS1  = Bigger than yours    / WCS SCI
ALIAS2  = BIGGEST              / WCS SCI
MT_LV1_1= Moving Target Level 1 / WCS SCI
MT_LV2_3= MT LEVEL 2_3         / WCS SCI
INSTRUME= WFPC2                / WCS SCI
BIASDFIL= uref$biasfile.ref    / WCS SCI
OBSET_ID= Jim                  / WCS SCI
OBSNUM  = 4q                   / WCS SCI
------------- file_type WCS, frame 2 -----------------
CRVAL1  =   3.095118070833E+02 / WCS SCI
CRVAL2  =   6.148479997017E+01 / WCS SCI
CRPIX1  =                 2072 / WCS SCI
CRPIX2  =                 1024 / WCS SCI
CD1_1   =         -7.16513E-06 / WCS SCI
CD1_2   =          1.14511E-05 / WCS SCI
CD2_1   =          1.18425E-05 / WCS SCI
CD2_2   =          8.04081E-06 / WCS SCI
CTYPE1  = RA---TAN             / WCS SCI
CTYPE2  = DEC--TAN             / WCS SCI
RA_APER =   3.095607457200E+02 / WCS SCI
DEC_APER=   6.150131629327E+01 / WCS SCI
MIR_REVR=                    T / WCS SCI
ORIENTAT=               54.924 / WCS SCI
LTV1    =                   24 / WCS SCI
LTV2    =                    0 / WCS SCI
LTM1_1  =                    1 / WCS SCI
LTM2_2  =                    1 / WCS SCI
PA_APER =   5.492397689819E+01 / WCS SCI
CENTERA1=                 2073 / WCS SCI
CENTERA2=                 1035 / WCS SCI
SIZAXIS1=                 4144 / WCS SCI
SIZAXIS2=                 2068 / WCS SCI
ATODSAT = 20000                / WCS SCI
------------- file_type WCS, frame 3 -----------------
ATODSAT = 30000                / WCS SCI

Examples:
Using the input files initially stored in the share/dat CVS library, we get the following results (annotations added)
!------------------------------------------------------------------------
!Interpretation of error messages and test output:
!------------------------------------------------------------------------
!
! Test illegal substring limits
ALL     DARKFILE  {DARKFILE(A:H)}  1   T = T
2003239185324-E-ERROR RULE_SKIPPED: Unable to convert substring DARKFILE(A:H) (1)
! 
! Test a null number
ALL     SURF_U    {SURF_V()}   1       T  = T
2003239185324-E-ERROR RULE_SKIPPED: Unknown syntax SURF_V() (1)
! 
! Test a negative index
ALL     MAG_U     {MAG_B(-1)}   1       T  = T
2003239185324-E-ERROR RULE_SKIPPED: Unknown syntax MAG_B(-1) (1)
! 
! Test an illegal number
ALL     MAG_B     {MAG_B(A)}   1       T  = T
2003239185324-E-ERROR RULE_SKIPPED: Unknown syntax MAG_B(A) (1)
! 
! Test illegal wildcard on condition
ALL     SURF_B    {SURF_R}     1    EXPSTART = {SUN_ALT(*)}
2003239185324-E-ERROR RULE_SKIPPED: No Wildcards on right of compare: SUN_ALT(*)  (1)
! 
! Test illegal wildcard on condition
ALL     SURF_U    {SURF_R}     1    MOONANGLE(*) =  BLANK
2003239185324-E-ERROR RULE_SKIPPED: No Wildcards on left of compare: MOONANGLE(*) (1)
! 
! Confused syntax in group notation
ALL     SURF_R    {SURF_B(*:2)} 1    T = T
2003239185324-E-ERROR RULE_SKIPPED: Unable to convert substring SURF_B(*:2) (1)
! 
! Missing close parens
ALL     SURF_V    {SURF_U(3:4}  1    T = T
2003239185324-E-ERROR RULE_SKIPPED: Missing delimeter SURF_U(3:4 (1)
! 
! Test negative group number
ALL     TARGNAME(-4) {ALIAS2}    1   ALIAS2      !=    BLANK
2003239185324-E-ERROR RULE_SKIPPED: Unknown syntax TARGNAME(-4) (1)
2003239185324-E-ERROR RULE_SKIPPED: unknown group value: ALIAS2 (1)
!
! ...make multiple keys, multiple groups for target_synonym.  Need to
!    propogate the other keys from group zero too.
!
ALL     TARGNAME(1) {ALIAS1}    1   ALIAS1      !=    BLANK
ALL     TARGNAME(2) {ALIAS2}    1   ALIAS2      !=    BLANK
!

|-keyword number
| |-group number
| |
1 0 ALIAS1 = Bigger than yours
2 0 ALIAS2 = BIGGEST
!.....see TARGNAME below
!
ALL     ASNTBL    LOAD        1     ASN_STAT       =    COMPLETE
ALL     ASNTBL    IGNORE      2           T        =    T
3 0 ASNTBL = IGNORE
!
! Copied from kr_test.dcx
4 0 ASN_MTYP = PRODUCE GALORE
!
! No rule for ASN_PROD
5 0 ASN_PROD = 
!
! Copied from kr_test.dcx
6 0 ASN_STAT = CGG1_DEFAULT
!
! Copied from kr_test.dcx
! ...note group is correct
7 0 ATODSAT = 10000
7 1 ATODSAT = 20000
7 2 ATODSAT = 30000
!
! Test undelimited substring (This is OK)
ALL     BIASDFIL  {BIASDFIL(5:)}  1   BIASDFIL   =  uref$?
! ....from kr_test.dcx:
! BIASDFIL= uref$biasfile.ref    / WCS SCI
!
8 0 BIASDFIL = biasfile.ref
!
! Test illegal substring limits (see error above)
ALL     DARKFILE  {DARKFILE(A:H)}  1   T = T
9 0 DARKFILE = 
!
! Test group(i) keyword copied to group(0) keyword
ALL     DIAG01 {ATODSAT(0)}  1       T        =    T
ALL     DIAG02 {ATODSAT(1)}  1       T        =    T
ALL     DIAG03 {ATODSAT(2)}  1       T        =    T
ALL     DIAG04 {ATODSAT(3)}  1       T        =    T
10 0 DIAG01 = 10000
11 0 DIAG02 = 20000
12 0 DIAG03 = 30000
13 0 DIAG04 = 
!
! Test equations still work
ALL     EXPFLAG  SM-1          1   EXPSTART     < [0.0+50499.0] !20 FEB 1997
ALL     EXPFLAG  SM-2          2   EXPSTART     < [0.0+52333.0] !01 MAR 2002
ALL     EXPFLAG  SM-3          3       T        =    T
14 0 EXPFLAG = SM-2
15 0 EXPSTART = 51000.0
!
! Test simple 'OR' condition
ALL     FILETYPE  T            1    INSTRUME     =    WFPC2
ALL     FILETYPE  F            2        T        =    T
16 0 FILETYPE = T
17 0 INSTRUME = WFPC2
!
! Used for error condition tests above
18 0 MAG_B = 
19 0 MAG_R = 
20 0 MAG_U = 
21 0 MAG_V = 
22 0 MOONANGL = 
!
! Test missing keyword value (no problem)
23 0 MTFLAG = 
!
! Test parsing capabilities:
!    MT_LVa_b, where a:MTP_LEVL
!                    b:MTP_LINE
!    ...and MTP_TEXT is the value
24 0 MTP_LEVL = 1
24 1 MTP_LEVL = 1
24 2 MTP_LEVL = 1
24 3 MTP_LEVL = 1
24 4 MTP_LEVL = 1
24 5 MTP_LEVL = 
24 6 MTP_LEVL = 
24 7 MTP_LEVL = 2
25 0 MTP_LINE = 1
25 1 MTP_LINE = 
25 2 MTP_LINE = 
25 3 MTP_LINE = 
25 4 MTP_LINE = 
25 5 MTP_LINE = 
25 6 MTP_LINE = 
25 7 MTP_LINE = 3
26 0 MTP_TEXT = Moving Target Level 1
26 1 MTP_TEXT = 
26 2 MTP_TEXT = 
26 3 MTP_TEXT = 
26 4 MTP_TEXT = 
26 5 MTP_TEXT = 
26 6 MTP_TEXT = 
26 7 MTP_TEXT = MT LEVEL 2_3
!
!...these are the input keywords from the .dcx file
!
27 0 MT_LV1_1 = Moving Target Level 1
28 0 MT_LV1_2 = 
29 0 MT_LV1_3 = 
30 0 MT_LV1_4 = 
31 0 MT_LV1_5 = 
32 0 MT_LV2_1 = 
33 0 MT_LV2_2 = 
34 0 MT_LV2_3 = MT LEVEL 2_3
35 0 MT_LV2_4 = 
36 0 MT_LV2_5 = 
37 0 MT_LV3_1 = 
38 0 MT_LV3_2 = 
39 0 MT_LV3_3 = 
40 0 MT_LV3_4 = 
41 0 MT_LV3_5 = 
!
!
!  This propogates the group 0 value.  
!  Note that some are overridden by a later rule..
!
ALL     PROGRMID(*) {PROGRMID}  1   TARGNAME     =    {TARGNAME}
ALL     OBSET_ID(*) {OBSET_ID}  1   TARGNAME     =    {TARGNAME}
ALL     OBSNUM(*)   {OBSNUM}    1   TARGNAME     =    {TARGNAME}
ALL     OBSERVTN(*) {OBSERVTN}  1   TARGNAME     =    {TARGNAME}
!...which are overridden with:
ALL     PROGRMID(*)  {PROGRMID}  1   MTP_TEXT      =   {MTP_TEXT}
ALL     OBSET_ID(*)  {OBSET_ID}  1   MTP_TEXT      =   {MTP_TEXT}
ALL     OBSNUM(*)    {OBSNUM}    1   MTP_TEXT      =   {MTP_TEXT}
!  since there are 3 TARGNAME group values only 3 OBSERVTN
!  however there are 7 group values for MTP_TEXT
!
42 0 OBSERVTN = 
42 1 OBSERVTN = 
42 2 OBSERVTN = 
43 0 OBSET_ID = Jim
43 1 OBSET_ID = Jim
43 2 OBSET_ID = Jim
43 3 OBSET_ID = Jim
43 4 OBSET_ID = Jim
43 5 OBSET_ID = Jim
43 6 OBSET_ID = Jim
43 7 OBSET_ID = Jim
44 0 OBSNUM = 4q
44 1 OBSNUM = 4q
44 2 OBSNUM = 4q
44 3 OBSNUM = 4q
44 4 OBSNUM = 4q
44 5 OBSNUM = 4q
44 6 OBSNUM = 4q
44 7 OBSNUM = 4q
45 0 PROGRMID = 05Q
45 1 PROGRMID = 05Q
45 2 PROGRMID = 05Q
45 3 PROGRMID = 05Q
45 4 PROGRMID = 05Q
45 5 PROGRMID = 05Q
45 6 PROGRMID = 05Q
45 7 PROGRMID = 05Q
!
!...input keyword for testing
46 0 SCAN_TYP = 
47 0 SURF_B = 
48 0 SURF_R = 
49 0 SURF_U = 
50 0 SURF_V = 12
!
! Make sure quoted spaces still work
ALL	TARDESC2 "QUOTED SPACE"  1	T	=	T
!
51 0 TARDESC2 = QUOTED SPACE
!
!...input keyword for testing
52 0 TARDESCR = 
53 0 TARGCAT = Top Notch Category
54 0 TARGCAT2 = 
!
! ...make multiple keys, multiple groups for target_synonym.  Need to
!    propogate the other keys from group zero too.
!
ALL     TARGNAME(1) {ALIAS1}    1   ALIAS1      !=    BLANK
ALL     TARGNAME(2) {ALIAS2}    1   ALIAS2      !=    BLANK
55 0 TARGNAME = Big Star
55 1 TARGNAME = Bigger than yours
55 2 TARGNAME = BIGGEST
!
! Test indexed keyword -> group:  Allow gaps
!
ALL     TARKEY1     NULL        1   TARKEY1      =    BLANK
ALL     TARKEY1(1)  {TARKEY2}   1   TARKEY2     !=    BLANK
ALL     TARKEY1(2)  {TARKEY3}   1   TARKEY3     !=    BLANK
ALL     TARKEY1(3)  {TARKEY4}   1   TARKEY4     !=    BLANK
ALL     TARKEY1(4)  {TARKEY5}   1   TARKEY5     !=    BLANK
ALL     TARKEY1(5)  {TARKEY6}   1   TARKEY6     !=    BLANK
ALL     TARKEY1(6)  {TARKEY7}   1   TARKEY7     !=    BLANK
ALL     TARKEY1(7)  {TARKEY8}   1   TARKEY8     !=    BLANK
ALL     TARKEY1(8)  {TARKEY9}   1   TARKEY9     !=    BLANK
ALL     TARKEY1(9)  {TARKEY10}  1   TARKEY10    !=    BLANK
!
56 0 TARKEY1 = target key 1
56 1 TARKEY1 = say something
56 2 TARKEY1 = 
56 3 TARKEY1 = nice
57 0 TARKEY10 = 
58 0 TARKEY2 = say something
59 0 TARKEY3 = 
60 0 TARKEY4 = nice
61 0 TARKEY5 = 
62 0 TARKEY6 = 
63 0 TARKEY7 = 
64 0 TARKEY8 = 
65 0 TARKEY9 = 
66 0 TAR_TYPE = 
!
!  Test temporary keywords created on the fly...
!
67 0 t_MOVER = IGNORE
68 0 t_SCANER = IGNORE
69 0 t_CATARG = LOAD
70 0 t_PIXRES = .1
!
!  Construct your own tests:
!	Add/modify keyword values in kr_test.dcx
!	change keyword rules in kr_test.rules
!	add new keywords in kr_test_cgg1.dat
!------------------------------------------------------------------------