original_docstring: 
      The matrix `w_tilde_curvature` is a matrix of dimensions [image_pixels, image_pixels] that encodes the PSF
      convolution of every pair of image pixels on the noise map. This can be used to efficiently compute the
      curvature matrix via the mappings between image and source pixels, in a way that omits having to repeat the PSF
      convolution on every individual source pixel. This provides a significant speed up for inversions of imaging
      datasets.
  
      The limitation of this matrix is that the dimensions of [image_pixels, image_pixels] can exceed many 10s of GB's,
      making it impossible to store in memory and its use in linear algebra calculations slow. This methods creates
      a sparse matrix that can compute the matrix `w_tilde_curvature` efficiently, albeit the linear algebra calculations
      in PyAutoArray bypass this matrix entire to go straight to the curvature matrix.
  
      For imaging data, w_tilde is a sparse matrix, whereby non-zero entries are only contained for pairs of image pixels
      where the two pixels overlap due to the kernel size. For example, if the kernel size is (11, 11) and two image
      pixels are separated by more than 20 pixels, the kernel will never convolve flux between the two pixels. Two image
      pixels will only share a convolution if they are within `kernel_overlap_size = 2 * kernel_shape - 1` pixels within
      one another.
  
      Thus, a `w_tilde_curvature_preload` matrix of dimensions [image_pixels, kernel_overlap_size ** 2] can be computed
      which significantly reduces the memory consumption by removing the sparsity. Because the dimensions of the second
      axes is no longer `image_pixels`, a second matrix `w_tilde_indexes` must also be computed containing the slim image
      pixel indexes of every entry of `w_tilde_preload`.
  
      In order for the preload to store half the number of values, owing to the symmetry of the `w_tilde_curvature`
      matrix, the image pixel pairs corresponding to the same image pixel are divided by two. This ensures that when the
      curvature matrix is computed these pixels are not double-counted.
  
      The values stored in `w_tilde_curvature_preload` represent the convolution of overlapping noise-maps given the
      PSF kernel. It is common for many values to be neglibly small. Removing these values can speed up the inversion
      and reduce memory at the expense of a numerically irrelevent change of solution.
  
      This matrix can then be used to compute the `curvature_matrix` in a memory efficient way that exploits the sparsity
      of the linear algebra.
  
      Parameters
      ----------
      noise_map_native
          The two dimensional masked noise-map of values which `w_tilde_curvature` is computed from.
      signal_to_noise_map_native
          The two dimensional masked signal-to-noise-map from which the threshold discarding low S/N image pixel
          pairs is used.
      kernel_native
          The two dimensional PSF kernel that `w_tilde_curvature` encodes the convolution of.
      native_index_for_slim_index
          An array of shape [total_x_pixels*sub_size] that maps pixels from the slimmed array to the native array.
  
      Returns
      -------
      ndarray
          A matrix that encodes the PSF convolution values between the noise map that enables efficient calculation of
          the curvature matrix, where the dimensions are reduced to save memory.
      
docstring: The matrix `w_tilde_curvature` is a matrix of dimensions [image_pixels, image_pixels] that encodes the PSF
  convolution of every pair of image pixels on the noise map. This can be used to efficiently compute the
  curvature matrix via the mappings between image and source pixels, in a way that omits having to repeat the PSF
  convolution on every individual source pixel. This provides a significant speed up for inversions of imaging
  datasets.
  
  The limitation of this matrix is that the dimensions of [image_pixels, image_pixels] can exceed many 10s of GB's,
  making it impossible to store in memory and its use in linear algebra calculations slow. This methods creates
  a sparse matrix that can compute the matrix `w_tilde_curvature` efficiently, albeit the linear algebra calculations
  in PyAutoArray bypass this matrix entire to go straight to the curvature matrix.
  
  For imaging data, w_tilde is a sparse matrix, whereby non-zero entries are only contained for pairs of image pixels
  where the two pixels overlap due to the kernel size. For example, if the kernel size is (11, 11) and two image
  pixels are separated by more than 20 pixels, the kernel will never convolve flux between the two pixels. Two image
  pixels will only share a convolution if they are within `kernel_overlap_size = 2 * kernel_shape - 1` pixels within
  one another.
  
  Thus, a `w_tilde_curvature_preload` matrix of dimensions [image_pixels, kernel_overlap_size ** 2] can be computed
  which significantly reduces the memory consumption by removing the sparsity.
  
  In order for the preload to store half the number of values, owing to the symmetry of the `w_tilde_curvature`
  matrix, the image pixel pairs corresponding to the same image pixel are divided by two. This ensures that when the
  curvature matrix is computed these pixels are not double-counted.
  
  The values stored in `w_tilde_curvature_preload` represent the convolution of overlapping noise-maps given the
  PSF kernel. It is common for many values to be neglibly small. Removing these values can speed up the inversion
  and reduce memory at the expense of a numerically irrelevent change of solution.
  
  This matrix can then be used to compute the `curvature_matrix` in a memory efficient way that exploits the sparsity
  of the linear algebra.
