;+ ; NAME: ; smei_star_split ; PURPOSE: ; Processes all individual star files (as created by Python ; script smei_star_split.py) and sorts their content into ; chronological order. ; CATEGORY: ; camera/idl/star ; CALLING SEQUENCE: PRO smei_star_split, wildcard, $ source = source , $ remove = remove , $ silent = silent , $ force = force ; INPUTS: ; wildcard scalar; type: string; default: '*' ; OPTIONAL INPUTS: ; source scalar; type: string; default: '.' ; source directory of files for individual stars ; OUTPUTS: ; Rewrites all the files for individual stars ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, FindAllFiles, smei_star_readpnt, smei_star_writepnt ; PROCEDURE: ; For each star a separate file is created in $SMEISKY0/star ; containing all the records for that star found in the ; pnt files stored in $SMEISKY0/pnt. ; MODIFICATION HISTORY: ; JAN-2007, Paul Hick (UCSD/CASS) ; JUL-2012, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Removed the part that creates the individual star files. ; This is now done with Python script smei_star_split.py ;- InitVar, source , '.' InitVar, wildcard , '*.txt.dirty' InitVar, remove , /key InitVar, silent , 0 InitVar, force , /key ; Sort file contents on time, i.e. make sure the entries ; in the star files are stored chronologically. start_mission = TimeSet('2003/02/01') uday = TimeUnit(/day) files = FindAllFiles(wildcard,paths=source,count=nfile) FOR ifile=0L,nfile-1 DO BEGIN dirty_file = files[ifile] clean_file = GetFileSpec(dirty_file,upto='name',/strict)+'.txt.clean' IF NOT force THEN $ IF (file_search(clean_file))[0] NE '' THEN $ continue IF smei_star_testpnt(dirty_file, /nohdr, silent=silent) EQ 2 THEN BEGIN message, /info, 'skip really bad dirty file, '+dirty_file continue ENDIF IF NOT smei_star_readpnt(dirty_file, /nohdr, stars, silent=silent) THEN $ message, 'oops: '+hide_env(dirty_file) ; Remove bad timestamps: happens if the lores time map ; does not have a time at the location of the star) dt = TimeOp(/subtract, TimeSet(stars.time), start_mission, uday) i = where(dt LT 0, complement=j) IF i[0] NE -1 THEN BEGIN message, /info, 'discarding '+strcompress(n_elements(i),/rem)+' point(s) with bad timestamp' IF j[0] NE -1 THEN stars = stars[j] ENDIF ; Remove stars marked as stars.done=2 (not enough points for fitting) ; (stars.done=0 should never happen) i = where(stars.done NE 1, complement=j) IF i[0] NE -1 THEN BEGIN message, /info, 'discarding '+strcompress(n_elements(i),/rem)+' point(s) for stars not fitted' IF j[0] NE -1 THEN stars = stars[j] ENDIF stars = stars[sort(stars.time)] smei_star_writepnt, clean_file, stars, camera=[1,2,3], /single_star IF smei_star_testpnt(clean_file, silent=silent) EQ 0 THEN $ IF remove THEN IF ext NE '.txt.clean' THEN $ tmp = do_file(/delete,clean_file,/silent) ENDFOR RETURN & END