pro cg_get_uvis_ff_modifier, sctime, channel, arrmod, wdir ; ; SET THIS PATH TO THE LOCATION OF THE FLAT-FIELD MODIFIER DATA FILES ; ; wdir_mods = '/Users/holsclaw/Cassini/UVIS/flat_field_modifiers/' ;wdir_mods = '' ; ; inputs: ; sctime: Cassini spacecraft time of an observation ; channel: 'EUV' or 'FUV' ; outputs: ; arrmod: an array (1024,64) of values to divide into the flat-field ; ; read in the filenames and acquisition times of the flat-field modifiers ; fmods = file_basename(file_search(wdir + channel+'*ff_modifier*.dat',count=nfiles)) sctime_mods = lonarr(nfiles) for i = 0, nfiles - 1 do sctime_mods[i] = strmid(fmods[i],strlen(fmods[i])-14,10) ; ; determine where the present observation occurred relative to the flat-field modifiers ; ndx_gt = where( sctime_mods gt sctime, count_gt, complement=ndx_lt ) ; ; if all modifiers were obtained after the observation, then return an array of 1's if count_gt eq nfiles then begin ;print, '** ' print, '** This observation occurred prior to the flat-field modifiers - no flat-field corrector adjustment' ;print, '** ' arrmod = fltarr(1024,64) + 1. endif ; ; if all modifiers were obtained before the observation, then use the last modifier ; if count_gt eq 0 then begin arrmod = fltarr(1024,64) openr,fid,wdir + fmods[nfiles-1],/get_lun readu,fid,arrmod free_lun,fid print, '** The following flat-field modifier was used:' print, '** ', fmods[nfiles-1] print, '** ' arrmod[*,61] = 1. endif ; ; if the observation occurred between two modifiers, then linearly interpolate between the two ; if (count_gt gt 0) and (count_gt lt nfiles) then begin arrmod1 = fltarr(1024,64) openr,fid,wdir + fmods[ndx_gt[0]-1],/get_lun readu,fid,arrmod1 free_lun,fid arrmod2 = fltarr(1024,64) openr,fid,wdir + fmods[ndx_gt[0]],/get_lun readu,fid,arrmod2 free_lun,fid m = (arrmod2-arrmod1)/double(sctime_mods[ndx_gt[0]]-sctime_mods[ndx_gt[0]-1]) arrmod = m*(sctime-sctime_mods[ndx_gt[0]-1])+arrmod1 print, '** The following flat-field modifiers were used:' print, '** ', fmods[ndx_gt[0]-1] print, '** ', fmods[ndx_gt[0]] print, '** ' arrmod[*,61] = 1. ;stop endif ; end