def _generate_changeparameters_couple_file(): print "Starting loading Full Response optics" full_response = pickle.load(open(os.path.join(_InputData.path_to_optics_files_dir,"FullResponse_couple"), 'rb')) print "Loading ended" disp_y = _get_dispersion_y_if_set_and_available() path_all_lists_json_file = os.path.join(_InputData.accel_path, "AllLists_couple.json") knobsdict = json.load(file(path_all_lists_json_file, 'r')) print "Loaded json file: " + path_all_lists_json_file varslist = [] for var in _InputData.variables_list: varslist = varslist + knobsdict[var] couple_twiss = _get_twiss_instance_of_getcouple() _InputData.model_cut_c = _calculate_automatic_model_cut_if_desired(couple_twiss) mad_twiss = full_response['0'] mad_twiss.Cmatrix() mode = 'C' couple_list = GenMatrix_coupleDy.make_list(couple_twiss, mad_twiss, _InputData.model_cut_c, _InputData.error_cut_c, mode) mode = 'D' disp_y_list = GenMatrix_coupleDy.make_list(disp_y, mad_twiss, _InputData.model_cut_d, _InputData.error_cut_d, mode) if 0 == len(couple_list) and 0 == len(disp_y_list): print >> sys.stderr, "Couple and dispersion lists are empty. Are model and/or error cuts too strict?" sys.exit(1) print "entering couple input", len(couple_list) couple_inp = GenMatrix_coupleDy.CoupleInput(varslist, couple_list, disp_y_list, _InputData.weights_list) print "computing the sensitivity matrix" sensitivity_matrix = couple_inp.computeSensitivityMatrix(full_response) # @UnusedVariable sensivity_matrix will be saved in couple_inp(vimaier) print "computing correct coupling " [deltas, varslist ] = GenMatrix_coupleDy.correctcouple(couple_twiss, disp_y, couple_inp, cut=_InputData.singular_value_cut, app=0, path=_InputData.output_path) print "deltas:", deltas
def _generate_changeparameters_couple_file(): print "Starting loading Full Response optics" full_response = pickle.load( open( os.path.join(_InputData.path_to_optics_files_dir, "FullResponse_couple"), 'rb')) print "Loading ended" disp_y = _get_dispersion_y_if_set_and_available() path_all_lists_json_file = os.path.join(_InputData.accel_path, "AllLists_couple.json") knobsdict = json.load(file(path_all_lists_json_file, 'r')) print "Loaded json file: " + path_all_lists_json_file varslist = [] for var in _InputData.variables_list: varslist = varslist + knobsdict[var] couple_twiss = _get_twiss_instance_of_getcouple() _InputData.model_cut_c = _calculate_automatic_model_cut_if_desired( couple_twiss) mad_twiss = full_response['0'] mad_twiss.Cmatrix() mode = 'C' couple_list = GenMatrix_coupleDy.make_list(couple_twiss, mad_twiss, _InputData.model_cut_c, _InputData.error_cut_c, mode) mode = 'D' disp_y_list = GenMatrix_coupleDy.make_list(disp_y, mad_twiss, _InputData.model_cut_d, _InputData.error_cut_d, mode) if 0 == len(couple_list) and 0 == len(disp_y_list): print >> sys.stderr, "Couple and dispersion lists are empty. Are model and/or error cuts too strict?" sys.exit(1) print "entering couple input", len(couple_list) couple_inp = GenMatrix_coupleDy.CoupleInput(varslist, couple_list, disp_y_list, _InputData.weights_list) print "computing the sensitivity matrix" sensitivity_matrix = couple_inp.computeSensitivityMatrix( full_response ) # @UnusedVariable sensivity_matrix will be saved in couple_inp(vimaier) print "computing correct coupling " [deltas, varslist ] = GenMatrix_coupleDy.correctcouple(couple_twiss, disp_y, couple_inp, cut=_InputData.singular_value_cut, app=0, path=_InputData.output_path) print "deltas:", deltas
dispy = [] if weights[4] == "1": dispy = metaclass.twiss(options.path + '/getDy.out') path_all_lists_json_file = os.path.join(accelpath, "AllLists_couple.json") knobsdict=json.load(file(path_all_lists_json_file, 'r')) print "Loaded json file: " + path_all_lists_json_file listvar = options.var.split(",") varslist = [] for var in listvar: varslist = varslist + knobsdict[var] MADTwiss = FullResponse['0'] MADTwiss.Cmatrix() mode = 'C' couplelist = GenMatrix_coupleDy.make_list(couple, MADTwiss, modelcutC, errorcutC, mode) mode = 'D' dispylist = GenMatrix_coupleDy.make_list(dispy, MADTwiss, modelcutD, errorcutD, mode) wei = [int(weights[0]), int(weights[1]), int(weights[2]), int(weights[3]), int(weights[4])] print "the weight option is " + str(wei) optDy = options.Dy print "entering couple input", len(couplelist) couple_inp = GenMatrix_coupleDy.CoupleInput(varslist, couplelist, dispylist, wei) print "computing the sensitivity matrix" sensitivity_matrix = couple_inp.computeSensitivityMatrix(FullResponse) print "computing correct coupling " [deltas, varslist ] = GenMatrix_coupleDy.correctcouple(couple, dispy, couple_inp, cut=cut, app=0, path=options.path)
dispy = [] if weights[4] == "1": dispy = metaclass.twiss(options.path + '/getDy.out') path_all_lists_json_file = os.path.join(accelpath, "AllLists_couple.json") knobsdict = json.load(file(path_all_lists_json_file, 'r')) print "Loaded json file: " + path_all_lists_json_file listvar = options.var.split(",") varslist = [] for var in listvar: varslist = varslist + knobsdict[var] MADTwiss = FullResponse['0'] MADTwiss.Cmatrix() mode = 'C' couplelist = GenMatrix_coupleDy.make_list(couple, MADTwiss, modelcutC, errorcutC, mode) mode = 'D' dispylist = GenMatrix_coupleDy.make_list(dispy, MADTwiss, modelcutD, errorcutD, mode) wei = [ int(weights[0]), int(weights[1]), int(weights[2]), int(weights[3]), int(weights[4]) ] print "the weight option is " + str(wei) optDy = options.Dy