Fix get_events() for CoMPASS csv files with waveforms #82
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In working with the BABY-1L-Run-2 foil activation data, libra-toolbox failed to upload the spectra from CoMPASS csv files with waveforms present. This PR fixes that problem.
Without this PR, the pandas.read_csv() function will read in the first csv file with a column header of length 8 even though the rows with actual data have 207 columns. The function will then assume that the last 8 columns are the correct ones, resulting in incorrect data assignment. And in reading any subsequent csv files that do not have a column header in the first row, get_events() function fails when trying to assign only 8 columns to data with 207 columns.
What this PR's version of get_events() does is to manually read just the first row of the first csv file with the column headers, and determine which column indices apply to the "TIMETAG" and "ENERGY" columns. Then it reads in the first csv file, skipping the first row which has the header, and indexes the times and energy values using the column indices determined previously. For all csv files after the first one, no rows are skipped in reading in the CSV file, and the same predetermined number indices are used to index the time and energy columns instead of indexing with
["TIMETAG"]and ["ENERGY"].