Exemple #1
0
        private void Calculate (bool recalc, string filename)
        {
                        
            
            //FILE fin = fopen("obs.dat", "r");
            
            //double Fi=43.7486111;   //{иЁа®в  ¬Ґбв  ­ Ў«о¤Ґ­Ёп ў Ја ¤гб е}
            //double Lamb=2.844444;  //{¤®«Ј®в  ¬Ґбв  ­ Ў«о¤Ґ­Ёп ў з б е}
            //double Fi = 59.4612;
            //double Lamb = 2 + 0.021944444444444444444444444443778;


            if (cbMethod.SelectedIndex == -1)
            {
                MessageBox.Show("Не выбран метод решения");
                return;
            }
            
            System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("ru-RU");
            int method = cbMethod.SelectedIndex;

            
            lObserv.Items.Clear();
            lOper2.Items.Clear();


            string ftscope = "e:\\1\\dpas\\MTM500M.dat";
            ftscope = tfiletscope.Text;
            if (ftscope == "")
            {
                MessageBox.Show("Выберите файл с настройками телескопа");
                return;
            }
            StreamReader finmtm = new StreamReader(ftscope);
            char[] separator = new char[] { (char)09, (char)32, '/', ':' };
            string line;
            string[] pars;
            line = finmtm.ReadLine();
            pars = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            int Dt = Convert.ToInt32(pars[0]);
            line = finmtm.ReadLine();
            pars = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            int JD_R = Convert.ToInt32(pars[0]);
            line = finmtm.ReadLine();
            line = line.Replace(".", ci.NumberFormat.NumberDecimalSeparator);
            line = line.Replace(",", ci.NumberFormat.NumberDecimalSeparator);
            pars = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            double Temp = Convert.ToDouble(pars[0]);
            line = finmtm.ReadLine();
            line = line.Replace(".", ci.NumberFormat.NumberDecimalSeparator);
            line = line.Replace(",", ci.NumberFormat.NumberDecimalSeparator);
            pars = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            double Dav = Convert.ToDouble(pars[0]);
            /*line = finmtm.ReadLine();
            pars = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            int God0 = Convert.ToInt32(pars[0]);
            int Mes0 = Convert.ToInt32(pars[1]);
            int Den0 = Convert.ToInt32(pars[2]);
            int Hour0 = Convert.ToInt32(pars[3]);
            int Min0 = Convert.ToInt32(pars[4]);
            line = finmtm.ReadLine();
            line = line.Replace(".", ci.NumberFormat.NumberDecimalSeparator);
            line = line.Replace(",", ci.NumberFormat.NumberDecimalSeparator);
            pars = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            double ds0 = Convert.ToDouble(pars[0]);
            double V = Convert.ToDouble(pars[1]);*/
            line = finmtm.ReadLine();
            line = line.Replace(".", ci.NumberFormat.NumberDecimalSeparator);
            line = line.Replace(",", ci.NumberFormat.NumberDecimalSeparator);
            pars = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            double Fi = Convert.ToDouble(pars[0]);
            line = finmtm.ReadLine();
            line = line.Replace(".", ci.NumberFormat.NumberDecimalSeparator);
            line = line.Replace(",", ci.NumberFormat.NumberDecimalSeparator);
            pars = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            double Lamb = Convert.ToDouble(pars[0]);
            line = finmtm.ReadLine();
            line = line.Replace(".", ci.NumberFormat.NumberDecimalSeparator);
            line = line.Replace(",", ci.NumberFormat.NumberDecimalSeparator);
            pars = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            double ex_t = Convert.ToDouble(pars[0]);
            double Eex_t = Convert.ToDouble(pars[1]);
            line = finmtm.ReadLine();
            line = line.Replace(".", ci.NumberFormat.NumberDecimalSeparator);
            line = line.Replace(",", ci.NumberFormat.NumberDecimalSeparator);
            pars = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
            double ex_d = Convert.ToDouble(pars[0]);
            double Eex_d = Convert.ToDouble(pars[1]);



            string fobs;
            int ii2;
            StreamReader fin2;

            if (recalc == false)
            {
                //StreamReader fin = new StreamReader("obs.dat");
                bool loggerfile = false;

                Fform2.lResult.Clear();
                fobs = tfileobs.Text;
                if (fobs == "")
                {
                    MessageBox.Show("Выберите файл с наблюдениями");
                    return;
                }
                fin2 = new StreamReader(fobs);
                line = "";
                ii2 = 0;
                line = fin2.ReadLine();
                if (line.IndexOf("Log") != -1)
                {
                    loggerfile = true;
                }

                if (loggerfile == true)
                {
                    progressBar1.Visible = true;
                    System.IO.FileInfo fi = new System.IO.FileInfo(fobs);
                    progressBar1.Maximum = (int)fi.Length;
                    progressBar1.Value = 0;
                    string fobsnew = LoggerToObs(fobs);
                    fobs = fobsnew;
                    progressBar1.Visible = false;
                    fin2.Close();
                    fin2 = new StreamReader(fobs);
                    line = "";
                    line = fin2.ReadLine();
                }

            }

            else //recalc==true
            {
                fobs = filename;
                fin2 = new StreamReader(fobs);
                line = "";
                ii2 = 0;
                line = fin2.ReadLine();
            }
            
            
            while (line != null)
            {
                
                ii2++;
                line = fin2.ReadLine();
            }
            
            fin2.Close();


            if (recalc == false)
            {
                FileInfo fn = new FileInfo(fobs);
                fobs = fobs + ".temp";
                fn.CopyTo(fobs, true);
            }
            
            int NN = ii2 * 2;
            int MM=0;
            if (method == 0) MM = 8;
            if (method == 1) // пр. восхождение
            {
                MM = 6;
                NN = NN / 2;
            }
            if (method == 2) // сколонение
            {
                MM = 4;
                NN = NN / 2;
            }

            StreamReader fin = new StreamReader(fobs);
            separator = new char[] { (char)09, (char)32, '/', ':' };
            double[] OC=new double [NN];
            double[] y = new double[NN];
            double[,] Fmatrix=new double[NN,MM];//8,36
            double[] c = new double[NN];//36
            lsfit.lsfitreport rep = new lsfit.lsfitreport();
            int info = 0;
            int i_count = 0;
            double Delta=0;
            lOper.Items.Clear();
            dg1.RowCount = MM;
            dg1.ColumnCount = 3;
            if (recalc == false)
            {
                for (int i = 0; i < dg1.RowCount; i++)
                {
                    dg1[0, i].Value = 1;
                }
            }
            else
            {
                int method_old = Convert.ToInt32((lSummary.Items[0].ToString())[7]) - 48;
                if (method != method_old)
                {
                    for (int i = 0; i < dg1.RowCount; i++)
                    {
                        dg1[0, i].Value = 1;
                    }
                }
                   
            }
            lSummary.Items.Clear();
           
            dg1.Columns[1].Width = 225;
            dg2.RowCount = NN;
            dg2.ColumnCount = 9;
            
            dg2.Columns[0].Name = "Number";
            dg2.Columns[1].Name = "Observation";
            dg2.Columns[2].Name = "Calculation";
            dg2.Columns[3].Name = "O-C";
            dg2.Columns[4].Name = "Alpha";
            dg2.Columns[5].Name = "Delta";
            dg2.Columns[6].Name = "T";
            dg2.Columns[7].Name = "Delta";
            dg2.Columns[8].Name = "Alpha";


            //MessageBox.Show(Convert.ToString(((CheckBox)dg1[0,0].Value).Checked));
               // MessageBox.Show(Convert.ToString(dg1[0,0].Value));
            
            int Alf1,Alf2,Delt1,Delt2;
            double Alf3,Delt3;
            
            while ((line = fin.ReadLine()) != null)
            {
                
                line = line.Replace(".", ci.NumberFormat.NumberDecimalSeparator);
                line = line.Replace(",", ci.NumberFormat.NumberDecimalSeparator);
                lOper2.Items.Add(line);
                pars = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);

                //Разбиваешь на составляющие. Дальше работаешь с массивом строк pars
                //textBox1.Text = Convert.ToString(pars.Length);
                int God=Convert.ToInt32(pars[0]);
                int Mes=Convert.ToInt32(pars[1]);
                int Den=Convert.ToInt32(pars[2]);
                int Hour=Convert.ToInt32(pars[3]);
                int Min=Convert.ToInt32(pars[4]);
                //double ss = Convert.ToDouble("11,1");
                pars[5]=pars[5].Replace(".", ci.NumberFormat.NumberDecimalSeparator);
                pars[5]=pars[5].Replace(",", ci.NumberFormat.NumberDecimalSeparator);
                double Sec=Convert.ToDouble(pars[5]);
                int NWE=Convert.ToInt32(pars[6]);
                Alf1=Convert.ToInt32(pars[7]);
                Alf2=Convert.ToInt32(pars[8]);
                pars[9]=pars[9].Replace(".", ci.NumberFormat.NumberDecimalSeparator);
                pars[9]=pars[9].Replace(",", ci.NumberFormat.NumberDecimalSeparator);
                Alf3=Convert.ToDouble(pars[9]);
                Delt1=Convert.ToInt32(pars[10]);
                Delt2=Convert.ToInt32(pars[11]);
                pars[12]=pars[12].Replace(".", ci.NumberFormat.NumberDecimalSeparator);
                pars[12]=pars[12].Replace(",", ci.NumberFormat.NumberDecimalSeparator);
                Delt3=Convert.ToDouble(pars[12]);
                double t1=Convert.ToDouble(pars[13]);
                double t2=Convert.ToDouble(pars[14]);
                double t3=Convert.ToDouble(pars[15]);
                double d1=Convert.ToDouble(pars[16]);
                double d2=Convert.ToDouble(pars[17]);
                double d3=Convert.ToDouble(pars[18]);
                int dtt=Convert.ToInt32(pars[19]);
                int ddd=Convert.ToInt32(pars[20]);

                double tin=t1+t2/60.0+t3/3600.0;
                double din=d1+d2/60.0+d3/3600.0;
                string WE;
                int Znnn = 1;
                if (NWE == 1)
                {
                    WE = "W";
                    Znnn = -1;
                }
                else
                {
                    WE = "E";
                    Znnn = 1;
                }
                int Zn_Delt = 1;
                if (Delt1 < 0)
                {
                    Zn_Delt = -1;
                    Delt1 = Math.Abs(Delt1);
                }
                if ((Delt1 == 0) && (Delt2 < 0))
                {
                    Zn_Delt = -1;
                    Delt2 = Math.Abs(Delt2);
                }
                if ((Delt1 == 0) && (Delt2 == 0) && (Delt3 < 0))
                {
                    Zn_Delt = -1;
                    Delt3 = Math.Abs(Delt3);
                }
                Delta = Zn_Delt * (Delt1 + Delt2 / 60.0 + Delt3 / 3600.0);
//                Delta = (Delt1 + Delt2 / 60.0 + Delt3 / 3600.0);

                Mathgr Mgr=new Mathgr();
                double dt_CCD=0;
                double dd_CCD = 0;
                if (NWE == 1)
                {
                    dt_CCD = -1.205 * ((dtt - 512.0) / Mgr.cos(Delta)) / 15.0;
                    dd_CCD = -1.205 * (ddd - 512.0);
                }
                if (NWE == 2)
                {
                    dt_CCD = 1.205 * ((dtt - 512.0) / Mgr.cos(Delta)) / 15.0;
                    dd_CCD = 1.205 * (ddd - 512.0);
                }

                Alf3 = Alf3 + dt_CCD;
                Delt3 = Delt3 + dd_CCD;
                
                //Delta = Zn_Delt * (Delt1 + Delt2 / 60.0 + Delt3 / 3600.0);
                
                Telescope Tscope = new Telescope();
                Tscope.Fi = Fi;
                Tscope.Lamb = Lamb;
                Tscope.Dt = Dt;
                Tscope.Temp = Temp;
                Tscope.Dav = Dav;
                Tscope.ex_t = ex_t;
                Tscope.ex_d = ex_d;
                Tscope.Eex_t = Eex_t;
                Tscope.Eex_d = Eex_d;
                Tscope.JD_R = JD_R;
                Tscope.Alf1 = Alf1;
                Tscope.Alf2 = Alf2;
                Tscope.Alf3 = Alf3;
                Tscope.WE = WE;
                Tscope.Zn_Delt = Zn_Delt;
                Tscope.Delt1 = Delt1;
                Tscope.Delt2 = Delt2;
                Tscope.Delt3 = Delt3;
                Tscope.God = God;
                Tscope.Mes = Mes;
                Tscope.Den = Den;
                Tscope.Hour = Hour;
                Tscope.Min = Min;
                Tscope.Sec = Sec;
                Tscope.Ustanovka();
                Type type = Tscope.GetType();
                BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
                PropertyInfo[] properties = type.GetProperties(flags);

                dg2[4, i_count].Value = Convert.ToString(Alf1) + " " + Convert.ToString(Alf2) + " " + Convert.ToString(Alf3);
                dg2[5, i_count].Value = Convert.ToString(Delt1) + " " + Convert.ToString(Delt2) + " " + Convert.ToString(Delt3);
                dg2[6, i_count].Value = Convert.ToString(Tscope.t);
                dg2[7, i_count].Value = Convert.ToString(Delta);
                double Alff=(Alf1 + Alf2 / 60.0 + Alf3 / 3600.0);
                dg2[8, i_count].Value = Convert.ToString(Alff);
                

               /* foreach (PropertyInfo property in properties)
                {

                    lOper.Items.Add("1");
                    lOper.Items.Add("Name: " + property.Name + ", Value: " + property.GetValue(Tscope, null));
                    //Console.WriteLine();
                }
                */
                
                //Tscope.Ustanovka(Fi,Lamb,Dt,WE,Temp,Dav,ex_t,Eex_t,ex_d,Eex_d,God0,Mes0,Den0,Hour0,Min0,ds0,V,JD_R,Alf1,Alf2,Alf3,Zn_Delt,Delt1,Delt2,Delt3,God,Mes,Den,Hour,Min,Sec);
                


                /*public static void lsfitlinear(ref double[] y,
    ref double[,] fmatrix,
    int n,
    int m,
    ref int info,
    ref double[] c,
    ref lsfitreport rep)*/
                if (method == 0)
                {

                    dg1[1, 0].Value = "Нуль-пункт по склонению";
                    dg1[1, 1].Value = "Установки пол.оси по азимуту";
                    dg1[1, 2].Value = "Установки пол.оси по широте (склонению)";
                    dg1[1, 3].Value = "Нуль-пункт по часовому углу";
                    dg1[1, 4].Value = "Наклонности";
                    dg1[1, 5].Value = "Коллимации";
                    dg1[1, 6].Value = "Гнутия по склонению";
                    dg1[1, 7].Value = "Гнутия по прямому восхождению";

                    Fmatrix[i_count, 0] = -1.0;
                    Fmatrix[i_count, 1] = Znnn * Mgr.cos(Fi) * Mgr.cos(15.0 * Tscope.t);
                    Fmatrix[i_count, 2] = Znnn * Mgr.sin(15.0 * Tscope.t);
                    Fmatrix[i_count, 3] = 0;
                    Fmatrix[i_count, 4] = 0;
                    Fmatrix[i_count, 5] = 0;
                    Fmatrix[i_count, 6] = Znnn * (-Mgr.sin(Fi) * Mgr.cos(Delta) - Mgr.cos(Fi) * Mgr.sin(Delta) * Mgr.cos(15.0 * Tscope.t));
                    Fmatrix[i_count, 7] = 0;

                    
                    // Fmatrix[i_count, 8] = 0;
                    // Fmatrix[i_count, 9] = 0;

                    Fmatrix[i_count + 1, 0] = 0;
                    Fmatrix[i_count + 1, 1] = Mgr.cos(Fi) * Mgr.sin(15.0 * Tscope.t) * Mgr.tn(Delta);
                    Fmatrix[i_count + 1, 2] = -Mgr.cos(15.0 * Tscope.t) * Mgr.tn(Delta);
                    Fmatrix[i_count + 1, 3] = 1.0;
                    Fmatrix[i_count + 1, 4] = (NWE == 1) ? Mgr.tn(Delta) : -Mgr.tn(Delta);
                    Fmatrix[i_count + 1, 5] = (NWE == 1) ? 1.0 / Mgr.cos(Delta) : -1.0 / Mgr.cos(Delta);
                    Fmatrix[i_count + 1, 6] = Mgr.sin(Fi) * Mgr.cos(Fi) * Mgr.sin(Delta) * Mgr.tn(Delta) + Mgr.cos(Fi) * Mgr.cos(15.0 * Tscope.t) * Mgr.cos(Fi) * Mgr.sin(Delta);
                    if (NWE != 1)
                    {
                        Fmatrix[i_count + 1, 6] = -Fmatrix[i_count + 1, 6];
                    }


                    Fmatrix[i_count + 1, 7] = Mgr.cos(Fi) * Mgr.sin(15.0 * Tscope.t) / Mgr.cos(Delta);

                    for (int j = 0; j < dg1.RowCount; j++)
                    {
                        Fmatrix[i_count, j] *= Convert.ToInt32(dg1[0, j].Value);
                        Fmatrix[i_count+1, j] *= Convert.ToInt32(dg1[0, j].Value);
                    }
                    
                    OC[i_count] = din - Tscope.DeltaL2;
                    OC[i_count + 1] = tin - Tscope.tL2;
                    lOper.Items.Add(Convert.ToString(Sec) + " " + Convert.ToString(i_count) + "   " + Convert.ToString(OC[i_count + 1]) + "   " + Convert.ToString(OC[i_count]) + "   " + Convert.ToString(Tscope.t) + "   " + Convert.ToString(Tscope.tL2) + "   " + Convert.ToString(Tscope.DeltaL2));
                    

                    i_count += 2;
                } //if

                if (method == 1)
                {
                    dg1[1, 0].Value = "Нуль пункт по часовому углу";
                    dg1[1, 1].Value = "Установки пол.оси по азимуту";
                    dg1[1, 2].Value = "Установки пол.оси по широте";
                    dg1[1, 3].Value = "Наклонности";
                    dg1[1, 4].Value = "Коллимации";
                    dg1[1, 5].Value = "Гнутия по прямому восхождению";
                    

                    Fmatrix[i_count, 0] = 1.0;
                    Fmatrix[i_count, 1] = Mgr.cos(Fi) * Mgr.sin(15.0 * Tscope.t) * Mgr.tn(Delta);
                    Fmatrix[i_count, 2] = -Mgr.cos(15.0 * Tscope.t) * Mgr.tn(Delta);
                    Fmatrix[i_count, 3] = (NWE == 1) ? Mgr.tn(Delta) : -Mgr.tn(Delta);
                    Fmatrix[i_count, 4] = (NWE == 1) ? 1.0 / Mgr.cos(Delta) : -1 / Mgr.cos(Delta);
                    Fmatrix[i_count, 5] = Mgr.cos(Fi) * Mgr.sin(15.0 * Tscope.t) / Mgr.cos(Delta);

                    for (int j = 0; j < dg1.RowCount; j++)
                    {
                        Fmatrix[i_count, j] *= Convert.ToInt32(dg1[0, j].Value);
                    }


                    OC[i_count] = tin - Tscope.tL2 + PopHor2(PopHor(Tscope.t), PopVert(Tscope.t)) / 60 + PopVert2(PopHor(Tscope.t), PopVert(Tscope.t)) / 60;
                    lOper.Items.Add(Convert.ToString(Sec) + " " + Convert.ToString(i_count) + "   " +  "   " + Convert.ToString(OC[i_count]) + "   " + Convert.ToString(Tscope.t) + "   " + Convert.ToString(Tscope.tL2) + "   " + Convert.ToString(Tscope.DeltaL2));
                    i_count += 1;
                }

                if (method == 2)
                {
                    dg1[1, 0].Value = "Нуль-пункт по склонению";
                    dg1[1, 1].Value = "Установки пол.оси по азимуту";
                    dg1[1, 2].Value = "Установки пол.оси по склонению";
                    dg1[1, 3].Value = "Гнутия по склонению";
                    
                    Fmatrix[i_count, 0] = -1.0;
                    Fmatrix[i_count, 1] = Znnn * Mgr.cos(Fi) * Mgr.cos(15.0 * Tscope.t);
                    Fmatrix[i_count, 2] = Znnn * Mgr.sin(15.0 * Tscope.t);
                    Fmatrix[i_count, 3] = Znnn * (-Mgr.sin(Fi) * Mgr.cos(Delta) - Mgr.cos(Fi) * Mgr.sin(Delta) * Mgr.cos(15.0 * Tscope.t));

                    for (int j = 0; j < dg1.RowCount; j++)
                    {
                        Fmatrix[i_count, j] *= Convert.ToInt32(dg1[0, j].Value);
                    }

                    OC[i_count] = din - Tscope.DeltaL2;
                    lOper.Items.Add(Convert.ToString(Sec) + " " + Convert.ToString(i_count) + "   "+ "   " + Convert.ToString(OC[i_count]) + "   " + Convert.ToString(Tscope.t) + "   " + Convert.ToString(Tscope.tL2) + "   " + Convert.ToString(Tscope.DeltaL2));
                    i_count += 1;
                }

                
            
            } //while

            //Start least squares method
            //MessageBox.Show(Convert.ToString(i_count));
            lsfit.lsfitlinear(ref OC, ref Fmatrix, i_count, MM, ref info, ref c, ref rep);
            //MessageBox.Show(Convert.ToString(info));
            for (int ii = 0; ii < MM; ii++)
            {
                dg1[2, ii].Value = Math.Round(c[ii]*60,5);
                lOper.Items.Add(Convert.ToString(c[ii]));
            }
            lOper.Items.Add(" ");
            lSummary.Items.Add("Method " + Convert.ToString(method)); //7th symbol 
            lSummary.Items.Add("FileName " + fobs);
            lSummary.Items.Add("Average error     " + Convert.ToString(rep.avgerror*60));
            lSummary.Items.Add("Maximum error     "+Convert.ToString(rep.maxerror*60));


            lOper.Items.Add(rep.avgerror);
            lOper.Items.Add(rep.maxerror);
            // zdes' budem probivat' schitat' nevyazku
            for (int ii = 0; ii < NN; ii++)
            {
                double ypol=0;
                for (int jj = 0; jj < MM; jj++)
                {
                    ypol += Fmatrix[ii, jj] * c[jj];
                }
                lOper.Items.Add(OC[ii]-ypol);
                //dg2[0, ii].Value = (int)ii / 2;
                if (method == 0) dg2[0, ii].Value = (int)ii / 2;
                else dg2[0, ii].Value = ii;

                dg2[1, ii].Value = Math.Round(OC[ii]*60,5);
                dg2[2, ii].Value = Math.Round(ypol*60,5);
                dg2[3, ii].Value = Math.Round((OC[ii] - ypol)*60,5);



                /*for (int jj = 0; jj < 4; jj++)
                {
                    if (Math.Abs(OC[ii] - ypol) / 5 > rep.avgerror)
                    {
                        dg2[jj, ii].Style.BackColor = Color.Red;
                    }
                }*/
            }


            Fform2.lResult.Text += "\n";
            
            Fform2.lResult.Text += "---------------------------";
            Fform2.lResult.Text += "\n";
                     

            for (int i = 0; i < dg1.RowCount; i++)
            {
                string str = "";
                for (int j = 0; j < dg1.ColumnCount; j++)
                {
                    str += dg1[j, i].Value + "   ";
                }
                Fform2.lResult.Text += (str+"\n");
            }
            

            //Обработка и раскраска
            double xav = 0;
            for (int ii = 0; ii < dg2.Rows.Count; ii++)
            {
                xav += Convert.ToDouble(dg2[3, ii].Value);
            }
            xav = xav / dg2.Rows.Count;
           
            double ss = 0;
            for (int ii = 0; ii < dg2.Rows.Count; ii++)
            {
                ss += (Convert.ToDouble(dg2[3, ii].Value) - xav) * (Convert.ToDouble(dg2[3, ii].Value) - xav);
            }
            double ss2 = Math.Sqrt(ss / dg2.Rows.Count);

            for (int ii = 0; ii < dg2.Rows.Count; ii++)
            {
                if (Math.Abs(Convert.ToDouble(dg2[3, ii].Value)) > 3*ss2)
                {
                    for (int jj = 0; jj < 6; jj++)
                    {
                        dg2[jj, ii].Style.BackColor = Color.Red;
                    }
                }
            }




            fin.Close();
        }
