def singPertParam(n1,d,beta, angle, n, m, itermax, xmin, xmax, ymin, ymax,filename,colorMap): start = time.time() #First we need to calculate the critical point that we are going to iterate on: r = pow((d/n1)*abs(beta), 1.0/(n1+d)) #The set of critical points is a circle with the radius given by above, for now we will take the right-most real value on this circle: critPoint = r*complex(cos(angle), sin(angle)) ix, iy = mgrid[0:n, 0:m] x = linspace(xmin, xmax, n)[ix] y = linspace(ymin, ymax, m)[iy] c = x+complex(0,1)*y del x, y # save a bit of memory, we only need z img = zeros(c.shape, dtype=int) ix.shape = n*m iy.shape = n*m c.shape = n*m #Sets all of the z_0 values if critPoint == 0: z = critPoint**n1 + copy(c) else: z = critPoint**n1 + copy(c) + (beta)/(critPoint.conjugate()**d) for i in xrange(itermax): if not len(z): break # all points have escaped #multiply(z, z, z) #add(z, c, z) z = pow(z, n1) + c + (beta)/(pow(z.conjugate(), d)) # these are the points that have escaped rem = abs(z)>2.0 img[ix[rem], iy[rem]] = i+1 rem = -rem z = z[rem] ix, iy = ix[rem], iy[rem] c = c[rem] print 'Time taken:', time.time()-start img[img==0] = itermax + 1 image = imshow(img.T, origin='lower left') if not colorMap == "": image.set_cmap(colorMap) image.write_png(filename+'.png', noscale=True)
def singPertPhase(n1,d,beta,c2,n, m, itermax, xmin, xmax, ymin, ymax,filename,colorMap): start = time.time() ix, iy = mgrid[0:n, 0:m] x = linspace(xmin, xmax, n)[ix] y = linspace(ymin, ymax, m)[iy] z = x+complex(0,1)*y del x, y # save a bit of memory, we only need z img = zeros(z.shape, dtype=int) ix.shape = n*m iy.shape = n*m z.shape = n*m #Sets all of the z_0 values #z = z**n1 + c2 + (beta)/(z.conjugate()**d) for i in xrange(itermax): if not len(z): break # all points have escaped #multiply(z, z, z) #add(z, c, z) z = z**n1 + c2 + (beta)/(z.conjugate()**d) # these are the points that have escaped rem = abs(z)>2.0 img[ix[rem], iy[rem]] = i+1 rem = -rem z = z[rem] ix, iy = ix[rem], iy[rem] print 'Time taken:', time.time()-start img[img==0] = itermax + 1 image = imshow(img.T, origin='lower left') if not colorMap == "": image.set_cmap(colorMap) image.write_png(filename+'.png', noscale=True)
def apply_callback(data): """This function will be called to apply changes""" def validate_color(value): if not is_color_like(value): value='None' return value general = data[0] ind = 0 if has_curve: ind += 1 curves = data[ind] if has_image: ind += 1 images = data[ind] if has_patch: ind += 1 patches = data[ind] if has_text: ind += 1 texts = data[ind] # Set / General title, autoXY, equal, has_legend, loc, xmin, xmax, xlabel, \ xscale, ymin, ymax, ylabel, yscale = general autoX, autoY = autoXY axes.set_xscale(xscale) axes.set_yscale(yscale) axes.set_autoscalex_on(autoX) axes.set_autoscaley_on(autoY) axes.set_title(title) axes.set_xlim(xmin, xmax) axes.set_xlabel(xlabel) axes.set_ylim(ymin, ymax) axes.set_ylabel(ylabel) if equal : axes.set_aspect("equal") else : axes.set_aspect("auto") has_label = False if has_curve: # Set / Curves for index, curveopts in enumerate(curves): line = linedict[curvelabels[index]] label, visible, linestyle, linewidth, color, marker, \ markersize, markerfacecolor, markeredgecolor, markevery = curveopts if not label.startswith('_') : has_label=True line.set_label(label) line.set_visible(visible) line.set_linestyle(linestyle) line.set_linewidth(linewidth) line.set_color(validate_color(color)) line.set_markeredgecolor(validate_color(markeredgecolor)) line.set_markerfacecolor(validate_color(markerfacecolor)) line.set_markersize(markersize) if marker == 'none': marker='None' line.set_marker(marker) markevery = markevery if markevery>0 else 1 line.set_markevery(markevery) if has_image: # Set / Images for index, imageopts in enumerate(images): image = imagedict[imagelabels[index]] label, cmap_name, alpha, interpolation, \ filterrad, xmin, xmax, ymin, ymax = imageopts image.set_label(label) image.set_cmap(matplotlib.cm.get_cmap(cmap_name)) if alpha >= 0 and alpha <= 1: # Ignoring invalid values image.set_alpha(alpha) image.set_interpolation(interpolation) if filterrad > 0: # Ignoring invalid values image.set_filterrad(filterrad) image.set_extent((xmin, xmax, ymin, ymax)) if has_patch: for index, patch_elt in enumerate(patches): patch = patchdict[patchlabels[index]] label, zorder, visible, linestyle, linewidth, \ edgecolor, fill, facecolor, alpha = patch_elt if not label.startswith('_') : has_label = True patch.set_label(label) patch.set_zorder(zorder) patch.set_visible(visible) patch.set_ls(linestyle) patch.set_lw(linewidth) patch.set_fill(fill) patch.set_alpha(alpha) patch.set_ec(validate_color(edgecolor)) patch.set_fc(validate_color(facecolor)) if has_text: for index, text_elt in enumerate(texts): text = textdict[textlabels[index]] label, visible, text_content, xpos, ypos, halign, \ valign, fontsize, is_bold, fontcolor = text_elt text.set_label(label) text.set_visible(visible) text.set_text(text_content) text.set_x(xpos) text.set_y(ypos) text.set_ha(halign) text.set_va(valign) if is_bold : text.set_weight("bold") else: text.set_weight('normal') text.set_size(fontsize) text.set_color(validate_color(fontcolor)) if has_curve: if has_legend and has_label: axes.legend(loc=loc) else: axes.legend_ = None elif has_legend: axes.legend(loc=loc) else: axes.legend_ = None # Redraw if axes.get_legend() is not None: axes.legend() figure = axes.get_figure() figure.canvas.draw()