Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Transformation - Sample nonEquidistant

Description and usage

This transformation is used to convert a non equidistant time series to an equidistant time series. The value at this time step will derived from sampling the equidistant time series. It is possible to configure how the equidistant time series should be sampled.

The available options are:

...

Table of Contents
maxLevel4
minLevel4

options

  • maxGapLength (Only implemented for linear and block interpolation.)
  • ignoreMissing / validationRule

maxGaplength: Gaps equal to or smaller than maxGapLength will be filled with sampled values. Gaps larger than maxGapLength will not be filled. If maxGapLength is not defined, then all gaps will be filled with sampled values.

ignoreMissing: if true, then missing values are ignored. If false, then an output value will be missing if one or more of the corresponding input values are missing or unreliable. Default is true.


Examples

Below examples are shown. Each example uses the same non-equidistant input timeseries, but a different sampling method is applied. The output timeseries has timesteps of 1 day.

Accumulate

Accumulates the values, weighted to the timestep, to the wanted output timestep.

TimeWeightedAverage

Calculates the average value while taking the time between different values into account.

This is implemented as follows:

  • The target time step is split over the source time steps.
  • All the values of the parts of the source time steps are mutliplied by the amount of milliseconds and added together.
  • The result of that addition is then divided by the amount of milliseconds of the target time step.

An example can be seen in the table below where a time series with non equidistant time step is resampled to a 15 minute time step.

Row TimeBFormulaResult
713-6-2021 08:45:000,015B70,015
813-6-2021 08:56:470,016

913-6-2021 09:00:000,017(B8 * 707000 + B9 * 193000) / 9000000,016214444
1013-6-2021 09:11:470,021

1113-6-2021 09:11:530,017

1213-6-2021 09:13:530,014

1313-6-2021 09:13:580,016

1413-6-2021 09:15:000,018(B10 * 707000 + B11 * 6000 + B12 * 120000 + B13 * 5000 + B14 * 62000) / 9000000,019805556
1513-6-2021 09:26:470,017

1613-6-2021 09:26:480,018

1713-6-2021 09:30:000,016(B15 * 707000 + B16 * 1000 + B17 * 192000) / 9000000,0167877778
1813-6-2021 09:41:470,015

1913-6-2021 09:45:000,015(B18 * 707000 + B19 * 193000) / 9000000,015
2013-6-2021 10:00:000,016B200,016
2113-6-2021 10:11:470,018

2213-6-2021 10:11:500,017

2313-6-2021 10:15:000,015(B21 * 707000 + B22 * 3000 + B23 * 190000) / 9000000,017363333


Zero

Every input value that fits an output timestep is stored in the output timeseries. In this case that is only the last value, at 06-01-2014. All other values in the output timeseries are set to zero.


 Image Added


Missing

Every input value that fits an output timestep is stored in the output timeseries. In this case that is only the last value, at 06-01-2014. All other values in the output timeseries are set to missing.


Image Added


PreviousTimeStep

The first input value to be found after each (output) timestep is stored in the output timeseries.


Image Added



NextTimeStep

The first input value to be found before each (output) timestep is stored in the output timeseries.


Image Added


Block

The first input value to be found before each (output) timestep is stored in the output timeserie, and repeated until a new value is found.


Image Added



Linear

The value of each output timestep is calculated, by interpolating the input values just before and after the output timestep. Essentially, the value is found at the point where the line connecting these values, crosses the timestep.
Image Added


LinearOrClosest

This method is a variation on the previous method. For every output timestep the method will search for input values in a searchwindow of 1 timestep-range before, and 1 timestep range after the output timestep. In this example, that means that for output timestep 02-01-2014 00:00 the method will look for a value in the searchwindow 01-01-2014 00:00 until 02-01-2014 00:00, and for one value in the searchwindow 02-01-2014 00:00  until 03-01-2014 00:00.
If there are input values before and after the output timestep, then these values are interpolated (this is the case for output timestep 02-01-2014 00:00). If there is only one value before or after, this value is stored (this is the case at 03-01-2014 00:00).
  • accumulate
  • block
  • linear
  • linearOrClosest
  • missing
  • nextTimeStep
  • previousTimeStep
  • zero

Closest

For each time step in the output time series the closest value in the sampled equidistant input time series is used as the output value.

ClosestForward

For each time step in the output time series the closest value after the output time step in the sampled equidistant input time series is used as the output value.

ClosestBackward

For each time step in the output time series the closest value before the output time step in the sampled equidistant input time series is used as the output value.

Linear

For each time step in the output time series the output value will be determined by linear interpolation between the closest value before the output time step and the closest value

after the output time step

Missing

All output values are set to missing.


Image Added


In the image below the results from both methods are depicted.


Image Added


Configuration

A basic configuration of the function is described below.

Code Block
languagexml
<?xml version="1.0" encoding="UTF-8"?>
<transformationModule version="1.0" xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/transformationModule.xsd">
	<!--Input time series-->
	<variable>
		<variableId>Q_in</variableId>
		<timeSeriesSet>
			<moduleInstanceId>ImportDatabase</moduleInstanceId>
			<valueType>scalar</valueType>
			<parameterId>Q.obs</parameterId>
			<locationSetId>HydroGauges_HuangChuan</locationSetId>
			<timeSeriesType>external historical</timeSeriesType>
			<timeStep unit="nonequidistant"/>
			<relativeViewPeriod unit="day" start="-16" end="0" startOverrulable="true"/>
			<readWriteMode>add originals</readWriteMode>
		</timeSeriesSet>
	</variable>
	<!--Output time series-->
	<variable>
		<variableId>Q_out</variableId>
		<timeSeriesSet>
			<moduleInstanceId>HuangChuan_Update_Pre</moduleInstanceId>
			<valueType>scalar</valueType>
			<parameterId>Q.obs</parameterId>
			<locationSetId>HydroGauges_HuangChuan</locationSetId>
			<timeSeriesType>external historical</timeSeriesType>
			<timeStep unit="hour" multiplier="6"/>
			<relativeViewPeriod unit="day" start="-16" end="0" startOverrulable="true"/>
			<readWriteMode>add originals</readWriteMode>
		</timeSeriesSet>
	</variable>
	<!--Transformations-->
	<transformation id="nonequidistant to equidistant">
		<sample>
			<nonEquidistant>
				<nonEquidistantInputVariable>
					<variableId>Q_in</variableId>
				</nonEquidistantInputVariable>
				<interpolationType>linear</interpolationType>
				<outputVariable>
					<variableId>Q_out</variableId>
				</outputVariable>
			</nonEquidistant>
		</sample>
	</transformation>
</transformationModule>

Image Modified

Save

Save

Save

Save

Save