Пример #1
0
def build_universal_config(config_dir):
    """
    Build uni_config.yaml in the config_dir

    :param config_dir: directory where  exp_description.yaml
    :raise:
    """
    config_yaml_filename = os.path.join(config_dir,'exp_description.yaml')
    res=yamlutils.read_yaml(config_yaml_filename)[0]
    #    pprint(res)

    if not 'frames' in res:
        logging.error(str.format('Section FRAMES not found in config file {0}',config_yaml_filename))
        raise AttributeError
    uc = UniversalConfigBuilder()
    #TODO: fix this hack
    uc.add_section({'preprocess_config': res['preprocess_config']})
    uc.add_section({'description': res['description']})
    groups = get_groups(res['frames'])
    start_data_angle=0
    for group_name in natsorted(groups.keys()):
        group = groups[group_name]
        files,start_data_angle = get_files_in_group(group, root=config_dir, start_data_angle=start_data_angle)
        for f in files:
            uc.add_frame(group_name=group_name, frame_type=f['type'], file_name=f['name'],
                image_format=f['image_format'], angle=f['angle'], exposure_time=f['exposure_time'],
                rotation_angle=f['rotation_angle'])
    uc.save2yaml(os.path.join(config_dir,'uni_config.yaml'))
Пример #2
0
def build_universal_config(config_dir):
    """
    Build uni_config.yaml in the config_dir

    :param config_dir: directory where  exp_description.yaml
    :raise:
    """
    config_yaml_filename = os.path.join(config_dir,'exp_description.yaml')
    res=yamlutils.read_yaml(config_yaml_filename)[0]
    #    pprint(res)

    if not 'frames' in res:
        logging.error(str.format('Section FRAMES not found in config file {0}',config_yaml_filename))
        raise AttributeError
    uc = UniversalConfigBuilder()
    #TODO: fix this hack
    uc.add_section({'preprocess_config': res['preprocess_config']})
    uc.add_section({'description': res['description']})
    data_dir=os.path.join(config_dir,'Data')
    files=glob.glob(os.path.join(data_dir,'*.tif'))
    for f_path in sorted(files):
        fname=os.path.split(f_path)[-1]
        f_prefix=fname.split('.')[0]
        if f_prefix=='eb':
            uc.add_frame(group_name='0',frame_type='empty',file_name=f_path,image_format='tiff',angle=0)
        elif f_prefix=='dc':
            uc.add_frame(group_name='0',frame_type='dark',file_name=f_path,image_format='tiff',angle=0)
        else:
            angle=float(f_prefix.replace(',','.'))
            uc.add_frame(group_name='0',frame_type='data',file_name=f_path,image_format='tiff',angle=angle)
    uc.save2yaml(os.path.join(config_dir,'uni_config.yaml'))
Пример #3
0
def build_universal_config(config_dir):
    """
    Build uni_config.yaml in the config_dir

    :param config_dir: directory where  exp_description.yaml
    :raise:
    """
    config_yaml_filename = os.path.join(config_dir,'exp_description.yaml')
    res=yamlutils.read_yaml(config_yaml_filename)[0]
    #    pprint(res)

    if not 'frames' in res:
        logging.error(str.format('Section FRAMES not found in config file {0}',config_yaml_filename))
        raise AttributeError
    uc = UniversalConfigBuilder()
    #TODO: fix this hack
    uc.add_section({'preprocess_config': res['preprocess_config']})
    uc.add_section({'description': res['description']})
    files=get_files(config_dir)
    for f in files:
        uc.add_frame(group_name='0', frame_type=f['type'], file_name=f['name'],
            image_format=f['image_format'], angle=f['angle'], exposure_time=f['exposure_time'],
            rotation_angle=0)
    #add dark type by value
    if 'dark_value' in res['frames']:
        uc.add_frame(group_name='0', frame_type='dark', file_name=res['frames']['dark_value'],
            image_format='number', angle=0, exposure_time=1, rotation_angle=0)
    uc.save2yaml(os.path.join(config_dir,'uni_config.yaml'))