You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed this issue when visualizing localizations with EquatorialPlot, where the probability heatmap isn't rendered correctly when the centroid RA is close to 0 or 360 degrees. This can be illustrated using a local copy of glg_healpix_all_bn220130968_v01.fit:
In the case of localizations, the lon_array specified to plot_heatmap() will contain values in $[0, 360]$. However, the call to SkyCoord() will convert the last 360 value to 0. E.g.:
This appears to cause the issue when subsequently rendering the heatmap. Note that it's only visible when centroids straddle RA=0/360 degrees, other localisation centroids are rendered correctly. I've also noticed a similar issue with the contour lineswhere although it doesn't impact the visualisation as much as the heatmaps, the lines are broken, and I assume it's also due to the use of SkyCoord.
I have a local workaround that overrides plot_heatmap() to exclude the call to SkyCoord(), where the specified lon_array and lat_array are passed directly to SkyHeatmap, similar to the previous GBM Data Tools implementation:
fromgdt.core.plot.plotimportSkyHeatmapclassFixEquatorialPlot(EquatorialPlot):
defplot_heatmap(self, heatmap, lon_array, lat_array, **kwargs):
"""Plot a heatmap on the sky. This is a workaround for the issue in the parent SkyPlot.plot_heatmap(), where the meshgrid results in a lon_array starting/ending with 0 degrees. This causes issues where the heatmap generated from a HEALPix location is populated at both RA=0/360 degrees, resulting in an unexpected output from the subsequent call to Matplotlib's pcolormesh(). The old GBM Data Tools didn't generate a meshgrid, and just passes the specified coordinate arrays unchanged. Args: heatmap (np.array): A 2D array of values ra_array (np.array): The array of longitudinal gridpoints dec_array (np.array): The array of latitudinal gridpoints **kwargs: Options to pass to :class:`~gdt.plot.plot.SkyHeatmap` """heatmap=SkyHeatmap(
lon_array,
lat_array,
heatmap,
self.ax,
frame=self._frame,
flipped=self._flipped,
**kwargs
)
returnheatmap
This results in a correct rendering of the heatmap, similar to that contained in the catalo:
Your proposed fix would work only for EquatorialPlot, and the problem would still be present for GalacticPlot and SpacecraftPlot. The intent is to allow plotting in other frames (currently Galactic and spacecraft), and after you identified the root cause of the issue, I think the fix in PR #38 addresses that for any frame.
Thanks @AdamGoldstein-USRA, that was just a quick workaround to get the correct plot here. I've tried the modifed lib.py and sky.py and the plot is rendered as expected with the following, so I'll close this issue:
I've noticed this issue when visualizing localizations with
EquatorialPlot
, where the probability heatmap isn't rendered correctly when the centroid RA is close to 0 or 360 degrees. This can be illustrated using a local copy of glg_healpix_all_bn220130968_v01.fit:The following plot is generated:
According to the GBM catalog, the correct skymap should look like:
The issue appears to be caused by the transformation of specified lon/lat arrays to
SkyCoord
inSkyMap.plot_heatmap()
:gdt-core/src/gdt/core/plot/sky.py
Lines 456 to 467 in 91020a3
In the case of localizations, the$[0, 360]$ . However, the call to
lon_array
specified toplot_heatmap()
will contain values inSkyCoord()
will convert the last 360 value to 0. E.g.:This appears to cause the issue when subsequently rendering the heatmap. Note that it's only visible when centroids straddle RA=0/360 degrees, other localisation centroids are rendered correctly. I've also noticed a similar issue with the contour lineswhere although it doesn't impact the visualisation as much as the heatmaps, the lines are broken, and I assume it's also due to the use of
SkyCoord
.I have a local workaround that overrides
plot_heatmap()
to exclude the call toSkyCoord()
, where the specifiedlon_array
andlat_array
are passed directly toSkyHeatmap
, similar to the previous GBM Data Tools implementation:This results in a correct rendering of the heatmap, similar to that contained in the catalo:
I can create a PR with this fix but I wanted to check first whether the
SkyCoord
usage was required for other reasons.The text was updated successfully, but these errors were encountered: