def paramvsRpart(Npx, pxlen, R_part_min, R_part_max, R_part_step, N_part, tipFunc, h, aspectratio_min, aspectratio_max, aspectratio_step, N_sample, paramFunc, y_label): '''tipFunc deve essere una funzione. paramFunc deve essere una funzione sola della superficie/ dell'immagine. ''' #z = mf.genFlat(Npx) R_part = np.linspace(R_part_min, R_part_max, R_part_step) aspectratio = np.linspace(aspectratio_min, aspectratio_max, aspectratio_step) plt.figure() np.random.seed(123) plt_colors = [np.random.random(3) for _ in range(len(aspectratio) + 1) ] # +1 per la superficie stessa for i in range(N_sample): print('N_sample = ' + str(i + 1)) z_param = [] img_param = [] for R in R_part: print('R_part = ' + str(R)) z = mf.genFlat(Npx) z_N = mf.genUnifIsolSph(z, pxlen, N_part, R, R) z_param.append(paramFunc(z_N * pxlen)) for ar in aspectratio: tip_ar = tipFunc(pxlen, h, ar) img_ar = mph.grey_dilation(z_N, structure=-tip_ar) img_param.append(paramFunc(img_ar * pxlen)) plt_label = 'surface' if i == 0 else '' # visualizza label solo una volta plt.plot(R_part, z_param, marker='.', color=plt_colors[-1], label=plt_label) for j in range(len(aspectratio)): plt_label = 'a.r. = ' + str( aspectratio[j] ) if i == 0 else '' # visualizza label solo una volta plt.plot(R_part, img_param[j::len(aspectratio)], marker='.', color=plt_colors[j], label=plt_label) plt.xlabel(r'$R_{part} [nm]$') plt.ylabel(y_label) plt.grid() plt.legend() plt.tight_layout()
def paramvsNpart(Npx, pxlen, rmin, rmax, N_part_min, N_part_max, N_partstep, tipFunc, h, tipparname, tipmin, tipmax, tipstep, N_sample, paramFunc, filename): '''tipFunc deve essere una funzione. paramFunc deve essere una funzione sola della superficie/ dell'immagine. ''' N_part = np.linspace(N_part_min, N_part_max, N_partstep) tip = np.linspace(tipmin, tipmax, tipstep) out = open(filename, 'w') out.write( str(Npx) + ' ' + str(pxlen) + ' ' + str((rmax + rmin) / 2) + ' ' + str(h) + ' ' + str(mf.Ncp(pxlen, Npx, (rmin + rmax) / 2)) + ' ') out.write('#Npx, pxlen, avR_part, h_tip, Ncp(avR_part)\n') for m in tip: out.write(str(m) + ' ') out.write('#tip_' + tipparname + ' (rows)\n') for i in range(N_sample): print('N_sample = ' + str(i + 1)) z_param = [] img_param = [] xyr = [] z = mf.genFlat(Npx) for N in N_part: out.write(str(int(N)) + ' ') print('N_part = ' + str(int(N))) z, xyr = mf.genUnifIsolSph(z, pxlen, int(N), rmin, rmax, xyr, True) # mf.plotfalsecol(z,pxlen) z_param.append(paramFunc(z)) # print('max height surface=',h_max(z,10)) for m in tip: if tipparname == 'angle': tip_ar = tipFunc(pxlen, h, angle=m) if tipparname == 'r': tip_ar = tipFunc(pxlen, h, r=m) img_ar = mph.grey_dilation(z, structure=-tip_ar) img_param.append(paramFunc(img_ar)) # print('max height image=',h_max(z,10)) out.write('#Npart\n') for j in range(len(N_part)): out.write(str(z_param[j]) + ' ') out.write('#Surface par\n') for i in range(len(tip)): for j in range(len(N_part)): out.write(str(img_param[i + j * len(tip)]) + ' ') out.write('\n') out.write('\n') out.close() print('datas printed in ' + filename)
thres = 15 #nm Npart = 250 #number of particles on the map h = 80 ar = 2 #MAP------------------------------------------------- z = mf.genFlat(Npx) #z=mf.genHexSpikes(z,pxlen,20,2,20) #z=mf.genNormNoise(z,pxlen,100,50) #z=mf.genFlat(Npx) #z=gaussian_filter(z,20) #z=mf.genSphere(z,pxlen,np.array([100,100,20,70]),np.array([10,30])) #z=mf.genUnifSph(z,pxlen,10,5,10) #, xmin=22, xmax=58, ymin=62, ymax=78) #z=mf.genNormSph(z,pxlen,Npart,20,0) #, xmin=22, xmax=58, ymin=62, ymax=78) z = mf.genUnifIsolSph(z, pxlen, Npart, rmin, rmax) #, xmin=22, xmax=58, ymin=62, ymax=78) #Tip------------------------------------------------ #occhio che h/a>>pxlen tip = mf.genParabolicTip(pxlen, h, ar) #tip=mf.genPyramidTip(pxlen,50,2) #----------la dilation non funziona bene con piramide ?? #tip=mf.genSemisphTip(pxlen,40,1) #IMG------------------------------------------------ img = mph.grey_dilation(z, structure=-tip) #PLOT-----------------------------------------------