Repository navigation
Fix bug in sigma clip mask - #3792
Merged
Merged
Conversation
Member
Author
|
This PR also fixes a bug where Also, I took the opportunity to add the |
Member
|
I don't see anything controversial with this. But perhaps the addition of new keywords is worth a mention in the change log. And addition to its documentation showing how to use the new keywords would not hurt. |
Member
Author
|
Thanks, @pllim. Done. |
Member
|
👍 If no one objects or merge after Memorial Day, I will do it. |
Member
|
@larrybradley , I merged it. |
saimn
added a commit
to saimn/astropy
that referenced
this pull request
Mar 23, 2016
The axis argument was added in astropy#3792 and is passed correctly to sigma_clip, but then mean, median and std did not use axis and were computed on the whole array. This commit changes this to use axis to compute the statistics. Also another minor annoyance is that, with Numpy 1.10, np.ma.median always return a MaskedArray, even when axis is None. This was not the case in previous version (and will probably be fixed in the future), and mean and std return a scalar. So if it happens here, we take the first element of the array.
saimn
added a commit
to saimn/astropy
that referenced
this pull request
Mar 23, 2016
The axis argument was added in astropy#3792 and is passed correctly to sigma_clip, but then mean, median and std did not use axis and were computed on the whole array. This commit changes this to use axis to compute the statistics. Also another minor annoyance is that, with Numpy 1.10, np.ma.median always return a MaskedArray, even when axis is None. This was not the case in previous version (and will probably be fixed in the future), and mean and std return a scalar. So if it happens here, we take the first element of the array.
saimn
added a commit
to saimn/astropy
that referenced
this pull request
Apr 12, 2016
The axis argument was added in astropy#3792 and is passed correctly to sigma_clip, but then mean, median and std did not use axis and were computed on the whole array. This commit changes this to use axis to compute the statistics. Also another minor annoyance is that, with Numpy 1.10, np.ma.median always return a MaskedArray, even when axis is None. This was not the case in previous version (and will probably be fixed in the future), and mean and std return a scalar. So if it happens here, we take the first element of the array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recent changes to
sigma_clip(#3595) made it possible for themaskto be scalarFalsein the returned masked array in the case where no values are clipped. The problem with that is the advertised method for getting the good values,good_only = filtered_data.data[~filtered_data.mask], does not work correctly with a scalar mask value. If themaskis scalarFalsethen~maskis scalarTrue, which is then translated to an index of simply1.This PR ensures the returned
maskalways has the same shape asdataand usesnp.ma.compressedinsigma_clipped_statsinstead offiltered_data.data[~filtered_data.mask]to get the good data values.