public static string FindDataSource(RiverSystemScenario scenario, object target, string element, string inputSet = null) { var ri = GetReflectedItem(target, element); Network theNetwork = scenario.Network; InputSet theInputSet = null; if (inputSet != null) { IList <InputSet> inputSets = theNetwork.InputSets; theInputSet = inputSets.FirstOrDefault(i => i.Name == inputSet); } if (theInputSet == null) { theInputSet = theNetwork.DefaultInputSet; } DataManager dm = theNetwork.DataManager; foreach (var name in dm.DataGroups.Select(g => g.GetFullPath(ri, theInputSet)).Where(name => !String.IsNullOrEmpty(name))) { return(name); } return(""); }
//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 }); } }
public static void InitialiseModelsForConstituent(RiverSystemScenario s, Constituent c) { ConstituentsManagement cm = s.Network.ConstituentsManagement; cm.Elements.OfType <NetworkElementConstituentData>().ForEachItem(d => { if (d.Data == null) { d.Data = new ConstituentsModel(); } d.Data.GetModel(c, DefaultSourceSinkType(d)); if (!d.Data.ConstituentPlayedValues.Any(cpv => cpv.Constituent == c)) { d.Data.ConstituentPlayedValues.Add(new ConstituentPlayedValue(c) { PlayedType = ConstituentPlayedValue.ConstituentPlayedType.varConcentration }); } d.Reset(cm, false, null, ScenarioType.RiverManager); }); foreach (var catchment in s.Network.Catchments.OfType <Catchment>()) { foreach (var functionalUnit in catchment.FunctionalUnits.OfType <StandardFunctionalUnit>()) { InitialiseConstituentSources(s, catchment, functionalUnit, c); } } }
public static DataTable FunctionalUnits(RiverSystemScenario scenario) { var result = new DataTable(); result.Columns.Add("Catchment", typeof(string)); scenario.Network.FunctionalUnitConfiguration.fuDefinitions.ForEachItem(fud => result.Columns.Add(fud.Name, typeof(double))); foreach (ICatchment ic in scenario.Network.Catchments) { Catchment c = ic as Catchment; if (c == null) { continue; } var row = result.NewRow(); row["Catchment"] = c.Name; c.FunctionalUnits.ForEachItem(fu => { row[fu.definition.Name] = fu.areaInSquareMeters; }); result.Rows.Add(row); } return(result); }
public VeneerStatus(RiverSystemScenario s) { Version = PROTOCOL_VERSION; SourceVersion = new Constants.ProductVersion().GetFullVersionString(); ProjectFile = s.Project.FileName; Scenario = s.Name; }
//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}); } }
public DataGroupItem AddToScenario(RiverSystemScenario scenario) { var dm = scenario.Network.DataManager; var asFile = Items.All(i => i.DetailsAsCSV == null); var dataGroupType = asFile ? typeof(FileCentralDataSource) : typeof(GeneratedCentralDataSource); var dataGroup = DataGroupItem.CreateGroup(dataGroupType, scenario.Network.InputSets); dataGroup.Name = Name; if (asFile) { dataGroup.InputSetItems.ForEachItem(i => { FileCentralDataSource ds = i.DataSource.SourceInformation as FileCentralDataSource; ds.Filename = Name; }); } dm.DataGroups.Add(dataGroup); if (Items == null) { return(dataGroup); } for (int i = 0; i < Items.Length; i++) { var item = Items[i]; item.AddToGroup(scenario, dataGroup, i); } return(dataGroup); }
public E2CatchmentRREvaluator(RiverSystemScenario scenario) { this.scenario = scenario; RiverSystem.Node node = scenario.Network.outletNodes()[0] as RiverSystem.Node; theRunoff = scenario.NetworkRunner.record("Flow", node.Outflow); scenario.NetworkRunner.execute(); observedRunoff = (TimeSeries)theRunoff.copy( ); }
public static SchematicNetworkConfigurationPersistent GetSchematic(RiverSystemScenario scenario) { object tmp; scenario.AuxiliaryInformation.TryGetValue(SchematicNetworkControl.AUX_CONFIG, out tmp); SchematicNetworkConfigurationPersistent schematic = tmp as SchematicNetworkConfigurationPersistent; return(schematic); }
private static RiverSystemScenario CreateEmptyScenario(Options options) { var project = RiverSystemProject.CreateProject("Created Project"); var scenario = new RiverSystemScenario(project); var scenarioContainer = new RiverSystemScenarioContainer(scenario); project.AddScenario(scenarioContainer); return(scenario); }
public static void InitialiseModelsForConstituentSource(RiverSystemScenario s) { foreach (var catchment in s.Network.Catchments.OfType <Catchment>()) { foreach (var functionalUnit in catchment.FunctionalUnits.OfType <StandardFunctionalUnit>()) { foreach (var constituent in s.SystemConfiguration.Constituents) { InitialiseConstituentSources(s, catchment, functionalUnit, constituent); } } } }
internal void AddToGroup(RiverSystemScenario scenario, DataGroupItem dataGroup, int index) { DataSourceItem sourceItem = dataGroup.InputSetItems[index].DataSource; sourceItem.Name = Name; if (DetailsAsCSV == null) { LoadFromFile(dataGroup, sourceItem); } else { LoadFromDetails(dataGroup, sourceItem); } }
private static void InitialiseConstituentSources(RiverSystemScenario scenario, Catchment catchment, StandardFunctionalUnit fu, Constituent constituent) { ConstituentsManagement cm = scenario.Network.ConstituentsManagement; FunctionalUnitConstituentData model = cm.GetConstituentData <CatchmentElementConstituentData>(catchment).GetFunctionalUnitData(fu); ConstituentContainer constituentModel = model.ConstituentModels.SingleOrDefault(f => f.Constituent.Equals(constituent)); if (constituentModel == null) { constituentModel = new ConstituentContainer(constituent); model.ConstituentModels.Add(constituentModel); } #if V3 || V4_0 || V4_1 || V4_2 || V4_3 if (constituentModel.ConstituentSources.Count == scenario.SystemConfiguration.ConstituentSources.Count) { return; } #else if (constituentModel.ConstituentSources.Length == scenario.SystemConfiguration.ConstituentSources.Count) { return; } #endif scenario.SystemConfiguration.ConstituentSources.ForEachItem(cs => { if (constituentModel.ConstituentSources.Any(csc => csc.ConstituentSource == cs)) { return; } #if V3 || V4_0 || V4_1 || V4_2 || V4_3 constituentModel.ConstituentSources.Add(new ConstituentSourceContainer(cs, new NilConstituent(), new PassThroughFilter())); #else constituentModel.AddConstituentSources(new ConstituentSourceContainer(cs, new NilConstituent(), new PassThroughFilter())); #endif }); /* * var defaultConstituentSource = scenario.SystemConfiguration.ConstituentSources.First(cs => cs.IsDefault); #if V3 || V4_0 || V4_1 || V4_2 || V4_3_0 * constituentModel.ConstituentSources.Add(new ConstituentSourceContainer(defaultConstituentSource, new NilConstituent(), new PassThroughFilter())); #else * constituentModel.AddConstituentSources(new ConstituentSourceContainer(defaultConstituentSource, new NilConstituent(), new PassThroughFilter())); #endif */ }
public static void printPrams(RiverSystemScenario scenario, ISystemConfiguration pSet) { StringBuilder sb = new StringBuilder(); foreach (Catchment c in scenario.Network.catchmentList) { foreach (StandardFunctionalUnit fu in c.FunctionalUnits) { List <AccessorMemberInfo> accessorInfoList = MetaParameterSet.KnownParameters(fu.rainfallRunoffModel); foreach (var accessorMemberInfo in accessorInfoList) { sb.AppendLine(c.Name + ":" + fu.definition.Name + ":" + accessorMemberInfo.Name + ":" + accessorMemberInfo.GetValue(fu.rainfallRunoffModel)); } sb.AppendLine("-----"); } } (pSet as MetaParameterSet).RealConfiguration = sb.ToString(); Console.WriteLine(sb.ToString()); }
public static void EnsureElementsHaveConstituentProviders(RiverSystemScenario scenario) { Network network = scenario.Network; ConstituentsManagement cm = network.ConstituentsManagement; Action <INetworkElement> ensure = element => { cm.NetworkElementAdded(element, null); }; network.Nodes.ForEachItem(ensure); network.Links.ForEachItem(ensure); /* * var element = sender as INetworkElement; * if (element != null && !_elementsDictionary.ContainsKey(element)) * _elementsDictionary.Add(element, ElementDataFactory.GetNetworkElementConstituentData(element)); */ }
public GeoJSONFeature(Link l, RiverSystemScenario scenario, bool useSchematicLocation) { id = LinkURL(l); properties.Add("name", l.Name); properties.Add(FeatureTypeProperty, "link"); properties.Add("from_node", NodeURL((Node)l.UpstreamNode, l.Network)); properties.Add("to_node", NodeURL((Node)l.DownstreamNode, l.Network)); properties.Add("length", l.Length); if (useSchematicLocation) { var schematic = ScriptHelpers.GetSchematic(scenario); if (scenario != null) { geometry = new GeoJSONGeometry(SchematicLocationForNode(l.from, schematic), SchematicLocationForNode(l.to, schematic)); return; } } geometry = new GeoJSONGeometry(l, useSchematicLocation); }
public GeoJSONFeature(Node n,RiverSystemScenario scenario,bool useSchematicLocation) { id = NodeURL(n); properties.Add("name",n.Name); properties.Add(FeatureTypeProperty, "node"); Coordinate loc = n.location; var schematic = ScriptHelpers.GetSchematic(scenario); if (schematic != null) { PointF schematicLocation = SchematicLocationForNode(n, schematic); properties.Add("schematic_location",new double[] {schematicLocation.X,schematicLocation.Y}); if (useSchematicLocation) loc = new Coordinate(schematicLocation); } properties.Add(ResourceProperty, UriTemplates.Resources.Replace("{resourceName}", ResourceName(n))); geometry = new GeoJSONGeometry(loc); }
public VariableSummary(AbstractFunctionVariable v,RiverSystemScenario scenario) { Scenario = scenario; Variable = v; Name = v.Name; FullName = v.FullName; ID = v.id; VariableType = v.GetType().Name; if (v is BilinearVariable) { VeneerSupported = false; } else if (v is ContextVariable) { VeneerSupported = false; } else if (v is ModelledVariable) { VeneerSupported = false; } else if (v is PatternVariable) { VeneerSupported = false; } else if (v is LinearVariable) { VeneerSupported = true; PiecewiseFunctionData = new SimplePiecewise(v as LinearVariable); PiecewiseFunction = String.Format("/variables/{0}/Piecewise", FullName.Replace("$", "")); } else if (v is TimeSeriesVariable) { VeneerSupported = true; var tsV = (TimeSeriesVariable) v; VeneerDebugInfo += kvp("DisplayName", tsV.DisplayName) + kvp("ResultUnit", tsV.ResultUnit.Name); TimeSeriesData = new SimpleTimeSeries(FindTimeSeries()); TimeSeries = String.Format("/variables/{0}/TimeSeries", FullName.Replace("$", "")); } }
public VariableSummary(AbstractFunctionVariable v, RiverSystemScenario scenario) { Scenario = scenario; Variable = v; Name = v.Name; FullName = v.FullName; ID = v.id; VariableType = v.GetType().Name; if (v is BilinearVariable) { VeneerSupported = false; } else if (v is ContextVariable) { VeneerSupported = false; } else if (v is ModelledVariable) { VeneerSupported = false; } else if (v is PatternVariable) { VeneerSupported = false; } else if (v is LinearVariable) { VeneerSupported = true; PiecewiseFunctionData = new SimplePiecewise(v as LinearVariable); PiecewiseFunction = String.Format("/variables/{0}/Piecewise", FullName.Replace("$", "")); } else if (v is TimeSeriesVariable) { VeneerSupported = true; var tsV = (TimeSeriesVariable)v; VeneerDebugInfo += kvp("DisplayName", tsV.DisplayName) + kvp("ResultUnit", tsV.ResultUnit.Name); TimeSeriesData = new SimpleTimeSeries(FindTimeSeries()); TimeSeries = String.Format("/variables/{0}/TimeSeries", FullName.Replace("$", "")); } }
public MetaParameterSet(object system) { var r = new List <AccessorMemberInfo>( ); RiverSystemScenario riverSystemScenario = system as RiverSystemScenario; foreach (var item in riverSystemScenario.Network.catchmentList) { Catchment catchment = item as Catchment; foreach (StandardFunctionalUnit functionalUnit in catchment.FunctionalUnits) { List <AccessorMemberInfo> list = KnownParameters(functionalUnit.rainfallRunoffModel); r.AddRange(list); } } foreach (AccessorMemberInfo key in r) { if (!availableParameters.Contains(key)) { availableParameters.Add(key); } } }
public static TimeSeries FindInputTimeSeries(RiverSystemScenario scenario, object target, string element, string inputSet = null) { var ri = GetReflectedItem(target, element); Network theNetwork = scenario.Network; InputSet theInputSet = null; if (inputSet != null) { IList <InputSet> inputSets = theNetwork.InputSets; theInputSet = inputSets.FirstOrDefault(i => i.Name == inputSet); } if (theInputSet == null) { theInputSet = theNetwork.DefaultInputSet; } DataManager dm = theNetwork.DataManager; return(dm.GetUsedTimeSeries(theInputSet, ri)); }
public GeoJSONFeature(Node n, RiverSystemScenario scenario, bool useSchematicLocation) { id = NodeURL(n, scenario.Network); properties.Add("name", n.Name); properties.Add(FeatureTypeProperty, "node"); Coordinate loc = n.location; var schematic = ScriptHelpers.GetSchematic(scenario); if (schematic != null) { PointF schematicLocation = SchematicLocationForNode(n, schematic); properties.Add("schematic_location", new double[] { schematicLocation.X, schematicLocation.Y }); if (useSchematicLocation) { loc = new Coordinate(schematicLocation); } } properties.Add(ResourceProperty, UriTemplates.Resources.Replace("{resourceName}", ResourceName(n))); geometry = new GeoJSONGeometry(loc); }
public static void ConfigureAssuranceRule(RiverSystemScenario scenario, string level = "Off", string name = null, string category = null) { var config = scenario.GetScenarioConfiguration <AssuranceConfiguration>(); LogLevel logLevel; if (!Enum.TryParse <LogLevel>(level, true, out logLevel)) { throw new Exception("Unknown log level"); } if (name == null) { scenario.Network.AssuranceManager.DefaultLogLevels.ForEachItem(ar => { ConfigureAssuranceRule(scenario, level, ar.Name, ar.Category); }); return; } bool needToAdd = false; AssuranceRule rule = GetAssuranceRule(name, category, config.Entries); if (rule == null) { rule = GetAssuranceRule(name, category, scenario.Network.AssuranceManager.DefaultLogLevels); needToAdd = true; } if (rule == null) { throw new Exception("Unknown assurance rule"); } rule.LogLevel = logLevel; if (needToAdd) { config.Entries.Add(rule); } }
public void ReplaceInScenario(RiverSystemScenario scenario, DataGroupItem existing) { var dm = scenario.Network.DataManager; var name = Name; Name = string.Format("TMP___{0}", name); var newItem = AddToScenario(scenario); foreach (var origDetail in existing.DataDetails) { var destDetail = newItem.DataDetails.First(dd => dd.Name == origDetail.Name); foreach (var usage in origDetail.Usages) { destDetail.Usages.Add(usage); } origDetail.Usages.Clear(); } Name = name; newItem.Name = name; dm.RemoveGroup(existing); dm.Refresh(); }
public static string FindDataSource(RiverSystemScenario scenario, object target, string element, string inputSet = null) { var ri = GetReflectedItem(target, element); Network theNetwork = scenario.Network; InputSet theInputSet = null; if (inputSet != null) { IList<InputSet> inputSets = theNetwork.InputSets; theInputSet = inputSets.FirstOrDefault(i => i.Name == inputSet); } if (theInputSet == null) theInputSet = theNetwork.DefaultInputSet; DataManager dm = theNetwork.DataManager; foreach (var name in dm.DataGroups.Select(g => g.GetFullPath(ri,theInputSet)).Where(name => !String.IsNullOrEmpty(name))) { return name; } return ""; }
public ParseDataRequests(RiverSystemScenario scenario) { Scenario = scenario; }
private IObjectiveEvaluator<MetaParameterSet> buildNewEvaluator( RiverSystemScenario scenario ) { return new E2CatchmentRREvaluator( scenario ); }
private static RainfallRunoffModel[] findAllAwbmInstances(RiverSystemScenario scenario) { return(RiverSystem.TestingSupport.TestHelperRiverSystem.RainfallRunoffModels(scenario).FindAll((x => (x is AWBM))).ToArray()); }
public LumpedAWBMFactory(RiverSystemScenario scenario, IRandomNumberGeneratorFactory rng) { this.scenario = scenario; this.random = rng.CreateRandom(); GetMetaParameterSet(); }
public InputSets(RiverSystemScenario scenario) { Scenario = scenario; }
public GeoJSONFeature(Link l, RiverSystemScenario scenario, bool useSchematicLocation) { id = LinkURL(l); properties.Add("name", l.Name); properties.Add(FeatureTypeProperty, "link"); properties.Add("from_node", NodeURL(l.UpstreamNode)); properties.Add("to_node", NodeURL(l.DownstreamNode)); if (useSchematicLocation) { var schematic = ScriptHelpers.GetSchematic(scenario); if (scenario != null) { geometry = new GeoJSONGeometry(SchematicLocationForNode(l.from,schematic),SchematicLocationForNode(l.to,schematic)); return; } } geometry = new GeoJSONGeometry(l, useSchematicLocation); }
public static void InitialiseModelsForConstituent(RiverSystemScenario s, Constituent c) { ConstituentsManagement cm = s.Network.ConstituentsManagement; cm.Elements.OfType<NetworkElementConstituentData>().ForEachItem(d => { if (d.Data == null) d.Data = new ConstituentsModel(); d.Data.GetModel(c, DefaultSourceSinkType(d)); }); foreach (var catchment in s.Network.Catchments.OfType<Catchment>()) { foreach (var functionalUnit in catchment.FunctionalUnits.OfType<StandardFunctionalUnit>()) { InitialiseConstituentSources(s,catchment, functionalUnit,c); } } }
public static void EnsureElementsHaveConstituentProviders(RiverSystemScenario scenario) { Network network = scenario.Network; ConstituentsManagement cm = network.ConstituentsManagement; Action<INetworkElement> ensure = element => { cm.NetworkElementAdded(element,null); }; network.Nodes.ForEachItem(ensure); network.Links.ForEachItem(ensure); /* var element = sender as INetworkElement; if (element != null && !_elementsDictionary.ContainsKey(element)) _elementsDictionary.Add(element, ElementDataFactory.GetNetworkElementConstituentData(element)); */ }
private static void InitialiseConstituentSources(RiverSystemScenario scenario, Catchment catchment, StandardFunctionalUnit fu, Constituent constituent) { ConstituentsManagement cm = scenario.Network.ConstituentsManagement; FunctionalUnitConstituentData model = cm.GetConstituentData<CatchmentElementConstituentData>(catchment).GetFunctionalUnitData(fu); ConstituentContainer constituentModel = model.ConstituentModels.SingleOrDefault(f => f.Constituent.Equals(constituent)); if (constituentModel == null) { constituentModel = new ConstituentContainer(constituent); model.ConstituentModels.Add(constituentModel); } if (constituentModel.ConstituentSources.Count > 0) return; var defaultConstituentSource = scenario.SystemConfiguration.ConstituentSources.First(cs => cs.IsDefault); constituentModel.ConstituentSources.Add(new ConstituentSourceContainer(defaultConstituentSource, new NilConstituent(), new PassThroughFilter())); }
public static SchematicNetworkConfigurationPersistent GetSchematic(RiverSystemScenario scenario) { object tmp; scenario.AuxiliaryInformation.TryGetValue(SchematicNetworkControl.AUX_CONFIG, out tmp); SchematicNetworkConfigurationPersistent schematic = tmp as SchematicNetworkConfigurationPersistent; return schematic; }
public static TimeSeries FindInputTimeSeries(RiverSystemScenario scenario, object target, string element, string inputSet=null) { var ri = GetReflectedItem(target, element); Network theNetwork = scenario.Network; InputSet theInputSet = null; if (inputSet != null) { IList<InputSet> inputSets = theNetwork.InputSets; theInputSet = inputSets.FirstOrDefault(i => i.Name == inputSet); } if(theInputSet==null) theInputSet= theNetwork.DefaultInputSet; DataManager dm = theNetwork.DataManager; return dm.GetUsedTimeSeries(theInputSet,ri); }
public void Initialise(RiverSystemScenario scenario) { this.scenario = scenario; }