Skip to content

Commit

Permalink
remove config nonsense
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy2211 committed Dec 15, 2024
1 parent 3e0f442 commit 215baab
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 92 deletions.
56 changes: 0 additions & 56 deletions autoarray/operators/over_sampling/over_sample_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,62 +553,6 @@ def over_sample_size_via_radial_bins_from(
return Array2D(values=sub_size, mask=grid.mask)


def over_sample_size_via_adaptive_scheme_from(
grid: Grid2D, name: str, centre: Tuple[float, float]
) -> Array2D:
"""
Returns a 2D grid whose over sampling is adaptive, placing a high number of sub-pixels in the regions of the
grid closest to the centre input (y,x) coordinates.
This adaptive over sampling is primarily used in PyAutoGalaxy, to evaluate the image of a light profile
(e.g. a Sersic function) with high levels of sub gridding in its centre and lower levels of sub gridding
further away from the centre (saving computational time).
The `autogalaxy_workspace` and `autolens_workspace` packages have guides called `over_sampling.ipynb`
which describe over sampling in more detail.
The inputs `name` and `centre` typically correspond to the name of the light profile (e.g. `Sersic`) and
its `centre`, so that the adaptive over sampling parameters for that light profile are loaded from config
files and used to setup the grid.
Parameters
----------
name
The name of the light profile, which is used to load the adaptive over sampling parameters from config files.
centre
The (y,x) centre of the adaptive over sampled grid, around which the highest sub-pixel resolution is placed.
Returns
-------
A new Grid2D with adaptive over sampling.
"""

if not grid.is_uniform:
raise exc.GridException(
"You cannot make an adaptive over-sampled grid from a non-uniform grid."
)

sub_size_list = conf.instance["grids"]["over_sampling"]["sub_size_list"][name]
radial_factor_list = conf.instance["grids"]["over_sampling"]["radial_factor_list"][
name
]

centre = grid.geometry.scaled_coordinate_2d_to_scaled_at_pixel_centre_from(
scaled_coordinate_2d=centre
)

return over_sample_size_via_radial_bins_from(
grid=grid,
sub_size_list=sub_size_list,
radial_list=[
min(grid.pixel_scales) * radial_factor
for radial_factor in radial_factor_list
],
centre_list=[centre],
)


def over_sample_size_via_adapt_from(
data: Array2D,
noise_map: Array2D,
Expand Down
37 changes: 1 addition & 36 deletions test_autoarray/config/grids.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,4 @@

radial_minimum:
radial_minimum:
MockGridRadialMinimum: 2.5


# Over sampling is an important numerical technique, whereby light profiles images are evaluated on a higher resolution
# grid than the image data to ensure the calculation is accurate.

# By default, a user does not specify the over sampling factor, and a default over sampling scheme is used for each
# profile. This scheme first goes to the centre of the profile, and computes circles with certain radial values
# (e.g. radii). It then assigns an over sampling `sub_size` to each circle, where the central circles have the highest
# over sampling factor and the outer circles have the lowest.

# The size of the circles that are appropriate for determining the over sampling factor are dependent on the resolution
# of the grid. For a high resolution grid (e.g. low pixel scale), a smaller circle central circle is necessary to
# over sample the profile accurately. The config file below therefore specifies the "radial factors" used for
# automatically determining the over sampling factors for each profile, which is the factor the pixel scale is multiplied
# by to determine the circle size.

# The config entry below defines the default over sampling factor for each profile, where:

# radial_factor_list: The factors that are multiplied by the pixel scale to determine the circle size that is used.
# sub_size_list: The over sampling factor that is used for each circle size.

# For the default entries below, oversampling of degree 32 x 32 is used within a circle of radius 3.01 x pixel scale,
# 4 x 4 within a circle of radius 10.01 x pixel scale and 2 x 2 for all pixels outside of this radius.

# For unit tests, we disable this feature by setting the over sampling factors to 1.0 and the sub sizes to 1.

over_sampling:
radial_factor_list:
MockGrid1DLikeObj: [1.0]
MockGrid2DLikeObj: [1.0]
MockGridRadialMinimum: [1.0]
sub_size_list:
MockGrid1DLikeObj: [1, 1]
MockGrid2DLikeObj: [1, 1]
MockGridRadialMinimum: [1, 1]
MockGridRadialMinimum: 2.5

0 comments on commit 215baab

Please sign in to comment.