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 CoaddPsf construction in default reducer subtask. #52

Merged
merged 1 commit into from Mar 28, 2017

Conversation

isullivan
Copy link
Contributor

  • Add tests of newly-generated PSFs
  • Fix a few docstrings
  • Add some fixes that arose during testing

Copy link
Contributor Author

@isullivan isullivan left a comment

Choose a reason for hiding this comment

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

Looks good, I had only a few comments. Since I initiated the pull request, it looks like I can't mark it as 'approved', so in the future please create a pull request before sending a ticket for review.

sumy2 += y*y*f
sumx += x*f
sumy += y*f
sum += f
Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about sumf instead of sum, since sum is an existing function.

@@ -523,7 +563,7 @@ def _reduceImage(self, mapperResults, exposure, **kwargs):
result = self.reducerSubtask.run(mapperResults, exposure, **kwargs)
return result

def _generateGrid(self, exposure, forceEvenSized=False):
def _generateGrid(self, exposure, forceEvenSized=False, **kwargs):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add a comment describing what you expect to pass through **kwargs

Copy link
Contributor

Choose a reason for hiding this comment

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

That is noted in a comment where this function is called (line 528) but will add a comment here.

it just copies over the PSF from the original exposure). To be
investigated in DM-9629.
3. To be done: correct handling of masks as well.
2. This correctly handles varying PSFs, constructing the resulting
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. and 2. here aren't really 'known issues', since they're features. Maybe move them to a separate 'Features' section.

Copy link
Contributor

Choose a reason for hiding this comment

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

Kept 1 and 2 in Notes, moved 3. and 4. to 'Known issues' section.

@@ -230,14 +231,15 @@ def run(self, mapperResults, exposure, **kwargs):
newMI = newExp.getMaskedImage()

reduceOp = self.config.reduceOperation
weights = None
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you remove this? I don't see anywhere that it would be valid for weights to be None

Copy link
Contributor

Choose a reason for hiding this comment

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

Need to set weights to None so that it is kept in function scope. Moved the setting to None to inside the first if clause -- when it won't be needed.

subMI.getVariance().getArray()[isNotNan] += patchMI.getVariance().getArray()[isNotNan]
if reduceOp == 'average':
# wsubim is a view into the `weights` Image
wsubim = afwImage.ImageI(weights, item.getBBox())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wsubim is not a very clear variable name. Maybe weightsView or wtSubView or something.

a `subExposure` element, from which the component Psfs are
extracted (thus the reducerTask cannot have
`reduceOperation = 'none'`.
exposure : afwImage.Exposure
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suggest you write this as lsst.afw.image.Exposure, instead of using the shortened afwImage here, since it will show up in the documentation without the context of the import statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same comment applies to pipeBase above and measAlg below

Copy link
Contributor

Choose a reason for hiding this comment

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

Will do in my commit to DM-7611, if that's okay (works off the same codebase and I don't want to add more conflicts).

mycatalog = afwTable.ExposureCatalog(schema)

# We're just using the exposure's WCS (assuming that the subExposures'
# WCSs are the same, which they better be!).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you add a check and raise an exception if the WCS's were different?

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, but how to compare WCSs? Will investigate...

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, done.

import lsst.pex.config as pexConfig
import lsst.meas.algorithms as measAlg
import lsst.pipe.base as pipeBase
import lsst.daf.base as dafBase
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please insert the new import statements in alphabetical order.


if reduceOp == 'average':
newMI /= weights
wts = weights.getArray().astype(np.float)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you need to check for weights being zero anywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, I'm already working on setting a mask value to invalid in this case. This will be implemented as part of DM-7611 (about to submit for review).

- Add tests of newly-generated PSFs
- Fix a few docstrings
- Add some fixes that arose during testing
@djreiss djreiss merged commit 3bb0bbf into master Mar 28, 2017
@ktlim ktlim deleted the tickets/DM-9629 branch August 25, 2018 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants