示例#1
0
def save_state():
    """Save the program state, for debugging purposes."""

    # relax data store singleton import.  Must be done here!
    try:
        from data_store import Relax_data_store; ds = Relax_data_store()

    # Ok, this is not relax so don't do anything!
    except ImportError:
        return

    # Append the date and time to the save file.
    now = time.localtime()
    file_name = "relax_state_%i%02i%02i_%02i%02i%02i" % (now[0], now[1], now[2], now[3], now[4], now[5])

    # Open the file for writing.
    if bz2:
        sys.stderr.write("\nStoring the relax state in the file '%s.bz2'.\n\n" % file_name)
        file = BZ2File(file_name+'.bz2', 'w')
    else:
        sys.stderr.write("\nStoring the relax state in the file '%s'.\n\n" % file_name)
        file = open(file_name, 'w')

    # Pickle the data class and write it to file
    pickle.dump(ds, file, 1)

    # Close the file.
    file.close()
示例#2
0
文件: errors.py 项目: bopopescu/relax
def save_state():
    """Save the program state, for debugging purposes."""

    # relax data store singleton import.  Must be done here!
    try:
        from data_store import Relax_data_store
        ds = Relax_data_store()

    # Ok, this is not relax so don't do anything!
    except ImportError:
        return

    # Append the date and time to the save file.
    now = time.localtime()
    file_name = "relax_state_%i%02i%02i_%02i%02i%02i" % (
        now[0], now[1], now[2], now[3], now[4], now[5])

    # Open the file for writing.
    if bz2:
        sys.stderr.write(
            "\nStoring the relax state in the file '%s.bz2'.\n\n" % file_name)
        file = BZ2File(file_name + '.bz2', 'w')
    else:
        sys.stderr.write("\nStoring the relax state in the file '%s'.\n\n" %
                         file_name)
        file = open(file_name, 'w')

    # Pickle the data class and write it to file
    pickle.dump(ds, file, 1)

    # Close the file.
    file.close()
示例#3
0
# Store to dic
dic['R'] = R
dic['I0'] = I0
dic['params'] = params
dic['np'] = np
dic['sim'] = sim
dic['nt_min'] = nt_min
dic['nt_max_list'] = nt_max_list
dic['all_times'] = all_times
dic['I_err_level'] = I_err_level
dic['I_err_std'] = I_err_std
dic['all_errors'] = all_errors

# Write to pickle.
pickle.dump( dic, open( "estimate_errors_data_settings.cp", "wb" ) )

# Minfx settings
#min_algor = 'simplex'
min_algor = 'BFGS'
min_options = ()

# Make global counters
global np_i
np_i = 0
global sim_j
sim_j = 0

########### Define functions ##################################

def func_exp(params=None, times=None):
示例#4
0
# Store to dic
dic['R'] = R
dic['I0'] = I0
dic['params'] = params
dic['np'] = np
dic['sim'] = sim
dic['nt_min'] = nt_min
dic['nt_max_list'] = nt_max_list
dic['all_times'] = all_times
dic['I_err_level'] = I_err_level
dic['I_err_std'] = I_err_std
dic['all_errors'] = all_errors

# Write to pickle.
pickle.dump( dic, open( "estimate_errors_data_settings.cp", "wb" ) )

# Minfx settings
#min_algor = 'simplex'
min_algor = 'BFGS'
min_options = ()

# Make global counters
global np_i
np_i = 0
global sim_j
sim_j = 0

########### Define functions ##################################

def func_exp(params=None, times=None):