aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/photcal/lib
diff options
context:
space:
mode:
Diffstat (limited to 'noao/digiphot/photcal/lib')
-rw-r--r--noao/digiphot/photcal/lib/apfile.h117
-rw-r--r--noao/digiphot/photcal/lib/fitparams.h7
-rw-r--r--noao/digiphot/photcal/lib/io.h78
-rw-r--r--noao/digiphot/photcal/lib/lexer.h60
-rw-r--r--noao/digiphot/photcal/lib/mctable.h28
-rw-r--r--noao/digiphot/photcal/lib/obsfile.h51
-rw-r--r--noao/digiphot/photcal/lib/parser.h169
-rw-r--r--noao/digiphot/photcal/lib/prdefs.h30
-rw-r--r--noao/digiphot/photcal/lib/preval.h41
-rw-r--r--noao/digiphot/photcal/lib/prstruct.h344
-rw-r--r--noao/digiphot/photcal/lib/prtoken.h42
-rw-r--r--noao/digiphot/photcal/lib/warning.dat11
12 files changed, 978 insertions, 0 deletions
diff --git a/noao/digiphot/photcal/lib/apfile.h b/noao/digiphot/photcal/lib/apfile.h
new file mode 100644
index 00000000..16b3f18d
--- /dev/null
+++ b/noao/digiphot/photcal/lib/apfile.h
@@ -0,0 +1,117 @@
+# Set up the definitions for the required input photometry file fields
+
+define CAT_NFIELDS 10
+
+define CAT_IMAGE 1 # the image name
+define CAT_XCENTER 2 # x center position
+define CAT_YCENTER 3 # y center position
+define CAT_IFILTER 4
+define CAT_ITIME 5
+define CAT_XAIRMASS 6 # the airmass
+define CAT_OTIME 7 # the airmass
+define CAT_RAPERT 8 # list of aperture radii
+define CAT_MAG 9 # list of magnitudes
+define CAT_MERR 10 # list of magnitude errors
+
+# Set up the definitions for the required input airmass file fields
+
+define OBS_NFIELDS 5
+
+define OBS_IMAGE 1 # the image name
+define OBS_IFILTER 2 # filter id
+define OBS_ITIME 3 # exposure time
+define OBS_XAIRMASS 4 # the airmass
+define OBS_OTIME 5 # the time of observation
+
+# Define the image name symbol table data structure
+
+define LEN_IMT_STRUCT (8 + 2 * SZ_FNAME + 2)
+
+define IMT_IMNO Memi[$1] # the image sequence number
+define IMT_NENTRIES Memi[$1+1] # number of data entries
+define IMT_OFFSET Memi[$1+2] # offset to image data
+define IMT_RO Memr[P2R($1+3)] # the HWHM of the psf
+define IMT_ITIME Memr[P2R($1+4)] # the exposure time
+define IMT_XAIRMASS Memr[P2R($1+5)] # the airmass
+define IMT_NXAIRMASS Memr[P2R($1+6)] # the normalized airmass
+define IMT_OTIME Memr[P2R($1+7)] # the normalized airmass
+define IMT_IFILTER Memc[P2C($1+8)] # the filter id
+define IMT_IMNAME Memc[P2C($1+8+SZ_FNAME+1)] # the image name
+
+define LEN_IMTABLE 100 # initial length of the image table
+define DEF_BUFSIZE 1000 # default object data buffer size
+
+
+# Define the fitting code structures
+
+define LEN_AGRSTRUCT 35
+
+define AGR_DM Memi[$1] # pointer to model estimates
+define AGR_DDDR Memi[$1+1] # pointer to r0 derivative estimates
+define AGR_T Memi[$1+2] # pointer to parameter derivatives
+define AGR_U Memi[$1+3] # pointer to accumulation matrix
+define AGR_V Memi[$1+4] # pointer to accumulation vector
+define AGR_POLD Memi[$1+5] # pointer to previous parameters incr
+define AGR_DP Memi[$1+6] # pointer to parameter increments
+define AGR_PCLAMPS Memi[$1+7] # pointer to parameter clamps
+define AGR_PARAMS Memi[$1+8] # pointer to parameters
+define AGR_PERRORS Memi[$1+9] # pointer to parameter errors
+define AGR_RBAR Memi[$1+11] # pointer to mean radii
+define AGR_THEO Memi[$1+12] # pointer to the model estimates
+define AGR_W Memi[$1+13] # pointer to the working weight array
+define AGR_ADOPT Memi[$1+14] # pointer to the adopted differences
+define AGR_WOBS Memi[$1+15] # pointer to the weighted observations
+define AGR_OBS Memi[$1+16] # pointer to the observations
+define AGR_WADO Memi[$1+17] # pointer to the errors in observations
+define AGR_CUM Memi[$1+18] # pointer to the accumulated differences
+define AGR_TCUM Memi[$1+19] # pointer to the accumulated differences
+define AGR_WCUM Memi[$1+20] # pointer to the accumulated errors
+define AGR_MAGS Memi[$1+21] # the temporary magnitude array
+define AGR_CMAGS Memi[$1+22] # the summed magnitude array
+define AGR_TMAGS Memi[$1+23] # the total summed magnitude array
+define AGR_WMAGS Memi[$1+24] # the summed magnitude error array
+define AGR_AVE Memi[$1+25] # pointer to the model averages
+define AGR_RESID Memi[$1+26] # pointer to the residuals
+define AGR_RESSQ Memi[$1+27] # pointer to the residuals squared
+define AGR_WR Memi[$1+28] # pointer to the sum of the weights
+define AGR_TAVE Memi[$1+29] # pointer to the model averages
+define AGR_TRESID Memi[$1+30] # pointer to the residuals
+define AGR_TRESSQ Memi[$1+31] # pointer to the residuals squared
+define AGR_TWR Memi[$1+32] # pointer to the sum of the weights
+
+# Define some miscellaneous parameters
+
+define DEF_AIROFFSET 1.25
+define MAX_MTERMS 5
+define AGR_ITMAX 300
+
+# Define the permitted plot types
+
+define AGR_FIT 1
+define AGR_ARESIDUALS 2
+define AGR_CUMULATIVE 3
+define AGR_XRESIDUALS 4
+define AGR_YRESIDUALS 5
+define AGR_BRESIDUALS 6
+
+# Define the interactive colon commands
+
+define AGR_CMDS "|show|image|nparams|swings|pwings|pgauss|rgescale|\
+xwings|smallap|largeap|"
+
+define AGR_CMD_SHOW 1
+define AGR_CMD_IMAGE 2
+define AGR_CMD_MTERMS 3
+define AGR_CMD_SWINGS 4
+define AGR_CMD_PWINGS 5
+define AGR_CMD_PGAUSS 6
+define AGR_CMD_RGESCALE 7
+define AGR_CMD_XWINGS 8
+define AGR_CMD_SMALLAP 9
+define AGR_CMD_LARGEAP 10
+
+define AGR_SHOWCMDS "|model|seeing|parameters|"
+
+define AGR_CMD_MODEL 1
+define AGR_CMD_SEEING 2
+define AGR_CMD_PARAMETERS 3
diff --git a/noao/digiphot/photcal/lib/fitparams.h b/noao/digiphot/photcal/lib/fitparams.h
new file mode 100644
index 00000000..85a27782
--- /dev/null
+++ b/noao/digiphot/photcal/lib/fitparams.h
@@ -0,0 +1,7 @@
+# Define the weighting options.
+
+define FWT_OPTIONS "|uniform|photometric|equations|"
+
+define FWT_UNIFORM 1
+define FWT_PHOTOMETRIC 2
+define FWT_EQUATIONS 3
diff --git a/noao/digiphot/photcal/lib/io.h b/noao/digiphot/photcal/lib/io.h
new file mode 100644
index 00000000..f3f8e26f
--- /dev/null
+++ b/noao/digiphot/photcal/lib/io.h
@@ -0,0 +1,78 @@
+# The include file for PHOTCAL i/o
+
+# Formatting definitions for MKCATALOG
+
+define MKCAT_KYCATALOG "CATALOG:" # the catalog title keyword
+define MKCAT_KYNCOLS "NCOLS:" # the number of columns keyword
+define MKCAT_KYHDRLENGTH "HDRLENGTH:" # the column header length keyword
+
+define MKCAT_MAXCOLWIDTH 79 # the maximum column width
+define MKCAT_IDCOLWIDTH 15 # the default id column width
+define MKCAT_COLWIDTH 10 # the default data column width
+define MKCAT_NCOLS 10 # the default number of columns
+define MKCAT_SZGAP 2 # the size of the intercolumn gap
+
+define MKCAT_COMMENTSTR "# " # the comment string
+define MKCAT_CONTSTR "* " # the continuation string
+define MKCAT_BLANKSTR " " # the blank string
+define MKCAT_NULLSTR "" # the null string
+define MKCAT_SZSTR 2 # the size of MKCAT strings
+
+define MKCAT_COMMENTCHAR '#' # the comment character
+
+
+# Define the initial sizes for internal table storage.
+
+define LEN_CATDAT 100
+define LEN_CATOBS 100
+define LEN_OBSOBS 100
+
+
+# General catalog and observations formatting definitions
+
+define COMMENT "^\#" # the comment string
+define CONTINUATION "^\* " # the continuation character
+
+# Maximum number of continuation lines. This constant is used only for
+# memory allocation and not to check for the number of lines.
+
+define MAX_CONT 10
+
+
+# Record names for FITPARAMS output file. These are the record names
+# used by the DTTEXT procedures to identify records in a text database.
+
+define STATUS "status" # fit status
+define WEIGHTING "weights" # weights definition
+define ERRORS "errors" # error definition
+define VARIANCE "variance" # fit variance
+define STDEV "stdeviation" # fit standard deviation
+define AVSQERROR "avsqerror" # average error squared
+define AVERROR "averror" # average error
+define AVSQSCATTER "avsqscatter" # additional scatter-squared
+define AVSCATTER "avscatter" # additional scatter
+define MSQ "msq" # fit mean-square
+define RMS "rms" # fit root-mean-square
+define CHISQR "chisqr" # fit reduced chi-squared
+define REFERENCE "reference" # reference equation name
+define FITTING "fitting" # fitting equation name
+define DERIVATIVES "derivatives" # derivative equation names
+define PARAMETERS "parameters" # parameter names
+define VALUES "values" # parameter values
+define ERRORS "errors" # parameter errors
+
+
+# Define the permitted output types for EVALFIT and INVERTFIT
+
+define TYPE_ALL 1
+define TYPE_PROGRAM 2
+define TYPE_STANDARDS 3
+define TYPE_STRING ",all,program,standards,"
+
+
+# Define the permitted output error types for EVALFIT and INVERTFIT
+
+define ERR_UNDEFINED 1
+define ERR_OBSERRORS 2
+define ERR_EQUATIONS 3
+define ERR_OPTIONS ",undefined,obserrors,equations,"
diff --git a/noao/digiphot/photcal/lib/lexer.h b/noao/digiphot/photcal/lib/lexer.h
new file mode 100644
index 00000000..b3d610d4
--- /dev/null
+++ b/noao/digiphot/photcal/lib/lexer.h
@@ -0,0 +1,60 @@
+# Lexer structure lengths
+define LEN_ID SZ_LINE # string length
+define LEN_CODE SZ_LINE # code length
+define LEN_LEX (3+LEN_ID+LEN_CODE) # total structure length
+
+# Lexer structure
+define LEX_TOK Memi[$1+0] # token
+define LEX_VAL Memr[P2R($1+1)] # numeric value (if any)
+define LEX_ID Memc[P2C($1+2)] # character string
+define LEX_CLEN Memi[$1+LEN_ID+2] # code length
+define LEX_CODE ($1+LEN_ID+3) # RPN code buffer
+
+
+# Minimum number of characters required when a keyword is abbreviated
+define ABBREVIATE 3
+
+
+# Keywords
+define KEYWORDS "|catalog|observations|extinction|transformations|\
+ |fit|constant|delta|\
+ |error|weight|minimum|maximum|\
+ |set|derivative|plot|"
+
+# Keyword codes
+define K_CATALOG 1 # catalog section
+define K_OBSERVATION 2 # observation section
+define K_EXTINCTION 3 # extinction section
+define K_TRANSFORMATION 4 # transformation section
+ # newline 5
+define K_FIT 6 # fitting parameter declaration
+define K_CONSTANT 7 # constant parameter declaration
+define K_DELTA 8 # parameter delta declaration
+ # newline 9
+define K_ERROR 10 # error column/equation
+define K_WEIGHT 11 # weight column/equation
+define K_MIN 12 # minimum equation (error/weight)
+define K_MAX 13 # maximum equation (error/weight)
+ # newline 14
+define K_SET 15 # set equation
+define K_DERIVATIVE 16 # derivative equation
+define K_PLOT 17 # plot equations
+
+
+# Functions
+define FUNCTIONS "|abs|acos|asin|atan|cos|exp|log|log10|sin|\
+ |sqrt|tan|"
+
+# Function codes
+define K_ABS 1 # absolute value
+define K_ACOS 2 # arccosine
+define K_ASIN 3 # arcsine
+define K_ATAN 4 # arctangent
+define K_COS 5 # cosine
+define K_EXP 6 # sine
+define K_LOG 7 # natural logarithm
+define K_LOG10 8 # decimal logarithm
+define K_SIN 9 # sine
+ # newline 10
+define K_SQRT 11 # square root
+define K_TAN 12 # tangent
diff --git a/noao/digiphot/photcal/lib/mctable.h b/noao/digiphot/photcal/lib/mctable.h
new file mode 100644
index 00000000..70d8b9c9
--- /dev/null
+++ b/noao/digiphot/photcal/lib/mctable.h
@@ -0,0 +1,28 @@
+# Multicolumn table structure.
+
+# Pointer Mem
+define MEMP Memi
+
+# Magic number
+define MAGIC 1989
+
+# Growing factor computation. This formula is used to compute
+# the increment is memory allocation in terms of the memory
+# already allocated, but avoiding a zero or a large factor.
+# The real number in the formula represents the fraction to grow,
+# and it should be greater than zero and less than one, although
+# the formula takes care of out of range values.
+define GROWFACTOR min (max (int ($1 * 0.5), 1), $1) # 50%
+
+# Multi-column table structure
+define LEN_MCTABLE 10 # structure size
+define MCT_MAGIC Memi[$1+0] # magic number
+define MCT_TYPE Memi[$1+1] # table data type
+define MCT_MAXROW Memi[$1+2] # max number of rows (growing)
+define MCT_MAXCOL Memi[$1+3] # max number of columns (fixed)
+define MCT_INCROWS Memi[$1+4] # row growing increment
+define MCT_NPROWS Memi[$1+5] # highest row entered
+define MCT_NPCOLS Memi[$1+6] # highest column entered
+define MCT_NGROWS Memi[$1+7] # highest row gotten
+define MCT_NGCOLS Memi[$1+8] # highest column gotten
+define MCT_DATA MEMP[$1+9] # data buffer pointer
diff --git a/noao/digiphot/photcal/lib/obsfile.h b/noao/digiphot/photcal/lib/obsfile.h
new file mode 100644
index 00000000..e101428c
--- /dev/null
+++ b/noao/digiphot/photcal/lib/obsfile.h
@@ -0,0 +1,51 @@
+# Set up the definitions for the required input fields
+
+define CAT_NFIELDS 10
+
+define CAT_IMAGE 1 # the image name
+define CAT_XCENTER 2 # x center position
+define CAT_YCENTER 3 # y center position
+define CAT_IFILTER 4 # the filter id
+define CAT_ITIME 5 # the exposure time
+define CAT_XAIRMASS 6 # the airmass
+define CAT_OTIME 7 # the time of observation
+define CAT_MAG 8 # magnitude
+define CAT_MERR 9 # magnitude error
+define CAT_ID 10 # the object name
+
+define OBS_NFIELDS 5
+
+define OBS_IMAGE 1 # the image name
+define OBS_IFILTER 2 # the corrected filter id
+define OBS_ITIME 3 # the corrected exposure time
+define OBS_XAIRMASS 4 # the corrected airmass
+define OBS_OTIME 5 # the corrected time of observation
+
+# Define the IMTABLE data structure
+
+define LEN_IMT_STRUCT (10 + 3 * SZ_FNAME + 3)
+
+define IMT_IMSETNO Memi[$1] # the image set id number
+define IMT_IMNO Memi[$1+1] # the image sequence number
+define IMT_OFFSET Memi[$1+2] # offset to image data
+define IMT_NENTRIES Memi[$1+3] # number of data entries
+define IMT_XSHIFT Memr[P2R($1+4)] # x shift in pixels
+define IMT_YSHIFT Memr[P2R($1+5)] # y shift in pixels
+define IMT_APERCOR Memr[P2R($1+6)] # aperture corrections
+define IMT_ITIME Memr[P2R($1+7)] # the exposure times
+define IMT_XAIRMASS Memr[P2R($1+8)] # the airmasses
+define IMT_OTIME Memr[P2R($1+9)] # time of observations
+define IMT_IFILTER Memc[P2C($1+10)] # the filter ids
+define IMT_LABEL Memc[P2C($1+10+SZ_FNAME+1)] # image set labels
+define IMT_IMNAME Memc[P2C($1+10+2*SZ_FNAME+2)] # image names
+
+# Miscellaneous
+
+define LEN_IMTABLE 100 # initial length of the image table
+define DEF_BUFSIZE 1000 # default object data buffer size
+
+define FIRST_COLUMN 3
+define DELTA_COLUMN 2
+
+define DEF_LENLABEL 15 # the default object label length
+define DEF_LENINDEX 6 # the default index
diff --git a/noao/digiphot/photcal/lib/parser.h b/noao/digiphot/photcal/lib/parser.h
new file mode 100644
index 00000000..da88ffeb
--- /dev/null
+++ b/noao/digiphot/photcal/lib/parser.h
@@ -0,0 +1,169 @@
+# PARSER.H - Parser codes to use with the prget and prput procedures.
+
+
+# Parser tables (pointer)
+
+define SYMTABLE 1 # symbol table
+define OBSTABLE 2 # observational variable table
+define CATTABLE 3 # catalog variable table
+define PARTABLE 4 # fitting and constant parameter table
+define EXTTABLE 5 # extinction equation table
+define TRNTABLE 6 # transformation equation table
+define SETTABLE 7 # set equation table
+define TRCATTABLE 8 # temporary ref. catalog var. table
+define TROBSTABLE 9 # temporary ref. obs. var. table
+define TFCATTABLE 10 # temporary fit catalog var. table
+define TFOBSTABLE 11 # temporary fit obs. var. table
+define TPARTABLE 12 # temporary parameter table
+
+
+# Parser counters (int)
+
+define NERRORS 20 # errors
+define NWARNINGS 21 # warnings
+define NOBSVARS 22 # observational variables
+define NCATVARS 23 # catalog variables
+define NFITPARS 24 # fitting parameters
+define NTOTPARS 25 # parameters (fitting + constant)
+define NSETEQS 26 # set equations
+define NEXTEQS 27 # extinction equations
+define NTRNEQS 28 # transformation equations
+
+
+# Parser column limit values (int)
+
+define MINCOL 30 # min. input column
+define MINOBSCOL 31 # min. observational column
+define MAXOBSCOL 32 # max. observational column
+define MINCATCOL 33 # max. catalog column
+define MAXCATCOL 34 # max. catalog column
+
+
+# Parser flags (int)
+
+define FLAGEQSECT 40 # equation section
+define FLAGERRORS 41 # flag errors (YES/NO)
+
+
+# Symbol types (int)
+
+define PTY_OBSVAR 50 # observation input variable
+define PTY_CATVAR 51 # catalog input variable
+define PTY_FITPAR 52 # fitting parameter
+define PTY_CONST 53 # constant parameter
+define PTY_SETEQ 54 # set equation
+define PTY_EXTEQ 55 # extinction equation
+define PTY_TRNEQ 56 # transformation equation
+
+
+# Symbol attributes (int, pointer)
+
+define PSYMTYPE 60 # type (int)
+define PSYMNUM 61 # number (int)
+define PSYMSUB 62 # substructure (pointer)
+
+
+# Input variable attributes (int)
+
+define PINPCOL 70 # column
+define PINPERRCOL 71 # error column
+define PINPWTSCOL 72 # error column
+define PINPSPARE 73 # spare flag
+
+
+# Fitting parameter attributes (real)
+
+define PFITVALUE 80 # value
+define PFITDELTA 81 # delta
+
+
+# Set equation character strings (int)
+
+define PSEQEQ 90 # equation
+define PSEQERROR 91 # error
+define PSEQERRMIN 92 # minimum error
+define PSEQERRMAX 93 # maximum error
+define PSEQWEIGHT 94 # weight
+define PSEQWTSMIN 95 # minimum weight
+define PSEQWTSMAX 96 # maximum weight
+
+
+# Set equation code pointers (int)
+
+define PSEQRPNEQ 100 # equation
+define PSEQRPNERROR 101 # error
+define PSEQRPNERRMIN 102 # minimum error
+define PSEQRPNERRMAX 103 # maximum error
+define PSEQRPNWEIGHT 104 # weight
+define PSEQRPNWTSMIN 105 # minimum weight
+define PSEQRPNWTSMAX 106 # maximum weight
+
+
+# Transformation equation counters (int)
+
+define PTEQNRCAT 110 # number of catalog var. (reference)
+define PTEQNROBS 111 # number of obs. variables (reference)
+define PTEQNRVAR 112 # number of variables (reference)
+define PTEQNFCAT 113 # number of catalog variables (fit)
+define PTEQNFOBS 114 # number of obs. variables (fit)
+define PTEQNFVAR 115 # number of variables (fit)
+define PTEQNVAR 116 # total number of variables (ref + fit)
+define PTEQNPAR 117 # number of parameters
+define PTEQNFPAR 118 # number of fitting parameters
+
+
+# Transformation equation character strings (pointer)
+
+define PTEQFIT 120 # fit
+define PTEQREF 121 # reference
+define PTEQDER 122 # derivatives
+define PTEQERROR 123 # error
+define PTEQERRMIN 124 # minimum error
+define PTEQERRMAX 125 # maximum error
+define PTEQWEIGHT 126 # weight
+define PTEQWTSMIN 127 # minimum weight
+define PTEQWTSMAX 128 # maximum weight
+define PTEQXPLOT 129 # x plot
+define PTEQYPLOT 130 # y plot
+
+
+# Transformation equation codes (pointer)
+
+define PTEQRPNFIT 140 # fitting
+define PTEQRPNREF 141 # reference
+define PTEQRPNDER 142 # derivatives
+define PTEQRPNERROR 143 # error
+define PTEQRPNERRMIN 144 # minimum error
+define PTEQRPNERRMAX 145 # maximum error
+define PTEQRPNWEIGHT 146 # weight
+define PTEQRPNWTSMIN 147 # minimum weight
+define PTEQRPNWTSMAX 148 # maximum weight
+define PTEQRPNXPLOT 149 # x plot
+define PTEQRPNYPLOT 150 # y plot
+
+
+# Transformation equation buffers (pointer)
+
+define PTEQSPAR 160 # parameter symbols
+define PTEQSPARVAL 161 # parameter values
+define PTEQSPLIST 162 # parameter list
+define PTEQSREFVAR 163 # reference eq. variable symbols
+define PTEQSREFCNT 164 # reference eq. variable counters
+define PTEQSFITVAR 165 # fit eq. variable symbols
+define PTEQSFITCNT 166 # fit eq. variable counters
+
+
+# Transformaion equation variable symbols and counters (int)
+
+define PTEQREFVAR 170 # reference eq. variable symbols
+define PTEQREFCNT 171 # reference eq. counter
+define PTEQFITVAR 172 # fit eq. variable symbols
+define PTEQFITCNT 173 # fit eq. counter
+
+
+# Transformation equation fitting and constant parameter
+# attributes (int, real)
+
+define PTEQPAR 180 # parameter symbols (int)
+define PTEQPARVAL 181 # parameter values (real)
+define PTEQPLIST 182 # parameter list (int)
diff --git a/noao/digiphot/photcal/lib/prdefs.h b/noao/digiphot/photcal/lib/prdefs.h
new file mode 100644
index 00000000..3f60a528
--- /dev/null
+++ b/noao/digiphot/photcal/lib/prdefs.h
@@ -0,0 +1,30 @@
+# PRDEFS.H -- Parser definitions.
+
+
+# ----------------------------------------------------------------------
+# Severity error codes.
+define PERR_WARNING 1 # warning
+define PERR_SYNTAX 2 # syntax error
+define PERR_SEMANTIC 3 # semantic error
+define PERR_POSTPROC 4 # post processing error
+
+
+# ----------------------------------------------------------------------
+# Equation sections. Equations are divided in sections by the parser, to
+# take different semantic actions over expressions depending on the section.
+
+define PRS_SETEQ 1 # beginning of set equation
+
+define PRS_TRNREF 2 # transformation reference equation
+define PRS_TRNFIT 3 # transformation fitting equation
+define PRS_TRNDER 4 # transformation derivative equations
+define PRS_TRNPLOT 5 # transformation plot equations
+
+define PRS_ERREQ 6 # error equation
+define PRS_WTSEQ 7 # weight equation
+define PRS_LMTEQ 8 # limit equations
+
+# -------------------------------------------------------------------------
+# Define some default parameter values
+
+define DEF_PFITDELTA 0.1
diff --git a/noao/digiphot/photcal/lib/preval.h b/noao/digiphot/photcal/lib/preval.h
new file mode 100644
index 00000000..32e6f31c
--- /dev/null
+++ b/noao/digiphot/photcal/lib/preval.h
@@ -0,0 +1,41 @@
+# Evaluator codes. These codes are the only ones recognized by the
+# run-time expression evaluator, during the evaluation of the RPN
+# code generated by the parser.
+
+# End of code marker
+define PEV_EOC (-1)
+
+# Numbers
+define PEV_NUMBER 0 # real constant
+
+# Variables
+define PEV_OBSVAR 1 # observational variable
+define PEV_CATVAR 2 # catalog variable
+define PEV_PARAM 3 # fitting or constant parameter
+define PEV_SETEQ 4 # set equation
+define PEV_EXTEQ 5 # extinction equation
+define PEV_TRNEQ 6 # transformation equation
+
+# Unary operators
+define PEV_UPLUS 10 # unary plus
+define PEV_UMINUS 11 # unary minus
+
+# Binary operators
+define PEV_PLUS 20 # addition
+define PEV_MINUS 21 # substraction
+define PEV_STAR 22 # multiplication
+define PEV_SLASH 23 # division
+define PEV_EXPON 24 # exponentiation
+
+# Functions
+define PEV_ABS 30 # absolute value
+define PEV_ACOS 31 # arc cosine
+define PEV_ASIN 32 # arc sine
+define PEV_ATAN 33 # arc tangent
+define PEV_COS 34 # cosine
+define PEV_EXP 35 # exponential
+define PEV_LOG 36 # natural logarithm
+define PEV_LOG10 37 # decimal logarithm
+define PEV_SIN 38 # sine
+define PEV_SQRT 39 # square root
+define PEV_TAN 40 # tangent
diff --git a/noao/digiphot/photcal/lib/prstruct.h b/noao/digiphot/photcal/lib/prstruct.h
new file mode 100644
index 00000000..f5a25e73
--- /dev/null
+++ b/noao/digiphot/photcal/lib/prstruct.h
@@ -0,0 +1,344 @@
+# PRSTRUCT.H -- Parser symbol table structure.
+
+
+# Pointer access
+define MEMP Memi
+
+
+# ----------------------------------------------------------------------
+# Parser symbol structure. The symbol table is handled by the SYMTAB
+# procedures. The following is the definition of the structure associated
+# with each identifier in the table. The following diagram shows graphically
+# this structure:
+#
+# offset
+# +---------------------------------------+
+# 0 | symbol type |
+# +---------------------------------------+
+# 1 | symbol number |
+# +---------------------------------------+
+# 2 | substructure pointer | ->
+# +---------------------------------------+
+# 3 next free location
+#
+
+# Symbol structure length
+define LEN_PSYM 3
+
+# Symbol structure definition
+define PSYM_TYPE Memi[$1+0] # type
+define PSYM_NUM Memi[$1+1] # sequential number
+define PSYM_SUB MEMP[$1+2] # symbol substructure
+# next free location ($1 + 3) == LEN_PSYM !!!
+
+
+# ----------------------------------------------------------------------
+# Input column substructure. This substructure is supported for catalog
+# and observation input columns (PTY_CATCOL and PTY_OBSCOL). The following
+# diagram shows graphically this structure:
+#
+# offset
+# +---------------------------------------+
+# 0 | input column number |
+# +---------------------------------------+
+# 1 | error column number |
+# +---------------------------------------+
+# 2 | weight column number |
+# +---------------------------------------+
+# 3 | spare column flag |
+# +---------------------------------------+
+# 4 next free location
+#
+
+# Input column substructure length.
+define LEN_PINP 4
+
+# Input column substructure definition
+define PINP_COL Memi[$1+0] # input column
+define PINP_ERRCOL Memi[$1+1] # error column
+define PINP_WTSCOL Memi[$1+2] # weight column
+define PINP_SPARE Memi[$1+3] # spare flag (YES/NO)
+# next free location ($1 + 4) == LEN_PINP !!!
+
+
+# ----------------------------------------------------------------------
+# Fitting parameter substructure. This substructure is supported for
+# fitting and constant parameters (PTY_FITPAR and PTY_CONST). The
+# following diagram shows graphically this structure:
+#
+# offset
+# +---------------------------------------+
+# 0 | parameter value |
+# +---------------------------------------+
+# 1 | parameter delta |
+# +---------------------------------------+
+# 2 next free location
+#
+
+# Fitting parameter substructure length.
+define LEN_PFIT 2
+
+# Fitting parameter substructure definition
+define PFIT_VALUE Memr[P2R($1+0)] # parameter value
+define PFIT_DELTA Memr[P2R($1+1)] # parameter delta
+# next free location ($1 + 2) == LEN_PFIT !!!
+
+
+# ----------------------------------------------------------------------
+# Set equation substructure. This substructure is supported for set
+# equation symbols (PTY_SETEQ). The length of this substructure is
+# fixed.
+#
+# offset
+# +---------------------------------------+
+# 0 | set equation string offset |
+# +---------------------------------------+
+# 1 | error equation string offset |
+# +---------------------------------------+
+# 2 | min error equation string offset |
+# +---------------------------------------+
+# 3 | max error equation string offset |
+# +---------------------------------------+
+# 4 | weight equation string offset |
+# +---------------------------------------+
+# 5 | min weight equation string offset |
+# +---------------------------------------+
+# 6 | max weight equation string offset |
+# +---------------------------------------+
+# 7 | weight equation string offset |
+# +---------------------------------------+
+# 8 | error equation code pointer | ->
+# +---------------------------------------+
+# 9 | min error equation code pointer | ->
+# +---------------------------------------+
+# 10 | max error equation code pointer | ->
+# +---------------------------------------+
+# 11 | weight equation code pointer | ->
+# +---------------------------------------+
+# 12 | min weight equation code pointer | ->
+# +---------------------------------------+
+# 13 | max weight equation code pointer | ->
+# +---------------------------------------+
+# 14 next free location
+#
+
+# Set equation substructure length.
+define LEN_PSEQ 14
+
+# Set equation substructure definition
+define PSEQ_EQ Memi[$1 + 0] # equation string offset
+define PSEQ_ERROR Memi[$1 + 1] # error equation string offset
+define PSEQ_ERRMIN Memi[$1 + 2] # min error equation string offset
+define PSEQ_ERRMAX Memi[$1 + 3] # max error equation string offset
+define PSEQ_WEIGHT Memi[$1 + 4] # weight equation string offset
+define PSEQ_WTSMIN Memi[$1 + 5] # min weight equation string offset
+define PSEQ_WTSMAX Memi[$1 + 6] # max weight equation string offset
+define PSEQ_RPNEQ MEMP[$1 + 7] # equation code
+define PSEQ_RPNERROR MEMP[$1 + 8] # error equation code
+define PSEQ_RPNERRMIN MEMP[$1 + 9] # min error equation code
+define PSEQ_RPNERRMAX MEMP[$1 + 10] # max error equation code
+define PSEQ_RPNWEIGHT MEMP[$1 + 11] # weigt equation code
+define PSEQ_RPNWTSMIN MEMP[$1 + 12] # min weight equation code
+define PSEQ_RPNWTSMAX MEMP[$1 + 13] # max weight equation code
+# next free location ($1 + 14) == LEN_PSEQ !!!
+
+
+# ----------------------------------------------------------------------
+# Transformation equation substructure. This substructure is supported
+# for transformation equation symbols (PTY_TRNEQ). The length of this
+# substructure is variable, and depends on the total number of variables
+# (nvar) and parameters (npar) in the equation. The following diagram
+# shows graphically this structure:
+#
+# offset
+# +---------------------------------------+
+# 0 | number of ref. catalog var. = nrcat |
+# +---------------------------------------+
+# 1 | number of ref. obs. var. = nrobs |
+# +---------------------------------------+
+# 2 | total number of ref. var. = nrvar |
+# +---------------------------------------+
+# 3 | number of fit catalog var. = nfcat |
+# +---------------------------------------+
+# 4 | number of fit obs. var. = nfobs |
+# +---------------------------------------+
+# 5 | total number of fit var. = nfvar |
+# +---------------------------------------+
+# 6 | total number of variables = nvar |
+# +---------------------------------------+
+# 7 | ref. variable symbol offsets (nrvar) |
+# | ... |
+# | ... |
+# +---------------------------------------+
+# 1 * nrvar + 7 | ref. variable counters (nrvar) |
+# | ... |
+# | ... |
+# +---------------------------------------+
+# 2 * nrvar + 7 | fit variable symbol offsets (nfvar) |
+# | ... |
+# | ... |
+# +---------------------------------------+
+# 2 * nrvar + 1 * nfvar + 7 | fit variable counters (nfvar) |
+# | ... |
+# | ... |
+# +---------------------------------------+
+# 2 * nvar + 7 | number of parameters = npar |
+# +---------------------------------------+
+# 2 * nvar + 8 | number of fitting parameters |
+# +---------------------------------------+
+# 2 * nvar + 9 | parameter symbol offsets (npar) |
+# | ... |
+# | ... |
+# +---------------------------------------+
+# 2 * nvar + 1 * npar + 9 | parameter values (npar) |
+# | ... |
+# | ... |
+# +---------------------------------------+
+# 2 * nvar + 2 * npar + 9 | parameter list (npar) |
+# | ... |
+# | ... |
+# +---------------------------------------+
+# 2 * nvar + 3 * npar + 9 | fit equation string offset |
+# +---------------------------------------+
+# 2 * nvar + 3 * npar + 10 | reference equation string offset |
+# +---------------------------------------+
+# 2 * nvar + 3 * npar + 11 | error equation string offset |
+# +---------------------------------------+
+# 2 * nvar + 3 * npar + 12 | min error equation string offset |
+# +---------------------------------------+
+# 2 * nvar + 3 * npar + 13 | max error equation string offset |
+# +---------------------------------------+
+# 2 * nvar + 3 * npar + 14 | weight equation string offset |
+# +---------------------------------------+
+# 2 * nvar + 3 * npar + 15 | min weight equation string offset |
+# +---------------------------------------+
+# 2 * nvar + 3 * npar + 16 | max weight equation string offset |
+# +---------------------------------------+
+# 2 * nvar + 3 * npar + 17 | X plot equation string offset |
+# +---------------------------------------+
+# 2 * nvar + 3 * npar + 18 | Y plot equation string offset |
+# +---------------------------------------+
+# 2 * nvar + 3 * npar + 19 | derivative equation offsets (npar) |
+# | ... |
+# | ... |
+# +---------------------------------------+
+# 2 * nvar + 4 * npar + 19 | fit equation code pointer | ->
+# +---------------------------------------+
+# 2 * nvar + 4 * npar + 20 | reference equation code pointer | ->
+# +---------------------------------------+
+# 2 * nvar + 4 * npar + 21 | error equation code pointer | ->
+# +---------------------------------------+
+# 2 * nvar + 4 * npar + 22 | min error equation code pointer | ->
+# +---------------------------------------+
+# 2 * nvar + 4 * npar + 23 | max error equation code pointer | ->
+# +---------------------------------------+
+# 2 * nvar + 4 * npar + 24 | weight equation code pointer | ->
+# +---------------------------------------+
+# 2 * nvar + 4 * npar + 25 | min weight equation code pointer | ->
+# +---------------------------------------+
+# 2 * nvar + 4 * npar + 26 | max weight equation code pointer | ->
+# +---------------------------------------+
+# 2 * nvar + 4 * npar + 27 | X plot equation code pointer | ->
+# +---------------------------------------+
+# 2 * nvar + 4 * npar + 28 | Y plot equation code pointer | ->
+# +---------------------------------------+
+# 2 * nvar + 4 * npar + 29 | deriv. equation code pointers (npar) | ->
+# | ... | ->
+# | ... | ->
+# +---------------------------------------+
+# 2 * nvar + 5 * npar + 29 next free location
+#
+
+# Transformation equation substructure length. The macro parameters are
+# the total number of variables (npar), and the number of parameters (npar)
+# for the equation.
+define LEN_PTEQ (2 * $1 + 5 * $2 + 29)
+
+# Transformation equation substructure definition
+# - number of catalog and observation variables, and total number of variables
+# for reference equation.
+define PTEQ_NRCAT Memi[$1 + 0]
+define PTEQ_NROBS Memi[$1 + 1]
+define PTEQ_NRVAR Memi[$1 + 2]
+# - number of catalog and observation variables, and total number of variables
+# for fit equation.
+define PTEQ_NFCAT Memi[$1 + 3]
+define PTEQ_NFOBS Memi[$1 + 4]
+define PTEQ_NFVAR Memi[$1 + 5]
+# - total number of variables in the reference and fit equations.
+define PTEQ_NVAR Memi[$1 + 6]
+# - start of reference variable symbol offsets, and variable counters
+define PTEQ_SREFVAR ($1 + 7)
+define PTEQ_SREFCNT ($1 + 1 * PTEQ_NRVAR($1) + 7)
+# - start of fit variable symbol offsets, and variable counters
+define PTEQ_SFITVAR ($1 + 2 * PTEQ_NRVAR($1) + 7)
+define PTEQ_SFITCNT ($1 + 2 * PTEQ_NRVAR($1) + 1 * PTEQ_NFVAR($1) + 7)
+# - total number of parameters and number of parameters to be fitted.
+define PTEQ_NPAR Memi[$1 + 2 * PTEQ_NVAR($1) + 7]
+define PTEQ_NFPAR Memi[$1 + 2 * PTEQ_NVAR($1) + 8]
+# - Start of parameter offsets, parameter values, parameter list
+define PTEQ_SPAR ($1 + 2 * PTEQ_NVAR($1) + 9)
+define PTEQ_SPARVAL ($1 + 2 * PTEQ_NVAR($1) + 1 * PTEQ_NPAR($1) + 9)
+define PTEQ_SPLIST ($1 + 2 * PTEQ_NVAR($1) + 2 * PTEQ_NPAR($1) + 9)
+# - fitting and reference equation string offsets
+define PTEQ_FIT Memi[$1 + 2 * PTEQ_NVAR($1) + 3 * PTEQ_NPAR($1) + 9]
+define PTEQ_REF Memi[$1 + 2 * PTEQ_NVAR($1) + 3 * PTEQ_NPAR($1) + 10]
+# - error, minimum error, and maximum error equation string offsets
+define PTEQ_ERROR Memi[$1 + 2 * PTEQ_NVAR($1) + 3 * PTEQ_NPAR($1) + 11]
+define PTEQ_ERRMIN Memi[$1 + 2 * PTEQ_NVAR($1) + 3 * PTEQ_NPAR($1) + 12]
+define PTEQ_ERRMAX Memi[$1 + 2 * PTEQ_NVAR($1) + 3 * PTEQ_NPAR($1) + 13]
+# - weight, minimum weight, and maximum weight equation string offsets
+define PTEQ_WEIGHT Memi[$1 + 2 * PTEQ_NVAR($1) + 3 * PTEQ_NPAR($1) + 14]
+define PTEQ_WTSMIN Memi[$1 + 2 * PTEQ_NVAR($1) + 3 * PTEQ_NPAR($1) + 15]
+define PTEQ_WTSMAX Memi[$1 + 2 * PTEQ_NVAR($1) + 3 * PTEQ_NPAR($1) + 16]
+# - plot equation string offsets
+define PTEQ_XPLOT Memi[$1 + 2 * PTEQ_NVAR($1) + 3 * PTEQ_NPAR($1) + 17]
+define PTEQ_YPLOT Memi[$1 + 2 * PTEQ_NVAR($1) + 3 * PTEQ_NPAR($1) + 18]
+# - derivative equation string offsets
+define PTEQ_SDER ($1 + 2 * PTEQ_NVAR($1) + 3 * PTEQ_NPAR($1) + 19)
+# - fitting and reference equation codes
+define PTEQ_RPNFIT MEMP[$1 + 2 * PTEQ_NVAR($1) + 4 * PTEQ_NPAR($1) + 19]
+define PTEQ_RPNREF MEMP[$1 + 2 * PTEQ_NVAR($1) + 4 * PTEQ_NPAR($1) + 20]
+# - error equation, minimum error, and maximum error codes
+define PTEQ_RPNERROR MEMP[$1 + 2 * PTEQ_NVAR($1) + 4 * PTEQ_NPAR($1) + 21]
+define PTEQ_RPNERRMIN MEMP[$1 + 2 * PTEQ_NVAR($1) + 4 * PTEQ_NPAR($1) + 22]
+define PTEQ_RPNERRMAX MEMP[$1 + 2 * PTEQ_NVAR($1) + 4 * PTEQ_NPAR($1) + 23]
+# - weigth, minimum weight, maximum weight equation codes
+define PTEQ_RPNWEIGHT MEMP[$1 + 2 * PTEQ_NVAR($1) + 4 * PTEQ_NPAR($1) + 24]
+define PTEQ_RPNWTSMIN MEMP[$1 + 2 * PTEQ_NVAR($1) + 4 * PTEQ_NPAR($1) + 25]
+define PTEQ_RPNWTSMAX MEMP[$1 + 2 * PTEQ_NVAR($1) + 4 * PTEQ_NPAR($1) + 26]
+# - plot equation code3
+define PTEQ_RPNXPLOT MEMP[$1 + 2 * PTEQ_NVAR($1) + 4 * PTEQ_NPAR($1) + 27]
+define PTEQ_RPNYPLOT MEMP[$1 + 2 * PTEQ_NVAR($1) + 4 * PTEQ_NPAR($1) + 28]
+# - start of derivarive equation codes
+define PTEQ_SRPNDER ($1 + 2 * PTEQ_NVAR($1) + 4 * PTEQ_NPAR($1) + 29)
+# - next free location == LEN_PTEQ
+# ($1 + 2 * PTEQ_NVAR($1) + 5 * PTEQ_NPAR($1) + 29)
+
+# Vector access
+define PTEQ_AREFVAR Memi[PTEQ_SREFVAR($1)] # ref. variable sym. off.
+define PTEQ_AREFCNT Memi[PTEQ_SREFCNT($1)] # ref. variable counters
+define PTEQ_AFITVAR Memi[PTEQ_SFITVAR($1)] # fit variable sym. off.
+define PTEQ_AFITCNT Memi[PTEQ_SFITCNT($1)] # fit variable counters
+define PTEQ_APAR Memi[PTEQ_SPAR($1)] # parameter sym. offsets
+define PTEQ_APARVAL Memr[P2R(PTEQ_SPARVAL($1))] # parameter values
+define PTEQ_APLIST Memi[PTEQ_SPLIST($1)] # fitting parameter list
+define PTEQ_ADER Memi[PTEQ_SDER($1)] # derivative string offsets
+define PTEQ_ARPNDER MEMP[PTEQ_SRPNDER($1)] # derivative code
+
+# Individual access for variable symbols and counters.
+define PTEQ_REFVAR Memi[PTEQ_SREFVAR($1) + $2 - 1] # ref. var. symbol off.
+define PTEQ_REFCNT Memi[PTEQ_SREFCNT($1) + $2 - 1] # ref. var. counter
+define PTEQ_FITVAR Memi[PTEQ_SFITVAR($1) + $2 - 1] # fit var. symbol off.
+define PTEQ_FITCNT Memi[PTEQ_SFITCNT($1) + $2 - 1] # fit var. counter
+
+# Individual access for fitting parameter symbols, values and list. The
+# second argument is the parameter number, relative to the equation.
+define PTEQ_PAR Memi[PTEQ_SPAR($1) + $2 - 1] # symbol offset
+define PTEQ_PARVAL Memr[P2R(PTEQ_SPARVAL($1) + $2 - 1)] # value
+define PTEQ_PLIST Memi[PTEQ_SPLIST($1) + $2 - 1] # list element
+
+# Individual access for derivative equation string offsets and codes. The
+# second argument is the parameter number relative to the equation.
+define PTEQ_DER Memi[PTEQ_SDER($1) + $2 - 1] # string offset
+define PTEQ_RPNDER Memi[PTEQ_SRPNDER($1) + $2 - 1] # code
diff --git a/noao/digiphot/photcal/lib/prtoken.h b/noao/digiphot/photcal/lib/prtoken.h
new file mode 100644
index 00000000..8b3119a8
--- /dev/null
+++ b/noao/digiphot/photcal/lib/prtoken.h
@@ -0,0 +1,42 @@
+define OBSSECT 257
+define CATSECT 258
+define EXTSECT 259
+define TRNSECT 260
+define FITID 261
+define CONSTID 262
+define DELTAID 263
+define ERRORID 264
+define WEIGHTID 265
+define MINID 266
+define MAXID 267
+define DERIVID 268
+define PLOTID 269
+define SETID 270
+define F_ABS 271
+define F_ACOS 272
+define F_ASIN 273
+define F_ATAN 274
+define F_COS 275
+define F_EXP 276
+define F_LOG 277
+define F_LOG10 278
+define F_SIN 279
+define F_SQRT 280
+define F_TAN 281
+define IDENTIFIER 282
+define INUMBER 283
+define RNUMBER 284
+define PLUS 285
+define MINUS 286
+define STAR 287
+define SLASH 288
+define EXPON 289
+define COLON 290
+define SEMICOLON 291
+define COMMA 292
+define EQUAL 293
+define LPAR 294
+define RPAR 295
+define EOFILE 296
+define UPLUS 297
+define UMINUS 298
diff --git a/noao/digiphot/photcal/lib/warning.dat b/noao/digiphot/photcal/lib/warning.dat
new file mode 100644
index 00000000..4611b226
--- /dev/null
+++ b/noao/digiphot/photcal/lib/warning.dat
@@ -0,0 +1,11 @@
+
+
+ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+ WARNING FROM THE PHOTCAL PACKAGE LOADER
+ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+
+ The SDAS external package TABLES optionally used by some of the
+ PHOTCAL tasks is not available. The tasks MKNOBSFILE and
+ MKOBSFILE will run only on APPHOT/DAOPHOT output files written
+ in text database format (the default), but will not run on
+ files written in ST tables format.