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

Change SkyGaussian to spherical representation #2034

Conversation

Projects
2 participants
@luca-giunti
Copy link
Contributor

luca-giunti commented Feb 15, 2019

Redefined the SkyGaussian spatial model. The new function is correctly normalized on the celestial sphere, and reduces to an ordinary Gaussian definition in small angle approximation.

@adonath adonath added the feature label Feb 16, 2019

@adonath adonath self-requested a review Feb 16, 2019

@adonath adonath added this to the 0.11 milestone Feb 16, 2019

@adonath adonath added this to In progress in Modeling via automation Feb 16, 2019

@adonath
Copy link
Member

adonath left a comment

Thanks @luca-giunti! This looks very good to me. I've left two inline comments about the quantity
handling in .evaluate() once those are addressed the PR is ready to be merged.

exponent = -0.5 * (sep / sigma) ** 2
return norm * np.exp(exponent)
a = 1.0 - np.cos(sigma)
norm = (1 / (4 * np.pi * a * (1.0 - np.exp(-1.0 / a)))) * u.sr ** -1

This comment has been minimized.

Copy link
@adonath

adonath Feb 16, 2019

Member

The term (...) * u,sr ** -1 creates a new quantity object every time the method is evaluated. By default all the data will be copied, which slows down the computation a lot. Please remove it here. Here is some info about this http://docs.astropy.org/en/stable/units/index.html#astropy-units-performance

a = 1.0 - np.cos(sigma)
norm = (1 / (4 * np.pi * a * (1.0 - np.exp(-1.0 / a)))) * u.sr ** -1
exponent = -0.5 * ((1 - np.cos(sep)) / a)
return (norm * np.exp(exponent)).to("deg-2")

This comment has been minimized.

Copy link
@adonath

adonath Feb 16, 2019

Member

Instead creating the quantity and doing the unit conversion here could you just create a Quantity object like so:

return u.Quantity(norm * np.exp(exponent), unit="sr1", copy=False)

The same as is done for the SkyDisk model...

@luca-giunti

This comment has been minimized.

Copy link
Contributor Author

luca-giunti commented Feb 18, 2019

Thank you @adonath for your comment! I agree, now the .evaluate() should be more efficient. It returns a Quantity with units sr-1, similarly to what SkyDisk does

@adonath
Copy link
Member

adonath left a comment

Thanks, @luca-giunti!

@adonath adonath merged commit e05988c into gammapy:master Feb 18, 2019

3 checks passed

Codacy/PR Quality Review Up to standards. A positive pull request.
Details
Scrutinizer Analysis: No new issues – Tests: passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

Modeling automation moved this from In progress to Done Feb 18, 2019

@adonath adonath changed the title Redefine symmetric gaussian spatial model on the sphere Change symmetric gaussian spatial model to spherical representation Mar 26, 2019

@adonath adonath changed the title Change symmetric gaussian spatial model to spherical representation Change SkyGaussian to spherical representation Mar 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.