Exemple #2
0
        public void Ustanovka()
        {
            if (Delt1 > 87)
            {
                MessageBox.Show("Delta>87");
                return;
            }

            Calendar JDC = new Calendar(God, Mes, Den + (Hour + Min / 60.0 + Sec / 3600.0) / 24.0);
//            Calendar JD0C = new Calendar(God0, Mes0, Den0 + Hour0 / 24.0);
            
//            double AA=Den+(Hour+Min/60.0+(Sec+ds0+(JDC.juldate-JD0C.juldate)*V)/3600.0)/24.0;
//            JDC=new Calendar(God,Mes,AA);     //Какая-то хренотень
            JDC.calcdat();                              
            JDC.JULDAT();
            double D = JDC.day;
            int G = JDC.year;
            double A0=(D-Math.Truncate(D))*24;
            double H=Math.Truncate(A0);
            double A1=A0-H;
            double Mi=Math.Truncate(A1*60);
            double A2=A1-Mi/60.0;
            double S=A2*60*60;

            double Gmt=H+Mi/60.0+S/3600.0-Dt;
            double STg=JDC.startime(G,JDC.juldate,Gmt);
            double STm=STg+Lamb;
            if (STm>24) STm-=24.0;
            if (STm<0) STm+=24.0;

            double STm1=Math.Truncate(STm);
            A1=STm-STm1;
            double STm2=Math.Truncate(A1*60);
            A2=A1-STm2/60.0;
            double STm3=A2*60.0*60.0;

            double t0=(JDC.juldate-2415020.0)/36525.0;
            double mm=3.07234+0.00186*t0;
            double n=20.0467-0.0085*t0;
            double Alf=Alf1+Alf2/60.0+Alf3/3600.0;
            double Zn;
            if ((Zn_Delt==1)||(1==2/*Zn_Delt==" "*/)) Zn=1;
                    else Zn=-1;
            double Delt=Zn*(Delt1+Delt2/60.0+Delt3/3600.0);
            Calendar JDTC=new Calendar(JD_R,1,0.0);
            Mathgr Mgr=new Mathgr();
            double Alfa=Alf+(JDC.juldate-JDTC.juldate)/365.25*(mm+n/15.0*Mgr.sin(Alf*15.0)*Mgr.tn(Delt))/3600.0;
            double test_1 = (mm + n / 15.0 + Mgr.sin(Alf * 15.0) * Mgr.tn(Delt)) ;
            double Delta=Delt+(JDC.juldate-JDTC.juldate)/365.25*(n*Mgr.cos(Alf*15))/3600.0;

            t = STm - Alfa;
            if (Math.Abs(t) > 12.0) t = -24.0 * t / Math.Abs(t) + t;

            double z = Mgr.acs(Mgr.sin(Delta)*Mgr.sin(Fi)+Mgr.cos(Delta)*Mgr.cos(Fi)*Mgr.cos(t*15.0));
            if (Math.Abs(z) > 87) { MessageBox.Show("Z>87"); return; };
            double Ref = Refr(z, Temp, Dav);
            double Refa, Refd;
            if (z != 0)
            {
                A0 = Mgr.acs((Mgr.sin(Fi) - Mgr.sin(Delta) * Mgr.cos(z)) / (Mgr.cos(Delta) * Mgr.sin(z)));
                if (t != 0)
                    Refa = Ref * Mgr.sin(A0) / Mgr.cos(Delta) * t / Math.Abs(t) / 15.0;
                else
                    Refa = 0;
                Refd = Ref * Mgr.cos(A0);
            }
            else
            {
                Refa = 0;
                Refd = 0;
            }


            double tL0 = STm - (Alfa + Refa / (3600.0 * 15.0));
            if (Math.Abs(tL0) > 12.0) tL0 = -24.0 * tL0 / Math.Abs(tL0) + tL0;
            double tLOL = tL0 * 15.0;
            if (tLOL < 0)
                tLOL = -tLOL;
            else
                tLOL = 360 - tLOL;
            if (WE == "E")
                tLOL = tLOL + 180.0;
            if (tLOL > 360)
                tLOL -= 360;
            if (tLOL < 0)
                tLOL += 360.0;


            double IL0 = ESPn(JDC.juldate);
            double beta = -20.4958 / 3600.0;
            double d_alf = beta * Mgr.cos(IL0) * Mgr.cos(23.5) * Mgr.cos(Alfa) / Mgr.cos(Delta) + beta * Mgr.sin(IL0) * Mgr.sin(Alfa) / Mgr.cos(Delta);
            double d_delt = beta * Mgr.cos(IL0) * Mgr.cos(23.5) * (Mgr.tn(23.5) * Mgr.cos(Delta) - Mgr.sin(Alfa) * Mgr.sin(Delta)) + beta * Mgr.sin(IL0) * Mgr.cos(Alfa) * Mgr.sin(Delta);

            double AlfaL2 = Alfa + d_alf / 15.0 + Refa / (3600 * 15);
            tL2 = STm - AlfaL2;
            if (Math.Abs(tL2) > 12.0)
                tL2 = -24.0 * tL2 / Math.Abs(tL2) + tL2;
            tL2 = tL2 * 15.0;
            if (tL2 < 0)
                tL2 = -tL2;
            else
                tL2 = 360 - tL2;
            if (WE == "E")
                tL2 += 180;
            double D_ex_t = (ex_t * Mgr.sin(tL2 - Eex_t)) / 60.0;
            tL2 = tL2 + D_ex_t;
            if (tL2 > 360)
                tL2 -= 360;
            if (tL2 < 0)
                tL2 += 360;

            DeltaL2 = Delta + d_delt + Refd / 3600.0;
            if (WE == "W")
                DeltaL2 = DeltaL2+0.0;
            if (WE == "E")
                DeltaL2 = 180.0 - DeltaL2;


            double D_ex_d = (ex_d * Mgr.sin(DeltaL2 - Eex_d)) / 60.0;
            DeltaL2 = DeltaL2 + D_ex_d;

            double Mz=1.0/Mgr.cos(z)-40.0*Math.Exp(-2.25*Math.Log(90.0-z));



        }