Conversation
…cattering only particles
…IncandScatNumEnsemble with core and shell diameters.
…ult is Flase. Set to True for leo fits.
|
Ah. I need to change the tests as well. Now beam_shape test removed for now. |
rcjackson
left a comment
There was a problem hiding this comment.
Overall, this is really good. Some more documentation is needed, as well as unit tests for each of the LEO fit types. In addition, I request that commented out code be removed from the final version (comment notes are fine).
pysp2/util/leo_fit.py
Outdated
| my_high_gain_scatterers['PkHt_ch0'].values))/ \ | ||
| np.sum(my_high_gain_scatterers['PkHt_ch0'].values)) | ||
| #high_gain_split_position = my_high_gain_scatterers['PkSplitPos_ch3'].values | ||
| #low_gain_split_position = my_low_gain_scatterers['PkSplitPos_ch7'].values |
There was a problem hiding this comment.
Please remove commented out code.
pysp2/util/leo_fit.py
Outdated
| #normalize the profile to range [~0,1] | ||
| profile_ch4 = (data_ch4 - base_ch4) / peak_height_ch4 | ||
| #insert the profile as it was recorded (no shifting due to PEAK POSITION or PSD POSITION) | ||
| #my_high_gain_profiles_[i,:] = profile |
There was a problem hiding this comment.
More commented out code to remove at this line.
pysp2/util/leo_fit.py
Outdated
| # moving_average_window, axis=0) | ||
| #moving_median_high_gain_base = np.nanpercentile(moving_high_gain_base, 10,axis=1) | ||
| #moving_median_low_gain_base = np.nanpercentile(moving_low_gain_base, 10,axis=1) | ||
|
|
There was a problem hiding this comment.
Past 4 lines here are commented out code that should not be in the final product if not used.
| #leo_Base_ch0[iloc_high_gain[:-moving_average_window+1]] = moving_median_high_gain_base | ||
| #leo_Base_ch4 = np.zeros(scatter_low_gain_accepted.shape)*np.nan | ||
| #leo_Base_ch4[iloc_low_gain[:-moving_average_window+1]] = moving_median_low_gain_base | ||
|
|
There was a problem hiding this comment.
Please remove this block of commented code.
pysp2/util/leo_fit.py
Outdated
| * LAST BIN TO USE FOR LEO FIT (from split detector) (DONE) | ||
| * do also for LG. | ||
| * TAKE BASELINE SCAT FROM ACTUAL TRACERS IN LEO_FIT | ||
| """ |
There was a problem hiding this comment.
I would put this into the docstring section under a new "Notes" section to inform the user about what is done and what needs to be implemented.
There was a problem hiding this comment.
I removed this because it has already been implemented and those notes were mostly for my self.
pysp2/util/leo_fit.py
Outdated
| #Low gain | ||
| for i in range(my_binary.sizes['event_index']): | ||
| #max_value = data_ch0[i,:].max() - data_ch0[i,:].min() | ||
| #bins_ = bins[num_base_pts_2_avg:leo_fit_max_pos[i]] |
There was a problem hiding this comment.
Commented lines of code to remove.
| from .DMTGlobals import DMTGlobals | ||
|
|
||
| def calc_diams_masses(input_ds, debug=True, factor=1.0, Globals=None): | ||
| def calc_diams_masses(input_ds, debug=True, factor=1.0, Globals=None, leo_fits=False): |
There was a problem hiding this comment.
Please add documentation for the leo_fits flag in the docstring below.
There was a problem hiding this comment.
I added text to the documentation.
pysp2/util/particle_properties.py
Outdated
| print("Number of incandescence particles rejected for min. peak height = %d" % rejectMinIncandTotal) | ||
| print("Number of incandescence particles rejected for peak width = %d" % rejectIncandWidthTotal) | ||
| #print("Number of incandescence particles rejected for fat peak = %d" % rejectFatPeakTotal) | ||
| #print("Number of incandescence particles rejected for peak pos. = %d" % rejectFtPosTotal) |
There was a problem hiding this comment.
I would keep as much debug output as possible, so if these two new rejection criteria are recorded, I would keep them in.
There was a problem hiding this comment.
Those commented out lines are from the scattering channels. So I removed them. They are shown earlier. The lines that are not commented out (98-100) are rejection criteria that have not previously been shown for incandescence.
| leo_Scat_not_sat = 1e-18 * (Globals.c0Scat1 + Globals.c1Scat1*leo_PkHt_ch0 + Globals.c2Scat1*leo_PkHt_ch0**2) | ||
| leo_Scat_sat = 1e-18 * (Globals.c0Scat2 + Globals.c1Scat2*leo_PkHt_ch4 + Globals.c2Scat2*leo_PkHt_ch4**2) | ||
| leo_Scatter = np.where(PkHt_ch0 < Globals.ScatMaxPeakHt1, leo_Scat_not_sat, leo_Scat_sat) | ||
| #leo_Scatter = np.where(accepted_incand, leo_Scatter, np.nan) |
There was a problem hiding this comment.
Please remove if not used.
tests/test_gfit.py
Outdated
| #coeff, beam_profile = pysp2.util.beam_shape( | ||
| # my_binary, beam_position_from='peak maximum', Globals=pysp2.util.DMTGlobals()) | ||
| #np.testing.assert_almost_equal(coeff, [9.83851858e-01, 4.64317390e+01, | ||
| # 1.14337852e+01, 4.46761788e-03]) |
There was a problem hiding this comment.
I would make unit tests for each of your beam_position_from flags.
There was a problem hiding this comment.
Good point! Now I've added those as well.
…o match the rest of the code
|
Now all the requested changes should have been done, including unit tests for the leo_fit() function. |
Changed typo.
|
This looks good to go. I am merging. I will cut a new PySP2 release here shortly. |
First (beta) version of a working version of LEO fits for PySP2. Work is still needed on the details/tweaks, but the essentials should be there to expand on.