def build_cfg(user_cfg): """ Populate a dictionary containing the s2p parameters from a user config file. This dictionary is contained in the global variable 'cfg' of the config module. Args: user_cfg: user config dictionary """ # check that all the mandatory arguments are defined check_parameters(user_cfg) # fill the config module: updates the content of the config.cfg dictionary # with the content of the user_cfg dictionary cfg.update(user_cfg) # sets keys 'clr', 'cld' and 'roi' of the reference image to None if they # are not already defined. The default values of these optional arguments # can not be defined directly in the config.py module. They would be # overwritten by the previous update, because they are in a nested dict. cfg['images'][0].setdefault('clr') cfg['images'][0].setdefault('cld') cfg['images'][0].setdefault('roi') cfg['images'][0].setdefault('wat') # Make sure that input data have absolute paths for i in range(0, len(cfg['images'])): for d in ['clr', 'cld', 'roi', 'wat', 'img', 'rpc']: if d in cfg['images'][i] and cfg['images'][i][d] is not None: cfg['images'][i][d] = os.path.abspath(cfg['images'][i][d]) # check the zoom factor z = cfg['subsampling_factor'] assert (z > 0 and z == np.floor(z)) # ensure that the coordinates of the ROI are multiples of the zoom factor, # to avoid bad registration of tiles due to rounding problems. x = cfg['roi']['x'] y = cfg['roi']['y'] w = cfg['roi']['w'] h = cfg['roi']['h'] x, y, w, h = common.round_roi_to_nearest_multiple(z, x, y, w, h) cfg['roi'] = {'x': x, 'y': y, 'w': w, 'h': h} # if srtm is disabled set disparity range method to sift if 'disable_srtm' in cfg and cfg['disable_srtm']: cfg['disp_range_method'] = 'sift' # get utm zone if 'utm_zone' not in cfg or cfg['utm_zone'] is None: cfg['utm_zone'] = rpc_utils.utm_zone(cfg['images'][0]['rpc'], x, y, w, h)
def build_cfg(user_cfg): """ Populate a dictionary containing the s2p parameters from a user config file. This dictionary is contained in the global variable 'cfg' of the config module. Args: user_cfg: user config dictionary """ # check that all the mandatory arguments are defined check_parameters(user_cfg) # fill the config module: updates the content of the config.cfg dictionary # with the content of the user_cfg dictionary cfg.update(user_cfg) # sets keys 'clr', 'cld' and 'roi' of the reference image to None if they # are not already defined. The default values of these optional arguments # can not be defined directly in the config.py module. They would be # overwritten by the previous update, because they are in a nested dict. cfg['images'][0].setdefault('clr') cfg['images'][0].setdefault('cld') cfg['images'][0].setdefault('roi') cfg['images'][0].setdefault('wat') # Make sure that input data have absolute paths for i in range(0,len(cfg['images'])): for d in ['clr','cld','roi','wat','img','rpc']: if d in cfg['images'][i] and cfg['images'][i][d] is not None: cfg['images'][i][d] = os.path.abspath(cfg['images'][i][d]) # check the zoom factor z = cfg['subsampling_factor'] assert(z > 0 and z == np.floor(z)) # ensure that the coordinates of the ROI are multiples of the zoom factor, # to avoid bad registration of tiles due to rounding problems. x = cfg['roi']['x'] y = cfg['roi']['y'] w = cfg['roi']['w'] h = cfg['roi']['h'] x, y, w, h = common.round_roi_to_nearest_multiple(z, x,y, w, h) cfg['roi'] = {'x': x, 'y': y, 'w': w, 'h': h} # if srtm is disabled set disparity range method to sift if 'disable_srtm' in cfg and cfg['disable_srtm']: cfg['disp_range_method'] = 'sift' # get utm zone if 'utm_zone' not in cfg or cfg['utm_zone'] is None: cfg['utm_zone'] = rpc_utils.utm_zone(cfg['images'][0]['rpc'], x, y, w, h)
def build_cfg(user_cfg): """ Populate a dictionary containing the s2p parameters from a user config file. This dictionary is contained in the global variable 'cfg' of the config module. Args: user_cfg: user config dictionary """ # check that all the mandatory arguments are defined check_parameters(user_cfg) # fill the config module: updates the content of the config.cfg dictionary # with the content of the user_cfg dictionary cfg.update(user_cfg) # sets keys 'clr', 'cld' and 'roi' of the reference image to None if they # are not already defined. The default values of these optional arguments # can not be defined directly in the config.py module. They would be # overwritten by the previous update, because they are in a nested dict. cfg['images'][0].setdefault('clr') cfg['images'][0].setdefault('cld') cfg['images'][0].setdefault('roi') cfg['images'][0].setdefault('wat') # Make sure that input data have absolute paths for i in range(0, len(cfg['images'])): for d in ['clr', 'cld', 'roi', 'wat', 'img', 'rpc']: if d in cfg['images'][i] and cfg['images'][i][ d] is not None and not os.path.isabs(cfg['images'][i][d]): cfg['images'][i][d] = os.path.abspath(cfg['images'][i][d]) x = cfg['roi']['x'] y = cfg['roi']['y'] w = cfg['roi']['w'] h = cfg['roi']['h'] cfg['roi'] = {'x': x, 'y': y, 'w': w, 'h': h} # get utm zone if 'utm_zone' not in cfg or cfg['utm_zone'] is None: cfg['utm_zone'] = rpc_utils.utm_zone(cfg['images'][0]['rpc'], x, y, w, h)