-1

I have a laser that is sent through a signal splitter. 90% of the light goes into a diffuser and that is detected by a Photomultiplier tube (PMT). The other 10% of the signal goes to a separate silicon photodiode that is used to monitor the power of the laser during diffuser testing. The diffuser is rotated through a range of -60° to +60° and stops every 3° to record the area of the optical signal from both the PMT and the photodiode (this is referred to as one scan). The data recorded by the photodiode is used to normalize the area of the PMT like this:

angle1 = np.array(PMT1[0]), area1 = np.array(PMT[1])
p1 = np.array(diode1[1]), `area1_norm = area1 * 0.01 / p1 

The data is in terms of (x,y) = ([angle], [area]). I want to calculate the average and the standard deviation for the normalized PMT area at each angular position of the diffuser. So say for three sets of photodiode areas:

PMT1 = ([-60,-57,-54,-51,-48,-45,-42,-39,-36,-33,-30,-27,-24,-21,-18,-15,-12,-9,-6,-3,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60],[7.099,7.317,7.543,7.811,7.955,8.194,8.292,8.558,8.862,8.906,9.166,9.265,9.354,9.641,9.748,9.856,9.906,9.805,9.936,9.950,9.892,9.944,9.867,9.808,9.696,9.732,9.624,9.480,9.389,9.244,9.187,8.955,8.673,8.538,8.227,8.161,7.966,7.679,7.442,7.307,7.017])
diode1 = ([-60,-57,-54,-51,-48,-45,-42,-39,-36,-33,-30,-27,-24,-21,-18,-15,-12,-9,-6,-3,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60],[0.01011,0.01007,0.01013,0.01005,0.01014,0.01018,0.01013,0.01021,0.01020,0.01020,0.01019,0.01028,0.01021,0.01026,0.01025,0.01020,0.01024,0.01029,0.01019,0.01023,0.01027,0.01019,0.01031,0.01030,0.01031,0.01034,0.01021,0.01019,0.01019,0.01025,0.01034,0.01020,0.01024,0.01029,0.01011,0.01013,0.01025,0.01013,0.01025,0.01004,0.01003])
 
PMT2 = ([-60,-57,-54,-51,-48,-45,-42,-39,-36,-33,-30,-27,-24,-21,-18,-15,-12,-9,-6,-3,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60],([6.947,7.196,7.376,7.610,7.853,8.096,8.299,8.410,8.567,8.702,8.896,9.1429.425,9.400,9.527,9.654,9.614,9.870,9.943,9.998,10.05,9.969,9.951,9.957,9.828,9.803.9.629,9.419,9.313,9.170,9.084,8.885,8.793,8.513,8.328,8.130,7.939,7.677,7.431,7.184,6.905])
diode2 = ([-60,-57,-54,-51,-48,-45,-42,-39,-36,-33,-30,-27,-24,-21,-18,-15,-12,-9,-6,-3,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60],[0.01016,0.01004,0.01019,0.01023,0.01018,0.01022,0.01036,0.01027,0.01023,0.01034,0.01033,0.01026,0.01028,0.01040,0.01035,0.01034,0.01032,0.01039,0.01021,0.01036,0.01035,0.01025,0.01024,0.01035,0.01034,0.01030,0.01028,0.01038,0.01020,0.01024,0.01028,0.01017,0.01014,0.01025,0.01022,0.01025,0.01022,0.01025,0.01022,0.01025,0.01021])
 
PMT3 = ([-60,-57,-54,-51,-48,-45,-42,-39,-36,-33,-30,-27,-24,-21,-18,-15,-12,-9,-6,-3,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60],[7.116,7.364,7.668,7.868,8.011,8.321,8.567,8.699,8.876,9.154,9.346,9.591,9.524,9.744,9.969,9.989,10.08,10.20,10.16,10.13,10.19,10.11,10.03,10.03,9.936,9.732,9.655,9.492,9.305,9.245,9.120,8.877,8.833,8.635,8.470,8.217,7.980,7.844,7.534,7.336,6.966])
diode3 = ([-60,-57,-54,-51,-48,-45,-42,-39,-36,-33,-30,-27,-24,-21,-18,-15,-12,-9,-6,-3,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60],[0.01016,0.01004,0.01019,0.01023,0.01018,0.01022,0.01036,0.01027,0.01023,0.01034,0.01033,0.01026,0.01028,0.01040,0.01035,0.01034,0.01032,0.01039,0.01021,0.01036,0.01035,0.01025,0.01024,0.01035,0.01034,0.01030,0.01028,0.01038,0.01020,0.01024,0.01028,0.01017,0.01014,0.01025,0.01022,0.01025,0.01022,0.01025,0.01022,0.01025,0.01021,0.01006,0.01021,001020,0.01012])

I would use diode1 data to normalize the y values in PMT1 and so forth. The x values are the same for each data set because they're just repeated scans. I am interested in calculating the average and standard deviation for the y values (for the PMT) at each corresponding x angle. So for each angle, I should have one value for the average normalized PMT area and one value for the standard deviation of the normalized PMT area. I hope that makes sense and thank you in advance for the help!

Mr. T
  • 11,960
  • 10
  • 32
  • 54
  • So it is three sets of data. One data set has both a PMT and a corresponding photodiode. So in the experiment, the diffuser is rotated through the angles. The PMT and photodiode area are recorded simultaneously. The photodiode area is used to normalize the corresponding PMT area using the code I provided. So from after the normalization process, I have three new sets of PMT data- area1_norm, area2_norm, area3_norm in the form of x,y = (angle, area) like before. I need to know the average and the standard deviation for the area of all the new, normalized PMT areas at each angle. – Rachel Fister Jan 16 '22 at 16:02
  • It does not have to do with my actual question- it is just important that it is used to normalize the PMT data before the average/standard deviation of that data is taken. So if you can see how I use the diode data to normalize the PMT data, and turn it into the ara1_norm, etc. I then need the average/standard deviation of that new area1_norm data. And yes, I wish I had thought of only including a few angles for simplicity. My actual data contains 20 scans so I limited it to 3 thinking that was making it easier. But I didn't think of that as well, I am sorry. – Rachel Fister Jan 16 '22 at 16:40
  • 1
    No worries, you are new here. Please read [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) and [What does it mean when an answer is "accepted"?](https://stackoverflow.com/help/accepted-answer) Help us to help you by writing good questions - questions that reflect your problem but are short and to the point. – Mr. T Jan 16 '22 at 16:51
  • That is excellent, I will take a look! Thank you very much for all of the help. Have a good day. – Rachel Fister Jan 16 '22 at 16:56
  • So I am looking at this and it doesn't work unfortunately. Before taking the standard deviation of the PMT data, it must be normalized using the photodiode area. I provided my section of the code that does that. So using that, how do I take the standard deviation of the new PMT area, defined as area1_norm, etc? – Rachel Fister Jan 17 '22 at 08:43
  • nevermind, I figured it out. Thank you – Rachel Fister Jan 17 '22 at 09:49

1 Answers1

0

It seems you want to calculate the mean and standard deviation over three lists.

import numpy as np

PMT1 = ([-60,-57,-54,-51,-48,-45,-42,-39], [7.099,7.317,7.543,7.811,7.955,8.194,8.292,8.558])
diode1 = ([-60,-57,-54,-51,-48,-45,-42,-39], [0.01011,0.01007,0.01013,0.01005,0.01014,0.01018,0.01013,0.01021])
 
PMT2 = ([-60,-57,-54,-51,-48,-45,-42,-39], [6.947,7.196,7.376,7.610,7.853,8.096,8.299,8.410])
diode2 = ([-60,-57,-54,-51,-48,-45,-42,-39], [0.01016,0.01004,0.01019,0.01023,0.01018,0.01022,0.01036,0.01027])
 
PMT3 = ([-60,-57,-54,-51,-48,-45,-42,-39], [7.116,7.364,7.668,7.868,8.011,8.321,8.567,8.699])
diode3 = ([-60,-57,-54,-51,-48,-45,-42,-39], [0.01016,0.01004,0.01019,0.01023,0.01018,0.01022,0.01036,0.01027])

PMT_angles=np.asarray(PMT1[0])

PMT_areas = np.asarray([PMT1[1], PMT2[1], PMT3[1]])
PMT_area_mean = PMT_areas.mean(axis=0)
PMT_area_std = PMT_areas.std(axis=0)

print("data are not normalized", PMT_angles, PMT_area_mean, PMT_area_std, sep="\n")


diodes = np.asarray([diode1[1], diode2[1], diode3[1]])
PMT_areas_norm = PMT_areas * 0.01 / diodes
PMT_area_norm_mean = PMT_areas_norm.mean(axis=0)
PMT_area_norm_std = PMT_areas_norm.std(axis=0)

print("normalized data", PMT_angles, PMT_area_norm_mean, PMT_area_norm_std, sep="\n")

Sample output:

data are not normalized
[-60 -57 -54 -51 -48 -45 -42 -39]
[7.054      7.29233333 7.529      7.763      7.93966667 8.20366667
 8.386      8.55566667]
[0.07597807 0.07076879 0.11961884 0.11066165 0.06540812 0.09210984
 0.12801823 0.11799529]
normalized data
[-60 -57 -54 -51 -48 -45 -42 -39]
[6.95443202 7.25604302 7.40323101 7.63404969 7.8095549  8.03757223
 8.15517005 8.34706   ]
[0.08293366 0.06868433 0.12086692 0.1418983  0.06818333 0.09024843
 0.10777657 0.11750536]
Mr. T
  • 11,960
  • 10
  • 32
  • 54