import clr clr.AddReference('DHI.Solutions.TimeseriesManager.Tools.Processing') from DHI.Solutions.TimeseriesManager.Tools.Processing import * clr.AddReference('DHI.Solutions.Generic') from DHI.Solutions.Generic import * def FlagOutliers(): """ """ lowerValue = 0 upperValue = 10 inputGroupPath = "/Discharge" tsmod = app.Modules.Get("Time Series Manager") inputGroup = tsmod.TimeSeriesGroupList.Fetch(inputGroupPath) q = Query(); q.Add(QueryElement('GroupId', inputGroup.Id, QueryOperator.Eq)); tsList = tsmod.TimeSeriesList.Fetch(q) for ts in tsList: tool = app.Tools.CreateNew('Flag outliers') tool.InputItems.Add(ts) tool.Smoothing = SmoothingOption.Disabled tool.LowerLimit = lowerValue tool.UpperLimit = upperValue tool.AddFlagsToCopy = True tool.FlagOutliers = "Out of Range Q" tool.ReplaceExisting = True tool.Option = CriteriaOption.Outside_range tool.Execute() tsOut = tool.OutputItems[0] tsOut.GroupId = inputGroup.Id tsmod.TimeSeriesList.Delete(ts) tsmod.TimeSeriesList.Add(tsOut) tsOut.UpdateFlagValues(tsOut.GetAll())