Exemplo n.º 1
0
        //public static string FindMemberFromAka(Type t, string aka)
        //{
        //    foreach (MemberInfo memberInfo in t.GetMembers())
        //    {
        //        if (AkaAttribute.FindAka(memberInfo).ToLower() == aka.ToLower())
        //            return memberInfo.Name;
        //    }
        //    return null;
        //}

        public static void AssignTimeSeries(RiverSystemScenario scenario, object target, string element,
                                            string dataGroupName, string dataItem, int column = 0)
        {
            var ri = GetReflectedItem(target, element);

            var dm = scenario.Network.DataManager;

            dm.RemoveUsage(ri);

            var dataGroup = dm.DataGroups.Where(dg => dg.Name == dataGroupName).FirstOrDefault();

            if (dataGroup == null)
            {
                dataGroup      = DataGroupItem.CreateGroup <GeneratedCentralDataSource>(scenario.Network.DefaultInputSet);
                dataGroup.Name = dataGroupName;
                dm.DataGroups.Add(dataGroup);
            }

            var dataGroupItem = dataGroup.DataDetails.Where(dgi => dgi.Name == dataItem).FirstOrDefault();

            if (dataGroupItem == null)
            {
                Data[]     loaded = NonInteractiveIO.Load(dataItem);
                TimeSeries ts     = loaded[column] as TimeSeries;
                ts.name = dataItem;
                dataGroup.CreateUsage <GeneratedDataDetails>(ri, ts);
            }
            else
            {
                dataGroupItem.Usages.Add(new DataUsage {
                    ReflectedItem = ri
                });
            }
        }
Exemplo n.º 2
0
        private void LoadFromFile(DataGroupItem dataGroup, DataSourceItem sourceItem)
        {
            FileCentralDataSource ds = sourceItem.SourceInformation as FileCentralDataSource;

            TimeSeries[] allTS = (TimeSeries[])NonInteractiveIO.Load(ds.Filename);
            if (allTS == null)
            {
                return;
            }
            for (var i = 0; i < allTS.Length; i++)
            {
                var             ts       = allTS[i];
                DataDetailsItem dataItem = new DataDetailsItem
                {
                    Data = new TimeSeriesPersistent {
                        TimeSeries = ts
                    },
                    DataInformation = new FileDataDetails {
                        Name = ts.name, ReloadOnRun = ReloadOnRun, Column = i
#if V3 || V4_0 || V4_1 || V4_2
#else
                        , StartDate = ts.Start
#endif
                    }
                };
                sourceItem.Data.Add(dataItem);

                var gdd = new GenericDataDetails {
                    Name = ts.name
                };
                gdd.AssociatedData.Add(dataItem);
                dataGroup.DataDetails.Add(gdd);
            }
        }
Exemplo n.º 3
0
        public static void Run(RunComplexType runSettings, Diagnostics diagnostics, string[] args)
        {
            TimeSeries[] results =
                (TimeSeries[])
                NonInteractiveIO.Load(runSettings.workDir + "\\" + runSettings.Property(Keys.OUTPUT_FILE));
            diagnostics.Log(3, string.Format("Loaded {0} time series", results.Length));

            string forcedTimeStep = runSettings.Property(Keys.FORCED_TIMESTAMP);
            TimeSeriesCollectionComplexType fewsTimeSeriesCollection = TIMEProxy.FromTimeSeriesCollection(results, runSettings.timeZone, forcedTimeStep);
            string outputFn = runSettings.outputTimeSeriesFile[0];

            FEWSPIProxy.WriteTimeSeriesCollection(outputFn, fewsTimeSeriesCollection);
            diagnostics.Log(3, string.Format("Written {0} time series to {1}", fewsTimeSeriesCollection.series.Length, outputFn));

            diagnostics.Log(3, "All Done");
        }