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

tickets/DM-20129 #9

Merged
merged 14 commits into from Jul 25, 2019
Merged

tickets/DM-20129 #9

merged 14 commits into from Jul 25, 2019

Conversation

fred3m
Copy link
Contributor

@fred3m fred3m commented Jun 29, 2019

Add unit tests to ensure the package is working and to track changes in a simple blend.

Copy link
Contributor

@natelust natelust left a comment

Choose a reason for hiding this comment

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

Few question/comments mostly looks fine.

# If the source is too faint for background detection,
# initialize it as a PointSource
pass
if not initialized:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this happen if the pointSource is set to False?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see the above comment, but am just wondering the logic, should there not just be an error thrown or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Part of this might be the nomenclature. Both ExtendedSource and PointSource are used to model extended sources, they just differ in their initialization. An ExtendedSource uses a multiband coadd to attempt to initialize large extended sources but requires a certain signal to noise level to function properly. Very faint sources barely above the background will not have enough flux to meet this requirement, so we initialize them as a point source but they are still allowed to grow.

tests/test_deblend.py Outdated Show resolved Hide resolved
tests/utils.py Outdated Show resolved Hide resolved
# also using scipy.signal.convolve as a sanity check
morphs = np.array([scipy.signal.convolve(m, targetPsfImage, method="direct", mode="same")
for m in morphs])
morphs /= morphs.max()
Copy link
Contributor

Choose a reason for hiding this comment

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

This may just be me reviewing quickly without thinking through too much, but do you want the max or the sum in the normalization

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 max. This seems to be a more stable normalization, most likely because the center of most objects is better behaved. Recall that the value of a pixel in the model is the product of its SED and the morphology in that pixel. Since the center of an object has a higher S/N it is easier for the optimization algorithm to correctly fit the center and takes more time to fit the outside of a source. If we instead use a normalization of the entire morphology then fiddling with flux on the outskirts of an object also adjusts the flux in the center (due to the normalization of all the pixels) and takes longer to converge.

psfImages /= psfImages.sum(axis=(1, 2))[:, None, None]

channels = range(len(images))
return targetPsfImage, psfImages, images, channels, seds, morphs, targetPsf, psfs
Copy link
Contributor

Choose a reason for hiding this comment

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

When you have thing many parameters consider returning a pipe_base.Struct, collections.namedtuple, or types.SimpleNamespace so that it is easier to reason and work with so many objects.

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 know what you mean but I'm not a big fan of returning a new class just for a return value.

@fred3m fred3m merged commit 7ac3d52 into master Jul 25, 2019
@fred3m fred3m deleted the tickets/DM-20129 branch July 25, 2019 12:34
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