docstring_tokens: The matrix ` w_tilde_curvature ` is a matrix of dimensions [ image_pixels image_pixels ] that encodes the PSF convolution of every pair of image pixels on the noise map . This can be used to efficiently compute the curvature matrix via the mappings between image and source pixels in a way that omits having to repeat the PSF convolution on every individual source pixel . This provides a significant speed up for inversions of imaging datasets . The limitation of this matrix is that the dimensions of [ image_pixels image_pixels ] can exceed many 10s of GB ' s making it impossible to store in memory and its use in linear algebra calculations slow . This methods creates a sparse matrix that can compute the matrix ` w_tilde_curvature ` efficiently albeit the linear algebra calculations in PyAutoArray bypass this matrix entire to go straight to the curvature matrix . For imaging data w_tilde is a sparse matrix whereby non - zero entries are only contained for pairs of image pixels where the two pixels overlap due to the kernel size . For example if the kernel size is ( 11 11 ) and two image pixels are separated by more than 20 pixels the kernel will never convolve flux between the two pixels . Two image pixels will only share a convolution if they are within ` kernel_overlap_size = 2 * kernel_shape - 1 ` pixels within one another . Thus a ` w_tilde_curvature_preload ` matrix of dimensions [ image_pixels kernel_overlap_size ** 2 ] can be computed which significantly reduces the memory consumption by removing the sparsity . In order for the preload to store half the number of values owing to the symmetry of the ` w_tilde_curvature ` matrix the image pixel pairs corresponding to the same image pixel are divided by two . This ensures that when the curvature matrix is computed these pixels are not double - counted . The values stored in ` w_tilde_curvature_preload ` represent the convolution of overlapping noise - maps given the PSF kernel . It is common for many values to be neglibly small . Removing these values can speed up the inversion and reduce memory at the expense of a numerically irrelevent change of solution . This matrix can then be used to compute the ` curvature_matrix ` in a memory efficient way that exploits the sparsity of the linear algebra .
code: def w_tilde_curvature_preload_imaging_from(
      noise_map_native: np.ndarray, kernel_native: np.ndarray, native_index_for_slim_index
  ) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
      """
      The matrix `w_tilde_curvature` is a matrix of dimensions [image_pixels, image_pixels] that encodes the PSF
      convolution of every pair of image pixels on the noise map. This can be used to efficiently compute the
      curvature matrix via the mappings between image and source pixels, in a way that omits having to repeat the PSF
      convolution on every individual source pixel. This provides a significant speed up for inversions of imaging
      datasets.
  
      The limitation of this matrix is that the dimensions of [image_pixels, image_pixels] can exceed many 10s of GB's,
      making it impossible to store in memory and its use in linear algebra calculations slow. This methods creates
      a sparse matrix that can compute the matrix `w_tilde_curvature` efficiently, albeit the linear algebra calculations
      in PyAutoArray bypass this matrix entire to go straight to the curvature matrix.
  
      For imaging data, w_tilde is a sparse matrix, whereby non-zero entries are only contained for pairs of image pixels
      where the two pixels overlap due to the kernel size. For example, if the kernel size is (11, 11) and two image
      pixels are separated by more than 20 pixels, the kernel will never convolve flux between the two pixels. Two image
      pixels will only share a convolution if they are within `kernel_overlap_size = 2 * kernel_shape - 1` pixels within
      one another.
  
      Thus, a `w_tilde_curvature_preload` matrix of dimensions [image_pixels, kernel_overlap_size ** 2] can be computed
      which significantly reduces the memory consumption by removing the sparsity. Because the dimensions of the second
      axes is no longer `image_pixels`, a second matrix `w_tilde_indexes` must also be computed containing the slim image
      pixel indexes of every entry of `w_tilde_preload`.
  
      In order for the preload to store half the number of values, owing to the symmetry of the `w_tilde_curvature`
      matrix, the image pixel pairs corresponding to the same image pixel are divided by two. This ensures that when the
      curvature matrix is computed these pixels are not double-counted.
  
      The values stored in `w_tilde_curvature_preload` represent the convolution of overlapping noise-maps given the
      PSF kernel. It is common for many values to be neglibly small. Removing these values can speed up the inversion
      and reduce memory at the expense of a numerically irrelevent change of solution.
  
      This matrix can then be used to compute the `curvature_matrix` in a memory efficient way that exploits the sparsity
      of the linear algebra.
  
      Parameters
      ----------
      noise_map_native
          The two dimensional masked noise-map of values which `w_tilde_curvature` is computed from.
      signal_to_noise_map_native
          The two dimensional masked signal-to-noise-map from which the threshold discarding low S/N image pixel
          pairs is used.
      kernel_native
          The two dimensional PSF kernel that `w_tilde_curvature` encodes the convolution of.
      native_index_for_slim_index
          An array of shape [total_x_pixels*sub_size] that maps pixels from the slimmed array to the native array.
  
      Returns
      -------
      ndarray
          A matrix that encodes the PSF convolution values between the noise map that enables efficient calculation of
          the curvature matrix, where the dimensions are reduced to save memory.
      """
  
      image_pixels = len(native_index_for_slim_index)
  
      kernel_overlap_size = (2 * kernel_native.shape[0] - 1) * (
          2 * kernel_native.shape[1] - 1
      )
  
      curvature_preload_tmp = np.zeros((image_pixels, kernel_overlap_size))
      curvature_indexes_tmp = np.zeros((image_pixels, kernel_overlap_size))
      curvature_lengths = np.zeros(image_pixels)
  
      for ip0 in range(image_pixels):
  
          ip0_y, ip0_x = native_index_for_slim_index[ip0]
  
          kernel_index = 0
  
          for ip1 in range(ip0, curvature_preload_tmp.shape[0]):
  
              ip1_y, ip1_x = native_index_for_slim_index[ip1]
  
              noise_value = w_tilde_curvature_value_from(
                  value_native=noise_map_native,
                  kernel_native=kernel_native,
                  ip0_y=ip0_y,
                  ip0_x=ip0_x,
                  ip1_y=ip1_y,
                  ip1_x=ip1_x,
              )
  
              if ip0 == ip1:
                  noise_value /= 2.0
  
              if noise_value > 0.0:
  
                  curvature_preload_tmp[ip0, kernel_index] = noise_value
                  curvature_indexes_tmp[ip0, kernel_index] = ip1
                  kernel_index += 1
  
          curvature_lengths[ip0] = kernel_index
  
      curvature_total_pairs = int(np.sum(curvature_lengths))
  
      curvature_preload = np.zeros((curvature_total_pairs))
      curvature_indexes = np.zeros((curvature_total_pairs))
  
      index = 0
  
      for i in range(image_pixels):
  
          for data_index in range(int(curvature_lengths[i])):
  
              curvature_preload[index] = curvature_preload_tmp[i, data_index]
              curvature_indexes[index] = curvature_indexes_tmp[i, data_index]
  
              index += 1
  
      return (curvature_preload, curvature_indexes, curvature_lengths)
