Esempio n. 1
0
        private void MakeED()
        {
            //Fill Rho array
            try
            {
                RhoCalc.IsOneSigma      = Holdsigma.Checked;
                RhoCalc.ZOffset         = Zoffset.ToDouble();
                RhoCalc.GetSubRoughness = SubRough.ToDouble();
                RhoCalc.BoxCount        = BoxCount.ToInt();
                RhoCalc.SubphaseSLD     = SubphaseSLD.ToDouble();
                RhoCalc.SuperphaseSLD   = SupSLDTB.ToDouble();

                //Blank our Rho data from the previous iteration
                RhoCalc.RhoArray.Clear();
                RhoCalc.LengthArray.Clear();
                RhoCalc.SigmaArray.Clear();

                BoxRhoArray.ForEach(p => RhoCalc.RhoArray.Add(p.ToDouble()));
                BoxLengthArray.ForEach(p => RhoCalc.LengthArray.Add(p.ToDouble()));
                BoxSigmaArray.ForEach(p => RhoCalc.SigmaArray.Add(p.ToDouble()));

                if (Holdsigma.Checked)
                {
                    ChangeRoughnessArray();
                }

                GreyFields();

                RhoCalc.UpdateProfile();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Esempio n. 2
0
        public override void SaveParamsForReport()
        {
            ReportGenerator g = ReportGenerator.Instance;

            g.ClearReflModelInfo();
            int arrayconst = 2;

            List <string> ginfo = new List <string>();

            if (HoldsigmaCB)
            {
                ginfo.Add("The reflectivity curve was fit with a single roughness parameter\n");
            }
            else
            {
                ginfo.Add(String.Format("The reflectivity curve was fit with {0} roughness parameters\n", BoxCountTB + 1));
                arrayconst = 3;
            }

            ginfo.Add("Percent Error in Q: " + QSpreadTB.ToString() + "\n");
            ginfo.Add("Normalization Factor: " + NormalizationFactor.ToString() + "\n");
            ginfo.Add("Low Q Offset: " + LowQOffset.ToString() + "\n");
            ginfo.Add("High Q Offset: " + HighQOffset.ToString() + "\n");
            ginfo.Add("Superphase SLD: " + SubphaseSLDTB.ToString() + "\n");
            ginfo.Add("Subphase SLD: " + SubphaseSLD.ToString() + "\n");
            ginfo.Add("Wavelength: " + WavelengthTB.ToString() + "\n");
            ginfo.Add("Chi Square for reflectivity fit: " + ChiSquare.ToString() + "\n");
            ginfo.Add(string.Format("The subphase roughness was: {0:#.### E-0} " + (char)0x00B1 + " {1:#.### E-0}\n", SubRoughTB, CovarArray[0]));


            for (int i = 0; i < BoxCountTB; i++)
            {
                ginfo.Add((i + 1).ToString());
                ginfo.Add(LengthArray[i].ToString("#.### E-0") + " " + (char)0x00B1 + " " + CovarArray[arrayconst * i + 1].ToString("#.### E-0"));

                if (!m_bUseSLD)
                {
                    ginfo.Add(RhoArray[i].ToString("#.### E-0") + " " + (char)0x00B1 + " " + CovarArray[arrayconst * i + 2].ToString("#.### E-0"));
                }
                else
                {
                    ginfo.Add((RhoArray[i] * SubphaseSLDTB).ToString("#.### E-0") + " " + (char)0x00B1 + " " + (CovarArray[arrayconst * i + 2] * SubphaseSLDTB).ToString("#.### E-0"));
                }

                if (HoldsigmaCB)
                {
                    ginfo.Add(SigmaArray[i].ToString("#.### E-0") + " " + (char)0x00B1 + " " + CovarArray[0].ToString("#.### E-0"));
                }
                else
                {
                    ginfo.Add(SigmaArray[i].ToString("#.### E-0") + " " + (char)0x00B1 + " " + CovarArray[arrayconst * i + 3].ToString("#.### E-0"));
                }
            }

            g.SetReflModelInfo = ginfo;
        }
        //Update our variables after validation
        private void Variable_Changed(object sender, EventArgs e)
        {
            try
            {
                if (m_isupdating == false)
                {
                    RhoGraphing.SupSLD = ReflGraphing.SupSLD = SupSLDTB.ToDouble();
                    RhoGraphing.SubSLD = ReflGraphing.SubSLD = SubphaseSLD.ToDouble();
                    ReflGraphing.SetGraphType(Properties.Settings.Default.ForceRQ4, DBFCB.Checked);
                    ReflGraphing.SetGraphType(Properties.Settings.Default.ForceRQ4, DBFCB.Checked);

                    MakeReflectivity();
                }
            }
            catch { }
        }
        private void MakeReflectivity()
        {
            //Fill Rho array
            try
            {
                ReflCalc.IsOneSigma          = Holdsigma.Checked;
                ReflCalc.ZOffset             = 25;
                ReflCalc.GetSubRoughness     = SubRough.ToDouble();
                ReflCalc.BoxCount            = BoxCount.ToInt();
                ReflCalc.SubphaseSLD         = SubphaseSLD.ToDouble();
                ReflCalc.SuperphaseSLD       = SupSLDTB.ToDouble();
                ReflCalc.HighQOffset         = Rightoffset.ToInt();
                ReflCalc.LowQOffset          = CritOffset.ToInt();
                ReflCalc.NormalizationFactor = NormCorrectTB.ToDouble();
                ReflCalc.ImpNormCB           = ImpNormCB.Checked;
                ReflCalc.QSpreadTB           = QSpreadTB.ToDouble();
                //Blank our Rho data from the previous iteration
                ReflCalc.RhoArray.Clear();
                ReflCalc.LengthArray.Clear();
                ReflCalc.SigmaArray.Clear();

                RhoArray.ForEach(p => ReflCalc.RhoArray.Add(p.ToDouble()));
                LengthArray.ForEach(p => ReflCalc.LengthArray.Add(p.ToDouble()));
                SigmaArray.ForEach(p => ReflCalc.SigmaArray.Add(p.ToDouble()));

                if (Holdsigma.Checked)
                {
                    ChangeRoughnessArray();
                }

                ReflCalc.UpdateProfile();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
        public ConstrainedReflmodeling(RhoFit RhoCalc)
        {
            InitializeComponent();

            ReflCalc  = new ReflFit(RhoCalc as BoxReflFitBase);
            m_bUseSLD = Properties.Settings.Default.UseSLDSingleSession;

            SigmaArray      = new List <TextBox>(6);
            LengthArray     = new List <TextBox>(6);
            RhoArray        = new List <TextBox>(6);
            HoldSigmaArray  = new List <CheckBox>(6);
            HoldLengthArray = new List <CheckBox>(6);
            HoldRhoArray    = new List <CheckBox>(6);

            if (m_bUseSLD)
            {
                tabControl1.TabPages[1].Text = "SLD";
                RhoLabel.Text = "SLD";
            }
            else
            {
                tabControl1.TabPages[1].Text = "Electron Density";
            }

            WavelengthTB.Text = ((double)(1.24)).ToString();

            //Initialize the arrays
            MakeArrays();

            //Copy over the values
            BoxCount.Text     = RhoCalc.BoxCount.ToString();
            SubRough.Text     = RhoCalc.GetSubRoughness.ToString();
            SubphaseSLD.Text  = RhoCalc.SubphaseSLD.ToString();
            SupSLDTB.Text     = RhoCalc.SuperphaseSLD.ToString();
            Holdsigma.Checked = RhoCalc.IsOneSigma;


            //Setup the Graph
            ReflGraphing = new Graphing(string.Empty);
            ReflGraphing.SetGraphType(Properties.Settings.Default.ForceRQ4, DBFCB.Checked);
            ReflGraphing.SubSLD = SubphaseSLD.ToDouble();
            ReflGraphing.SupSLD = SupSLDTB.ToDouble();
            ReflGraphing.CreateGraph(RhoGraph, "Reflectivity", "Q/Qc", "Intensity / Fresnel", AxisType.Log);
            ReflGraphing.LoadDatawithErrorstoGraph("Reflectivity Data", System.Drawing.Color.Black, SymbolType.Circle, 5, ReflData.Instance.GetQData, ReflData.Instance.GetReflData);

            //Set up ED Graph
            RhoGraphing        = new Graphing(string.Empty);
            RhoGraphing.SubSLD = SubphaseSLD.ToDouble();
            RhoGraphing.UseSLD = m_bUseSLD;
            RhoGraphing.SetGraphType(false, false);

            if (m_bUseSLD == false)
            {
                RhoGraphing.CreateGraph(EDzedGraphControl1, "Electron Density Profile", "Z", "Normalized Electron Density", AxisType.Linear);
            }
            else
            {
                RhoGraphing.CreateGraph(EDzedGraphControl1, "SLD Profile", "Z", "SLD", AxisType.Linear);
            }


            RhoGraphing.Pane.XAxis.Scale.Min = 0;
            RhoGraphing.Pane.XAxis.Scale.Max = ReflCalc.Z[ReflCalc.Z.Length - 1];

            loadingCircle2.Visible           = loadingCircle1.Visible = false;
            loadingCircle2.NumberSpoke       = loadingCircle1.NumberSpoke = 25;
            loadingCircle2.InnerCircleRadius = loadingCircle1.InnerCircleRadius = 60;
            loadingCircle2.OuterCircleRadius = loadingCircle1.OuterCircleRadius = 120;
            loadingCircle2.RotationSpeed     = loadingCircle1.RotationSpeed = 150;
            loadingCircle2.SpokeThickness    = loadingCircle1.SpokeThickness = 3;

            //Initialize constrain form
            ConstrForm = new Constraints(6);
            GreyFields();

            //Setup the callback if the graph updates the bounds
            ReflGraphing.ChangedBounds += new Graphing.ChangedEventHandler(PointChanged);

            //Setup the callback to update the frontend with new information
            ReflCalc.Update += new BoxReflFitBase.UpdateProfileHandler(ReflCalc_Update);
            ReflCalc_Update(null, null);
            MakeReflectivity();
        }