Beispiel #1
0
        public TextData(string inpfile)
        {
            //calParams = new List<double> { -1.0e-4, 1.4e-17, -8.7e-19 };
            effMeas = new ObservableEntityCollection <EfficiencyMeasurement>();
            double eff    = 0.9999999999999;
            double effunc = 0.000000000005;

            effMeas.Add(new EfficiencyMeasurement(Properties.Settings.Default.LOWERELIMT, eff, effunc));
            effMeas.Add(new EfficiencyMeasurement((Properties.Settings.Default.LOWERELIMT + Properties.Settings.Default.UPPERELIMIT) / 2, eff, effunc));
            effMeas.Add(new EfficiencyMeasurement(Properties.Settings.Default.UPPERELIMIT, eff, effunc));
            order = 2;
            effMeas.CollectionChanged += EffMeas_CollectionChanged;
            GetCalibrationParameters();
            //define the defult delimiter
            delimiter = ',';
            //define the defult column order
            columnOrder = new List <InputColumns>()
            {
                InputColumns.Energy, InputColumns.Area, InputColumns.AreaUnc, InputColumns.Other, InputColumns.FWHM, InputColumns.Other,
                InputColumns.Other, InputColumns.TotalCounts
            };

            acqTime     = DateTime.MinValue;
            collTime    = DateTime.MinValue;
            elapsedWait = collTime - acqTime;
            countTime   = 0.0;
            file        = inpfile;
        }
Beispiel #2
0
        public UserSpecData(string inpfile)
        {
            //calParams = new List<double> { -1.0e-4, 1.4e-17, -8.7e-19 };
            effMeas = new ObservableEntityCollection <EfficiencyMeasurement>();
            double eff    = 0.9999999999999;
            double effunc = 0.000000000005;

            effMeas.Add(new EfficiencyMeasurement(Properties.Settings.Default.LOWERELIMT, eff, effunc));
            effMeas.Add(new EfficiencyMeasurement((Properties.Settings.Default.LOWERELIMT + Properties.Settings.Default.UPPERELIMIT) / 2, eff, effunc));
            effMeas.Add(new EfficiencyMeasurement(Properties.Settings.Default.UPPERELIMIT, eff, effunc));
            order = 2;
            GetCalibrationParameters();

            effMeas.CollectionChanged += EffMeas_CollectionChanged;
            acqTime     = DateTime.MinValue;
            collTime    = DateTime.MinValue;
            elapsedWait = collTime - acqTime;
            countTime   = 0.0;
            file        = inpfile;
        }
Beispiel #3
0
        /// <summary>
        /// Gets the peak inforamtion async
        /// </summary>
        /// <param name="peaks"></param>
        /// <returns></returns>
        public override async Task LoadDataAsync(DataTable peaks)
        {
            /**********get the data async******/
            camfile.ReadFile(file);
            //time
            Task <DateTime> acqTask  = Task.Run(() => camfile.GetAqusitionTime());
            Task <DateTime> sampTask = Task.Run(() => camfile.GetSampleTime());
            Task <double>   liveTask = Task.Run(() => camfile.GetLiveTime());
            //sepectrum
            Task <uint[]> specTask = Task.Run(() => camfile.GetSpectrum());
            //peaks
            Task <Peak[]> peakTask = Task.Run(() => camfile.GetPeaks().ToArray());
            //calibrations
            Task <double[]>          ecalTask     = Task.Run(() => camfile.GetEnergyCalibration());
            Task <double[]>          shapeCalTask = Task.Run(() => camfile.GetShapeCalibration());
            Task <EfficiencyPoint[]> effCalTask   = Task.Run(() => camfile.GetEfficiencyPoints().ToArray());

            //assign variables
            collTime    = await sampTask;
            acqTime     = await acqTask;
            elapsedWait = collTime - acqTime;
            countTime   = await liveTask;
            spectrum    = await specTask;


            //assign the calibration info
            energyCoeff = await ecalTask;
            shapeCoeff  = await shapeCalTask;
            //efficiency is not necessary, if there isn't efficiency calibration add some defaults
            try
            {
                effMeas = new ObservableEntityCollection <EfficiencyMeasurement>();
                EfficiencyPoint[] effpts = await effCalTask;
                if (effpts.Length < 2)
                {
                    throw new FileFormatException("Not enough efficiency points to perfom calculations");
                }

                for (int i = 0; i < effpts.Length; i++)
                {
                    effMeas.Add(new EfficiencyMeasurement(effpts[i].Energy, effpts[i].Efficiency, effpts[i].EfficiencyUncertainty));
                }
            }
            catch (FileFormatException)
            {
                double eff    = 0.9999999999999;
                double effunc = 0.000000000005;
                effMeas.Add(new EfficiencyMeasurement(Properties.Settings.Default.LOWERELIMT, eff, effunc));
                effMeas.Add(new EfficiencyMeasurement((Properties.Settings.Default.LOWERELIMT + Properties.Settings.Default.UPPERELIMIT) / 2, eff, effunc));
                effMeas.Add(new EfficiencyMeasurement(Properties.Settings.Default.UPPERELIMIT, eff, effunc));
                order = 2;
            }

            effMeas.CollectionChanged += EffMeas_CollectionChanged;
            //assign the peaks
            Peak[] filePeaks = await peakTask;
            //add the peaks to the datatable
            foreach (Peak pk in filePeaks)
            {
                DataRow row = peaks.NewRow();
                row["ENERGY"]    = pk.Energy;
                row["FWHM"]      = pk.FullWidthAtHalfMaximum;
                row["AREA"]      = pk.Area;
                row["AREAUNC"]   = pk.AreaUncertainty;
                row["CONTINUUM"] = pk.Continuum;
                row["CRITLEVEL"] = pk.CriticalLevel;
                peaks.Rows.Add(row);
            }
            order     = effMeas.Count > 7 ? 5 : effMeas.Count > 2 ? effMeas.Count - 2 : 3;
            calParams = GetCalibrationParameters();
        }