;+ ; NAME: ; smei_star_test ; PURPOSE: ; Test integrity of star time series files ; Works for pnt files, and for files made for ; individual stars (if /nohdr) is set. ; CATEGORY: ; camera/idl/star ; CALLING SEQUENCE: FUNCTION smei_star_testpnt, files, $ nohdr = nohdr , $ silent = silent ; INPUTS: ; files scalar or array; type: none ; OPTIONAL INPUTS: ; /nohdr ; OUTPUTS: ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, FindAllFiles, smei_star_readpnt, smei_star_writepnt ; TimeSet, TimeOp ; PROCEDURE: ; Checks for duplicate times ; Checks for times before start of mission (this catches ; data points without a valid time for which the time ; is set to 2000/01/01 ; Checks for timea after end of mission (should never happen) ; MODIFICATION HISTORY: ; JUL-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- nfile = n_elements(files) IF nfile EQ 0 THEN BEGIN message, /info, 'no files specified' RETURN, -1 ENDIF uday = TimeUnit(/day) start_mission = TimeSet('2003/02/01') end_mission = TimeSet('2011/10/01') status = bytarr(nfile) FOR ifile=0L,nfile-1 DO BEGIN tmp = files[ifile] IF NOT smei_star_readpnt(tmp,nohdr=nohdr,stars,silent=silent) THEN $ message, 'truncated records, or try /nohdr? '+hide_env(tmp) tt = TimeSet(stars.time) dt = TimeOp(/subtract, tt, start_mission, uday) i = where(dt LT 0) IF i[0] NE -1 THEN BEGIN message, /info, strjoin(stars[i].time,' ') message, /info, 'timestamp too early: '+hide_env(tmp) status[ifile] = 1 ENDIF dt = TimeOp(/subtract, tt, end_mission , uday) i = where(dt GT 0) IF i[0] NE -1 THEN BEGIN message, /info, strjoin(stars[i].time,' ') message, /info, 'timestamp too late: '+hide_env(tmp) status[ifile] = 1 ENDIF name = uniq(stars.name,sort(stars.name)) IF n_elements(name) EQ 1 THEN BEGIN name = stars[0].name ; There should be no duplicate times, except for two special situations: ; - When a star transits between cameras it is fit in each camera. ; This results in two data points at (almost) the same time ; - If a star straddles the joint between beginning and end of the map ; if may be fitted in two successive orbits at (almost) the same ; time times = stars.time+strcompress(stars.camera,/rem) i = sort(times) IF n_elements(uniq(times,i)) NE n_elements(times) THEN BEGIN FOR k=0L,n_elements(times)-1 DO BEGIN IF times[k] EQ '' THEN continue i = where(times EQ times[k],count) IF count EQ 2 THEN BEGIN IF silent LE 0 THEN message, /info, "duplicate time "+stars[k].time+": "+strcompress(count,/rem)+" times for camera "+strcompress(stars[k].camera,/rem) times[i] = '' IF status[ifile] EQ 0 THEN status[ifile] = 1 ENDIF ELSE IF count GT 2 THEN BEGIN IF silent LE 0 THEN message, /info, "duplicate time "+stars[k].time+": "+strcompress(count,/rem)+" times" times[i] = '' IF status[ifile] EQ 0 THEN status[ifile] = 2 ENDIF ENDFOR message, /info, 'duplicate times: '+hide_env(tmp) ENDIF IF (where(strpos([jpl_body(/string),usno_body()],strcompress(name,/rem)) NE -1))[0] NE -1 THEN BEGIN message, /info, 'skipping '+name continue ENDIF star_close = uniq(stars.name_close,sort(stars.name_close)) ; Indices into stars tmp = where_common( strcompress(stars[star_close].name_close,/rem), [jpl_body(/string),usno_body()], absent=absent ) IF absent[0] EQ -1 THEN BEGIN ; Can't happen, I think message, /info, 'only planets and asteroids on stars-close list' status[ifile] = 1 continue ENDIF star_close = star_close[absent] IF n_elements(star_close) EQ 1 THEN BEGIN IF stars[star_close[0]].name_close NE ' -' THEN status[ifile] = 2 ENDIF ELSE BEGIN star_close = stars[star_close].name_close loc = stars[0].radec message, /info, 'inconsistent "nearby star" behavior' status[ifile] = 2 FOR i=0L,n_elements(star_close)-1 DO BEGIN IF star_close[i] NE ' -' THEN BEGIN close_loc = smei_star_list(name=star_close[i],/silent) close_loc = smei_star_info(close_loc,/degrees) message, /info, stars[0].name+' hides behind '+star_close[i]+': '+strcompress(sphere_distance(loc,close_loc,/degrees),/rem) ENDIF ENDFOR ENDELSE ENDIF ENDFOR RETURN, status & END