I have a 32 core machine with 256gb ram and am new to parallel computing. I have to run this line:
Flag=data.flag [:,:,x]
which is a very large matrix. "x" refers to the sub-matrix that I want to store to file. But "changes" 64 times and each iteration takes +- 8min, hence the need to parallelize it
I've looked at a few examples: https://www.machinelearningplus.com/python/parallel-processing-python/ and https://docs.python.org/3.7/library/multiprocessing.html#multiprocessing-programming
Function for code:
def multi_flagger(antenna_no):
recv=data.corr_products[antenna_no][0] # Gets the antenna name and polarization value
flagger=data.flags[:, :, antenna_no] # Flags the data based on the antenna value
mat_flag = np.matrix(flagger) # Morphs the 2d array into a matrix
np.save('Flagged_data_'+str(recv)+'_.npy', mat_flag) # Saves the data to a file
pool.map(multi_flagger, for i in range(2))
pool.close()
I get this error:
File "<ipython-input-58-e1a6f9779b9a>", line 1 pool.map(multi_flagger, for i in range(2)) ^ SyntaxError: invalid syntax`
What I would like is 64 .npy files written to disk