예제 #1
0
        # Open the image frame
        frame = Frame.from_file(image_path)

        # Determine the preparation name
        if frame.filter is not None: prep_name = str(frame.filter)
        else: prep_name = image_name

        # Set the row entries
        names_column.append(image_name)
        paths_column.append(image_path)
        prep_names_column.append(prep_name)

# Create the table
data = [names_column, paths_column, prep_names_column]
table = tables.new(data, names)

# Check whether the preparation directory exists
prep_path = fs.join(config.path, "prep")
if not fs.is_directory(prep_path): fs.create_directory(prep_path)

# Save the table
prep_info_table_path = fs.join(prep_path, "prep_info.dat")
tables.write(table, prep_info_table_path, format="ascii.ecsv")

# -----------------------------------------------------------------

# Create a PreparationInitializer instance
initializer = PreparationInitializer(config)

# Run the data initializer
예제 #2
0
name_column = []
par_a_column = []
par_b_column = []

for ind in ga.new_population:

    # Give the individual a unique name
    name = time.unique_name(precision="micro")
    name_column.append(name)
    par_a_column.append(ind.genomeList[0])
    par_b_column.append(ind.genomeList[1])

# Create the parameters table
data = [name_column, par_a_column, par_b_column]
names = ["Unique name", "Parameter a", "Parameter b"]
new_parameters_table = tables.new(data, names)

# -----------------------------------------------------------------

# Save the new parameters table
tables.write(new_parameters_table, new_parameters_path, format="ascii.ecsv")

# Dump the GA
ga.saveto(new_path)

# -----------------------------------------------------------------

# Save the state of the random generator
new_random_path = fs.join(new_generation_path, "rndstate.pickle")
save_state(new_random_path)
        # Open the image frame
        frame = Frame.from_file(image_path)

        # Determine the preparation name
        if frame.filter is not None: prep_name = str(frame.filter)
        else: prep_name = image_name

        # Set the row entries
        names_column.append(image_name)
        paths_column.append(image_path)
        prep_names_column.append(prep_name)

# Create the table
data = [names_column, paths_column, prep_names_column]
table = tables.new(data, names)

# Check whether the preparation directory exists
prep_path = fs.join(config.path, "prep")
if not fs.is_directory(prep_path): fs.create_directory(prep_path)

# Save the table
prep_info_table_path = fs.join(prep_path, "prep_info.dat")
tables.write(table, prep_info_table_path, format="ascii.ecsv")

# -----------------------------------------------------------------

# Create a PreparationInitializer instance
initializer = PreparationInitializer(config)

# Run the data initializer
예제 #4
0
name_column = []
par_a_column = []
par_b_column = []

for ind in ga.new_population:

    # Give the individual a unique name
    name = time.unique_name(precision="micro")
    name_column.append(name)
    par_a_column.append(ind.genomeList[0])
    par_b_column.append(ind.genomeList[1])

# Create the parameters table
data = [name_column, par_a_column, par_b_column]
names = ["Unique name", "Parameter a", "Parameter b"]
new_parameters_table = tables.new(data, names)

# -----------------------------------------------------------------

# Save the new parameters table
tables.write(new_parameters_table, new_parameters_path, format="ascii.ecsv")

# Dump the GA
ga.saveto(new_path)

# -----------------------------------------------------------------

# Save the state of the random generator
new_random_path = fs.join(new_generation_path, "rndstate.pickle")
save_state(new_random_path)
예제 #5
0
파일: score.py 프로젝트: wdobbels/CAAPR
    score = chi_squared_function([parameter_a_tab, parameter_b_tab])

    # Keep track of index of lowest score
    if lowest_score is None or score < lowest_score:
        lowest_score = score
        index_lowest = index

    # Add the score to the list
    name = table["Unique name"][index]
    names.append(name)
    scores.append(score)

# Create the chi squared table
data = [names, scores]
names = ["Unique name", "Chi-squared"]
chi_squared_table = tables.new(data, names)

# Determine the path to the chi squared table
chi_squared_path = fs.join(generation_path, "chi_squared.dat")

# Write the chi squared table
tables.write(chi_squared_table, chi_squared_path, format="ascii.ecsv")

# -----------------------------------------------------------------

best_parameter_a = table["Parameter a"][index_lowest]
best_parameter_b = table["Parameter b"][index_lowest]

best_path = fs.join(generation_path, "best.dat")

with open(best_path, 'w') as best_file: