def setColors(cls): """class function that gives a dictionnary of colors for each sourceFile defined so far """ cls.subroutine_colors = dict(zip(cls.findSubroutine.keys(), autiwa.colorList(len(cls.findSubroutine)))) #~ pdb.set_trace() return 0
def setColors(cls): """class function that gives a dictionnary of colors for each sourceFile defined so far """ cls.subroutine_colors = dict( zip(cls.findSubroutine.keys(), autiwa.colorList(len(cls.findSubroutine)))) #~ pdb.set_trace() return 0
def setModColors(cls): """class function that gives a dictionnary of colors for each sourceFile defined so far """ try: cls.mod_colors = dict( zip(cls.findSource.keys(), autiwa.colorList(len(cls.findSource)))) except: pdb.set_trace() return 0
id_max = int((t_max - ref_time[0]) / delta_t) t_max = ref_time[id_max] else: id_max = ref_len - 1 t_max = ref_time[-1] # We get the index for the t_min value if ('t_min' in locals()): id_min = int((t_min - ref_time[0]) / delta_t) t_min = ref_time[id_min] else: id_min = 0 t_min = ref_time[0] # We generate a list of colors colors = [ '#'+li for li in autiwa.colorList(nb_planete)] # We display plots fig = pl.figure(1) pl.clf() fig.subplots_adjust(left=0.12, bottom=0.1, right=0.96, top=0.95, wspace=0.26, hspace=0.26) # We create subplots. add_subplot(2, 3, 1) means we have 2 lines, 3 columns, # and that the active plot is the first, starting from top left (for 6 plots in total) plot_a = fig.add_subplot(2, 2, 1) if (isaLog and isLog): plot = plot_a.loglog elif (isaLog and not(isLog)): plot = plot_a.semilogy elif (not(isaLog) and isLog): plot = plot_a.semilogx
print("resonance %i:%i between %s and %s : min(std) = %f" % (res.numerator, res.denominator, name[planet], name[planet+1], standard_deviation)) if (delta_longitude.std() < STD_THRESHOLD): longitude_res[planet] = True #~ pdb.set_trace() #~ finir ça, il faut que je teste la libration là. Normalement, j'ai fait tout ce qui était nécessaire pour lire les fichiers, #~ parcourir les planètes puis les résonnances. Penser que j'ai bloqué le nombre de planète à 2, histoire de pas avoir trop de #~ calculs et de voir les erreurs directement. # We display the resonances # We generate a list of colors tmp = autiwa.colorList(nb_planets) colors = [ '#'+li for li in autiwa.colorList(nb_planets)] markersize_prefactor = 6 / (min(mass)**0.33) for planet in range(nb_planets): # We display a circle for the planet pl.plot(a[planet], mass[planet], 'o', color=colors[planet], markersize=int(markersize_prefactor * (mass[planet])**0.33)) ylims = list(pl.ylim()) xlims = list(pl.xlim()) # We display the convergence zone if (vars().has_key('CZ')): if (type(CZ) == list): pl.plot(CZ[1], CZ[0], '-.', color="#000000")
(res.numerator, res.denominator, name[planet], name[planet + 1], standard_deviation)) if (delta_longitude.std() < STD_THRESHOLD): longitude_res[planet] = True #~ pdb.set_trace() #~ finir ça, il faut que je teste la libration là. Normalement, j'ai fait tout ce qui était nécessaire pour lire les fichiers, #~ parcourir les planètes puis les résonnances. Penser que j'ai bloqué le nombre de planète à 2, histoire de pas avoir trop de #~ calculs et de voir les erreurs directement. # We display the resonances # We generate a list of colors tmp = autiwa.colorList(nb_planets) colors = ['#' + li for li in autiwa.colorList(nb_planets)] markersize_prefactor = 6 / (min(mass)**0.33) for planet in range(nb_planets): # We display a circle for the planet pl.plot(a[planet], mass[planet], 'o', color=colors[planet], markersize=int(markersize_prefactor * (mass[planet])**0.33)) ylims = list(pl.ylim()) xlims = list(pl.xlim()) # We display the convergence zone
autiwa.lancer_commande("rm %s*" % FRAME_PREFIX) # We delete the previous frames delta_t_min = (t_max - t_min) / (float(NB_FRAMES - 1.0)) # Number of timestep between each frame # real number to be as close as possible from the real value, and do not encounter rounding problems. # The conversion to an integer is done at the very end. ts_per_frame = delta_t_min / delta_t # If there is too many frames for the outputs availables, we impose 1 output between each frames and reduce the total number of frames if ts_per_frame < 1: ts_per_frame = 1 NB_FRAMES = id_max - id_min + 1 # We generate a list of colors tmp = autiwa.colorList(nb_planete) colors = ["#" + li for li in autiwa.colorList(nb_planete)] if not (isTail): angles = [2 * pi / NB_POINTS * i for i in range(NB_POINTS)] angles.append(angles[0]) # we want to have a full circle, perfectly closed angles = np.array(angles) fig = pl.figure() plot_orbits = fig.add_subplot(1, 1, 1) plot = plot_orbits.plot MAX_LENGTH = len(str(NB_FRAMES)) # The maximum number of characters needed to display for frame_i in range(1, NB_FRAMES + 1):
# We define a list of folder names we don't want to read. # Theses names will be suppressed from the final list, in case they exist. dossier_suppr = ["output", "indiv_simu_01"] ####################### # On se place dans le dossier de simulation souhaité ####################### liste_meta_simu = [dir for dir in os.listdir(".") if os.path.isdir(dir)] autiwa.suppr_dossier(liste_meta_simu, dossier_suppr) liste_meta_simu.sort() nb_meta_simu = len(liste_meta_simu) # We generate a list of colors colors = [ '#' + li for li in autiwa.colorList(nb_meta_simu, exclude=['000000']) ] # We chose the number of plot in x and y axis for the p.multi # environment in order to plot ALL the resonant angles and have x and # y numbers as close on from another as possible. There are q+1 # resonant angles, the period ratio and w1 - w2, i.e q+3 plots nb_plots_x = 1 nb_plots_y = 1 while (nb_plots_x * nb_plots_y < nb_meta_simu): if (nb_plots_x == nb_plots_y): nb_plots_y += 1 else: nb_plots_x += 1 subplot_index = nb_plots_x * 100 + nb_plots_y * 10
id_max = int((t_max - ref_time[0]) / delta_t) t_max = ref_time[id_max] else: id_max = ref_len - 1 t_max = ref_time[-1] # We get the index for the t_min value if ('t_min' in locals()): id_min = int((t_min - ref_time[0]) / delta_t) t_min = ref_time[id_min] else: id_min = 0 t_min = ref_time[0] # We generate a list of colors colors = ['#' + li for li in autiwa.colorList(nb_planete)] # We display plots fig = pl.figure(1) pl.clf() fig.subplots_adjust(left=0.12, bottom=0.1, right=0.96, top=0.95, wspace=0.26, hspace=0.26) # We create subplots. add_subplot(2, 3, 1) means we have 2 lines, 3 columns, # and that the active plot is the first, starting from top left (for 6 plots in total) plot_a = fig.add_subplot(2, 2, 1) if (isaLog and isLog):
####################### # We define a list of folder names we don't want to read. # Theses names will be suppressed from the final list, in case they exist. dossier_suppr = ["output", "indiv_simu_01"] ####################### # On se place dans le dossier de simulation souhaité ####################### liste_meta_simu = [dir for dir in os.listdir(".") if os.path.isdir(dir)] autiwa.suppr_dossier(liste_meta_simu,dossier_suppr) liste_meta_simu.sort() nb_meta_simu = len(liste_meta_simu) # We generate a list of colors colors = [ '#'+li for li in autiwa.colorList(nb_meta_simu, exclude=['000000'])] # We chose the number of plot in x and y axis for the p.multi # environment in order to plot ALL the resonant angles and have x and # y numbers as close on from another as possible. There are q+1 # resonant angles, the period ratio and w1 - w2, i.e q+3 plots nb_plots_x = 1 nb_plots_y = 1 while (nb_plots_x * nb_plots_y < nb_meta_simu): if (nb_plots_x == nb_plots_y): nb_plots_y += 1 else: nb_plots_x += 1 subplot_index = nb_plots_x * 100 + nb_plots_y * 10 # .-. .-. .-. .-. .-. .-. .-. .-. .-.
# We prepare the plot fig = pl.figure(1) nb_subplot = autiwa.get_subplot_shape(len(focals)) fig.subplots_adjust(left=0.12, bottom=0.1, right=0.96, top=0.95, wspace=0.26, hspace=0.26) #~ myxfmt = ScalarFormatter(useOffset=True) #~ myxfmt._set_offset(1e5) #~ myxfmt.set_scientific(True) #~ myxfmt.set_powerlimits((-3, 3)) myxfmt = FormatStrFormatter('%.0f') myminorxfmt = FormatStrFormatter('%.1f') # We generate a list of colors colors = [ '#'+li for li in autiwa.colorList(len(dofs))] for focal_length in focals: nb_subplot += 1 plot_dof = fig.add_subplot(nb_subplot) # We define a fake subplot that is in fact only the plot. #~ dof_near = [] #~ dof_far = [] for (required_dof, color) in zip(dofs, colors): distances = [] for (aperture, aperture_name) in zip(aperture_values, aperture_names): distance = findCorrespondingDistance(dof=required_dof, aperture=aperture, circle_of_confusion=CIRCLE_OF_CONFUSION, focal_length=focal_length) distances.append(distance)
decorated = [(final_mass[i], i, final_name[i]) for i in range(nb_final)] decorated.sort(reverse=True) # We get the final planets, the bigger the firsts for (i , (mass, dumb, name)) in enumerate(decorated): final_name[i] = name final_mass[i] = mass # We get all the association of name/index of planets ind_of_planet = {} for (ind, filename) in enumerate(liste_aei): basename = os.path.splitext(filename)[0] ind_of_planet[basename] = ind # We generate a list of colors tmp = autiwa.colorList(MAX_COLORED, exclude=['ffffff', COLOR_FINAL, COLOR_EJECTED]) tmp.extend([COLOR_FINAL]*(nb_final-MAX_COLORED)) # We initialize the total color list. # By default, all the planets have the same colors, that will illustrate ejection and collisions with the sun colors = ['#'+COLOR_EJECTED] * nb_planete # For the planets that remains in the simulation at the end, we change the color (either a flashy one for the most massives, or a default one) for (name, color) in zip(final_name, tmp): colors[ind_of_planet[name]] = '#'+color tableau = open('info.out', 'r') # We must read the file backward because at the beginning, we only have the color of a few planets. lines = tableau.readlines()
nb_final = len(final_name) decorated = [(final_mass[i], i, final_name[i]) for i in range(nb_final)] decorated.sort(reverse=True) # We get the final planets, the bigger the firsts for (i, (mass, dumb, name)) in enumerate(decorated): final_name[i] = name final_mass[i] = mass # We get all the association of name/index of planets ind_of_planet = {} for (ind, filename) in enumerate(liste_aei): basename = os.path.splitext(filename)[0] ind_of_planet[basename] = ind # We generate a list of colors tmp = autiwa.colorList(MAX_COLORED, exclude=['ffffff', COLOR_FINAL, COLOR_EJECTED]) tmp.extend([COLOR_FINAL] * (nb_final - MAX_COLORED)) # We initialize the total color list. # By default, all the planets have the same colors, that will illustrate ejection and collisions with the sun colors = ['#' + COLOR_EJECTED] * nb_planete # For the planets that remains in the simulation at the end, we change the color (either a flashy one for the most massives, or a default one) for (name, color) in zip(final_name, tmp): colors[ind_of_planet[name]] = '#' + color tableau = open('info.out', 'r') # We must read the file backward because at the beginning, we only have the color of a few planets. lines = tableau.readlines() tableau.close()