Commit 596e3caf authored by Teresa Slaven-Blair's avatar Teresa Slaven-Blair
Browse files

User defined nside in create_external_skymap

parent 668b4e15
......@@ -203,7 +203,7 @@ def get_upload_external_skymap(graceid, search, skymap_link=None):
).delay()
def create_external_skymap(ra, dec, error, pipeline, notice_type=111):
def create_external_skymap(ra, dec, error, in_nside, pipeline, notice_type=111):
"""Create a sky map, either a gaussian or a single
pixel sky map, given an RA, dec, and error radius.
......@@ -236,12 +236,12 @@ def create_external_skymap(ra, dec, error, pipeline, notice_type=111):
if pipeline == 'Swift':
error /= np.sqrt(-2 * np.log1p(-.9))
error_radius = error * u.deg
nside = pixel_resolution_to_nside(error_radius, round='up')
# nside = pixel_resolution_to_nside(error_radius, round='up')
nside = in_nside
else:
nside = np.inf
if nside >= max_nside:
if int(nside) >= int(max_nside):
nside = max_nside
# Find the one pixel the event can localized to
hpx = HEALPix(nside, 'ring', frame=ICRS())
skymap = np.zeros(hpx.npix)
......@@ -251,7 +251,6 @@ def create_external_skymap(ra, dec, error, pipeline, notice_type=111):
# If larger error, create gaussian sky map
hpx = HEALPix(nside, 'ring', frame=ICRS())
ipix = np.arange(hpx.npix)
# Evaluate Gaussian.
center = SkyCoord(ra * u.deg, dec * u.deg)
distance = hpx.healpix_to_skycoord(ipix).separation(center)
......@@ -284,7 +283,6 @@ def create_external_skymap(ra, dec, error, pipeline, notice_type=111):
skymap = sum(
weight * hp.sphtfunc.smoothing(skymap, sigma=np.radians(scale))
for weight, scale in zip(weights, scales))
# Renormalize due to possible lack of precision
return skymap / skymap.sum()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment