0

I'm a making a list of constants in which one of the constants is exactly equal to a structured array. This value is used in another constant that creates a few problems.

path = '/users/unsername/Desktop/untitled folder/python files/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 

Keeping R shows the the values after, like k and delt_c to have a Invalid Syntax error. When i eliminated the R value, it'll remove all errors. How can I fix this? I think the main culprit is my M = data[:] value

iron2man
  • 1,787
  • 5
  • 27
  • 39

1 Answers1

1

You missed a closing bracket in the line defining M. Replace

((3*M)/((rho_m)*4*(np.pi))**(1.0/3.0)

with

((3*M)/((rho_m)*4*(np.pi))**(1.0/3.0)) # missed closing bracket at end of line
albert
  • 8,027
  • 10
  • 48
  • 84
  • oops. my bad. One last question, am i defining M correctly? – iron2man Dec 05 '15 at 17:46
  • That depends on what `data` is like... I might help you if you could provide some further information about `data`. If I solved your question please tick my answer in order to mark you question as answered. – albert Dec 05 '15 at 17:49
  • I will, it has a 5 minute timer. The array is just a large list of masses. The size is 167197 and the shape (167197,). I'm trying to use this whole list for a calculation i am trying to do. – iron2man Dec 05 '15 at 17:53
  • So you should take a look at [this answer](http://stackoverflow.com/a/509295/3991125) explaining how to slice a list and access the desired element. If you want to use every list element and redo all your calculation steps for each element contained in the list I would suggest a somehow `for element in list` loop. – albert Dec 05 '15 at 18:01