;+ ;NAME: ; ksc_ffi_index ;PURPOSE: ; Generate a psuedo SXT index structure from an FFI image in KSC raw format ;CATEGORY: ; SXT operation software ;CALLING SEQUENCE: ; ksc_ffi_index, ffi_header, index ; ksc_ffi_index, ffi_header, index, /verbose ;PROGRAM INPUTS: ; ffi_header ; /verbose - If set, send a message to the screen ;PROGRAM OUTPUTS: ; index - SXT index structure. Not many fields are filled in ; and the year is assumed to by the year of the current time. ;INPUT PARAMETER: ; None ;COMMON BLOCKS: ; None ;SIDE EFFECTS: ; None. ;RESTRICTIONS: ; The year, image array size, and exposure times are inferred from the ffi_header ; and may not be absolutely correct. ;Modification history: ; H.Hara Oct 2, 1991, Written -- original name was ffi_head ; HSH 18-jan-96, changed some output stuff ; HSH 20-jul-96, use SUN2VAX for decoding integers ; 6-Sep-97, JRL, Renamed and changed to return an SXT index. ; Extended to allow use on Sun or OSF ;- pro ksc_ffi_index,ffi_header, index, verbose=verbose ; Set up the output structure: nfile = n_elements(ffi_header(0,*)) sxt_struct,sxt_index=sxt_index gen_struct,gen_index=gen_index index = {gen:gen_index,sxt:sxt_index} if nfile gt 1 then index = replicate(index,nfile) ; Set up the DPE and MBE vectors ii = replicate(index(0),30) & ii.sxt.ExpLevMode = indgen(30) ii.sxt.periph = replicate(1,30) ; Open nomask = gt_dpe(ii,/conv) ii.sxt.periph = replicate(6,30) ; With mask mask = gt_dpe(ii,/conv) ; Set up swap parameters: noswap_os=['vms','ultrix','OSF','linux'] ; list of noswap (extensible) chk=where(!version.os eq noswap_os,nscount) ; current OS in noswap list? qswap = nscount eq 0 ; assign boolean for i=0,nfile-1 do begin header = ffi_header(*,i) ; ### Day ### mmdd=string(header(52:55)) ;Observed Day ; print,'DAY, mmdd = '+mmdd yy = (anytim2ex(gt_day(!stime,/str)))(6) ; Assume current year months = [' ','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] day = string(header(54:55))+'-'+months(fix(string(header(52:53))))+'-'+strtrim(yy,2) ; #### DP time ##### h=long(header,56) if not qswap then sun2vax,h ; Wrong convention: data written on a Sun h=h/1000 hh=h/36004 h=h-3600*hh mm=h/60 ss=h-60*mm mm = strmid(string(mm),10,2) & ss = strmid(string(ss),10,2) TIME = string(hh,':',fix(mm),':',fix(ss), form='(i2.2,a,i2.2,a,i2.2)') if keyword_set(verbose) then print,time + ' ' + day time_str = anytim2ints(time + ' ' + day) index(i).gen.time = time_str.time index(i).gen.day = time_str.day if keyword_set(verbose) then print,'Time = '+fmt_tim(index(i)) if (anytim2ex(fmt_tim(index(i))))(6) eq 99 then stop ;*** ; ### DP Mode ### h=header(20) case 1 of h eq 0: dpmode=13 ; 'Quiet' h eq 1: dpmode= 9 ; 'Flare' endcase if keyword_set(verbose) then print,'DP MODE = ',dpmode index(i).gen.dp_mode = dpmode ; ### Bit Rate ### h=header(22) case 1 of h eq 0: bitrate=4 ; 'High' h eq 1: bitrate=2 ; 'Medium' endcase if keyword_set(verbose) then print,'BIT RATE = ',bitrate index(i).gen.dp_rate = 2^5 * bitrate ; #### Resolution #### h=header(89) case 1 of h eq 0: res=0 ; 'Full' h eq 1: res=1 ; 'Half' h eq 2: res=2 ; 'Quarter' endcase if keyword_set(verboes) then print,'RESOLUTION = ',res index(i).sxt.pfi_ffi = 1 ; This is an assumption ; #### Compression Mode #### h=fix(header(90)) com=['Comp','Low ','High'] if keyword_set(verbose) then print,'COMPRESSION = '+com(h) index(i).sxt.imgparam = h * 4 + res ; #### Filter Information #### fila=strmid(string(fix(header(87))),7,1) filb=strmid(string(fix(header(88))),7,1) if keyword_set(verbose) then $ print,'B/A = '+filb+'/'+fila,' (',gt_filtb(filb,/str),')' index(i).sxt.periph = filb * 2^3 + fila ; #### Exposure Time #### hhh = header(80:83) hhh = long(hhh,0) if not qswap then sun2vax,hhh ; Wrong convention: data written on a Sun h = hhh/100. exposure=h/1000. case 1 of h lt 1000. : begin expt=strmid(string(h),6,5) c=' ms' end h ge 1000. : begin h=h/1000. expt=strmid(string(h),6,5) c=' s' end endcase if keyword_set(verbose) then print,'EXPOSURE = '+expt+c if fila eq 6 then xx = min(abs(mask-exposure*1000),cc) else $ xx = min(abs(nomask-exposure*1000),cc) index(i).sxt.ExpLevMode = cc ; Inferred MBE value ; #### Exposure Mode #### h=fix(header(64)) exmod=['Normal','Dark ','Cal ','Error '] if keyword_set(verbose) then print,'EXP = '+exmod(h) ExpLevMode = h index(i).sxt.ExpLevMode = index(i).sxt.ExpLevMode + 2^6 * h ; #### The next is a complete assumption #### index(i).sxt.shape_cmd = ([[1024,512],[512,512],[256,256]])(*,res) endfor index.sxt.shape_sav = index.sxt.shape_cmd if keyword_set(verbose) then print,get_info(index,/non) end