I have a function
def dist_to_center(ra_center,dec_center):
# finding theta
cos_ra = np.cos(ra_center-var1['ra'])
cos_dec = np.cos(dec_center-var1['dec'])
sin_dec = np.sin(dec_center)*np.sin(var1['dec'])
theta = np.arccos((cos_ra*cos_dec)+sin_dec*(1-cos_ra))
numerator = theta*comoving_dist
denominator = 1+var1['zcosmo']
# THE FINAL CALCULATED DISTANCE TO CENTRE
dist_to_center = (numerator/denominator)
return dist_to_center
I want to make use of my processors, so I am using multiprocess pool like this:
if __name__ == '__main__':
pool = Pool(processes=6)
pool.map(dist_to_center, ra_center, dec_center) #calling the function with it's inputs
pool.close()
pool.join()
The code seems to be proper and is working, but only 1 processor is running instead of the 6 I have called. What am I doing wrong here?
ra_center.shapeanddec_center.shape?ra_centeranddec_centerare one-dimensional arrays when you callpool.map()?ra_centeranddec_centerare numpy array's which are inputs for my function. Should I not call them inpool.map?? Because I thoughtpool.maptakes the function and then it's inputs