;+ ; NAME: ; smei_sky_cleantime ; PURPOSE: ; Removes averages from slices of a skymap that are between ; two orbital time intervals, determined by the number of ; slices. (default 360 slices) ; CATEGORY: ; camera/idl/toolbox ; CALLING SEQUENCE: FUNCTION smei_sky_cleantime , $ skymap , $ ; equatorial map timemap , $ ; low-res orbtime map cammap=cammap , $ ; low-res camera coverage map camavg=camavg , $ ; camera or cameras to average slices=slices ; number of time slices ; INPUTS: ; skymap array[720,360]; type: float ; low res equatorial skymap ; timemap array[720,360]; type: float ; orbtime map ; OPTIONAL INPUTS: ; slices=slices scalar; type: float ; number of slices to cut map ; into for averaging times ; camavg=camavg scalar or array; type: integer ; camera or cameras to remove ; average values from (default: 3) ; must only contain integer values ; 1 2 or 3, or an array of those ; eg. [1,2,3] ; cammap=cammap array[720,360]; type: integer ; map of camera coverage ; (if either camavg or cammap are ; not provided, then the entire ; skymap will have the average ; removed in slices ; OUTPUT: ; skymap array[720,360]; type: float ; same as input map but with ; time-slice averages removed ; in specified camera only ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar ; MODIFICATION HISTORY: ; JAN-2010, John Clover (UCSD/CASS; jclover@ucsd.edu) ; OCT-2010, John Clover ; Added more flexibility, if nbin is changed in smei_sky, this should ; catch it and adjust appropriately. ;- InitVar, slices, 180.0 InitVar, camavg, 3 dimsky = size(skymap, /dim) dimtim = size(timemap, /dim) InitVar, cammap, fltarr(dimsky[0],dimsky[1]) print, 'CAMMAP: ', size(cammap, /dim) rebinfac = float(dimsky[0])/float(dimtim[0]) if rebinfac gt 1 then begin timemap = congrid(timemap,rebinfac*dimtim[0], rebinfac*dimtim[1]) dimtim = size(timemap, /dim) end ; if no cammap is provided, entire map is smoothed, this may not be good if max(cammap) eq 0 then camavg = 0 for j=0, n_elements(camavg)-1 do begin ; scoop out the values of the skymap that correspond to desired camera scoop = where(cammap eq camavg[j]) if scoop[0] ne -1 then begin newmap = fltarr(dimsky[0], dimsky[1]) newmap[*,*] = !values.f_nan newmap[scoop] = skymap[scoop] newtime = fltarr(dimtim[0],dimtim[1]) newtime[scoop] = timemap[scoop] maprange = abs(max(newtime)-min(newtime)) ; i want 360 (for example) slices per orbit, and if i have a half orbit i only want 180.0 ; so step should be static, determined by slices. ; slices = maprange/step step = 1.0/slices slicefrac = maprange*slices for i=0, fix(slicefrac)-1 do begin tstart = min(newtime)+i*step tend = tstart+step inda = where((newtime ge tstart) and (newtime lt tend)) if inda[0] ne -1 then begin iavg = mean(newmap[inda],/nan) newmap[inda] -= iavg end end skymap[scoop] = newmap[scoop] end end return, skymap end