TABLE  rawExp JOIN chipRun USING(exp_id) JOIN camRun USING(chip_id) JOIN fakeRun USING(cam_id) JOIN warpRun USING(fake_id) JOIN warpSkyfile USING(warp_id)
TITLE Warp Processed Skyfiles
FILE  warpProcessedSkyfiles_Images.php
MENU  ipp.science.dat

RESTRICT_COUNT WHERE dateobs >= CURDATE()
UNRESTRICTED WHERE dateobs >= CURDATE()

# UNRESTRICTED WHERE 0=1

# WHERE warpSkyfile.warp_id = warpRun.warp_id
# WHERE warpRun.fake_id = fakeRun.fake_id
# WHERE fakeRun.cam_id = camRun.cam_id
# WHERE camRun.chip_id = chipRun.chip_id
# WHERE chipRun.exp_id = rawExp.exp_id
# WHERE warpSkyfile.fault = 0

# define image names to be used below
# IMAGE VAR basename filerule camera class_id
IMAGE JPEG2 $camProcessedExp.path_base PPIMAGE.JPEG2 $rawExp.camera NONE

ARGS  ARG1  rawImfile.exp_id=$rawExp.exp_id
ARGS  ARG2  chipRun.chip_id=$chipRun.chip_id
ARGS  ARG3  camRun.cam_id=$camRun.cam_id
ARGS  ARG4  fakeRun.fake_id=$fakeRun.fake_id
ARGS  ARG5  warpRun.warp_id=$warpRun.warp_id
ARGS  ARG6  warpSkyfile.skycell_id=$warpSkyfile.skycell_id

ARGS  ARG8  warpRun.warp_id=$warpRun.warp_id
ARGS  ARG8  warpSkyCellMap.skycell_id=$warpSkyfile.skycell_id

ARGS  ARG7 warpRun.warp_id=$warpRun.warp_id
ARGS  ARG7 warpSkyfile.skycell_id=$warpSkyfile.skycell_id
ARGS  ARG7 camera=$rawExp.camera
ARGS  ARG7 basename=$warpSkyfile.path_base

OP   OP1  $rawExp.ra * 57.295783
OP   OP2  $rawExp.decl * 57.295783

#     field                    size  format  name         show    link to         extras
FIELD rawExp.exp_name,     	  5, %s,     Exp Name,     value,  warpStageSkyfileInputs.php, ARG8
FIELD rawExp.exp_id,     	  5, %d,     Exp ID,       value,  rawImfile.php,           ARG1
FIELD chipRun.chip_id,    	  7, %d,     Chip ID,      value,  chipProcessedImfile.php, ARG2
FIELD camRun.cam_id,    	  7, %d,     Cam ID,       value,  camProcessedExp.php,     ARG3
FIELD fakeRun.fake_id,    	  7, %d,     Fake ID,      value,  fakeProcessedImfile.php, ARG4
FIELD warpRun.warp_id,    	  7, %d,     Warp ID,      value,  warpStageExp.php,        ARG5
FIELD warpSkyfile.skycell_id, 	 10, %s,     skycell,      value,  warpProcessedSkyfiles.php, ARG6
FIELD warpRun.state,    	  7, %s,     state,        value,  warpProcessedSkyfiles.php, ARG7
FIELD warpRun.label,    	  7, %s,     label,        value
FIELD warpRun.data_group,    	  7, %s,     label,        data grp
FIELD warpRun.dist_group,    	  7, %s,     label,        dist grp
FIELD warpSkyfile.tess_id,    	 10, %s,     tess
FIELD warpSkyfile.good_frac,  	  5, %s,     good_frac
# FIELD warpSkyfile.ignored,     	  5, %s,     ignored
FIELD warpSkyfile.fault,      	  5, %s,     fault
FIELD rawExp.telescope,      	 10, %s,     Telescope
FIELD rawExp.camera,         	 10, %s,     Camera
FIELD rawExp.dateobs,        	 19, %T,     Date/Time
FIELD rawExp.ra,       	          8, %C, RA,          op=OP1    
FIELD rawExp.decl,       	  8, %C, DEC,         op=OP2
FIELD rawExp.object,         	  8, %s,     Object
FIELD rawExp.filter,         	 10, %s,     FILTER
FIELD rawExp.exp_time,       	  5, %.2f,   exp_time    
FIELD rawExp.airmass,        	  5, %.4f,   airmass     
FIELD rawExp.bg,             	  5, %.2f,   backgnd
FIELD rawExp.bg_stdev,       	  5, %.2f,   stdev    
FIELD rawExp.comment,  	         65, %s,     Comment

FIELD warpSkyfile.path_base,      5, %s,     path_base,   none

TAIL PHP insert_log ('LOG.EXP');
