Ejemplo n.º 1
0
        public static Spectrum operator /(Spectrum sp1, Spectrum sp2)
        {
            double leftLambda  = 0;
            double rightLambda = 0;

            if (sp1.xx[0] < sp2.xx[0])
            {
                leftLambda = sp2.xx[0];
            }
            else
            {
                leftLambda = sp1.xx[0];
            }

            if (sp1.xx[sp1.xx.Length - 1] < sp2.xx[sp2.xx.Length - 1])
            {
                rightLambda = sp1.xx[sp1.xx.Length - 1];
            }
            else
            {
                rightLambda = sp2.xx[sp2.xx.Length - 1];
            }


            sp1 = sp1.Trimmed(leftLambda, rightLambda);

            Interp.LinInterpolator li = new LinInterpolator(sp2.xx, sp2.yy);

            for (int i = 0; i < sp1.xx.Length; i++)
            {
                sp1.yy[i] = li.Interp(sp1.xx[i]) / sp1.yy[i];
            }
            sp1.Name = "Division.dat";
            return(sp1);
        }
Ejemplo n.º 2
0
        public static SpectrumMod operator +(SpectrumMod op1, Spectrum op2)
        {
            double leftLambda  = 0;
            double rightLambda = 0;

            if (op1.XX[0] < op2.XX[0])
            {
                leftLambda = op2.XX[0];
            }
            else
            {
                leftLambda = op1.XX[0];
            }

            if (op1.XX[op1.XX.Length - 1] < op2.XX[op2.XX.Length - 1])
            {
                rightLambda = op1.XX[op1.XX.Length - 1];
            }
            else
            {
                rightLambda = op2.XX[op2.XX.Length - 1];
            }


            op1 = op1.Trimmed(leftLambda, rightLambda);

            Interp.LinInterpolator li = new LinInterpolator(op2.XX, op2.YY);

            for (int i = 0; i < op1.XX.Length; i++)
            {
                op1.YY[i] = li.Interp(op1.XX[i]) + op1.YY[i];
            }

            return(op1);
        }