def make_parameter_dict(pdict, fixed_par=False, rescale=True, update_bounds=False): """ Update a parameter dictionary. This function will automatically set the parameter scale and bounds if they are not defined. Bounds are also adjusted to ensure that they encompass the parameter value. """ o = copy.deepcopy(pdict) o.setdefault('scale', 1.0) if rescale: value, scale = utils.scale_parameter(o['value'] * o['scale']) o['value'] = np.abs(value) * np.sign(o['value']) o['scale'] = np.abs(scale) * np.sign(o['scale']) if 'error' in o: o['error'] /= np.abs(scale) if update_bounds: o['min'] = o['value'] * 1E-3 o['max'] = o['value'] * 1E3 if fixed_par: o['min'] = o['value'] o['max'] = o['value'] if float(o['min']) > float(o['value']): o['min'] = o['value'] if float(o['max']) < float(o['value']): o['max'] = o['value'] return o
def make_parameter_dict(pdict, fixed_par=False, rescale=True): """ Update a parameter dictionary. This function will automatically set the parameter scale and bounds if they are not defined. Bounds are also adjusted to ensure that they encompass the parameter value. """ o = copy.deepcopy(pdict) if 'scale' not in o or o['scale'] is None: if rescale: value, scale = utils.scale_parameter(o['value']) else: value, scale = o['value'], 1.0 o['value'] = value o['scale'] = scale if 'error' in o: o['error'] /= np.abs(scale) if 'min' not in o: o['min'] = o['value'] * 1E-3 if 'max' not in o: o['max'] = o['value'] * 1E3 if fixed_par: o['min'] = o['value'] o['max'] = o['value'] if float(o['min']) > float(o['value']): o['min'] = o['value'] if float(o['max']) < float(o['value']): o['max'] = o['value'] # for k, v in o.items(): # o[k] = str(v) return o