Skip to content

config

Beamline or User Configuration Options

C

Names used in config object

Source code in mmg_toolbox/beamline_metadata/config.py
class C:
    """Names used in config object"""
    conf_file = 'config_file'
    default_directory = 'default_directory'
    normalise_factor = 'normalise_factor'
    replace_names = 'replace_names'
    metadata_string = 'metadata_string'
    metadata_list = 'metadata_list'
    metadata_label = 'metadata_label'
    default_metadata = 'default_metadata'
    beamline = 'beamline'
    scan_description = 'scan_description'
    scan_title = 'scan_title'
    roi = 'roi'

add_roi(config, name, cen_i, cen_j, wid_i=30, wid_j=30, image_name='IMAGE')

Create an image ROI (region of interest) and update the config

Parameters:

Name Type Description Default
config dict

dict of config values

required
name str

string name of the ROI

required
cen_i int | str

central pixel index along first dimension, can be callable string

required
cen_j int | str

central pixel index along second dimension, can be callable string

required
wid_i int

full width along first dimension, in pixels

30
wid_j int

full width along second dimension, in pixels

30
image_name str

string name of the image

'IMAGE'
Source code in mmg_toolbox/beamline_metadata/config.py
def add_roi(config: dict, name: str, cen_i: int | str, cen_j: int | str,
            wid_i: int = 30, wid_j: int = 30, image_name: str = 'IMAGE'):
    """
    Create an image ROI (region of interest) and update the config

    :param config: dict of config values
    :param name: string name of the ROI
    :param cen_i: central pixel index along first dimension, can be callable string
    :param cen_j: central pixel index along second dimension, can be callable string
    :param wid_i: full width along first dimension, in pixels
    :param wid_j: full width along second dimension, in pixels
    :param image_name: string name of the image
    """
    roi = (name, cen_i, cen_j, wid_i, wid_j, image_name)
    current_roi_list = config.get(C.roi, [])
    names = [c_roi[0] for c_roi in current_roi_list]
    if name in names:
        # overwrite
        current_roi_list[names.index(name)] = roi
    else:
        current_roi_list.append(roi)
    config[C.roi] = current_roi_list

beamline_config(beamline=None)

Returns the default beamline config dict

Source code in mmg_toolbox/beamline_metadata/config.py
def beamline_config(beamline: str | None = None) -> dict:
    """Returns the default beamline config dict"""
    config = CONFIG.copy()
    if beamline and beamline in BEAMLINE_CONFIG:
        config.update(BEAMLINE_CONFIG[beamline])
    elif beamline:
        config[C.beamline] = beamline
    return config