Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a reduce_rings method #3

Open
tjlane opened this issue Apr 21, 2014 · 0 comments
Open

add a reduce_rings method #3

tjlane opened this issue Apr 21, 2014 · 0 comments
Labels

Comments

@tjlane
Copy link
Owner

tjlane commented Apr 21, 2014

@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 ) 

@tjlane tjlane added the easyfix label Dec 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant