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

ccdmask (rebased and without master) #432

Merged
merged 29 commits into from Dec 13, 2016
Merged

ccdmask (rebased and without master) #432

merged 29 commits into from Dec 13, 2016

Conversation

MSeifert04
Copy link
Contributor

Supersedes #414.

I manually applied the changes made after the master merge. I discarded more than 10 branches because I couldn't get cherry-picking working. I hope you @joshwalawender don't mind that git now thinks I applied them?

@MSeifert04 MSeifert04 added this to the 1.2 milestone Dec 6, 2016
@MSeifert04 MSeifert04 changed the title Ccdmask 2 ccdmask (rebased and without master) Dec 6, 2016
@MSeifert04
Copy link
Contributor Author

MSeifert04 commented Dec 7, 2016

@astropy/ccdproc-maintainers I made some changes (mostly PEP stuff).

Would be very happy if you could review this.

Additionally I was thinking about putting the badcolumn part in a seperate function because it's mostly independant from the median/percentile part and it could also be useful in combination with other masking functions (for example astroscrappy or if one already has a "valid" mask).

@mwcraig
Copy link
Member

mwcraig commented Dec 7, 2016

Will do a quick review later today.

@MSeifert04
Copy link
Contributor Author

sphinx failure is unrelated: astropy/astropy#5568

@MSeifert04
Copy link
Contributor Author

Sorry @mwcraig I was just testing the new "review request" feature here. I hope you don't mind.

Copy link
Member

@mwcraig mwcraig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes requested are minor. @MSeifert04 -- I can do these later today if you do not have time, just let me know.

One broader question, the answer to which is, I think, no: Should the code try to enforce the recommendations for function parameters mentioned in the documentation? Am leaning towards no since the default parameter values are sensible and consistent with those guidelines.

Gaps of undetected pixels along the column direction of length less
than this amount are also flagged as bad pixels.

Notes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor quibble: the Parameters section should come before Notes

"""
Uses method based on the IRAF ccdmask task to generate a mask based on the
given input.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a statement explaining which index this function considers line and which is column. Looks like line is the first index and column is the second.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adressed below.


mask = ~np.isfinite(ratio.data)
medsub = (ratio.data -
ndimage.median_filter(ratio.data, size=(nlmed, ncmed)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a median filter in ccdproc now? We should use that...

Copy link
Contributor Author

@MSeifert04 MSeifert04 Dec 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes there is. I haven't changed it because that's just a wrapper around ndimage.median_filter and at this line we're already working on the pure numpy arrays so there is no difference.

If you like it should be as easy as replacing the ndimage.median_filter with median_filter.

csum_sigma = np.ma.MaskedArray(np.sqrt(c2 - c1 - csum))
colmask = _sigma_mask(csum.filled(1), csum_sigma,
lsigma, hsigma)
block_mask[:, :] |= colmask[None, :]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I know it is literally the same thing, I find np.newaxis easier to understand when reading the code than None

for line in six.moves.range(0, nlines - ngood - 1):
if mask[line, col]:
for i in six.moves.range(2, ngood + 2):
lend = line+i
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP8: Please add spaces around the operator.


ngood: `int`, optional
Gaps of undetected pixels along the column direction of length less
than this amount are also flagged as bad pixels.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pixels.pixels, if they are between pixels masked in that column.

from ..ccddata import CCDData


def test_ccdmask_pixels():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could a comment be added here about the intent of the test arrays? Are they snippets from larger images, should they have bad pixels or are those only added in the body of the test, etc.

Doesn't need to be super long, just enough so it is clearer what can (and cannot) be modified in the future.

@joshwalawender can maybe address this most easily.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry the additional tests incorrectly hide this comment. Could you repost it?

@mwcraig
Copy link
Member

mwcraig commented Dec 9, 2016

Sorry @mwcraig I was just testing the new "review request" feature here. I hope you don't mind.

No worries! I need to check whether notifications can be set up for this. Could be super-useful for assigning work.



def test_ccdmask_pixels():
flat1 = CCDData(np.array([[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[repost]
Could a comment be added here about the intent of the test arrays? Are they snippets from larger images, should they have bad pixels or are those only added in the body of the test, etc.

Doesn't need to be super long, just enough so it is clearer what can (and cannot) be modified in the future.

@joshwalawender can maybe address this most easily.

@mwcraig
Copy link
Member

mwcraig commented Dec 13, 2016

Merging, thanks @MSeifert04 and @joshwalawender

@mwcraig mwcraig merged commit e1acdf8 into astropy:master Dec 13, 2016
@MSeifert04 MSeifert04 deleted the ccdmask_2 branch December 13, 2016 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants