autofit.DirectoryPaths#
- class DirectoryPaths[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
If the
PYAUTO_TEST_MODEenvironment variable is set, atest_modesegment is inserted directly after the output root:/path/to/output/test_mode/folder_0/folder_1/name
This keeps smoke-test artefacts in a sibling tree so they cannot be picked up by a later real run with the same paths.
- Parameters:
name (
Optional[str]) – The name of the non-linear search, which is used as a folder name after thepath_prefix. For searchs this name is thename.path_prefix (
Optional[PathLike]) – 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 (
Optional[AbstractPaths]) – The parent paths object of this paths object.unique_tag (
Optional[str]) – A unique tag for the search, used to differentiate between searches with the same name.identifier (
str) – A custom identifier for the search, if this is not None it will be used instead of the automatically generated identifierimage_path_suffix (
str) – 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
Mark the search as complete by saving a file
Create a paths object which is the child of some parent paths object.
Paths for an analysis which is a child of another analysis.
Is there a file pickles/{name}.pickle?
Load an HDU from a fits file in the fits directory of the search.
Load a serialised object with the given name.
Load samples from the database
Load samples summary from the database.
Load the internal representation of a non-linear search from a pickle or dill file.
output_model_resultsRemove the object with the given name from the pickles folder.
Remove the internal representation of a non-linear search.
restoreCopy files from the
.zipfile to the samples folder.Save a numpy array as a csv file in the csvs directory of the search.
Save an HDU as a fits file in the fits directory of the search.
save_identifierSave a dictionary as a json file in the jsons directory of the search.
Write out the latent variables of the model to a file.
Serialise an object using dill and save it to the pickles directory of the search.
Save the final-result samples associated with the phase as a pickle
Save samples summary to the database.
Save the internal representation of a non-linear search as dill file.
save_summaryzip_removeCopy files from the sym linked search folder then remove the sym linked folder.
Attributes
identifierimage_pathThe path to the image folder.
Has the search been completed?
Is this a grid search which comprises a number of child searches?
non_linear_nameoutput_pathThe path to the output information for a search.
The search performed before this search.
profile_pathThe path to the profile folder.
Load the samples associated with the search from the output directory.
search_internal_pathThe path to the samples folder.
- save_object(name, obj, prefix='')[source]#
Serialise an object using dill and save it to the pickles directory of the search.
- save_json(name, object_dict, prefix='')[source]#
Save a dictionary as a json file in the jsons directory of the search.
- save_array(name, array)[source]#
Save a numpy array as a csv file in the csvs directory of the search.
- Parameters:
name (
str) – The name of the csv filearray (
ndarray) – The numpy array to save
- save_fits(name, fits, prefix='')[source]#
Save an HDU as a fits file in the fits directory of the search.
- load_fits(name, prefix='')[source]#
Load an HDU from a fits file in the fits directory of the search.
- load_object(name, prefix='')[source]#
Load a serialised object with the given name.
e.g. if the name is ‘model’ then pickles/model.pickle is loaded.
- remove_object(name)[source]#
Remove the object with the given name from the pickles folder.
- Parameters:
name (
str) – The name of a pickle file excluding .pickle
- save_search_internal(obj)[source]#
Save the internal representation of a non-linear search as dill file.
The results in this representation are required to use a search’s in-built tools for visualization, analysing samples and other tasks.
- load_search_internal()[source]#
Load the internal representation of a non-linear search from a pickle or dill file.
The results in this representation are required to use a search’s in-built tools for visualization, analysing samples and other tasks.
- Return type:
The results of the non-linear search in its internal representation.
- remove_search_internal()[source]#
Remove the internal representation of a non-linear search.
This deletes the entire search_internal folder, including a .pickle / .dill file containing the interal results and files with the timer values.
This folder can often have a large filesize, thus deleting it can reduce hard-disk use of the model-fit.
- property samples#
Load the samples associated with the search from the output directory.
- save_latent_samples(latent_samples)[source]#
Write out the latent variables of the model to a file.
- Parameters:
latent_samples – Samples describing the latent variables of the model
- save_samples_summary(samples_summary, name='samples_summary')[source]#
Save samples summary to the database.
- property parent: AbstractPaths#
The search performed before this search. For example, a search that is then compared to searches during a grid search.