Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/jax merge #215

Open
wants to merge 46 commits into
base: feature/jax_wrapper
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
93efbfb
imitate tracer api for point solver
rhayes777 Sep 30, 2024
6b94371
docs
rhayes777 Sep 30, 2024
c58617f
help
Jammy2211 Oct 25, 2024
a6d492f
change to analaysis and confdig
Jammy2211 Nov 1, 2024
e2a8eb4
fix agg extra galaxies
Jammy2211 Nov 5, 2024
bb3cdfa
version
Jammy2211 Nov 6, 2024
e03770c
multipole updated
Jammy2211 Nov 6, 2024
405c8d5
Merge pull request #208 from Jammy2211/feature/multipole_fix
Jammy2211 Nov 6, 2024
8086f33
another fix
Jammy2211 Nov 6, 2024
a5288cf
fix unit test
Jammy2211 Nov 6, 2024
9013366
Merge pull request #209 from Jammy2211/feature/multipole_2
Jammy2211 Nov 6, 2024
813c346
black
Jammy2211 Nov 13, 2024
0ad6c4a
'Updated version in __init__ to 2024.11.13.2
rhayes777 Nov 13, 2024
ae60a5a
DelaunayDrawer
Jammy2211 Nov 14, 2024
5e2c9d9
add_poisson_noise -> add_poisson_noise_to_data
Jammy2211 Nov 18, 2024
ecc1469
docstring
Jammy2211 Nov 18, 2024
f00693d
docstring
Jammy2211 Nov 18, 2024
f77390d
fix unit test
Jammy2211 Nov 18, 2024
9602c16
Merge pull request #211 from Jammy2211/feature/disable_noise
Jammy2211 Nov 18, 2024
1c7382c
Merge branch 'main' into feature/delaunay_visual
Jammy2211 Nov 18, 2024
2f33282
Merge pull request #210 from Jammy2211/feature/delaunay_visual
Jammy2211 Nov 18, 2024
791b4e1
errors -> reconstruction_noise_map
Jammy2211 Nov 20, 2024
f731ab4
Merge pull request #212 from Jammy2211/feature/inversion_noise_map
Jammy2211 Nov 20, 2024
f7ba6da
mask overlay in scribbler
Jammy2211 Nov 20, 2024
85c8ca8
fix agg
Jammy2211 Nov 24, 2024
c9ea985
cleaning up big clean up of over sample decorator
Jammy2211 Dec 14, 2024
dcf1c7b
fix tests by removing OverSampling API
Jammy2211 Dec 15, 2024
6abc996
fix majority of tesrts
Jammy2211 Dec 15, 2024
f8458f1
black
Jammy2211 Dec 15, 2024
7f1f9a9
horrible refactor nearly done
Jammy2211 Dec 15, 2024
ed65517
remove config nonsense
Jammy2211 Dec 15, 2024
137d403
uniform -> lp
Jammy2211 Dec 15, 2024
812eaaa
add over sample to util
Jammy2211 Dec 15, 2024
be0817c
Merge pull request #195 from Jammy2211/feature/operate_deflections_api
rhayes777 Dec 16, 2024
00b4d50
Revert "feature/operate deflections api"
rhayes777 Dec 16, 2024
8055f80
simplify grid over sampled API
Jammy2211 Dec 16, 2024
fe1f255
simplify API
Jammy2211 Dec 16, 2024
11e62b2
Merge branch 'main' into feature/over_sampling_refactor
Jammy2211 Dec 18, 2024
d963ffa
remove Grid2DIRregularUniform
Jammy2211 Dec 18, 2024
90cfb65
remove OverSamplingDataset
Jammy2211 Dec 20, 2024
74867f0
Merge pull request #213 from Jammy2211/revert-195-feature/operate_def…
Jammy2211 Jan 14, 2025
6eeba99
Merge pull request #214 from Jammy2211/feature/over_sampling_refactor
Jammy2211 Jan 15, 2025
a091828
remove annoying unit test
Jammy2211 Jan 15, 2025
342b978
'Updated version in __init__ to 2025.1.18.7
rhayes777 Jan 18, 2025
2b5b461
Merge branch 'main' into feature/jax_merge
Jammy2211 Jan 22, 2025
df9f901
merge more changes from main
Jammy2211 Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions autogalaxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from autoarray.dataset.imaging.dataset import Imaging # noqa
from autoarray.dataset.interferometer.dataset import Interferometer # noqa
from autoarray.dataset.dataset_model import DatasetModel
from autoarray.dataset.over_sampling import OverSamplingDataset
from autoarray.inversion.inversion.mapper_valued import MapperValued
from autoarray.inversion.pixelization import mesh # noqa
from autoarray.inversion import regularization as reg # noqa
Expand Down Expand Up @@ -35,11 +34,7 @@
from autoarray.structures.grids.uniform_1d import Grid1D # noqa
from autoarray.structures.grids.uniform_2d import Grid2D # noqa
from autoarray.structures.grids.irregular_2d import Grid2DIrregular # noqa
from autoarray.structures.grids.irregular_2d import Grid2DIrregularUniform # noqa
from autoarray.operators.over_sampling.uniform import OverSamplingUniform # noqa
from autoarray.operators.over_sampling.uniform import OverSamplerUniform # noqa
from autoarray.operators.over_sampling.iterate import OverSamplingIterate
from autoarray.operators.over_sampling.iterate import OverSamplerIterate
from autoarray.operators.over_sampling.over_sampler import OverSampler # noqa
from autoarray.structures.mesh.rectangular_2d import Mesh2DRectangular # noqa
from autoarray.structures.mesh.voronoi_2d import Mesh2DVoronoi # noqa
from autoarray.structures.mesh.delaunay_2d import Mesh2DDelaunay # noqa
Expand Down Expand Up @@ -113,4 +108,4 @@

