function get_an, header, dir, nframe, times=times, top=top, help=help IF KEYWORD_SET(help) THEN BEGIN PRINT,'function get_an, header, dir, nframe, times=times, top=top, help=help' PRINT,' PRINT,'USAGE: image = get_an(header, dir, nframe, times=times) PRINT,'Help: Junk = get_an(/help) prints this message PRINT,' PRINT,'header A structure from open_an necessary to read the frame PRINT,' header = {marker1:0UL, marker2:0UL, blocksize:0UL, version:0UL, nframes:0UL, width:0UL, Height:0UL, $ PRINT,' bits:0UL, eType:0L, eFormat:0L, infoblocksize:0UL, datablocksize:0UL, frameheadersize:0UL, $ PRINT,' frameblocksize:0UL, diroffset:0LL, dirsize:0UL, roibuff:0UL, timestampsize:0UL, packed:0L, lun:lun } PRINT,' PRINT,'dir A long64 array of pointers for each frame PRINT,' PRINT,'nframe ULong The frame you want PRINT,' PRINT,'times An array of structures with time information for each frame from open_an. PRINT,' If present, the time will be inserted at the bottom left of the image PRINT,' PRINT,'top If set the time will be at the top rather than at the bottom RETURN,0 ENDIF IF nframe GE N_ELEMENTS(dir) THEN BEGIN PRINT,'GET_an: Frame not available: ',nframe error = 'GET_an: Frame not available: ' RETURN,0 ENDIF ON_IOERROR, ioerror month = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] POINT_LUN, header.lun, dir(nframe)+ header.timestampsize framemark = ULONARR(2) READU, header.lun, framemark ; framemark = READ_BINARY(header.lun, data_type=13, data_dims=2, datastart = dir(nframe)+ header.timestampsize) IF (framemark(0) NE 'af128945'x ) OR (framemark(1) NE 'ab12a946'x ) THEN BEGIN PRINT,'GET_an: Frame marker unrecognised ' error = 'GET_an: Frame marker unrecognised ' PRINT,framemark, FORMAT='(4z)' RETURN,0 ENDIF; framemark offset = header.timestampsize + header.frameheadersize chunks = header.frameblocksize / 3 rawdata = BYTARR(3, chunks) POINT_LUN, header.lun, dir(nframe)+ offset READU, header.lun, rawdata ; ------------ unpack the packed 12 bit data --------------------------------------- image = INTARR(2, chunks) image(0,*) = 16*FIX(rawdata(0,*)) + FIX( rawdata(1,*) AND 'f0'x )/16 image(1,*) = FIX(rawdata(2,*)) + 256*FIX((rawdata(1,*) AND '0f'x )) image = REFORM(image, header.width, header.height) image = REVERSE(image,2) ; written in C order... IF KEYWORD_SET(times) THEN BEGIN IF N_ELEMENTS(times) NE N_ELEMENTS(dir) THEN timestamp = '' ELSE BEGIN date = month(times(nframe).month)+' '+ STRTRIM(times(nframe).day,2)+' '+STRTRIM(times(nframe).year,2) sec = times(nframe).sec + times(nframe).msec/1000.0 + times(nframe).usec/1.0e6 time = STRTRIM(times(nframe).hr,2)+':'+STRTRIM(times(nframe).minute,2)+':'+STRING(sec,FORMAT='(f9.6)') timestamp = ' Frame '+STRTRIM(nframe,2)+' '+date + ' '+time IF KEYWORD_SET(top) THEN tmp = image(0:299, header.height-219:header.height-1)/16 ELSE $ tmp = image(0:299, 1:19)/16 window,pmap,xsize=300,ysize=19, /pixmap, /free pmap = !d.window tv,tmp IF MEAN(TMP) GT 128 THEN color = 0 ELSE color = 255 xyouts, 0.0, 0.0, timestamp, color=color, /normal tmp2 = tvrd() scale = 16 IF KEYWORD_SET(top) THEN image(0:299, header.height-19:header.height-1 )= FIX(tmp2*scale) ELSE $ image(0:299,1:19) = FIX(tmp2*scale) wdelete,pmap ENDELSE ENDIF ;KEYWORD_SET(times) return, image ioerror: PRINT,'get_an: io error...' PRINT,!ERROR_STATE.MSG return,0 END; function get_an, header, nframe, times=times