@@ -474,7 +474,12 @@ def apply_over_sampling(
474474
475475 return dataset
476476
477- def apply_w_tilde (self , disable_fft_pad : bool = False ):
477+ def apply_w_tilde (
478+ self ,
479+ batch_size : int = 128 ,
480+ disable_fft_pad : bool = False ,
481+ use_jax : bool = False ,
482+ ):
478483 """
479484 The w_tilde formalism of the linear algebra equations precomputes the convolution of every pair of masked
480485 noise-map values given the PSF (see `inversion.inversion_util`).
@@ -487,39 +492,19 @@ def apply_w_tilde(self, disable_fft_pad: bool = False):
487492
488493 Returns
489494 -------
490- WTildeImaging
491- Precomputed values used for the w tilde formalism of linear algebra calculations.
495+ batch_size
496+ The size of batches used to compute the w-tilde curvature matrix via FFT-based convolution,
497+ which can be reduced to produce lower memory usage at the cost of speed
498+ disable_fft_pad
499+ The FFT PSF convolution is optimal for a certain 2D FFT padding or trimming,
500+ which places the fewest zeros around the image. If this is set to `True`, this optimal padding is not
501+ performed and the image is used as-is. This is normally used to avoid repadding data that has already been
502+ padded.
503+ use_jax
504+ Whether to use JAX to compute W-Tilde. This requires JAX to be installed.
492505 """
493506
494- logger .info ("IMAGING - Computing W-Tilde... May take a moment." )
495-
496- try :
497- import numba
498- except ModuleNotFoundError :
499- raise exc .InversionException (
500- "Inversion w-tilde functionality (pixelized reconstructions) is "
501- "disabled if numba is not installed.\n \n "
502- "This is because the run-times without numba are too slow.\n \n "
503- "Please install numba, which is described at the following web page:\n \n "
504- "https://pyautolens.readthedocs.io/en/latest/installation/overview.html"
505- )
506-
507- (
508- curvature_preload ,
509- indexes ,
510- lengths ,
511- ) = inversion_imaging_numba_util .w_tilde_curvature_preload_imaging_from (
512- noise_map_native = np .array (self .noise_map .native .array ).astype ("float64" ),
513- kernel_native = np .array (self .psf .native .array ).astype ("float64" ),
514- native_index_for_slim_index = np .array (
515- self .mask .derive_indexes .native_for_slim
516- ).astype ("int" ),
517- )
518-
519507 w_tilde = WTildeImaging (
520- curvature_preload = curvature_preload ,
521- indexes = indexes .astype ("int" ),
522- lengths = lengths .astype ("int" ),
523508 noise_map = self .noise_map ,
524509 psf = self .psf ,
525510 fft_mask = self .mask ,
0 commit comments