clr.AddReference('DHI.Solutions.Generic') clr.AddReference('SpreadsheetGear2017.Core') clr.AddReference('DHI.Solutions.SpreadsheetManager.UI.Tools.ExportSpreadsheet') clr.AddReference('DHI.Solutions.TimeseriesManager.Tools.Processing') clr.AddReference('DHI.Solutions.SystemManager.Tools.DataExportImportTool') clr.AddReference('DHI.Solutions.SpreadsheetManager.UI.Tools.ImportSpreadsheet') from DHI.Solutions.TimeseriesManager.Tools.Processing import * from DHI.Solutions.Generic import * from System.IO import * from System.Globalization import * from System import * def DoResampleTool(): """ """ # write your code here inputItems = [] tsmod = app.Modules.Get("Time Series Manager") ts1 = tsmod.TimeSeriesList.Fetch("/MyInputFolder/MyTimeseries") inputItems.append(ts1) outputItems = ResampleTool(inputItems,0,0,0,0,15,0,StartDateOffset.SpecificDateTime,TimeSpan(0),DateTime.Parse('28/11/2018 00:00:00'),False,TimeSpan(0),0) print 'done' group = tsmod.TimeSeriesGroupList.Fetch("/MyOutputFolder/") ts = outputItems[0] ts.GroupId = group.Id tsmod.TimeSeriesList.Add(ts) def ResampleTool(inputItems, timeStepYear, timeStepMonth, timeStepDay, timeStepHour, timeStepMinute, timeStepSecond, startDateOffset, startTimeOffset, startTime, interpolateAcrossGaps, maxAllowedGapDuration, maxNumberOfMissingValuesPerGap): """ The resample tool is used to change the time step of a time series into a user specified time step. It is possible to resample into larger and smaller time steps. @param inputItems @type Array Tool input items @param timeStepYear @type System.Int32 Smoothing window width settings @param timeStepMonth @type System.Int32 Smoothing window width settings @param timeStepDay @type System.Int32 Smoothing window width settings @param timeStepHour @type System.Int32 Smoothing window width settings @param timeStepMinute @type System.Int32 Smoothing window width settings @param timeStepSecond @type System.Int32 Smoothing window width settings @param startDateOffset @type DHI.Solutions.TimeseriesManager.Tools.Processing.StartDateOffset The start date offset used to force the resampling to start at a specific point in time. Default is None which means the start time used is dictated by the first time step in the time series. If this is set to Day , the resampling calculates the first timestep of the output by adding the StartTimeOffset to midnight of the first timestep of the input. If the result is beforethe start of the input it is used, otherwise another 24 hours are subtracted from the starttime (as the offset is assumed to be less that 24 hours). If StartDateOffset is SpecificDateTime, the StartTime is used to specify the exact first timestep in the output. @values StartDateOffset.None, StartDateOffset.Day, StartDateOffset.SpecificDateTime @param startTimeOffset @type System.TimeSpan This is used together with the start date offset for forcing the resampling to start at a specific point in time of a day. Default is 00:00:00 resulting in midnight of the day of the start of the input time series. @param startTime @type System.DateTime A specific datetime indicating the first time step in the resampled output timeseries. Used when StartDateOffset = SpecificDateTime @param interpolateAcrossGaps @type System.Boolean This property determines if the algorithm shall interpolate across gaps in the input time series. If set to true, the algorothm will interpolate across gaps that are less than a specified duration/number. If set to false, gaps in the input series will result in gaps in the output series. @param maxAllowedGapDuration @type System.TimeSpan If the algorithm shall interpolate across gaps in the input series, this property determines the maximum duration of gaps that can be interpolated across. If this duration is exceeded, the algorithm will not interpolate across the gap(s), resulting in gap(s) in the output series. The format is in "Days:Hrs:Min:Sec". @param maxNumberOfMissingValuesPerGap @type System.Int32 If the algorithm shall interpolate across gaps in the input series, this property determines the maximum number of empty values that can be interpolated across. If this number is exceeded the algorithm will not interpolate across the gap(s), resulting in gap(s) in the output series. """ tool = app.Tools.CreateNew('Resample') if isinstance(inputItems,list): for inputItem in inputItems: tool.InputItems.Add(inputItem) else: if inputItems <> None: tool.InputItems.Add(inputItems) tool.TimeStepYear = timeStepYear tool.TimeStepMonth = timeStepMonth tool.TimeStepDay = timeStepDay tool.TimeStepHour = timeStepHour tool.TimeStepMinute = timeStepMinute tool.TimeStepSecond = timeStepSecond tool.StartDateOffset = startDateOffset tool.StartTimeOffset = startTimeOffset tool.StartTime = startTime tool.InterpolateAcrossGaps = interpolateAcrossGaps tool.MaxAllowedGapDuration = maxAllowedGapDuration tool.MaxNumberOfMissingValuesPerGap = maxNumberOfMissingValuesPerGap tool.Execute() return tool.OutputItems