;+ ; :Description: ; This routine maps the index of the cbe data to a specific modulation pattern's index. ; The data from the cbe for a sc has to be summed for a specific roll angle to be used ; with the modulation pattern. Sin and Cos are factored in from the phase of the map center ; so this is a generalization of the stacked calibrated eventlist but can be used with ; an unstacked calibrated eventlist. To be used with hsi_cart_profile and hsi_cart_bproj_struct ; ; :Params: ; dmap - number of mod pat roll angles from 0 to pi ; mpat_roll_angle - modulation pattern roll angle ; cbe_roll_angle - calibrated eventlist roll angles to be matched to mpat roll angles ; ; reverse_indices - contains the mapping of the cbe indices for a 2pi modpat index ; modpat index is only on pi but ixmpat handles the mapping from 2pi to pi ; hist_cbe2mpat - only use the reverse_indices for positive values of this array ; ixmpat - see reverse_indices and commente code below ; signi - need a sign reversal for the sin term from pi to 2pi ; ; ; ; :Author: 26-jul-2017, richard.schwartz@nasa.gov ;- pro hsi_cart_modul_pattern_indices, dmap, mpat_roll_angle, cbe_roll_angle, reverse_indices, hist_cbe2mpat, ixmpat, signi twopi = 2.0 * !pi add_pi = ( last_item( mpat_roll_angle ) - mpat_roll_angle[0] ) le !pi mpat_ra = [ mpat_roll_angle, mpat_roll_angle + add_pi*!pi ] - (!pi / (2.0 * dmap)) cbe_angle = ((cbe_roll_angle mod twopi) + twopi) mod twopi ;find the index of the modpat roll angle for each cbe_roll_angle ixra = value_locate( mpat_ra, cbe_angle ) ;But, there are only mpat_ra from 0 to pi, so changes the ones from pi to 2pi to 0 to pi ixra = ixra mod (2*dmap) ;Get the set of indices on the cbe for each of the mpat_ra, but ;later we have to change the mpat_ra indices to the mpat_roll_angle indices ;when we compute ixmpat below hist_cbe2mpat = histogram( ixra, min = 0, max = dmap * 2 -1, rev = reverse_indices) ixmpat = lindgen( 2 * dmap ) mod dmap ; signi = [ fltarr( dmap ) + 1.0, fltarr( dmap ) - 1.0 ] ;sign flip from pi to 2pi for sin terms end