code: def _gal2idx(self, gal):
          
  
          # Make sure that l is in domain [-180 deg, 180 deg)
          l = coordinates.Longitude(gal.l, wrap_angle=180.*units.deg)
  
          j = (self._inv_pix_scale * (l.deg - self._l_bounds[0])).astype('i4')
          k = (self._inv_pix_scale * (gal.b.deg - self._b_bounds[0])).astype('i4')
  
          idx = (j < 0) | (j >= self._shape[0]) | (k < 0) | (k >= self._shape[1])
  
          if np.any(idx):
              j[idx] = -1
              k[idx] = -1
  
          return j, k, ~idx
docs: Converts from Galactic coordinates to pixel indices.
  
          Args:
              gal (:obj:`astropy.coordinates.SkyCoord`): Galactic coordinates. Must
                  store an array of coordinates (i.e., not be scalar).
  
          Returns:
              ``j, k, mask`` - Pixel indices of the coordinates, as well as a mask
              of in-bounds coordinates. Outputs have the same shape as the input
              coordinates.