;+ ; NAME: ; smei_rewind ; PURPOSE: ; Rewinds SMEI pipeline by clearing entries in status files ; in $SSWDB_SMEI/cat/sts ; CATEGORY: ; camera/idl/toolbox ; CALLING SEQUENCE: PRO smei_rewind, tt , $ cal = cal , $ base = base , $ orb = orb , $ sky = sky , $ camera = camera , $ notest = notest ; INPUTS: ; tt scalar or array[1]; time in the form of a ; string or standard time structure. The input time is ; truncated to the beginning of the day (0 UT). ; Usually specified in the form YYYY_DOY. This rewinds ; the pipeline back to (and including) the indicating ; day. ; OPTIONAL INPUT PARAMETERS: ; Four keywords are available to indicate which part of the ; pipeline processing is to redone. ; One and only one of the following four keyword must be set: ; /cal Redo everything starting with the calibration patterns ; /base Rebase all frames, redo "on-the-fly" patterns and skymaps ; /orb Redo the orbital "on-the-fly" pattern, and the skymaps ; /sky Redo only the skymaps ; ; camera=camera scalar, or array; type: integer; default: [1,2,3] ; list of cameras for which status are updated ; /notest no actual updates of the status files are made ; UNLESS this keyword is set. If /notest is NOT set ; then the content of the updated status files is ; written to screen only. ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; SIDE EFFECTS: ; Updates status files ; PROCEDURE: ; The status files are used in the script smei_pipeline.sh, and ; the IDL programs it calls to decide which steps to executed. ; Rewinding the pipeline with this procedure only will clear ; (set to zero) the appropriate flags in the status file, forcing ; the indicated steps to be redone. ; ; Note that this will only work if smei_pipeline.sh is set up ; in such a way that existing files are overwritten. In particular, ; this means that the /force keyword must be used on all IDL ; procedures executed. ; MODIFICATION HISTORY: ; MAR-2011, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Added documentation ;- InitVar, camera, [1,2,3] InitVar, cal , /key InitVar, base , /key InitVar, orb , /key InitVar, sky , /key InitVar, notest , /key IF cal+base+orb+sky NE 1 THEN $ message, 'set one, and only one, of /cal, /base, /orb, /sky' clr_cal = 0 clr_base = 0 clr_summary = 0 clr_orb = 0 clr_hdr = 0 clr_sky = 0 clr_msk = 0 SWITCH 1 OF cal : BEGIn clr_cal = 1 END base : BEGIN clr_base = 1 clr_hdr = 1 clr_summary = 1 END orb : BEGIN clr_orb = 1 END sky : BEGIN clr_sky = 1 clr_msk = 1 END ENDSWITCH CASE 1 OF IsTime(tt) : uu = tt IsType(tt,/string) : uu = TimeSet(tt) ELSE : message, 'first and only argument must be a time' ENDCASE is_remote = getenv('HOSTNAME') NE 'smei.ucsd.edu' uday = TimeUnit(/day) uu = TimeGet(uu,/bot,uday) sts_dir = smei_filepath(mode='sts') FOR icam=0,n_elements(camera)-1 DO BEGIN cam_int = camera[icam] cam_str = strcompress(cam_int,/rem) sts_files = FindAllFiles('c'+cam_str+'sts_*.txt',paths=sts_dir, count=count) IF count EQ 0 THEN continue i = where(TimeOp(/subtract,smei_filename(sts_files),uu,uday) GE 0, n) IF n EQ 0 THEN continue sts_files = sts_files[i] FOR i=0,n-1 DO BEGIN sts_file = sts_files[i] sts_hide = hide_env(sts_file) IF txt_read(sts_file,txt,/silent) NE 1 THEN $ message, 'error reading '+sts_hide IF clr_cal THEN BEGIN j = (where(txt EQ 'cal : 1'))[0] IF j NE -1 THEN txt[j] = 'cal : 0' ENDIF IF clr_base THEN BEGIN j = (where(txt EQ 'base : 1'))[0] IF j NE -1 THEN txt[j] = 'base : 0' ENDIF IF clr_orb THEN BEGIN j = (where(txt EQ 'orb : 1'))[0] IF j NE -1 THEN txt[j] = 'orb : 0' ENDIF IF clr_sky THEN BEGIN j = (where(txt EQ 'sky : 1'))[0] IF j NE -1 THEN txt[j] = 'sky : 0' ENDIF IF clr_hdr THEN BEGIN j = (where(txt EQ 'hdr : 1'))[0] IF j NE -1 THEN txt[j] = 'hdr : 0' ENDIF IF clr_summary THEN BEGIN j = (where(txt EQ 'summary : 1'))[0] IF j NE -1 THEN txt[j] = 'summary : 0' ENDIF IF clr_msk THEN BEGIN j = (where(txt EQ 'msk : 1'))[0] IF j NE -1 THEN txt[j] = 'msk : 0' ENDIF message, /info, sts_hide CASE 1 OF 1-notest: BEGIN print, sts_file FOR j=0,n_elements(txt)-1 DO print, txt[j] END is_remote: BEGIN ; smeidb.smei.ucsd.edu txt = strjoin(txt,string(10B)) ; 10B = new line spawn, 'echo "'+txt+'" | ssh soft@smei "cat - > '+sts_file+'"' END ELSE: BEGIN openw, /get_lun, iu, sts_file FOR j=0,n_elements(txt)-1 DO printf, iu, txt[j] free_lun, iu END ENDCASE ENDFOR ENDFOR RETURN & END