autofit.DatabasePaths#
- class autofit.DatabasePaths(session, name: str | None = None, path_prefix: str | None = None, is_identifier_in_paths=True, parent=None, save_all_samples=False, unique_tag: str | None = None)[source]#
Bases:
AbstractPathsManages the path structure for NonLinearSearch output, for analyses both not using and using the search API. Use via non-linear searches requires manual input of paths, whereas the search API manages this using the search attributes.
The output path within which the Paths objects path structure is contained is set via PyAutoConf, using the command:
from autoconf import conf conf.instance = conf.Config(output_path=”path/to/output”)
If we assume all the input strings above are used with the following example names:
name = “name” path_prefix = “folder_0/folder_1”
The output path of the NonLinearSearch results will be:
/path/to/output/folder_0/folder_1/name
- Parameters:
name – The name of the non-linear search, which is used as a folder name after the
path_prefix. For searchs this name is thename.path_prefix – A prefixed path that appears after the output_path but before the name variable.
is_identifier_in_paths – If True output path and symlink path terminate with an identifier generated from the search and model
parent (autofit.non_linear.paths.database.DatabasePaths) – The parent paths object of this paths object.
unique_tag – A unique tag for the search, used to differentiate between searches with the same name.
identifier – A custom identifier for the search, if this is not None it will be used instead of the automatically generated identifier
image_path_suffix – A suffix which is appended to the image path. This is used to differentiate between different image outputs, for example the image of the starting point of an MLE.
Methods
completedCreate a paths object which is the child of some parent paths object.
for_sub_analysisis_objectLoad an array from the database
Load a fits file from the database
Load a json file from the database
load_latent_samplesload_objectLoad samples from the database
load_samples_infoload_samples_summaryLoad samples summary from the database.
load_search_internaloutput_model_resultsremove_objectremove_search_internalrestoreCopy files from the
.zipfile to the samples folder.save_allSave an array as a json file in the database
Save a fits file in the database
save_identifierSave a dictionary as a json file in the database
Save latent variables.
save_objectsave_parent_identifierSave samples to the database
save_samples_summarySave samples summary to the database.
save_search_internalsave_summarysave_unique_tagRemove files from both the symlinked folder and the output directory
Attributes
fitidentifierimage_pathThe path to the image folder.
is_completeis_grid_searchnon_linear_nameoutput_pathThe path to the output information for a search.
The search performed before this search.
profile_pathThe path to the profile folder.
samplessearch_internal_pathThe path to the samples folder.
- property parent: AbstractPaths#
The search performed before this search. For example, a search that is then compared to searches during a grid search.
- create_child(name: str | None = None, path_prefix: str | None = None, is_identifier_in_paths: bool | None = None, identifier: str | None = None) DatabasePaths[source]#
Create a paths object which is the child of some parent paths object. This is done during a GridSearch so that results can be stored in the correct directory. It also allows database fit objects to be related correctly.
If no instance is set the prior median model is used to ensure that the parent object is queryable.
- Parameters:
identifier
name
path_prefix
is_identifier_in_paths – If False then this path’s identifier will not be added to its output path.
- Return type:
A new paths object
- save_json(name, object_dict: dict | list, prefix: str = '')[source]#
Save a dictionary as a json file in the database
- Parameters:
name – The name of the json
object_dict – The dictionary to save
- load_json(name: str, prefix: str = '') dict | list[source]#
Load a json file from the database
- Parameters:
name – The name of the json
- Return type:
The loaded dictionary
- save_array(name, array: ndarray)[source]#
Save an array as a json file in the database
- Parameters:
name – The name of the array
array – The array to save
- load_array(name: str) ndarray[source]#
Load an array from the database
- Parameters:
name – The name of the array
- Return type:
The loaded array
- save_fits(name: str, fits, prefix: str = '')[source]#
Save a fits file in the database
- Parameters:
name – The name of the fits file
fits – The fits file to save
- load_fits(name: str, prefix: str = '')[source]#
Load a fits file from the database
- Parameters:
name – The name of the fits file
- Return type:
The loaded hdu