;+ ; NAME: ; smei_buf_mget ; PURPOSE: ; Extracts all frames from specified l1a_files ; CATEGORY: ; camera/idl/buf ; CALLING SEQUENCE: PRO smei_buf_mget, l1a_files, destination=destination, nic=nic, fits=fits, $ _extra=_extra, nowrite=nowrite, gzip=gzip, silent=silent ; INPUTS: ; l1a_files array; type: string ; fully-qualified names of l1a_files ; OPTIONAL INPUT PARAMETERS: ; destination=destination ; scalar; type: string ; directory into which to write the individual frame files ; Output files have form c#frm_YYYY_DDD_HHMMSS (for padded ; frames) or c#roi_YYYY_DDD_HHMMSS (for unpadded ROI ; frames). # is the camera number (1,2 or 3). ; /nic if set (and a valid destination is specified) then frame are ; written in NIC file format (i.e. the data are stored in ; the same way as for the TMO data, but the trailer has ; a totally different structure) ; /fits if set (and a valid destination is specified) then a fits ; file is written ; (at this point the frame headers are not written into ; the fits file. ; /split_dir if writing out lots and lots of frames it is probably better ; to distribute the frames over multiple directories. ; If /split_dir is set then each day of data is split in ; 4-hour intervals over 6 directories with names ; destination/YYYY_DDD/HH with HH=00,04,08,12,16,20 ; ; /overwrite if set existing frames are overwritten ; (passed to smei_buf_prep) ; OPTIONAL OUTPUT PARAMETERS: ; INCLUDE: @compile_opt.pro ; On error, return to caller ; SEE ALSO: ; smei_buf_getframe, smei_buf_get ; CALLS: ; InitVar, IsType, CheckDir, smei_buf_read, smei_setup_roi, GetFileSpec ; smei_frm_write, smei_buf_prep, TimeSet, TimeUnit ; smei_property, hide_env, smei_buf_gzip ; PROCEDURE: ; This is a faster alternative to smei_buf_get. It processes all ; l1a_files in sequence and extracts/writes to disk all frame data. ; ; If either /nic of /fits is set then data are saved to binary files in ; the destination directory (no pointer data will be returned). ; ; File names will have the form c#frm_YYYY_DDD_HHMMSS.ext: ; # = camera id (1,2 or 3) ; ext = 'nic' or 'fts' ; ; /nic SET: ; ; A 512 byte trailer is added after the data array. ; The first 3 bytes are the characters 'buf' (to distinguish these ; files from e.g. the TMO data files). The next 256 is the unmodified ; header from the original frame (except for byte swapping to put the ; data in native machine format. ; ; /fits SET: ; ; STILL NEEDS WORK ; Writes bare fits file (no extra frame header info is put in the file yet, ; just the data are stored). ; MODIFICATION HISTORY: ; APR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- InitVar, nowrite, /key InitVar, nic , /key InitVar, fits , /key InitVar, gzip , /key InitVar, silent , 0 IF NOT fits THEN nic = 1 ; Make sure the destination directory exists, if specified. IF IsType(destination, /undefined) then begin message, /info, 'no destination directory specified' RETURN ENDIF IF destination NE 'SMEIDB?' THEN BEGIN IF NOT CheckDir(destination) THEN BEGIN message, /info, 'non-existent destination specified: '+hide_env(destination) RETURN ENDIF ENDIF message, /info, 'writing '+(['nic','fits'])[fits]+' files' frm_count = lonarr(4) need_gzip = 0L ;total_count = 0 ;for i=0L,n_elements(l1a-files)-1 do begin ; tmp = smei_buf_read(l1a_files, /get_file_header, file_header=hdri) ; total_count = total_count+hdri.total_frames ;endfor ;ifrm = -1 ;iloc = smei_frm_trackbase(ifrm, total_count) ; Initialize base tracking FOR i=0L,n_elements(l1a_files)-1 DO BEGIN old_count = frm_count WHILE smei_buf_read(l1a_files[i], /get_next_frame, $ frame_data=frame_data, frame_headers=hdri) DO BEGIN IF silent LE 0 THEN frm_message = smei_property(hdri,/name)+ $ strcompress(smei_property(hdri,/frame_nr))+ $ ' '+smei_property(hdri,/tlm_file) ; Decide whether or no go get the data. ; - Only write unsigned integer data to .nic file ; At this point hdr.fullframe is still zero for the ROI data. frame_ok = (1-nic OR hdri.bitpix EQ 16) AND 1-nowrite CASE frame_ok OF 0: IF silent LE 0 THEN message, /info, frm_message+' rejected' 1: BEGIN name = smei_buf_prep(hdri, destination, nic=nic, fits=fits, last_dir=last_dir, $ _extra=_extra, filelist=filelist, count=frm_count, comment=comment, $ gzip=gzip, need_gzip=need_gzip) IF silent LE 0 THEN message, /info, frm_message+' '+(['WR','SK'])[name EQ '']+comment IF name NE '' THEN BEGIN smei_frm_write, hdri, frame_data, name, count=frm_count need_gzip += 1L ENDIF END ENDCASE ENDWHILE dif_count = frm_count-old_count IF silent LE 1 THEN message, /info, $ strcompress(dif_count[0]+dif_count[1],/rem)+' frames'+$ '; write' +strcompress(dif_count[0])+ $ '; skip' +strcompress(dif_count[1])+ $ '; insert'+strcompress(dif_count[2])+ $ '; clone' +strcompress(dif_count[3]) ENDFOR ; last_dir is set by smei_buf_prep and will exist only if /split_dir is set. ; Even if /split_dir is set last_dir may not exist if smei_buf_prep was ; never called, i.e. if not a single frame was read from the L1A files. IF gzip THEN smei_buf_gzip, last_dir, need_gzip IF silent LE 1 THEN $ message, /info, $ 'totals:' +strcompress(frm_count[0]+frm_count[1])+' frames'+$ '; write' +strcompress(frm_count[0])+ $ '; skip' +strcompress(frm_count[1])+ $ '; insert'+strcompress(frm_count[2])+ $ '; clone' +strcompress(frm_count[3]) smei_setup_roi, /destroy RETURN & END