conf.instance.register(__file__)

__version__ = "2024.9.21.2"
__version__ = "2025.1.18.7"
23 changes: 12 additions & 11 deletions autogalaxy/aggregator/dataset_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ def _dataset_model_from(
except AttributeError:
dataset_model = None

if len(fit.children) > 0:
logger.info(
"""
Using database for a fit with multiple summed Analysis objects.

DatasetModel objects do not fully support this yet (e.g. variables across Analysis objects may not be correct)
so proceed with caution!
"""
)

return [dataset_model] * len(fit.children)
if fit.children is not None:
if len(fit.children) > 0:
Comment on lines +50 to +51
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None and empty array are both falsey

if fit.children:
    ...

logger.info(
"""
Using database for a fit with multiple summed Analysis objects.

DatasetModel objects do not fully support this yet (e.g. variables across Analysis objects may not be correct)
so proceed with caution!
"""
)

return [dataset_model] * len(fit.children)

return [dataset_model]
6 changes: 4 additions & 2 deletions autogalaxy/aggregator/galaxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ def _galaxies_from(fit: af.Fit, instance: af.ModelInstance) -> List[Galaxy]:
galaxies = instance.galaxies

if hasattr(instance, "extra_galaxies"):
galaxies = galaxies + fit.instance.extra_galaxies
if fit.instance.extra_galaxies is not None:
galaxies = galaxies + fit.instance.extra_galaxies

else:
galaxies = fit.instance.galaxies

if hasattr(fit.instance, "extra_galaxies"):
galaxies = galaxies + fit.instance.extra_galaxies
if fit.instance.extra_galaxies is not None:
galaxies = galaxies + fit.instance.extra_galaxies

if fit.children is not None:
if len(fit.children) > 0:
Expand Down
26 changes: 23 additions & 3 deletions autogalaxy/aggregator/imaging/imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,40 @@ def _imaging_from(
except AttributeError:
psf = None

over_sampling = fit.value(name="dataset.over_sampling")

dataset = aa.Imaging(
data=data,
noise_map=noise_map,
psf=psf,
over_sampling=over_sampling,
check_noise_map=False,
)

mask = aa.Mask2D.from_primary_hdu(primary_hdu=fit.value(name="dataset.mask"))

dataset = dataset.apply_mask(mask=mask)

try:
over_sample_size_lp = aa.Array2D.from_primary_hdu(
primary_hdu=fit.value(name="dataset.over_sample_size_lp")
).native
over_sample_size_lp = over_sample_size_lp.apply_mask(mask=mask)
except AttributeError:
over_sample_size_lp = 1

try:
over_sample_size_pixelization = aa.Array2D.from_primary_hdu(
primary_hdu=fit.value(name="dataset.over_sample_size_pixelization")
).native
over_sample_size_pixelization = over_sample_size_pixelization.apply_mask(
mask=mask
)
except AttributeError:
over_sample_size_pixelization = 1

dataset = dataset.apply_over_sampling(
over_sample_size_lp=over_sample_size_lp,
over_sample_size_pixelization=over_sample_size_pixelization,
)

dataset_list.append(dataset)

return dataset_list
Expand Down
2 changes: 0 additions & 2 deletions autogalaxy/aggregator/interferometer/interferometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ def _interferometer_from(
)
)

over_sampling = fit.value(name="dataset.over_sampling")
transformer_class = fit.value(name="dataset.transformer_class")

dataset = aa.Interferometer(
data=data,
noise_map=noise_map,
uv_wavelengths=uv_wavelengths,
real_space_mask=real_space_mask,
over_sampling=over_sampling,
transformer_class=transformer_class,
)

Expand Down
18 changes: 9 additions & 9 deletions autogalaxy/analysis/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def galaxies_via_instance_from(
if getattr(instance, "extra_galaxies", None) is not None:
return Galaxies(
galaxies=instance.galaxies + instance.extra_galaxies,
run_time_dict=run_time_dict
run_time_dict=run_time_dict,
)

return Galaxies(galaxies=instance.galaxies, run_time_dict=run_time_dict)
Expand Down Expand Up @@ -139,7 +139,7 @@ def profile_log_likelihood_function(
An `info_dict` is also created which stores information on aspects of the model and dataset that dictate
run times, so the profiled times can be interpreted with this context.

The results of this profiling are then output to hard-disk in the `prefiling` folder of the model-fit results,
The results of this profiling are then output to hard-disk in the `profiling` folder of the model-fit results,
which they can be inspected to ensure run-times are as expected.

Parameters
Expand Down Expand Up @@ -191,19 +191,19 @@ def profile_log_likelihood_function(
fit.figure_of_merit

try:
info_dict["image_pixels"] = self.dataset.grids.uniform.shape_slim
info_dict["sub_total_light_profiles"] = (
self.dataset.grids.uniform.over_sampler.sub_total
)
info_dict["image_pixels"] = self.dataset.grids.lp.shape_slim
info_dict[
"sub_total_light_profiles"
] = self.dataset.grids.lp.over_sampler.sub_total
except AttributeError:
pass

if fit.model_obj.has(cls=aa.Pixelization):
info_dict["use_w_tilde"] = fit.inversion.settings.use_w_tilde
try:
info_dict["sub_total_pixelization"] = (
self.dataset.grids.pixelization.over_sampler.sub_total
)
info_dict[
"sub_total_pixelization"
] = self.dataset.grids.pixelization.over_sampler.sub_total
except AttributeError:
pass
info_dict["use_positive_only_solver"] = (
Expand Down
11 changes: 8 additions & 3 deletions autogalaxy/analysis/analysis/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ def save_attributes(self, paths: af.DirectoryPaths):
hdu=self.dataset.noise_map.hdu_for_output,
prefix="dataset",
)
paths.save_json(
name="over_sampling",
object_dict=to_dict(self.dataset.over_sampling),
paths.save_fits(
name="over_sample_size_lp",
hdu=self.dataset.grids.lp.over_sample_size.native.hdu_for_output,
prefix="dataset",
)
paths.save_fits(
name="over_sample_size_pixelization",
hdu=self.dataset.grids.pixelization.over_sample_size.native.hdu_for_output,
prefix="dataset",
)
paths.save_json(
Expand Down
3 changes: 3 additions & 0 deletions autogalaxy/analysis/chaining_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ def extra_galaxies_from(

# extra_galaxies = result.instance.extra_galaxies.as_model((LightProfile, mp.MassProfile,), fixed="centre", prior_pass=True)

if not hasattr(result.instance, "extra_galaxies"):
return None

if result.instance.extra_galaxies is None:
return None

Expand Down
6 changes: 3 additions & 3 deletions autogalaxy/analysis/plotter_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def should_plot(name):
reconstructed_image=should_plot("reconstructed_image"),
reconstruction=should_plot("reconstruction"),
mesh_pixels_per_image_pixels=should_plot("mesh_pixels_per_image_pixels"),
errors=should_plot("errors"),
reconstruction_noise_map=should_plot("reconstruction_noise_map"),
regularization_weights=should_plot("regularization_weights"),
)

Expand Down Expand Up @@ -347,7 +347,7 @@ def should_plot(name):
pixelization_index=0,
reconstructed_image=True,
reconstruction=True,
errors=True,
reconstruction_noise_map=True,
regularization_weights=True,
)

Expand All @@ -366,7 +366,7 @@ def should_plot(name):
pixelization_index=0,
reconstructed_image=True,
reconstruction=True,
errors=True,
reconstruction_noise_map=True,
regularization_weights=True,
interpolate_to_uniform=True,
)
Expand Down
1 change: 1 addition & 0 deletions autogalaxy/config/general.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fits:
flip_for_ds9: true
grid:
remove_projected_centre: false # Whether 1D plots of a light profile should remove the central point to avoid the large numerical central value skewing the y axis.
max_evaluation_grid_size: 1000 # An evaluation grid whose shape is adaptive chosen is used to compute quantities like critical curves, this integer is the max size of the grid ensuring faster run times.
adapt:
adapt_minimum_percent: 0.01
Expand Down
Loading
Loading