# this file is based on the detRunSummary.d file: it uses the same tables restricted to the 
# master detrend runs which have been accepted

TABLE detRunSummary, detRun
TITLE Master Detrend Frames
FILE  masterDetrendFrames.php
MENU  ipp.detrend.dat

# the following WHERE clauses are added to all queries joined by AND
WHERE detRunSummary.accept = 1
WHERE detRun.det_id = detRunSummary.det_id
WHERE detRun.iteration = detRunSummary.iteration

ARGS  ARG1 detRunSummary.det_id=$detRunSummary.det_id

ARGS  ARG2 detInputExp.det_id=$detRunSummary.det_id
ARGS  ARG2 detInputExp.iteration=$detRunSummary.iteration

ARGS  ARG3 detProcessedExp.det_id=$detRunSummary.det_id

ARGS  ARG4 detResidExp.det_id=$detRunSummary.det_id
ARGS  ARG4 detResidExp.iteration=$detRunSummary.iteration

#     field                    width name          show         link to                   extras
FIELD detRunSummary.det_id,    5,    det ID,       value,       detRunSummary.php,        ARG1
FIELD detRunSummary.iteration, 3,    iter
FIELD detRun.det_type,         5,    type
FIELD detRun.state,            5,    state
FIELD *,                       20,   choose,       value=input, detInputExp.php,          ARG2
FIELD *,                       20,   choose,       value=proc,  detProcessedExp.php,      ARG3
FIELD *,                       20,   choose,       value=resid, detResidExp.php,          ARG4
FIELD detRunSummary.bg,        20,   bg
FIELD detRunSummary.bg_stdev,  20,   bg_stdev
# FIELD bg_mean_stdev, 20,   bg_mean_stdev

# this file illustrates a simple inner join to generate the output table
# assuming no other dynamic restrictions are added, this generates the following query:
# SELECT detRunSummary.det_id,detRunSummary.iteration,detRunSummary.iteration,detRun.det_type,detRunSummary.bg,detRunSummary.bg_stdev \
# FROM detRunSummary, detRun \
# WHERE detRunSummary.accept = 1 AND detRun.det_id = detRunSummary.det_id AND detRun.iteration = detRunSummary.iteration \
# LIMIT 20
