Summary description for Grads
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);
 }
Ejemplo n.º 3
0
 public Dimension(string name, Grads grads)
 {
     this.grads = grads;
     this.name = name;
     Result co = grads.Tell("q dims");
     if (co.Status != 0)
         throw new Exception("Cannot query grads!");
     parse_output(co.Output);
     co = grads.Tell("q file");
     limit = -1;
     foreach (string s in co.Output)
     {
         if (!s.Contains(name + "size"))
             continue;
         string tmp = s.Substring(s.IndexOf(name));
         tmp = tmp.Substring(tmp.IndexOf("= ") + 2);
         tmp = tmp.Substring(0, tmp.IndexOf(" "));
         limit = double.Parse(tmp);
     }
 }
Ejemplo n.º 4
0
 public FileInfo(Grads grads)
 {
     files=new Files(grads);
 }
Ejemplo n.º 5
0
 public Dims(Grads grads)
 {
     Result gr=grads.Query("dims");
     init(gr.Output);
 }