Jul-14-2020, 11:45 AM
I'm trying to save a txt file by manually entering the energy values in our experiment, but the code runs an error:
b = np.broadcast(*args[:32]) ValueError: shape mismatch: objects cannot be broadcast to a single shapeThe code looks like this:
name='I1' scan_number=np.array([23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) n_pts = 701 n_chnl = 4096 mca_start = 3116 name='I0' scan_number=np.array([45, 46, 47]) n_pts = 701 n_chnl = 4096 mca_start = 17138 x=np.arange(1, n_pts+1) energy=np.arange(7.65e+03, 8e+03, 0.5)
np.savetxt(file, np.transpose(([energy, area[:,0], area[:,0]])), header='Energy I0 I1 {}'.format(name))How do I fix this error? I should have energy values from 7.65 to 8.00 keV with 0.5 step / 701 points in the energy column, but the np.arange command doesn't seem to work.