本文整理汇总了C#中TimeSeries.Load方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSeries.Load方法的具体用法?C# TimeSeries.Load怎么用?C# TimeSeries.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.Load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
string stepMessage = "";
List<ConfigNode> timeseries, parameters;
List<string> cfg = new List<string>();
List<string> blocks = new List<string>();
DateTime start, end, actual;
FilePath root;
bool hasFolders;
TextFile config, errors;
string hdfTag;
FileName hdf5EXE = new FileName();
FilePath workingFolder = new FilePath();
FilePath tsPath;
Dictionary<string, TimeSeries> outTS = new Dictionary<string, TimeSeries>();
TimeSeries newTS = new TimeSeries();
List<string> failedPeriods = new List<string>();
int count_to_save;
bool use_year_on_path;
bool join_time_series;
string startFormat, endFormat, folderFormat;
errors = new TextFile("errors.log");
errors.OpenNewToWrite();
count_to_save = 0;
try
{
stepMessage = "command line arguments loading.";
CmdArgs cmdArgs = new CmdArgs(args);
if (cmdArgs.HasParameter("cfg"))
{
stepMessage = "configuration file loading.";
Config conf = new Config(cmdArgs.Parameters["cfg"]);
conf.Load();
stepMessage = "configuration file parsing.";
ConfigNode tsc = conf.Root.ChildNodes.Find(delegate(ConfigNode node) { return node.Name == "timeseries.to.extract"; });
if (tsc == null)
throw new Exception("block 'timeseries.to.extract' is missing.");
start = tsc["start.date"].AsDateTime();
end = tsc["end.date"].AsDateTime();
hdfTag = tsc["hdf.tag"].AsString();
hdf5EXE = tsc["exporter.exe"].AsFileName();
workingFolder = tsc["exporter.working"].AsFilePath();
tsPath = tsc["timeseries.output.path"].AsFilePath();
//root = tsc["root", ".\\"].AsFilePath();
hasFolders = tsc["has.folders", true].AsBool();
use_year_on_path = tsc["use.year.on.path", true].AsBool();
join_time_series = tsc["join.timeseries", true].AsBool();
folderFormat = tsc["folder.format", "{start}_{end}"].AsString();
startFormat = tsc["start.format", "yyyyMMddHH"].AsString();
endFormat = tsc["end.format", "yyyyMMddHH"].AsString();
blocks.Add("EXPORT_TYPE : " + tsc["export.type", 1].AsString());
blocks.Add("COMPUTE_RESIDUAL : " + tsc["compute.residual", 0].AsString());
blocks.Add("VARIABLE_GRID : " + tsc["variable.grid", 0].AsString());
blocks.Add("WATERPOINTS_NAME : " + tsc["points.name", "WaterPoints2D"].AsString());
blocks.Add("GRID_FILENAME : " + tsc["grid.name", "grid.dat"].AsString());
blocks.Add("");
timeseries = tsc.ChildNodes.FindAll(delegate(ConfigNode node) { return node.Name == "timeseries"; });
if (timeseries.Count < 1)
throw new Exception("Block 'timeseries' is missing. There must be at least one.");
//Creates the blocks of timeseries
foreach (ConfigNode n in timeseries)
{
blocks.Add("<BeginTimeSerie>");
blocks.Add(" NAME : " + n["name"].AsString());
blocks.Add(" COORD_Y : " + n["y"].AsString());
blocks.Add(" COORD_X : " + n["x"].AsString());
blocks.Add("<EndTimeSerie>");
blocks.Add("");
outTS[n["name"].AsString()] = new TimeSeries();
if (System.IO.File.Exists(tsPath.Path + n["name"].AsString() + ".ets"))
{
outTS[n["name"].AsString()].Load(new FileName(tsPath.Path + n["name"].AsString() + ".ets"));
}
}
parameters = tsc.ChildNodes.FindAll(delegate(ConfigNode node) { return node.Name == "parameters"; });
if (parameters.Count < 1)
throw new Exception("Block 'parameters' is missing. There must be at least one.");
//Creates the blocks of parameters
foreach (ConfigNode n in parameters)
{
blocks.Add("<BeginParameter>");
blocks.Add(" HDF_GROUP : " + n["group"].AsString());
blocks.Add(" PROPERTY : " + n["property"].AsString());
blocks.Add("<EndParameter>");
blocks.Add("");
}
config = new TextFile();
//.........这里部分代码省略.........
示例2: JoinTimeseriesByFolder
protected void JoinTimeseriesByFolder(FileName output, string filter, List<FilePath> folders_to_search, bool search_sub_folders = true, bool overwrite = true, TimeUnits tu = TimeUnits.SECONDS)
{
try
{
if (folders_to_search == null || folders_to_search.Count <= 0)
throw new Exception("No folders to search timeseries were defined.");
if (string.IsNullOrWhiteSpace(output.FullPath))
throw new Exception("No timeseries output was defined");
if (!System.IO.Directory.Exists(output.Path))
throw new Exception("The path '" + output.Path + "' doesn't exist.");
if (System.IO.File.Exists(output.FullPath) && !overwrite)
throw new Exception("The file '" + output.FullName + "' exists and overwrite is set to false.");
if (string.IsNullOrWhiteSpace(filter))
throw new Exception("Filter was not set.");
int found = 0;
List<FileName> files = new List<FileName>();
List<TimeSeries> timeSeries = new List<TimeSeries>();
System.IO.SearchOption so;
if (search_sub_folders)
so = System.IO.SearchOption.AllDirectories;
else
so = System.IO.SearchOption.TopDirectoryOnly;
foreach (FilePath path in folders_to_search)
{
found = FindFiles(path, files, filter, so);
foreach (FileName fi in files)
{
TimeSeries newTS = new TimeSeries();
newTS.Load(fi);
timeSeries.Add(newTS);
}
}
if (timeSeries.Count <= 0)
return;
//Finds the Start Date for the output timeseries in the list of loaded timeseries
DateTime start = timeSeries[0].StartInstant;
for (int i = 1; i < timeSeries.Count; i++)
{
if (timeSeries[i].StartInstant < start)
start = timeSeries[i].StartInstant;
}
TimeSeries outTS = new TimeSeries();
outTS.StartInstant = start;
outTS.TimeUnits = tu;
foreach (Column col in timeSeries[0].Columns)
{
Column newCol = new Column(col.ColumnType);
newCol.Header = col.Header;
outTS.AddColumn(newCol);
}
foreach (TimeSeries toJoin in timeSeries)
outTS.AddTimeSeries(toJoin);
outTS.Save(output);
}
catch (Exception ex)
{
exception_raised = true;
exception = new Exception("ScriptV8.JoinTimeseriesByFolder", ex);
throw exception;
}
}
示例3: JoinButton_Click
private void JoinButton_Click(object sender, EventArgs e)
{
try
{
if (TimeseriesList.Items.Count <= 0)
throw new GeneralException("No timeseries to join were defined.", ExceptionType.WARNING);
if (string.IsNullOrWhiteSpace(OutputTimeseriesTextbox.Text))
throw new GeneralException("You must define the output timeseries.", ExceptionType.WARNING);
else
{
try
{
output.FullPath = OutputTimeseriesTextbox.Text;
if (!System.IO.Directory.Exists(output.Path))
throw new GeneralException("The path '" + output.Path + "' doesn't exist.", ExceptionType.WARNING);
else if (System.IO.File.Exists(output.FullPath))
{
if (MessageBox.Show("The file '" + output.FullName + "' exists. Do you want to OVERWRITE it?", "WARNING", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
return;
}
}
catch (GeneralException)
{
throw;
}
catch (Exception ex)
{
throw new GeneralException(ex.Message, ExceptionType.ERROR);
}
}
FileName file = new FileName();
List<TimeSeries> timeSeries = new List<TimeSeries>();
foreach (object ts in TimeseriesList.Items)
{
file.FullPath = (string)ts;
TimeSeries newTS = new TimeSeries();
newTS.Load(file);
timeSeries.Add(newTS);
}
DateTime start = timeSeries[0].StartInstant;
for (int i = 1; i < timeSeries.Count; i++)
{
if (timeSeries[i].StartInstant < start)
start = timeSeries[i].StartInstant;
}
TimeSeries outTS = new TimeSeries();
outTS.StartInstant = start;
outTS.TimeUnits = (TimeUnits)Enum.Parse(typeof(TimeUnits), (string)TimeUnitsCombobox.SelectedItem, true);
foreach (Column col in timeSeries[0].Columns)
{
Column newCol = new Column(col.ColumnType);
newCol.Header = col.Header;
outTS.AddColumn(newCol);
}
foreach (TimeSeries toJoin in timeSeries)
outTS.AddTimeSeries(toJoin);
output.FullPath = OutputTimeseriesTextbox.Text;
outTS.Save(output);
MessageBox.Show("Proccess Completed.");
}
catch (GeneralException gex)
{
switch (gex.Type)
{
case ExceptionType.ERROR:
MessageBox.Show(gex.Message, "ERROR", MessageBoxButtons.OK);
break;
case ExceptionType.WARNING:
MessageBox.Show(gex.Message, "WARNING", MessageBoxButtons.OK);
break;
default:
MessageBox.Show("An unknown error happened. The message returned was: " + gex.Message, "ERROR", MessageBoxButtons.OK);
break;
}
}
catch (Exception ex)
{
MessageBox.Show("An unknown error happened. The message returned was: " + ex.Message, "ERROR", MessageBoxButtons.OK);
}
}
示例4: ExportByFolderList
//.........这里部分代码省略.........
cfg.WriteLine(" COORD_Y : " + ts.Y);
}
cfg.WriteLine("<EndTimeSerie>");
}
foreach (ParameterBlock p in opts.Parameters)
{
cfg.WriteLine("<BeginParameter>");
cfg.WriteLine(" PROPERTY : " + p.Name);
cfg.WriteLine(" HDF_GROUP : " + p.Group);
cfg.WriteLine("<EndParameter>");
}
cfg.Close();
//run HDFExporter Tool
app.Executable = opts.PathToHDFExporter;
app.UseShell = false;
app.WorkingDirectory = opts.WorkingFolder;
app.Arguments = "-c " + config_name;
app.CheckSuccessMethod = CheckSuccessMethod.DEFAULTOUTPUT;
app.TextToCheck = "successfully terminated";
app.Verbose = false;
app.Wait = true;
app.SearchTextOrder = SearchTextOrder.FROMEND;
AppExitStatus es;
if ((es = app.Run(this, e)) != AppExitStatus.Finished)
{
if (es != AppExitStatus.Canceled)
MessageBox.Show("HDFExporter tool has failed.", "ATTENTION", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!opts.KeepConfigFile)
{
try
{
System.IO.File.Delete(opts.WorkingFolder + config_name);
}
catch
{
}
}
if (opts.JoinTimeseries)
{
if (first)
{
foreach (TimeseriesBlock tsb in opts.TimeSeries)
{
TimeSeries new_ts = new TimeSeries();
new_ts.Load(new FileName(file.Path + tsb.Name + ".ets"));
new_ts.Name = tsb.Name + ".ets";
outputTS.Add(new_ts);
}
first = false;
}
else
{
int count = 0;
foreach (TimeseriesBlock tsb in opts.TimeSeries)
{
TimeSeries new_ts = new TimeSeries();
new_ts.Load(new FileName(file.Path + tsb.Name + ".ets"));
TimeSeries this_ts = outputTS[count];
this_ts.AddTimeSeries(new_ts);
new_ts = null;
if (!opts.KeepIntermediateTSFiles)
{
try
{
System.IO.File.Delete(file.Path + tsb.Name + ".ets");
}
catch
{
}
}
count++;
}
}
}
if (this.WorkerReportsProgress)
{
filesProcessed++;
int percentComplete = (int)((float)filesProcessed / (float)totalFiles * 100);
this.ReportProgress(percentComplete);
}
}
if (opts.JoinTimeseries)
{
foreach (TimeSeries ts in outputTS)
{
ts.Save(new FileName(new FilePath(opts.PathToOutputTimeSeries).Path + ts.Name + ".ets"));
}
}
}