Skip to content

Commit

Permalink
more informatie error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy2211 committed Oct 20, 2023
1 parent ddefad3 commit 2a6608a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 14 deletions.
2 changes: 1 addition & 1 deletion autoarray/config/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ numba:
nopython: true
parallel: false
pixelization:
voronoi_nn_max_interpolation_neighbors: 100
voronoi_nn_max_interpolation_neighbors: 300
structures:
native_binned_only: false # If True, data structures are only stored in their native and binned format. This is used to reduce memory usage in autocti.
test:
Expand Down
10 changes: 10 additions & 0 deletions autoarray/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ class ArrayException(Exception):
pass



class ConfigException(Exception):
"""
Raises exceptions associated with the `structures/array` modules and `Array` classes.
For example if a 2D array's shape and its corresponding 2D mask shape do not match.
"""

pass

class GridException(Exception):
"""
Raises exceptions associated with the `structures/grid` modules and `Grid` classes.
Expand Down
18 changes: 9 additions & 9 deletions autoarray/plot/mat_plot/two_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def plot_array(
# so that if a mask is irregular and zooming in creates white edges, that instead it doesnt have the eddge.
# This could just be a matplotlib settings to change the edge color?

# array = array.resized_from(new_shape=(401, 401))
# array = array.resized_from(new_shape=(401, 401))

if array.mask.is_all_false:
buffer = 0
Expand Down Expand Up @@ -338,14 +338,14 @@ def plot_array(
)
self.colorbar_tickparams.set(cb=cb)

# levels = np.logspace(np.log10(0.3), np.log10(20.0), 10)
# plt.contour(
# # array.mask.derive_grid.unmasked_sub_1,
# array.native[::-1],
# levels=levels,
# colors="black",
# extent=extent,
# )
levels = np.logspace(np.log10(0.3), np.log10(20.0), 10)
plt.contour(
# array.mask.derive_grid.unmasked_sub_1,
array.native[::-1],
levels=levels,
colors="black",
extent=extent,
)

grid_indexes = None

Expand Down
32 changes: 29 additions & 3 deletions autoarray/structures/structure_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,35 @@ def wrapper(
The grid_like object whose coordinates are radially moved from (0.0, 0.0).
"""

grid_radial_minimum = conf.instance["grids"]["radial_minimum"][
"radial_minimum"
][cls.__class__.__name__]
try:
grid_radial_minimum = conf.instance["grids"]["radial_minimum"][
"radial_minimum"
][cls.__class__.__name__]
except KeyError as e:
print(
fr"""
The {cls.__class__.__name__} profile you are using does not have a corresponding
entry in the `config/grid.yaml` config file.
When a profile is evaluated at (0.0, 0.0), they commonly break due to numericalinstabilities (e.g.
division by zero). To prevent this, the code relocates the (y,x) coordinates of the grid to a
minimum radial value, specified in the `config/grids.yaml` config file.
For example, if the value in `grid.yaml` is `radial_minimum: 1e-6`, then any (y,x) coordinates
with a radial distance less than 1e-6 to (0.0, 0.0) are relocated to 1e-6.
For a profile to be used it must have an entry in the `config/grids.yaml` config file. Go to this
file now and add your profile to the `radial_minimum` section. Adopting a value of 1e-6 is a good
default choice.
If you are going to make a pull request to add your profile to the source code, you should also
add an entry to the `config/grids.yaml` config file of the source code itself
(e.g. `PyAutoGalaxy/autogalaxy/config/grids.yaml`).
"""
)

import sys
sys.exit(1)

with np.errstate(all="ignore"): # Division by zero fixed via isnan
grid_radii = cls.radial_grid_from(grid=grid)
Expand Down
2 changes: 1 addition & 1 deletion test_autoarray/config/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ output:
model_results_every_update: 100
remove_files: false
pixelization:
voronoi_nn_max_interpolation_neighbors: 100
voronoi_nn_max_interpolation_neighbors: 300
profiling:
perform: false
repeats: 1
Expand Down

0 comments on commit 2a6608a

Please sign in to comment.