theta = np.linspace(-4 * np.pi, 4 * np.pi, 100) z = np.linspace(-2, 2, 100) r = z**2 + 1 x = r * np.sin(theta) y = r * np.cos(theta) ax.plot(r_ECI[:, 0] / 1000, r_ECI[:, 1] / 1000, r_ECI[:, 2] / 1000, label='Orbital Position', color='k') # Sphere to represent Earth # Make data u = np.linspace(0, 2 * np.pi, 100) v = np.linspace(0, np.pi, 100) x1 = rEarth / 1000 * np.outer(np.cos(u), np.sin(v)) y1 = rEarth / 1000 * np.outer(np.sin(u), np.sin(v)) z1 = rEarth / 1000 * np.outer(np.ones(np.size(u)), np.cos(v)) # Plot the surface ax.plot_surface(x1, y1, z1, cmap='GnBu') # Legend and labels ax.legend() ax.set_xlabel('X Pos (km)') ax.set_ylabel('Y Pos (km)') ax.set_zlabel('Z Pos (km)') ax.set_aspect('equal') plt.show()
t=25 #days def f(x, y): return np.sin(np.sqrt(x ** 2 + y ** 2)) x = np.linspace(-7, 7, 30) y = np.linspace(-5, 5, 30) X, Y = np.meshgrid(x, y) Z = f(X, Y) fig = plt.figure() ax = plt.axes(projection='3d') ax.contour3D(X, Y, Z, 50, cmap='binary') ax.set_xlabel('x') ax.set_ylabel('y') ax.set_zlabel('z'); # ## Models of bumblebee population growth over many seasons # # ### Infinite resources (exponential growth) # Assuming infinite resources in the environment (probably never the case in nature for bees) and nothing systematically killing populations, bumblebee populations will increase at $\frac{dx}{dt}= kx$, which solves to $x(t)= Ce^{kt}$. k is just some growth constant. # # ### Finite resources (logistic growth) # With finite resources, bee populations will grow according to $\frac {dx}{dt}=kx(1-\frac{x}{C})$, where k is a growth constant and C is the carrying capacity of the environment. An analytic solution is $x=\frac{C}{1+Ae^{-kt}}$ where $A=\frac{C-X_{0}}{X_{0}}$. # # ### Finite resources + big bad pesticides. # Now let's introduce neonicotinoid into the equation once the bees have reached carrying capacity. These pesticides both kill bees directly and decrease their reproductive capacity, so here I'll have a lower k as well as some constant d representing a proportion of bee deaths. # This scenario is represented by the differential equation $\frac{dx}{dt}= (k-d)x$, which solves to $x(t)= Ce^{(k-d)t}$ # In[3]:
from matplotlib import axes as ax from mpl_toolkits.mplot3d import Axes3D import numpy as np x, y, z, vx, vy, vz = np.loadtxt('./coordAa.dat.txt', unpack=True) print(len(x)) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(x, y, z, c='r', marker='.', s=0.1) #Axes3D.scatter(x,y,z) ax.set_xlabel('X [kpc]') ax.set_ylabel('Y [kpc]') ax.set_zlabel('Z [kpc]') #plt.axis([-1500., 1500., -1500., 1500, -1500, 1500]) ax.set_xlim3d(-1500, 1500) ax.set_ylim3d(-1500, 1500) ax.set_zlim3d(-1500, 1500) plt.show() radius = sorted([ np.sqrt(i**2 + j**2 + k**2) for i, j, k in zip(x, y, z) if np.sqrt(i**2 + j**2 + k**2) <= 300 ]) max_radius = max(radius) min_radius = min(radius) print(max_radius, min_radius)
total += x * y new[i][j] = total return new elif self.m == other.n: return other * self else: raise ValueError( "Cannot multiply two matrices of incompatable dimensions") if __name__ == "__main__": fig = plt.figure() ax = fig.gca(projection="3d") v3 = AVector("sin(x)", "cos(y)", "tan(z)") v3.quiver(ax) a, b, c = v3.evaluate(1, 1, 1) print(a, b, c) ax.set_xlabel("sin(x)") ax.set_ylabel("cos(y)") ax.set_zlabel("tan(z)") plt.show()