private void AssignCutoffLambdaValues() { try { var peakLambdaIndex = ELSpecList.FindIndex(x => x.Intensity == ELSpecList.Max(y => y.Intensity)); //find the index of the EL peak var presentIntensity = ELSpecList[peakLambdaIndex].Intensity; //find the peak intensity (should be 1.0 but this is safer) var indexCounter = peakLambdaIndex; //start counting at the peak while (presentIntensity > _cutoffHeuristic && indexCounter > 0) //search for the first index where the intensity is less than the cutoffHeuristic { indexCounter--; presentIntensity = ELSpecList[indexCounter].Intensity; } MinLambdaCutoff = ELSpecList[indexCounter].Wavelength; //get the wavelength at the cutoff index indexCounter = peakLambdaIndex; //rinse and repeat but in the opposite direction presentIntensity = ELSpecList[peakLambdaIndex].Intensity; while (presentIntensity > _cutoffHeuristic && indexCounter < ELSpecList.Count - 1) { indexCounter++; presentIntensity = ELSpecList[indexCounter].Intensity; } MaxLambdaCutoff = ELSpecList[indexCounter].Wavelength; } catch (Exception e) { Debug.WriteLine("Exception at ELSpecVM AssignCutoffLambdaValues(): " + e.ToString()); } }
private void LoadELSpecDataIntoList(string fp) { try { using (var sr = new StreamReader(fp)) { var reader = new CsvReader(sr); ELSpecList = reader.GetRecords <ELSpecDatum>().ToList <ELSpecDatum>(); var maxIntensity = ELSpecList.Max(i => i.Intensity); foreach (ELSpecDatum d in ELSpecList) { d.Intensity = d.Intensity / maxIntensity; } } } catch (Exception e) { MessageBox.Show(e.ToString()); } }