python
138 posts — page 10
-
using numpy dtype with loadtxt
Let's say you want to read a text file like this: filename start end fdsafda.fits 23143214 23143214 safdsafafds.fits 21423 23423432 you can use dtype to create a custom array, which is very flexible as you can work by row or columns with strings and floats in the same array: dt=np.dtype({'names':['filename','start','end'],'formats':['S100',np.float,np.float]}) [I tried also using np.str instead of S100 without success, anyone knows why?] then give this as input to loadtxt to load the file and create the array.
-
Stop ipcluster from a script
Ipcluster is easy to start but not trivial to stop from a script, after having finished the processing, here's the solution: from IPython.kernel import client mec = client.MultiEngineClient() mec.kill(controller=True)
-
load arrays from a text file with numpy
space separated text file with 5 arrays in columns: [sourcecode language="python"] ods,rings,gains,offsets,rparams = np.loadtxt(filename,unpack=True) [/sourcecode] quite impressive...