Open() public method

public Open ( String filename, System.IO.FileType filetype ) : void
filename String
filetype System.IO.FileType
return void
Ejemplo n.º 1
0
 public double Temperature(double lat, double lon, DateTime starttime, DateTime endtime)
 {
     Grads g = new Grads();
     NameValueCollection appsettings = System.Web.Configuration.WebConfigurationManager.AppSettings;
     g.Open(appsettings["CtlDirectory"], appsettings["CtlPrefix"], starttime);
     g.Lat.Start = lat - 0.1;
     g.Lat.End = lat + 0.1;
     g.Lon.Start = lon - 0.1;
     g.Lon.End = lon + 0.1;
     g.Time = starttime;
     double mean = 0;
     int t = endtime.Subtract(starttime).Hours;
     for (int i = 0; i < t; i++)
     {
         mean += g.Amean("tc");
         g.T.Value += 1;
     }
     return mean;
 }
Ejemplo n.º 2
0
 public string Classify(double lat, double lon, DateTime starttime, DateTime endtime)
 {
     Grads g = new Grads();
     g.Open(appsettings["CtlDirectory"], appsettings["CtlPrefix"], starttime);
     g.Lat.Start = lat - 0.1;
     g.Lat.End = lat + 0.1;
     g.Lon.Start = lon - 0.1;
     g.Lon.End = lon + 0.1;
     System.TimeSpan diff
     DateTime midtime = starttime.A
     g.Time = starttime;
     int nvars = int.Parse(appsettings.Get("NVars"));
     string row = "";
     for (int i = 0; i < nvars; i++)
     {
         row += g.Amean(appsettings.Get("Var" + i)) + " ";
     }
     string filename = RandFilename("predict", ".db2");
     StreamWriter sw = new StreamWriter(filename);
     sw.WriteLine(row);
     sw.Close();
     Process p = new Process();
     p.StartInfo.FileName = appsettings.Get("AutoclassExe");
     p.StartInfo.Arguments = "-predict " +  filename + " "
         + appsettings.Get("RParamsFilename").Replace(".r-params", ".results-bin") + " "
         + appsettings.Get("RParamsFilename").Replace(".r-params", ".search") + " "
         + appsettings.Get("RParamsFilename");
     p.Start();
     p.WaitForExit();
     string outputfile = filename.Replace(".db2", ".class-data-1");
     StreamReader sr = new StreamReader(outputfile);
     string line;
     while ((line = sr.ReadLine()) != null)
     {
         if (!line.StartsWith("DATA_CLASS"))
             continue;
         string class_name = line.Substring(line.IndexOf(' ') + 1);
         sr.Close();
         return class_name;
     }
     throw new Exception("Cannot classify lat: " + lat + " lon: " + lon);
 }