// GET api/Configuration public Microsoft.Research.Science.FetchClimate2.Serializable.FetchConfiguration Get() { var configuration = WebApiApplication.GetFetchConfiguration(DateTime.MaxValue); var toSerizlize = new Microsoft.Research.Science.FetchClimate2.Serializable.FetchConfiguration(configuration); return(toSerizlize); }
// GET api/Configuration?timestamp=03-Nov-2012%2012:00:00 public Microsoft.Research.Science.FetchClimate2.Serializable.FetchConfiguration Get(DateTime timestamp) { try { var configuration = WebApiApplication.GetFetchConfiguration(timestamp); var toSerizlize = new Microsoft.Research.Science.FetchClimate2.Serializable.FetchConfiguration(configuration); return(toSerizlize); } catch (ArgumentException exc) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = exc.Message }); } }
private void MergeCSV(DataSet dst, Tuple <string, string[]>[] requests) { var jobManager = WebApiApplication.GetSharedJobManager(Request); var dsr = requests.Select(r => new Tuple <DataSet, string[]>(DataSet.Open(jobManager.ResultDataSetUri(r.Item1, false)), r.Item2)).ToArray(); try { var config = WebApiApplication.GetFetchConfiguration(DateTime.MaxValue); TableExportHelper.MergeTable(config, dst, dsr); dst.Commit(); } finally { foreach (var r in dsr) { r.Item1.Dispose(); } } }
private void MergeCSV(DataSet dst, string[] hashes) { for (var i = 0; i < hashes.Length; i++) { using (var src = DataSet.Open(WebApiApplication.GetSharedJobManager(Request).ResultDataSetUri(hashes[i], false))) { var name = src.Metadata[RequestDataSetFormat.EnvironmentVariableNameKey].ToString(); if (src.Metadata.ContainsKey(RequestDataSetFormat.DataSourceNameKey)) { string[] dataSources = (string[])src.Metadata[RequestDataSetFormat.DataSourceNameKey]; var config = WebApiApplication.GetFetchConfiguration(DateTime.MaxValue); dst.Metadata[name + "_dataSourceNames"] = dataSources; dst.Metadata[name + "_dataSourceIDs"] = dataSources.Select(ds => config.DataSources.Where(dsd => dsd.Name == ds).First().ID).ToArray(); } bool isPointSet = src.Variables[RequestDataSetFormat.ValuesVariableName].Dimensions.Count() == 1; string visMethod = isPointSet ? "Points" : "Colormap"; if (i == 0) { if (src.Variables.Contains("lat")) { dst.AddVariableByValue(src.Variables["lat"]); } if (src.Variables.Contains("latmax")) { dst.AddVariableByValue(src.Variables["latmax"]); } if (src.Variables.Contains("latmin")) { dst.AddVariableByValue(src.Variables["latmin"]); } if (src.Variables.Contains("lon")) { dst.AddVariableByValue(src.Variables["lon"]); } if (src.Variables.Contains("lonmax")) { dst.AddVariableByValue(src.Variables["lonmax"]); } if (src.Variables.Contains("lonmin")) { dst.AddVariableByValue(src.Variables["lonmin"]); } dst.AddVariableByValue(src.Variables["hours"]); dst.AddVariableByValue(src.Variables["days"]); dst.AddVariableByValue(src.Variables["years"]); dst.Metadata["VisualHints"] = name + "_" + RequestDataSetFormat.ValuesVariableName + "Style: " + visMethod; } var valuesVar = src[RequestDataSetFormat.ValuesVariableName]; dst.AddVariable <double>(name + "_" + RequestDataSetFormat.ValuesVariableName, valuesVar.GetData(), valuesVar.Dimensions.Select(d => d.Name).ToArray()).Metadata["VisualHints"] = "Style: " + visMethod; var sdVar = src[RequestDataSetFormat.UncertaintyVariableName]; dst.AddVariable <double>(name + "_" + RequestDataSetFormat.UncertaintyVariableName, sdVar.GetData(), sdVar.Dimensions.Select(d => d.Name).ToArray()); if (src.Variables.Contains(RequestDataSetFormat.ProvenanceVariableName)) { var provVar = src[RequestDataSetFormat.ProvenanceVariableName]; dst.AddVariable <ushort>(name + "_" + RequestDataSetFormat.ProvenanceVariableName, provVar.GetData(), provVar.Dimensions.Select(d => d.Name).ToArray()); } } } dst.Commit(); }