Exemple #1
0
        # 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
initializer.run()

# -----------------------------------------------------------------
Exemple #2
0
    old_galactic_catalog_path = fs.join(galaxy_user_path, "galaxies.dat")
    old_stellar_catalog_path = fs.join(galaxy_user_path, "stars.dat")

    if fs.is_file(old_galactic_catalog_path):

        # Open the 'old' galaxy catalog
        old_galaxy_catalog = tables.from_file(old_galactic_catalog_path)

        # Create merged galaxy catalog
        galaxy_catalog = catalogs.merge_galactic_catalogs(
            galactic_catalog, old_galaxy_catalog)

        # Save the merged catalog
        path = fs.join(galaxy_user_path, "galaxies.dat")
        tables.write(galaxy_catalog, path)

    # If a galactic catalog file does not exist yet
    else:
        fs.copy_file(galactic_catalog_path, galaxy_user_path, "galaxies.dat")

    # Check whether there is a stellar catalog file in the galaxy's directory
    if fs.is_file(old_stellar_catalog_path):

        # Open the new stellar catalog
        stellar_catalog = tables.from_file(stellar_catalog_path)

        # Open the 'old' stellar catalog
        old_stellar_catalog = tables.from_file(old_stellar_catalog_path)

        # Create merged stellar catalog
Exemple #3
0
    # 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)

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

# Initialize evolution:
# self.initialize() # done in 'explore'
# self.internalPop.evaluate()
Exemple #4
0
    # 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)

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

# Initialize evolution:
# self.initialize() # done in 'explore'
# self.internalPop.evaluate()
        # 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
initializer.run()

# -----------------------------------------------------------------
Exemple #6
0
if fs.is_directory(galaxy_user_path):

    old_galactic_catalog_path = fs.join(galaxy_user_path, "galaxies.dat")
    old_stellar_catalog_path = fs.join(galaxy_user_path, "stars.dat")

    if fs.is_file(old_galactic_catalog_path):

        # Open the 'old' galaxy catalog
        old_galaxy_catalog = tables.from_file(old_galactic_catalog_path)

        # Create merged galaxy catalog
        galaxy_catalog = catalogs.merge_galactic_catalogs(galactic_catalog, old_galaxy_catalog)

        # Save the merged catalog
        path = fs.join(galaxy_user_path, "galaxies.dat")
        tables.write(galaxy_catalog, path)

    # If a galactic catalog file does not exist yet
    else: fs.copy_file(galactic_catalog_path, galaxy_user_path, "galaxies.dat")

    # Check whether there is a stellar catalog file in the galaxy's directory
    if fs.is_file(old_stellar_catalog_path):

        # Open the new stellar catalog
        stellar_catalog = tables.from_file(stellar_catalog_path)

        # Open the 'old' stellar catalog
        old_stellar_catalog = tables.from_file(old_stellar_catalog_path)

        # Create merged stellar catalog
        stellar_catalog = catalogs.merge_stellar_catalogs(stellar_catalog, old_stellar_catalog)
Exemple #7
0
    # 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:
    best_file.write("Parameter a: " + str(best_parameter_a) + "\n")
    best_file.write("Parameter b: " + str(best_parameter_b) + "\n")

popt, pcov = curve_fit(fit_function, test_data_x, test_data_y)
parameter_a_real = popt[0]
parameter_b_real = popt[1]