-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Add zscale interval based on Numdisplay's implementation #4776
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
Conversation
|
👍 to modifying. As for license, it is the same as PyFITS license, since it also came out of STScI, which is bound to AURA. |
astropy/visualization/zscale.py
Outdated
| KREJ = 2.5 | ||
| MAX_ITERATIONS = 5 | ||
|
|
||
| def zscale (image, nsamples=1000, contrast=0.25, bpmask=None, zmask=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless you can find a way to use bpmask and zmask, we can just remove them since they are not used (as stated in the docstring). I'll go through this in more detail when I get a chance.
|
c/c @larrybradley in case you are interested. |
|
Also, @parejkoj mentioned this implementation by @ctslater. |
| interval = ZScaleInterval() | ||
| vmin, vmax = interval.get_limits(self.data) | ||
| np.testing.assert_allclose(vmin, -20.) | ||
| np.testing.assert_allclose(vmax, +60.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the + necessary?
|
@pllim : Currently the Also the implementation from https://github.com/parejkoj/astropy/blob/luptonRGB/astropy/visualization/lupton_rgb.py#L55 already looks much simpler, so we may probably want to use that instead ? How should we proceed for this, @parejkoj @ctslater ? If you want to submit this as a new PR, I can close this one. |
|
Yeah, the other one looks simpler, but are they interchangable? I am neutral either way. If you do want to press ahead with this one and worry about performance, I would suggest profiling it first before attempting to optimize it. |
|
Ok, I went through the original code and simplified as much as I can. The result is much simpler and easier to understand. It is more similar to the implementation from https://github.com/parejkoj/astropy/blob/luptonRGB/astropy/visualization/lupton_rgb.py#L55, except that it iteratively fits and masks the pixels with extreme values. |
|
@saimn - thanks for working on this! Note that it will need an entry in the changelog for 1.2 |
|
Travis CI failure mentioned something wrong with Sphinx also issued warnings but perhaps a rebase against master would fix those? Not sure. |
|
When, this is all finalized, it is desirable to squash all the intermediate commits into one before merging. |
|
The sphinx build only needs a restart on travis from someone who can. |
|
Oh, it seems About the coverage: it seems the latest build failed for some network reason. The previous build seems fine (https://coveralls.io/builds/5778482) but I am always confused by coveralls' ui: it always display unrelated files, and I cannot find how to see the coverage by line (https://coveralls.io/builds/5778482/source?filename=astropy%2Fvisualization%2Finterval.py is empty, the new zscale module does not appear ...). @pllim Could you tell me how you saw the coverage ? |
FTR, its gives exactly the same results.
+ Merge the zsc_fit_line function in the zscale
|
Rebased on master (and #4784) to get rid of Numpy 1.6 tests ! |
|
@saimn , how about adding a mention of this in the documentation? |
|
@pllim - Good point, added it. |
docs/visualization/normalization.rst
Outdated
| ``clip`` argument is provided to control the behavior of the normalization when | ||
| values fall outside the limits:: | ||
| :class:`~astropy.visualization.PercentileInterval`, | ||
| :class:`~astropy.visualization.AsymmetricPercentileInterval` and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: Add an Oxford comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pllim - Done, didn't know this Oxford comma :)
|
@saimn - this looks great, and I can go ahead and merge it, but first, could you change: to That is, we are actually relicensing this file (and in the docstring below you can add a mention of NUMDISPLAY_LICENSE.rst if you like) |
|
@astrofrog - ok, done ! |
|
@saimn - one quick question: how does this deal with NaN values? |
|
@astrofrog - Oh, good point, and it doesn't deal with ... I have added a commit to filter the invalid values. |
|
@saimn - since it was a regression, maybe it's worth adding a test with NaNs. |
|
@bsipocz - yes indeed, seems reasonable, I will add a NaN in the test case. |
|
This looks good - thanks @saimn! |
|
Thanks :) |
Ref #4773
Currently this PR just add the zscale module from Numdisplay (BSD licensed), and provide an "interval" wrapper. Then a few questions before going on:
licenses/NUMDISPLAY_LICENSE.rst?