def plot_1D_visibilities(visibilities, model, parameters, params, index=0, \ fig=None): # Generate a figure and axes if not provided. if fig == None: fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(4.5, 4)) else: fig, ax = fig # Average the high resolution model radially. m1d = uv.average(model.visibilities[visibilities["lam"][index]+"_high"], \ gridsize=10000, binsize=3500, radial=True) # Plot the visibilities. ax.errorbar(visibilities["data1d"][index].uvdist/1000, \ visibilities["data1d"][index].amp, \ yerr=numpy.sqrt(1./visibilities["data1d"][index].weights),\ fmt="ko", markersize=8, markeredgecolor="k") # Plot the best fit model ax.plot(m1d.uvdist / 1000, m1d.amp, "g-") # Adjust the plot and add axes labels. ax.axis([1,visibilities["data1d"][index].uvdist.max()/1000*3,0,\ visibilities["data1d"][index].amp.max()*1.1]) ax.set_xscale("log", nonposx='clip') ax.set_xlabel("Baseline [k$\lambda$]") ax.set_ylabel("Amplitude [Jy]") # Return the figure and axes. return fig, ax
# Center the data. => need to update! data = uv.center(data, [visibilities["x0"][j], visibilities["y0"][j], 1.]) # Add the data to the dictionary structure. visibilities["data"].append(data) # Scale the weights of the visibilities to force them to be fit well. visibilities["data"][j].weights *= visibilities["weight"][j] # Average the visibilities radially. visibilities["data1d"].append(uv.average(data, gridsize=20, radial=True, \ log=True, logmin=data.uvdist[numpy.nonzero(data.uvdist)].min()*\ 0.95, logmax=data.uvdist.max()*1.05, mode="spectralline")) # Read in the image. visibilities["image"].append(im.readimfits(visibilities["image_file"][j])) ##################### # Read in the images. ##################### for j in range(len(images["file"])): images["data"].append(im.readimfits(images["file"][j])) ################################################################################ #
u = numpy.linspace(100.,1.5e7,10000) v = numpy.repeat(0.001,10000) t1 = time.time() vis = uv.interpolate_model(u, v, numpy.array([2.3e11]), m.images["image"], \ code="trift", dRA=0., dDec=0., nthreads=4) t2 = time.time() print(t2 - t1) # Do a high resolution model to compare with. m.run_visibilities(name="image", nphot=1e5, npix=1024, \ pixelsize=8*25./1024, lam="1000", phi=0, incl=0, code="radmc3d", \ dpc=100, verbose=False, nostar=True) m.visibilities["image"] = uv.average(m.visibilities["image"], \ gridsize=1000000, binsize=1000, radial=True) # Finally, plot the visibilities. plt.loglog(u/1e3, vis.amp*1000, "k-", \ label="Unstructured Fourier Transform, $N_{{pix}} = {0:d}^2$".format(\ npix_trift)) plt.plot(m.visibilities["image"].u/1e3, m.visibilities["image"].amp*1000, \ "r-", label="Traditional Image, $N_{pix} = 1024^2$") plt.xlabel("u [k$\lambda$]", fontsize=14) plt.ylabel(r"F$_{\nu}$ [mJy]", fontsize=14) plt.legend(loc="lower left")
# Get the time for each number of pixels. times = [] npix_arr = [32, 64, 128, 256, 512, 1024, 2048] pixelsize_arr = [25 / npix for npix in npix_arr] for npix in npix_arr: t1 = time.time() m.run_visibilities(name="image"+str(npix), nphot=1e5, npix=npix, \ pixelsize=25./npix, lam="1000", phi=0, incl=0, code="radmc3d", \ dpc=100, verbose=False, nostar=True) t2 = time.time() times.append(t2 - t1) m.visibilities["image"+str(npix)] = uv.average(m.visibilities["image"+\ str(npix)], gridsize=1000000, binsize=1000, radial=True) # Now make the plot. plt.loglog(npix_arr, times, "k.-", label="Traditional Image") plt.plot(trift_npix, trift_time, "o", label="Unstructured Image") plt.xlabel("$\sqrt{N_{pix}}$", fontsize=14) plt.ylabel("Time (s)", fontsize=14) plt.legend() plt.gca().tick_params(labelsize=14) plt.subplots_adjust(right=0.98, top=0.98, bottom=0.15, left=0.15)