schema: | |

keywords: | transformation, interpolation |

#### Description and Usage

This transformation function is used to interpolate data stored as a longitudinal profile to a track, which usually consist of three scalar time series: latitude, longitude and values. The transformation function takes the longitudinal profile, latitude and longitude time series as input and produces a new scalar time series with the values for the track.

The produced time series will have values for exactly those times for which the latitude and longitude input series were available. The values in the latitude and longitude series are used as WGS 1984 coordinates. To obtain the resulting value for this time / these coordinates, the transformation uses closest distance interpolation for both space and time. First the closest point in the longitudinal profile is found. Then, from the time series for this longitudinal profile point, the value at the closest time is selected as the output value.

The transformation contains an optimization which assumes that the "tracker" with which the track coordinates correspond, moves along the longitudinal profile at a pace slow enough to never pass more than 1 point in a single time step, i.e., for each latitude and longitude input time series, only for the first non-missing point the distance to all longitudinal profile points is calculated. After this "calibration", the transformation remembers which profile point was closest for the previous time step, and for subsequent time steps only the distance to the previously closest profile point and its direct neighbors is calculated, from which the closest profile point is selected.

If the coordinates for at least <minMissingStepsForRecalibration> subsequent time step are missing (NaN), the next non-missing point is treated as the first point in a new time series. By default, <minMissingStepsForRecalibration> will be set to 1. Note that if <minMissingStepsForRecalibration> is set to 0, the distance between all track points and longitudinal profile points is calculated, effectively removing the optimization. For the best possible optimization of this transformation, set <minMissingStepsForRecalibration> to the minimum amount of time steps a "tracker" will need to go from one longitudinal profile point to the next.

It is possible to provide a <maxDistance> (in meters). When this maximum distance is provided, the output value is set to missing if the distance between the track point and the closest profile point is found to be more than the provided maximum distance.

The transformation will produce a missing value if any of the following occurs:

- One of the track coordinates is missing (NaN) for this time step (or both are).
- The longitudinal profile contains a missing (NaN) value at the selected point and time.
- A maximum distance is given in the configuration and the closest profile point found is larger than this maximum distance.

#### Input/Output time series

This function takes three input time series and produces one output time series.

- <inputLongitudinalProfile>: A time series with <valueType> longitudinalprofile. The geodatum of this profile must be WGS 1984.
- <inputTrackX>: A scalar time series containing the longitude for each track point.
- <inputTrackY>: A scalar time series containing the latitude for each track point.
- <outputVariable>: A scalar time series which will contain the parameter value for each track point.

#### Configuration

A basic configuration of the function is described below. This describes the main elements and attributes required and provides an example configuration.

*<inputLongitudinalProfile>*

Required element defining the identifier of the longitudinalprofile input time series with input values. This Id must reference a valid input time series, i.e., a series of <valueType> longitudinalprofile that uses geoDatum WGS 1984.

*<inputTrackX>*

Required element defining the identifier of the scalar input time series with longitude input values. The input time series referenced must be scalar and have the same length, i.e., the same <timeStep> and <relativeViewPeriod> as the time series used for <inputTrackY> and <outputVariable>.

*<inputTrackY>*

Required element defining the identifier of the scalar input time series with latitude input values. The input time series referenced must be scalar and have the same length, i.e., the same <timeStep> and <relativeViewPeriod> as the time series used for <inputTrackX> and <outputVariable>.

*<maxDistance>*

Optional element defining the maximum distance in meters.

*<minMissingStepsForRecalibration>*

Optional element defining the minimum number of missing time steps (coordinates), for the transformation to interpret the next non-missing value as the first value in a new time series. Default value: 1.

*<outputVariable>*

Required element defining the identifier of the output time series with output values. The output time series referenced must be scalar and have the same length, i.e., the same <timeStep> and <relativeViewPeriod> as the time series used for <inputTrackX> and <outputVariable>.

*Example*

<transformation id="interpolation serial longitudinalProfileToTrack"> <interpolationSerial> <longitudinalProfileToTrack> <inputLongitudinalProfile> <variableId>profile_level</variableId> </inputLongitudinalProfile> <inputTrackX> <variableId>track_lon</variableId> </inputTrackX> <inputTrackY> <variableId>track_lat</variableId> </inputTrackY> <maxDistance>100.0</maxDistance> <minMissingStepsForRecalibration>2</minMissingStepsForRecalibration> <outputVariable> <variableId>track_level</variableId> </outputVariable> </longitudinalProfileToTrack> </interpolationSerial> </transformation>