code_tokens: def w_tilde_curvature_preload_imaging_from ( noise_map_native : np . ndarray , kernel_native : np . ndarray , native_index_for_slim_index ) -> Tuple [ np . ndarray , np . ndarray , np . ndarray ] : image_pixels = len ( native_index_for_slim_index ) kernel_overlap_size = ( 2 * kernel_native . shape [ 0 ] - 1 ) * ( 2 * kernel_native . shape [ 1 ] - 1 ) curvature_preload_tmp = np . zeros ( ( image_pixels , kernel_overlap_size ) ) curvature_indexes_tmp = np . zeros ( ( image_pixels , kernel_overlap_size ) ) curvature_lengths = np . zeros ( image_pixels ) for ip0 in range ( image_pixels ) : ip0_y , ip0_x = native_index_for_slim_index [ ip0 ] kernel_index = 0 for ip1 in range ( ip0 , curvature_preload_tmp . shape [ 0 ] ) : ip1_y , ip1_x = native_index_for_slim_index [ ip1 ] noise_value = w_tilde_curvature_value_from ( value_native = noise_map_native , kernel_native = kernel_native , ip0_y = ip0_y , ip0_x = ip0_x , ip1_y = ip1_y , ip1_x = ip1_x , ) if ip0 == ip1 : noise_value /= 2.0 if noise_value > 0.0 : curvature_preload_tmp [ ip0 , kernel_index ] = noise_value curvature_indexes_tmp [ ip0 , kernel_index ] = ip1 kernel_index += 1 curvature_lengths [ ip0 ] = kernel_index curvature_total_pairs = int ( np . sum ( curvature_lengths ) ) curvature_preload = np . zeros ( ( curvature_total_pairs ) ) curvature_indexes = np . zeros ( ( curvature_total_pairs ) ) index = 0 for i in range ( image_pixels ) : for data_index in range ( int ( curvature_lengths [ i ] ) ) : curvature_preload [ index ] = curvature_preload_tmp [ i , data_index ] curvature_indexes [ index ] = curvature_indexes_tmp [ i , data_index ] index += 1 return ( curvature_preload , curvature_indexes , curvature_lengths )
short_docstring: The matrix `w_tilde_curvature` is a matrix of dimensions [image_pixels, image_pixels] that encodes the PSF
  convolution of every pair of image pixels on the noise map.
