Using Custom Configs¶
All the previous examples have been based on configs which ship with the repository. However, it’s possible to specify custom tasks which are created outside of the ACI repository. An example of a custom task is shown in the Optics example. This page will go into detail about how this is done. See the code for specifics.
Creating Custom Configs¶
Because ACI is based on Hydra, you will need to specify any configurations from YAML (or via the command line). In this example, we specify configs via YAML files. To tell Hydra to look for config files within your directory, there are two steps.
First, as seen in the
Optics example, you have
to override config_path
in :meth:hydra_config.run_hydra
:
if __name__ == "__main__":
config_path = Path(__file__).parent / "configs"
run_hydra(main, config_path=config_path, config_name="optics_sweep")
This snippet basically tells Hydra to look in the configs
directory for a YAML
file named optics_sweep.yaml
. This file will be the base configuration for your task.
The second step is to add an additional path to the Hydra search path which includes
the global ACI configs. This should be done inside optics_sweep.yaml
:
hydra:
searchpath:
- pkg://cambrian/configs
Additionally, although not required, it’s recommend to only include configurations in
this file which overrides those that are set by default by cambrian
. We should then
load the base
configuration as the first default. Any configs that we set in the
YAML will then override the base
configuration.
defaults:
- base
Running the Example¶
Once you have your custom configs set up, you can run the example using the following command:
python tools/optics/optics_sweep.py
You should then find the video output to look like the following:
In this example, we sweep various aperture radii to demonstrate the relative blurring for different aperture size values. The radius is essentially a percentage that the aperture is open; a value of 0.1 corresponds to a 10% open aperture and 1.0 corresponds to a fully open aperture.