pro cg_get_uvis_modifier, sctime, channel, arrmod,def_file_keep ; ; SET THIS PATH ; wdir_mods = 'C:\Greg_Holsclaw\Cassini\UVIS\flat field modifiers\' wdir_mods = def_file_keep + 'UVIS_flat-field_modifiers' + path_sep() wdir_mods = def_file_keep + 'UVIS_cal_and_ff_modifiers' + path_sep(); 10/17/2016: added this path ; ; 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_mods+channel+'*ff*.dat',count=nfiles)); 10/17/2016: added ff* 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_mods+fmods[nfiles-1],/get_lun readu,fid,arrmod free_lun,fid 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_mods+fmods[ndx_gt[0]-1],/get_lun readu,fid,arrmod1 free_lun,fid arrmod2 = fltarr(1024,64) openr,fid,wdir_mods+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 endif ; end