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 take method to BinnedStatistic. #497

Merged
merged 1 commit into from Jun 1, 2018

Conversation

Projects
None yet
1 participant
@rainwoodman
Member

rainwoodman commented May 31, 2018

The take method behaves more or less like the traditional numpy indexing.
Either a boolean mask of the same shape of data, or boolean masks along
each axis is accept. It is more powerful and sometimes allows more
intuitive code segments than the current sel method; see the example in
docstring.

The full boolean mask is projected along each axis then 'and'ed to the
given mask along the axis.

If a list of indices is given along any axis, it is first converted to
a mask.

In the end the booleans are converted to lists because the finalize method
takes only indices.

Add a take method to BinnedStatistic.
The take method behaves more or less like the traditional numpy indexing.
Either a boolean mask of the same shape of data, or boolean masks along
each axis is accept. It is more powerful and sometimes allows more
intuitive code segments than the current sel method; see the example in
docstring.

The full boolean mask is projected along each axis then 'and'ed to the
given mask along the axis.

If a list of indices is given along any axis, it is first converted to
a mask.

In the end the booleans are converted to lists because the finalize method
takes only indices.
@rainwoodman

This comment has been minimized.

Member

rainwoodman commented May 31, 2018

One intention of this PR is to allow one to use very fine dk bins to keep only one unique |k| per bin. Currently it produces too many nans. The take function allows one to keep only those bins that are ever sampled with a simple call:

    r = FFTPower(field, mode='1d', dk=1e-4)
    pkmu = r.power.take(r.power['modes'] > 0)

This should alleviate the <p(k)> v.s. p() problem that occurred when comparing realizations to theory when p(k) is very tilted.

@Chris-Pedersen @sbird

@rainwoodman rainwoodman merged commit 83b114e into bccp:master Jun 1, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.03%) to 95.218%
Details

@rainwoodman rainwoodman deleted the rainwoodman:bin-take branch Jun 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment