Lv3_Z2_stat.py
def edit_par(par_file,var_dict):
    """
    Editing the input par file with updated parameter values in the form of a
    dictionary. Each key will have 1 value though.

    par_file - orbital parameter file for input into PINT's photonphase
    var_dict - dictionary, where each key corresponds to a variable to change in the par file, and has a 1-entry list!
    """
    dict_keys = var_dict.keys() #the variables that we want to iterate over
    new_par = par_file[:-4] + '_iter.par'

    line_no_dict = {}
    contents = open(par_file,'r').read().split('\n')
    for i in range(len(dict_keys)):
        line_no = [j for j in range(len(contents)) if dict_keys[i] in contents[j]][0] #finding indices for the variables we want to iterate over
        line_no_dict[dict_keys[i]] = [line_no] #dictionary key corresponds to a 1-entry list

    output_par = open(new_par,'w')
    for i in range(len(contents)):
        if contents[i].split(' ')[0] in dict_keys: #so if we reach a line corresponding to a variable we're iterating over
            output_par.write(contents[i].split(' ')[0] + ' '*10 + str(var_dict[contents[i].split(' ')[0]][0]) + '\n')
        else:
            output_par.write(contents[i] + '\n')
    output_par.close()

    return

    Editing the input par file with updated parameter values in the form of a
    dictionary. Each key will have 1 value though.

    par_file - orbital parameter file for input into PINT's photonphase
    var_dict - dictionary, where each key corresponds to a variable to change in the par file, and has a 1-entry list!
    
Editing the input par file with updated parameter values in the form of a
dictionary. Each key will have 1 value though.

orbital parameter file for input into PINT's photonphase
var_dict - dictionary, where each key corresponds to a variable to change in the par file, and has a 1-entry list!
Editing the input par file with updated parameter values in the form of a dictionary . Each key will have 1 value though . orbital parameter file for input into PINT ' s photonphase var_dict - dictionary where each key corresponds to a variable to change in the par file and has a 1 - entry list!
def edit_par(par_file,var_dict):
    dict_keys = var_dict.keys() 
    new_par = par_file[:-4] + '_iter.par'
    line_no_dict = {}
    contents = open(par_file,'r').read().split('\n')
    for i in range(len(dict_keys)):
        line_no = [j for j in range(len(contents)) if dict_keys[i] in contents[j]][0] 
        line_no_dict[dict_keys[i]] = [line_no] 
    output_par = open(new_par,'w')
    for i in range(len(contents)):
        if contents[i].split(' ')[0] in dict_keys: 
            output_par.write(contents[i].split(' ')[0] + ' '*10 + str(var_dict[contents[i].split(' ')[0]][0]) + '\n')
        else:
            output_par.write(contents[i] + '\n')
    output_par.close()
    return
def edit_par ( par_file , var_dict ) : dict_keys = var_dict . keys ( ) new_par = par_file [ : - 4 ] + '_iter.par' line_no_dict = { } contents = open ( par_file , 'r' ) . read ( ) . split ( '\n' ) for i in range ( len ( dict_keys ) ) : line_no = [ j for j in range ( len ( contents ) ) if dict_keys [ i ] in contents [ j ] ] [ 0 ] line_no_dict [ dict_keys [ i ] ] = [ line_no ] output_par = open ( new_par , 'w' ) for i in range ( len ( contents ) ) : if contents [ i ] . split ( ' ' ) [ 0 ] in dict_keys : output_par . write ( contents [ i ] . split ( ' ' ) [ 0 ] + ' ' * 10 + str ( var_dict [ contents [ i ] . split ( ' ' ) [ 0 ] ] [ 0 ] ) + '\n' ) else : output_par . write ( contents [ i ] + '\n' ) output_par . close ( ) return
Editing the input par file with updated parameter values in the form of a
dictionary.
Editing the input par file with updated parameter values in the form of a dictionary .
"""
    Editing the input par file with updated parameter values in the form of a
    dictionary. Each key will have 1 value though.

    par_file - orbital parameter file for input into PINT's photonphase
    var_dict - dictionary, where each key corresponds to a variable to change in the par file, and has a 1-entry list!
    """ #the variables that we want to iterate over #finding indices for the variables we want to iterate over #dictionary key corresponds to a 1-entry list #so if we reach a line corresponding to a variable we're iterating over
par_file
var_dict