short_docstring_tokens: The matrix ` w_tilde_curvature ` is a matrix of dimensions [ image_pixels image_pixels ] that encodes the PSF convolution of every pair of image pixels on the noise map .
comment: """
      The matrix `w_tilde_curvature` is a matrix of dimensions [image_pixels, image_pixels] that encodes the PSF
      convolution of every pair of image pixels on the noise map. This can be used to efficiently compute the
      curvature matrix via the mappings between image and source pixels, in a way that omits having to repeat the PSF
      convolution on every individual source pixel. This provides a significant speed up for inversions of imaging
      datasets.
  
      The limitation of this matrix is that the dimensions of [image_pixels, image_pixels] can exceed many 10s of GB's,
      making it impossible to store in memory and its use in linear algebra calculations slow. This methods creates
      a sparse matrix that can compute the matrix `w_tilde_curvature` efficiently, albeit the linear algebra calculations
      in PyAutoArray bypass this matrix entire to go straight to the curvature matrix.
  
      For imaging data, w_tilde is a sparse matrix, whereby non-zero entries are only contained for pairs of image pixels
      where the two pixels overlap due to the kernel size. For example, if the kernel size is (11, 11) and two image
      pixels are separated by more than 20 pixels, the kernel will never convolve flux between the two pixels. Two image
      pixels will only share a convolution if they are within `kernel_overlap_size = 2 * kernel_shape - 1` pixels within
      one another.
  
      Thus, a `w_tilde_curvature_preload` matrix of dimensions [image_pixels, kernel_overlap_size ** 2] can be computed
      which significantly reduces the memory consumption by removing the sparsity. Because the dimensions of the second
      axes is no longer `image_pixels`, a second matrix `w_tilde_indexes` must also be computed containing the slim image
      pixel indexes of every entry of `w_tilde_preload`.
  
      In order for the preload to store half the number of values, owing to the symmetry of the `w_tilde_curvature`
      matrix, the image pixel pairs corresponding to the same image pixel are divided by two. This ensures that when the
      curvature matrix is computed these pixels are not double-counted.
  
      The values stored in `w_tilde_curvature_preload` represent the convolution of overlapping noise-maps given the
      PSF kernel. It is common for many values to be neglibly small. Removing these values can speed up the inversion
      and reduce memory at the expense of a numerically irrelevent change of solution.
  
      This matrix can then be used to compute the `curvature_matrix` in a memory efficient way that exploits the sparsity
      of the linear algebra.
  
      Parameters
      ----------
      noise_map_native
          The two dimensional masked noise-map of values which `w_tilde_curvature` is computed from.
      signal_to_noise_map_native
          The two dimensional masked signal-to-noise-map from which the threshold discarding low S/N image pixel
          pairs is used.
      kernel_native
          The two dimensional PSF kernel that `w_tilde_curvature` encodes the convolution of.
      native_index_for_slim_index
          An array of shape [total_x_pixels*sub_size] that maps pixels from the slimmed array to the native array.
  
      Returns
      -------
      ndarray
          A matrix that encodes the PSF convolution values between the noise map that enables efficient calculation of
          the curvature matrix, where the dimensions are reduced to save memory.
      """