spherical_kde
0.1.2
Paket -paket ini memungkinkan Anda untuk melakukan estimasi kerapatan kernel yang belum sempurna pada suatu bola. Saran untuk perbaikan/ekstensi disambut.
Prinsip dasarnya adalah menggantikan fungsi tradisional Gaussian yang digunakan dalam estimasi kepadatan kernel dengan distribusi von mises-fisher.
Estimasi bandwidth masih kasar dan siap.
Impor numpyfrom spherical_kde impor sphericalkdeimport matplotlib.pyplot sebagai cartopy pltimport.crsfrom matplotlib.gridspec gridspec, gridspecfromsblotspec# pilih seed untuk plotnumpy deterministik.random.seed (seed = 0)# (10, 10)) gs_vert = gridspec (3, 1) gs_lower = gridspecfromsubplotspec (1, 2, subplot_spec = gs_vert [1]) fig.add_subplot (gs_vert [0], proyeksi = cartopy.crs.mollweide ()) ara. add_subplot (gs_lower [0], proyeksi = cartopy.crs.orthographic ()) fig.add_subplot (gs_lower [1], proyeksi = cartopy.crs.orthographic (-10, 45)) gbr.add_subplot (gs_vert [2], proyeksi = cartopy.crs.plateCarree ())# Pilih parameter untuk sampelNsamples = 100pi = numpy.pi# menghasilkan beberapa sampel yang berpusat pada (1,1) +/- 0,3 Radianstheta_Samples = numpy.random.normal (loc = 1, skala = 0,3 , size = nsamples) phi_samples = numpy.random.normal (loc = 1, skala = 0,3, ukuran = nsamples) phi_samples = numpy.mod (phi_samples, pi*2) kde_green = sphericalkde (phi_samples, theeta_samples #samples #samples, theeta_spleples #sample, theeta_samples #samples, theeta_samples #sample, theeta_samples #sample, theeta_samples #samples, theeta_samples #sample, theeta_samples #sample, theeta_samples #sample, theeta_samples #sample, theeta_samples #samples, theeta_samples #sample, theta_samples #samples #samples, theeta_splay ON (-1,1) +/- 0.4 Radianstheta_samples = numpy.random.normal (loc = 1, skala = 0,4, ukuran = nsamples) phi_samples = numpy.random.normal (loc = -1, skala = 0,4, ukuran = ukuran = ukuran = nsamples) phi_samples = numpy.mod (phi_samples, pi*2) kde_red = sphericalkde (phi_samples, theta_samples)# menghasilkan penyebaran sampel di sepanjang lintang 2, ketinggian 0.1theta_samples = numpy.random.norm. NormaMal (normaMal (normaMal (normaLom.norm. size=nsamples)phi_samples = numpy.random.uniform(low=-pi/2, high=pi/2, size=nsamples)phi_samples = numpy.mod(phi_samples, pi*2)kde_blue = SphericalKDE(phi_samples, theta_samples, bandwidth = 0.1) Untuk ax di gbr.axes: ax.set_global () ax.gridlines () ax.coastlines (linewidth = 0.1) kde_green.plot (ax, 'g') kde_green.plot_samples (ax) kde_red.plot (ax, ax, 'r') kde_blue.plot (ax, 'b')# simpan ke plotfig.tight_layout () fig.savefig ('plot.png')