public static TempSpec Sum(TempSpec spec1, TempSpec spec2, double rv1, double rv2) { if (spec1.Length != spec2.Length) { return(null); } TempSpec specSum = new TempSpec(spec1.Length); LinInterpolator li1 = new LinInterpolator(spec1.lambs, spec1.norm_intes); LinInterpolator li2 = new LinInterpolator(spec2.lambs, spec2.norm_intes); LinInterpolator liCont1 = new LinInterpolator(spec1.lambs, spec1.cont); LinInterpolator liCont2 = new LinInterpolator(spec2.lambs, spec2.cont); double lambda1 = spec1.Lambdas[0]; double lambda2 = spec1.Lambdas[spec1.Length - 1]; double dlambda = (lambda2 - lambda1) / spec1.Length; double c = 299792.458; double lambda, cont1, cont2; for (int i = 0; i < specSum.Length; i++) { lambda = lambda1 + i * dlambda; specSum.lambs[i] = lambda; cont1 = liCont1.InterpUni(lambda - lambda * rv1 / c); cont2 = liCont2.InterpUni(lambda - lambda * rv2 / c); specSum.cont[i] = cont1 + cont2; specSum.norm_intes[i] = (li1.InterpUni(lambda - lambda * rv1 / c) * cont1 + li2.InterpUni(lambda - lambda * rv2 / c) * cont2) / specSum.cont[i]; } return(specSum); }
private double[] Pars(double[] xy) { double[] pars = new double[(ord_o + 1) * (ord_x + 1)]; double r = 1; if (this.li != null) { r = li.InterpUni( lambds[(int)Math.Round(xy[0] * n_orders, 0)][(int)Math.Round(xy[1] * n_pixels, 0)]); } int k = 0; for (int i = 0; i <= ord_o; i++) { for (int j = 0; j <= ord_x; j++) { pars[k] = r * Math.Pow(xy[0], i) * Math.Pow(xy[1], j); k++; } } return(pars); }
private void DrawObsSpecGraph() { int n = lbOrders.SelectedIndex; if (n == -1) { return; } double lam_min = lambds[n].First(); double lam_max = lambds[n].Last(); if (lam_min > lam_max) { double buff; buff = lam_max; lam_max = lam_min; lam_min = buff; } plot.Clear(); if (tellur != null) { for (int i = 0; i < tellur.Size(); i++) { if (tellur.GetLeftBound(i) > lam_min && tellur.GetRightBound(i) < lam_max) { VerticalLine vl1 = new VerticalLine(tellur.GetLeftBound(i)); VerticalLine vl2 = new VerticalLine(tellur.GetRightBound(i)); FilledRegion fr = new FilledRegion(vl1, vl2); fr.Brush = Brushes.LightBlue; plot.Add(fr); } } } for (int i = 0; i < cutMask.Size(); i++) { if (cutMask.GetLeftBound(i) > lam_min && cutMask.GetRightBound(i) < lam_max) { VerticalLine vl1 = new VerticalLine(cutMask.GetLeftBound(i)); VerticalLine vl2 = new VerticalLine(cutMask.GetRightBound(i)); FilledRegion fr = new FilledRegion(vl1, vl2); fr.Brush = Brushes.Coral; plot.Add(fr); } } LinePlot lp = new LinePlot(); lp.AbscissaData = this.lambds[n]; lp.OrdinateData = this.fluxes[n]; plot.Add(lp); if (this.cont != null) { int nums = lambds[0].Length; LinePlot lp0 = new LinePlot(); lp0.AbscissaData = this.lambds[n]; lp0.OrdinateData = this.cont[n]; lp0.Color = Color.Green; plot.Add(lp0); if (this.tspec != null) { li = new LinInterpolator(tspec.Lambdas, tspec.NormFluxes); double[] ll = new double[nums]; double[] ff = new double[nums]; for (int i = 0; i < nums; i++) { ll[i] = lambds[n][i]; ff[i] = li.InterpUni(ll[i]) * cont[n][i]; } LinePlot lp1 = new LinePlot(); lp1.AbscissaData = ll; lp1.OrdinateData = ff; lp1.Color = Color.Red; plot.Add(lp1); } } plot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag()); plot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag()); plot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(true)); plot.XAxis1.Label = "Wavelength"; plot.YAxis1.Label = "Flux"; plot.Show(); plot.Refresh(); }