【发布时间】:2015-12-05 17:37:18
【问题描述】:
我正在制作一个常量列表,其中一个常量完全等于结构化数组。此值用于另一个常数,会产生一些问题。
path = '/users/unsername/Desktop/untitled 文件夹/python 文件/MSII_phasespace/'
os.chdir( path )
data = np.load('msii_phasespace.npy',mmap_mode='r')
# data.size: 167197
# data.shape: (167197,)
# data.dtype: dtype([('x', '<f4'), ('y', '<f4'), ('z', '<f4'),
# ('velx', '<f4'), ('vely', '<f4'), ('velz', '<f4'), ('m200', '<f4')])
## Constants
# Assuming the mean density is close to the critical density of the universe
rho_m = 3.3e-14 # kg km^-3
# rho_0 = 0.27 * 10**((-1)*26) km m^-3 // current density
M = data[:] # kg // Mass of dark matter haloes
R = ((3*M)/((rho_m)*4*(np.pi))**(1.0/3.0) # Km // Radius of sphere
# k = 0.001 # Mpc h^-1 // Wave Dispersion relation
k = (0.02) # Mpc^-1 // Current best normalization scale
delt_c = 1.686 # Critical overdensity of spherical collapse.
h = 73 # km s^-1 Mpc^-1 // Hubbles Constant in the simulation
e = 2.718281 # Eulers number
T_CMB = 2.725 # k // Temperature of present Cosmic Microwave Background
Omega_m = 0.27 # Mass density of current time by WMAP, z = 0
保留 R 会显示之后的值,例如 k 和 delt_c 会出现Invalid Syntax 错误。当我消除 R 值时,它将消除所有错误。我怎样才能解决这个问题?我认为罪魁祸首是我的M = data[:]值
【问题讨论】:
标签: python arrays syntax invalid-argument