Skip to content

Commit

Permalink
remove PLane.output_to_json
Browse files Browse the repository at this point in the history
  • Loading branch information
Jammy2211 committed Oct 16, 2023
1 parent 7995e61 commit 0df87fd
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 31 deletions.
2 changes: 1 addition & 1 deletion autogalaxy/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def save_results(self, paths: af.DirectoryPaths, result: ResultDataset):
try:
output_to_json(
obj=result.max_log_likelihood_plane,
file_path=paths._files_path / "plane.json"
file_path=paths._files_path / "plane.json",
)
except AttributeError:
pass
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/analysis/mock/mock_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(
adapt_galaxy_image_path_dict: Dict[ag.Galaxy, ag.Array2D] = None,
adapt_model_image: ag.Array2D = None,
max_log_likelihood_plane: ag.Plane = None,
max_log_likelihood_tracer = None,
max_log_likelihood_tracer=None,
):
super().__init__(
samples=samples,
Expand Down
4 changes: 0 additions & 4 deletions autogalaxy/plane/plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ def __init__(
self.run_time_dict = run_time_dict
self.run_time_dict = run_time_dict

def output_to_json(self, file_path: Union[Path, str]):
with open(file_path, "w+") as f:
json.dump(self.dict(), f, indent=4)

@property
def galaxy_redshifts(self) -> List[float]:
return [galaxy.redshift for galaxy in self.galaxies]
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/profiles/mass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
NFWMCRScatterLudlowSph,
NFWMCRLudlow,
gNFWMCRLudlow,
NFWVirialMassConcSph
NFWVirialMassConcSph,
)
from .stellar import (
Gaussian,
Expand Down
2 changes: 1 addition & 1 deletion autogalaxy/profiles/mass/dark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from .nfw_truncated import NFWTruncatedSph
from .nfw_truncated_mcr import NFWTruncatedMCRLudlowSph, NFWTruncatedMCRDuffySph
from .nfw_truncated_mcr_scatter import NFWTruncatedMCRScatterLudlowSph
from .nfw_virial_mass_conc import NFWVirialMassConcSph
from .nfw_virial_mass_conc import NFWVirialMassConcSph
12 changes: 6 additions & 6 deletions autogalaxy/profiles/mass/dark/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ def concentration(
redshift_of_cosmic_average_density="profile",
cosmology: LensingCosmology = Planck15(),
):
'''
"""
Computes the NFW halo concentration, `c_{200m}`
'''
"""
delta_concentration = self.delta_concentration(
redshift_object=redshift_profile,
redshift_source=redshift_source,
Expand Down Expand Up @@ -299,9 +299,9 @@ def radius_at_200(
redshift_of_cosmic_average_density="profile",
cosmology: LensingCosmology = Planck15(),
):
'''
"""
Returns `r_{200m}` for this halo in **arcseconds**
'''
"""
concentration = self.concentration(
redshift_profile=redshift_object,
redshift_source=redshift_source,
Expand All @@ -318,9 +318,9 @@ def mass_at_200_solar_masses(
redshift_of_cosmic_average_density="profile",
cosmology: LensingCosmology = Planck15(),
):
'''
"""
Returns `M_{200m}` of this NFW halo, in solar masses, at the given cosmology.
'''
"""
if redshift_of_cosmic_average_density == "profile":
redshift_calc = redshift_object
elif redshift_of_cosmic_average_density == "local":
Expand Down
8 changes: 4 additions & 4 deletions autogalaxy/profiles/mass/dark/mcr_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@


def kappa_s_and_scale_radius_for_duffy(mass_at_200, redshift_object, redshift_source):
'''
"""
Computes the AutoGalaxy NFW parameters (kappa_s, scale_radius) for an NFW halo of the given
mass, enforcing the Duffy '08 mass-concentration relation.
Interprets mass as *`M_{200c}`*, not `M_{200m}`.
'''
"""
cosmology = Planck15()

cosmic_average_density = (
Expand Down Expand Up @@ -58,12 +58,12 @@ def kappa_s_and_scale_radius_for_duffy(mass_at_200, redshift_object, redshift_so
def kappa_s_and_scale_radius_for_ludlow(
mass_at_200, scatter_sigma, redshift_object, redshift_source
):
'''
"""
Computes the AutoGalaxy NFW parameters (kappa_s, scale_radius) for an NFW halo of the given
mass, enforcing the Ludlow '16 mass-concentration relation.
Interprets mass as *`M_{200c}`*, not `M_{200m}`.
'''
"""
from colossus.cosmology import cosmology as col_cosmology
from colossus.halo.concentration import concentration as col_concentration

Expand Down
12 changes: 6 additions & 6 deletions autogalaxy/profiles/mass/dark/nfw_virial_mass_conc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
from autogalaxy.cosmology.wrap import Planck15


def kappa_s_and_scale_radius(virial_mass, concentration, virial_overdens, redshift_object, redshift_source):
def kappa_s_and_scale_radius(
virial_mass, concentration, virial_overdens, redshift_object, redshift_source
):
cosmology = Planck15()

cosmic_average_density = (
Expand Down Expand Up @@ -45,7 +47,7 @@ def kappa_s_and_scale_radius(virial_mass, concentration, virial_overdens, redshi
scale_radius = scale_radius_kpc / kpc_per_arcsec # scale radius in arcsec

return kappa_s, scale_radius, virial_radius


class NFWVirialMassConcSph(NFWSph):
def __init__(
Expand All @@ -57,7 +59,6 @@ def __init__(
redshift_object: float = 0.5,
redshift_source: float = 1.0,
):

"""
Spherical NFW profile initialized with the mass and concentration of the halo.
Expand All @@ -75,7 +76,7 @@ def __init__(
self.virial_mass = virial_mass
self.concentration = concentration
self.virial_overdens = virial_overdens

(
kappa_s,
scale_radius,
Expand All @@ -87,6 +88,5 @@ def __init__(
redshift_object=redshift_object,
redshift_source=redshift_source,
)

super().__init__(centre=centre, kappa_s=kappa_s, scale_radius=scale_radius)

4 changes: 2 additions & 2 deletions docs/advanced/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ to the non-linear search:
session = af.db.open_database("database.sqlite")
emcee = af.Emcee(
session=session, # This instructs the search to write to the .sqlite database.
session=session, # This can instruct the search to write to the .sqlite database.
)
When a model-fit is performed, a unique identifier is generated based on the model and non-linear search. However,
Expand All @@ -40,7 +40,7 @@ alongside the model and search to create the unique identifier:
emcee = af.Emcee(
path_prefix=path.join("features", "database"),
unique_tag=dataset_name, # This makes the unique identifier use the dataset name
session=session, # This instructs the search to write to the .sqlite database.
session=session, # This can instruct the search to write to the .sqlite database.
)
Lets suppose that we have performed 100 model-fits to 100 strong galaxies, and when we ran **PyAutoGalaxy** we told it
Expand Down
1 change: 0 additions & 1 deletion test_autogalaxy/aggregator/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def clean(database_file):
value=True,
)
def aggregator_from(database_file, analysis, model, samples):

result_path = path.join(conf.instance.output_path, database_file)

clean(database_file=database_file)
Expand Down
7 changes: 3 additions & 4 deletions test_autogalaxy/analysis/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def test__modify_before_fit__kmeans_pixelization_upper_limit_ajusted_based_on_ma
9, 1.0e-4
)

def test__save_results__plane_output_to_json(analysis_imaging_7x7):

def test__save_results__plane_output_to_json(analysis_imaging_7x7):
galaxy = ag.Galaxy(redshift=0.5)

model = af.Collection(galaxies=af.Collection(galaxy=galaxy))
Expand All @@ -102,12 +102,11 @@ def test__save_results__plane_output_to_json(analysis_imaging_7x7):
paths = af.DirectoryPaths()

analysis_imaging_7x7.save_results(
paths=paths,
result=ag.m.MockResult(max_log_likelihood_plane=plane, model=model)
paths=paths, result=ag.m.MockResult(max_log_likelihood_plane=plane, model=model)
)

plane = from_json(file_path=paths._files_path / "plane.json")

assert plane.galaxies[0].redshift == 0.5

os.remove(paths._files_path / "plane.json")
os.remove(paths._files_path / "plane.json")

0 comments on commit 0df87fd

Please sign in to comment.