;+ ; NAME: ; smei_star_split ; PURPOSE: ; Split pnt files into separate files for each star ; CATEGORY: ; camera/idl/star ; CALLING SEQUENCE: PRO smei_star_split ; INPUTS: ; (none) ; OUTPUTS: ; (none) ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; smei_star_formatpnt, smei_star_info, FindAllFiles, txt_read ; smei_star_readpnt, smei_star_writepnt ; PROCEDURE: ; A separate file is created for each file in $SMEISK0/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; pphick@ucsd.edu) ;- titles = smei_star_formatpnt(/get_titles) sky0 = getenv('SMEISKY0') star_dir = filepath(root=sky0,'star') ; Delete all files in star_dir files = FindAllFiles(paths=star_dir, count=nfile) IF nfile NE 0 THEN tmp = do_file(/delete, files) ; Pick up all pnt files tmp = filepath(root=sky0,subdir='pnt',['c1','c1m0','c2','c2m0','c3','c3m0']) files = FindAllFiles(paths=tmp, count=nfile) ; Loop over all pnt files ; Write each line to the file with extension ._txt for the right star. FOR ifile=0L,nfile-1 DO BEGIN IF txt_read(files[ifile], line, /silent) THEN BEGIN i = where(strmid(line,0,1) NE ';') IF i[0] NE -1 THEN line = line[i] nline = n_elements(line) FOR iline=0L,nline-1 DO BEGIN star_name = strmid(line[iline],0,12) star_file = filepath(root=getenv('SMEISKY0'),subdir='star',smei_star_filename(star_name)+'._txt') spawn, 'echo "'+line[iline]+'" >> '+star_file ENDFOR ENDIF ENDFOR ; Pick up all star files files = FindAllFiles('*._txt',paths=star_dir,count=nfile) ; Sort file contents on time, i.e. make sure the entries ; in the star files are stored chronologically. ; Change extension from ._txt to .txt FOR ifile=0L,nfile-1 DO BEGIN tmp = files[ifile] IF NOT smei_star_readpnt(tmp,/nohdr,stars) THEN message, 'oops: '+hide_env(tmp) smei_star_writepnt, GetFileSpec(tmp,upto='name')+'.txt', stars[sort(stars.time)] tmp = do_file(/delete,tmp,/silent) ENDFOR RETURN & END