@dermen I agree this function is a good idea. I got rid of it in the memory branch temporarily, but I think we should add it back in with a few tweaks. Curious what you think about the following:
Have it automatically deal with the mask (should be possible)
Have an option to discard shots (by index) as well as phi values
Adding a unit test
Original Code:
def reduce_rings ( self, factor ):
""" reduce self.num_phi by factor; WARNING: removes the mask; must make a new one """
if self.num_phi % factor != 0:
raise NotImplementedError( 'As of now, *factor* must be a multiple of *self.num_phi*' )
rp = np.copy( self.polar_intensities)
new_rp = np.zeros(( rp.shape[0], rp.shape[1],rp.shape[2] / factor ) )
# convolve algor. taken from stack overflow
for q in self.q_values:
for i in xrange( rp.shape[0] ) :
d = rp[ i,self.q_index(q),:]
d = np.convolve( d + [d[-1]], [1./factor]*factor,mode='valid' )[::factor]
new_rp[i,self.q_index(q),:] = d
return Rings( self.q_values, new_rp, self.k )
@dermen I agree this function is a good idea. I got rid of it in the memory branch temporarily, but I think we should add it back in with a few tweaks. Curious what you think about the following:
Original Code: