Skip to content

Commit 79998ed

Browse files
author
Sherwood Richers
committed
output hdf5 data without producing errors
1 parent 174d837 commit 79998ed

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

spinflip/angle_multiprocess_tools.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ def multiprocess_angles(self,
115115

116116
#compute angles at each point in ranges using multiprocess
117117
with Pool(n_cores) as pool:
118-
output_angles = pool.map(angle_at_point, iterable)
118+
output_angles = []
119+
for x in tqdm(pool.imap_unordered(angle_at_point, iterable), total = len(iterable)):
120+
output_angles.append(x)
121+
#output_angles = pool.map(angle_at_point, iterable)
119122

120123
#reshape output
121124
output_angles = np.array(output_angles).reshape(len(xs),len(ys),len(zs))
@@ -170,7 +173,7 @@ def solid_angles_plot(self,
170173
#colorbar
171174
plt.tight_layout()
172175
f.colorbar(im, label=r'Solid Angle (log)', location = 'bottom',ax=ax.ravel().tolist(), pad = 0.1,aspect=30)
173-
176+
174177
#axis labels
175178
middle_n = n//2
176179
ax[0,middle_n].set_xlabel(r'$x$-coordinate (km)', fontsize = 14)
@@ -219,7 +222,7 @@ def main(args):
219222
**kwargs)
220223

221224
#compute angles
222-
angles = Angles_obj.multiprocess_angles(h5_filename)
225+
angles = Angles_obj.multiprocess_angles(h5_filename=h5_filename)
223226

224227
#plot angles
225228
Angles_obj.solid_angles_plot(angles,
@@ -244,7 +247,7 @@ def main(args):
244247
parser.add_argument("-v", "--vmin", help="vmin for plot", type=float, default=None)
245248
parser.add_argument("-w", "--vmax", help="vmax for plot", type=float, default=None)
246249
parser.add_argument("-o", "--savefig", help="where to save plot", type=str, default='solidangleplot')
247-
parser.add_argument("-k", "--h5_filename", help="where to save h5 file", type=str, default=None)
250+
parser.add_argument("-k", "--h5_filename", help="where to save h5 file", type=str, default="angles")
248251
parser.add_argument("-a", "--kwargs", help="kwargs for solid angle calculation", type=dict, default={})
249252
args = parser.parse_args()
250253
main(args)

0 commit comments

Comments
 (0)