Config file - hzovaro/spaxelsleuth GitHub Wiki

Various important settings and variables required by spaxelsleuth are specified in a configuration file in JSON format. Default configurations are stored in config.json in the root spaxelsleuth directory.

There is one top-level entry in config.json for each data source (e.g., sami, s7 and lzifu). Each of these stores paths to the necessary input data products (e.g., data products (input_path) and and data cubes (data_cube_path)) and an output path (output_path) which is where output DataFrames are saved. For surveys such as SAMI where the data format is the same for each object, information such as default data cube sizes (N_x, N_y), spaxel sizes (as_per_px) and centre coordinates (x0_px, y0_px) are also specified in settings.

The default values in this file can be easily overridden by the user by creating a custom configuration file. The file can be stored anywhere, but must be in the same JSON format, where you only need to enter key-value pairs for settings you'd like to update. For example, to change where spaxelsleuth looks for the input data products, you can create a file named /path/to/config/file/.my_custom_config.json with the contents

{
    "cutout_path": "/some/path/cutouts/",
    "sami": {
        "output_path": "/some/path/spaxelsleuth_outputs/",
        "input_path": "/some/path/sami_data_products/",
        "data_cube_path": "/some/path/sami_data_cubes/"
    },
    "lzifu": {
        "output_path": "/some/path/spaxelsleuth_outputs/",
        "input_path": "/some/path/lzifu_data_products/",
        "data_cube_path": "/some/path/lzifu_data_cubes/"
    },
    ...
}

To override the default spaxelsleuth configuration settings, simply use the following lines at the start of your script or notebook:

from spaxelsleuth import load_user_config
load_user_config("/path/to/config/file/.my_custom_config.json")

The settings themselves can be accessed in the form of a dict using

from spaxelsleuth.config import settings
input_path = settings["sami"]["input_path"]  # for example

Known issues

  • Calling load_user_config() generally only works as intended the first time it is called. Multiple calls to load_user_config() during a python session will generally fail to update settings properly, most likely due to issues associated with updating global variables across files. If you need to change the configuration file, it is best to start over in a new python instance.

  • Occasionally, load_user_config() fails to update settings in all modules. I am unsure why this is. If you encounter this error, start over in a new python instance, or try changing the order in which you call certain functions.