Frequency Domain Analysis

    Name: CONV

    Input: Only support two input series. The types are both INT32 / INT64 / FLOAT / DOUBLE.

    Output: Output a single series. The type is DOUBLE. It is the result of convolution whose timestamps starting from 0 only indicate the order.

    Note: in the input series will be ignored.

    Examples

    Input series:

    SQL for query:

    1. select conv(s1,s2) from root.test.d2

    Output series:

    1. +-----------------------------+--------------------------------------+
    2. | Time|conv(root.test.d2.s1, root.test.d2.s2)|
    3. +-----------------------------+--------------------------------------+
    4. |1970-01-01T08:00:00.000+08:00| 7.0|
    5. |1970-01-01T08:00:00.001+08:00| 2.0|
    6. |1970-01-01T08:00:00.002+08:00| 7.0|
    7. |1970-01-01T08:00:00.003+08:00| 2.0|
    8. +-----------------------------+--------------------------------------+

    Deconv

    Usage

    This function is used to calculate the deconvolution, i.e. polynomial division.

    Name: DECONV

    Input: Only support two input series. The types are both INT32 / INT64 / FLOAT / DOUBLE.

    Parameters:

    • result: The result of deconvolution, which is ‘quotient’ or ‘remainder’. By default, the quotient will be output.

    Output: Output a single series. The type is DOUBLE. It is the result of deconvolving the second series from the first series (dividing the first series by the second series) whose timestamps starting from 0 only indicate the order.

    Note: NaN in the input series will be ignored.

    Examples

    Calculate the quotient

    When result is ‘quotient’ or the default, this function calculates the quotient of the deconvolution.

    Input series:

    1. +-----------------------------+---------------+---------------+
    2. | Time|root.test.d2.s3|root.test.d2.s2|
    3. +-----------------------------+---------------+---------------+
    4. |1970-01-01T08:00:00.000+08:00| 8.0| 7.0|
    5. |1970-01-01T08:00:00.001+08:00| 2.0| 2.0|
    6. |1970-01-01T08:00:00.002+08:00| 7.0| null|
    7. |1970-01-01T08:00:00.003+08:00| 2.0| null|
    8. +-----------------------------+---------------+---------------+

    SQL for query:

    1. select deconv(s3,s2) from root.test.d2

    Output series:

    1. +-----------------------------+----------------------------------------+
    2. | Time|deconv(root.test.d2.s3, root.test.d2.s2)|
    3. +-----------------------------+----------------------------------------+
    4. |1970-01-01T08:00:00.000+08:00| 1.0|
    5. |1970-01-01T08:00:00.001+08:00| 0.0|
    6. |1970-01-01T08:00:00.002+08:00| 1.0|
    7. +-----------------------------+----------------------------------------+

    Calculate the remainder

    When result is ‘remainder’, this function calculates the remainder of the deconvolution.

    Input series is the same as above, the SQL for query is shown below:

    1. select deconv(s3,s2,'result'='remainder') from root.test.d2

    Output series:

    1. +-----------------------------+--------------------------------------------------------------+
    2. | Time|deconv(root.test.d2.s3, root.test.d2.s2, "result"="remainder")|
    3. +-----------------------------+--------------------------------------------------------------+
    4. |1970-01-01T08:00:00.000+08:00| 1.0|
    5. |1970-01-01T08:00:00.001+08:00| 0.0|
    6. |1970-01-01T08:00:00.002+08:00| 0.0|
    7. |1970-01-01T08:00:00.003+08:00| 0.0|
    8. +-----------------------------+--------------------------------------------------------------+

    This function is used to calculate 1d discrete wavelet transform of a numerical series.

    Name: DWT

    Input: Only support a single input series. The type is INT32 / INT64 / FLOAT / DOUBLE.

    • method: The type of wavelet. May select ‘Haar’, ‘DB4’, ‘DB6’, ‘DB8’, where DB means Daubechies. User may offer coefficients of wavelet transform and ignore this parameter. Case ignored.
    • coef: Coefficients of wavelet transform. When providing this parameter, use comma ‘,’ to split them, and leave no spaces or other punctuations.
    • layer: Times to transform. The number of output vectors equals $layer+1$. Default is 1.

    Output: Output a single series. The type is DOUBLE. The length is the same as the input.

    Note: The length of input series must be an integer number power of 2.

    Examples

    Haar wavelet transform

    Input series:

    SQL for query:

    1. select dwt(s1,"method"="haar") from root.test.d1

    Output series:

    1. +-----------------------------+-------------------------------------+
    2. | Time|dwt(root.test.d1.s1, "method"="haar")|
    3. +-----------------------------+-------------------------------------+
    4. |1970-01-01T08:00:00.000+08:00| 0.14142135834465192|
    5. |1970-01-01T08:00:00.100+08:00| 1.909188342921157|
    6. |1970-01-01T08:00:00.200+08:00| 1.6263456473052773|
    7. |1970-01-01T08:00:00.300+08:00| 1.9798989957517026|
    8. |1970-01-01T08:00:00.400+08:00| 3.252691126023161|
    9. |1970-01-01T08:00:00.500+08:00| 1.414213562373095|
    10. |1970-01-01T08:00:00.600+08:00| 2.1213203435596424|
    11. |1970-01-01T08:00:00.700+08:00| 1.8384776479437628|
    12. |1970-01-01T08:00:00.800+08:00| -0.14142135834465192|
    13. |1970-01-01T08:00:00.900+08:00| 0.21213200063848547|
    14. |1970-01-01T08:00:01.000+08:00| -0.7778174761639416|
    15. |1970-01-01T08:00:01.100+08:00| -0.8485281289944873|
    16. |1970-01-01T08:00:01.300+08:00| -1.414213562373095|
    17. |1970-01-01T08:00:01.400+08:00| 0.42426400127697095|
    18. |1970-01-01T08:00:01.500+08:00| -0.42426408557066786|
    19. +-----------------------------+-------------------------------------+

    FFT

    Usage

    This function is used to calculate the fast Fourier transform (FFT) of a numerical series.

    Name: FFT

    Input: Only support a single input series. The type is INT32 / INT64 / FLOAT / DOUBLE.

    Parameters:

    • method: The type of FFT, which is ‘uniform’ (by default) or ‘nonuniform’. If the value is ‘uniform’, the timestamps will be ignored and all data points will be regarded as equidistant. Thus, the equidistant fast Fourier transform algorithm will be applied. If the value is ‘nonuniform’ (TODO), the non-equidistant fast Fourier transform algorithm will be applied based on timestamps.
    • result: The result of FFT, which is ‘real’, ‘imag’, ‘abs’ or ‘angle’, corresponding to the real part, imaginary part, magnitude and phase angle. By default, the magnitude will be output.
    • compress: The parameter of compression, which is within (0,1]. It is the reserved energy ratio of lossy compression. By default, there is no compression.

    Output: Output a single series. The type is DOUBLE. The length is the same as the input. The timestamps starting from 0 only indicate the order.

    Note: NaN in the input series will be ignored.

    Examples

    Uniform FFT

    With the default type, uniform FFT is applied.

    Input series:

    1. +-----------------------------+---------------+
    2. | Time|root.test.d1.s1|
    3. +-----------------------------+---------------+
    4. |1970-01-01T08:00:00.000+08:00| 2.902113|
    5. |1970-01-01T08:00:01.000+08:00| 1.1755705|
    6. |1970-01-01T08:00:02.000+08:00| -2.1755705|
    7. |1970-01-01T08:00:03.000+08:00| -1.9021131|
    8. |1970-01-01T08:00:05.000+08:00| 1.9021131|
    9. |1970-01-01T08:00:06.000+08:00| 0.1755705|
    10. |1970-01-01T08:00:07.000+08:00| -1.1755705|
    11. |1970-01-01T08:00:08.000+08:00| -0.902113|
    12. |1970-01-01T08:00:09.000+08:00| 0.0|
    13. |1970-01-01T08:00:10.000+08:00| 0.902113|
    14. |1970-01-01T08:00:11.000+08:00| 1.1755705|
    15. |1970-01-01T08:00:12.000+08:00| -0.1755705|
    16. |1970-01-01T08:00:13.000+08:00| -1.9021131|
    17. |1970-01-01T08:00:14.000+08:00| -1.0|
    18. |1970-01-01T08:00:15.000+08:00| 1.9021131|
    19. |1970-01-01T08:00:16.000+08:00| 2.1755705|
    20. |1970-01-01T08:00:17.000+08:00| -1.1755705|
    21. |1970-01-01T08:00:18.000+08:00| -2.902113|
    22. |1970-01-01T08:00:19.000+08:00| 0.0|
    23. +-----------------------------+---------------+

    SQL for query:

    1. select fft(s1) from root.test.d1

    Output series:

    1. +-----------------------------+----------------------+
    2. | Time| fft(root.test.d1.s1)|
    3. +-----------------------------+----------------------+
    4. |1970-01-01T08:00:00.000+08:00| 0.0|
    5. |1970-01-01T08:00:00.001+08:00| 1.2727111142703152E-8|
    6. |1970-01-01T08:00:00.002+08:00| 2.385520799101839E-7|
    7. |1970-01-01T08:00:00.003+08:00| 8.723291723972645E-8|
    8. |1970-01-01T08:00:00.004+08:00| 19.999999960195904|
    9. |1970-01-01T08:00:00.005+08:00| 9.999999850988388|
    10. |1970-01-01T08:00:00.006+08:00| 3.2260694930700566E-7|
    11. |1970-01-01T08:00:00.007+08:00| 8.723291605373329E-8|
    12. |1970-01-01T08:00:00.008+08:00| 1.108657103979944E-7|
    13. |1970-01-01T08:00:00.009+08:00| 1.2727110997246171E-8|
    14. |1970-01-01T08:00:00.010+08:00|1.9852334701272664E-23|
    15. |1970-01-01T08:00:00.011+08:00| 1.2727111194499847E-8|
    16. |1970-01-01T08:00:00.012+08:00| 1.108657103979944E-7|
    17. |1970-01-01T08:00:00.013+08:00| 8.723291785769131E-8|
    18. |1970-01-01T08:00:00.014+08:00| 3.226069493070057E-7|
    19. |1970-01-01T08:00:00.015+08:00| 9.999999850988388|
    20. |1970-01-01T08:00:00.016+08:00| 19.999999960195904|
    21. |1970-01-01T08:00:00.017+08:00| 8.723291747109068E-8|
    22. |1970-01-01T08:00:00.018+08:00| 2.3855207991018386E-7|
    23. |1970-01-01T08:00:00.019+08:00| 1.2727112069910878E-8|
    24. +-----------------------------+----------------------+

    Note: The input is $y=sin(2\pi t/4)+2sin(2\pi t/5)$ with a length of 20. Thus, there are peaks in $k=4$ and $k=5$ of the output.

    Uniform FFT with Compression

    Input series is the same as above, the SQL for query is shown below:

    1. select fft(s1, 'result'='real', 'compress'='0.99'), fft(s1, 'result'='imag','compress'='0.99') from root.test.d1

    Output series:

    1. +-----------------------------+----------------------+----------------------+
    2. | Time| fft(root.test.d1.s1,| fft(root.test.d1.s1,|
    3. | | "result"="real",| "result"="imag",|
    4. | | "compress"="0.99")| "compress"="0.99")|
    5. +-----------------------------+----------------------+----------------------+
    6. |1970-01-01T08:00:00.000+08:00| 0.0| 0.0|
    7. |1970-01-01T08:00:00.001+08:00| -3.932894010461041E-9| 1.2104201863039066E-8|
    8. |1970-01-01T08:00:00.002+08:00|-1.4021739447490164E-7| 1.9299268669082926E-7|
    9. |1970-01-01T08:00:00.003+08:00| -7.057291240286645E-8| 5.127422242345858E-8|
    10. |1970-01-01T08:00:00.004+08:00| 19.021130288047125| -6.180339875198807|
    11. |1970-01-01T08:00:00.005+08:00| 9.999999850988388| 3.501852745067114E-16|
    12. |1970-01-01T08:00:00.019+08:00| -3.932894898639461E-9|-1.2104202549376264E-8|
    13. +-----------------------------+----------------------+----------------------+

    Note: Based on the conjugation of the Fourier transform result, only the first half of the compression result is reserved. According to the given parameter, data points are reserved from low frequency to high frequency until the reserved energy ratio exceeds it. The last data point is reserved to indicate the length of the series.

    This function performs low-pass filtering on the input series and extracts components above the cutoff frequency. The timestamps of input will be ignored and all data points will be regarded as equidistant.

    Name: HIGHPASS

    Input: Only support a single input series. The type is INT32 / INT64 / FLOAT / DOUBLE.

    Parameters:

    • wpass: The normalized cutoff frequency which values (0,1). This parameter cannot be lacked.

    Note: NaN in the input series will be ignored.

    Examples

    Input series:

    SQL for query:

    1. select highpass(s1,'wpass'='0.45') from root.test.d1

    Output series:

    1. +-----------------------------+-----------------------------------------+
    2. | Time|highpass(root.test.d1.s1, "wpass"="0.45")|
    3. +-----------------------------+-----------------------------------------+
    4. |1970-01-01T08:00:00.000+08:00| 0.9999999534830373|
    5. |1970-01-01T08:00:01.000+08:00| 1.7462829277628608E-8|
    6. |1970-01-01T08:00:02.000+08:00| -0.9999999593178128|
    7. |1970-01-01T08:00:03.000+08:00| -4.1115269056426626E-8|
    8. |1970-01-01T08:00:04.000+08:00| 0.9999999925494194|
    9. |1970-01-01T08:00:06.000+08:00| -1.0000000183304454|
    10. |1970-01-01T08:00:07.000+08:00| 6.260191433311374E-10|
    11. |1970-01-01T08:00:08.000+08:00| 1.0000000018134796|
    12. |1970-01-01T08:00:09.000+08:00| -3.097210911744423E-17|
    13. |1970-01-01T08:00:10.000+08:00| -1.0000000018134794|
    14. |1970-01-01T08:00:11.000+08:00| -6.260191627862097E-10|
    15. |1970-01-01T08:00:12.000+08:00| 1.0000000183304454|
    16. |1970-01-01T08:00:14.000+08:00| -0.9999999925494196|
    17. |1970-01-01T08:00:15.000+08:00| 4.111526915498874E-8|
    18. |1970-01-01T08:00:16.000+08:00| 0.9999999593178128|
    19. |1970-01-01T08:00:17.000+08:00| -1.7462829341296528E-8|
    20. |1970-01-01T08:00:18.000+08:00| -0.9999999534830369|
    21. |1970-01-01T08:00:19.000+08:00| -1.035237222742873E-16|
    22. +-----------------------------+-----------------------------------------+

    Note: The input is $y=sin(2\pi t/4)+2sin(2\pi t/5)$ with a length of 20. Thus, the output is $y=sin(2\pi t/4)$ after high-pass filtering.

    IFFT

    Usage

    This function treats the two input series as the real and imaginary part of a complex series, performs an inverse fast Fourier transform (IFFT), and outputs the real part of the result. For the input format, please refer to the output format of FFT function. Moreover, the compressed output of FFT function is also supported.

    Name: IFFT

    Input: Only support two input series. The types are both INT32 / INT64 / FLOAT / DOUBLE.

    Parameters:

    • start: The start time of the output series with the format ‘yyyy-MM-dd HH:mm:ss’. By default, it is ‘1970-01-01 08:00:00’.
    • interval: The interval of the output series, which is a positive number with an unit. The unit is ‘ms’ for millisecond, ‘s’ for second, ‘m’ for minute, ‘h’ for hour and ‘d’ for day. By default, it is 1s.

    Output: Output a single series. The type is DOUBLE. It is strictly equispaced. The values are the results of IFFT.

    Note: If a row contains null points or NaN, it will be ignored.

    Examples

    Input series:

    1. +-----------------------------+----------------------+----------------------+
    2. | Time| root.test.d1.re| root.test.d1.im|
    3. +-----------------------------+----------------------+----------------------+
    4. |1970-01-01T08:00:00.000+08:00| 0.0| 0.0|
    5. |1970-01-01T08:00:00.001+08:00| -3.932894010461041E-9| 1.2104201863039066E-8|
    6. |1970-01-01T08:00:00.002+08:00|-1.4021739447490164E-7| 1.9299268669082926E-7|
    7. |1970-01-01T08:00:00.003+08:00| -7.057291240286645E-8| 5.127422242345858E-8|
    8. |1970-01-01T08:00:00.004+08:00| 19.021130288047125| -6.180339875198807|
    9. |1970-01-01T08:00:00.005+08:00| 9.999999850988388| 3.501852745067114E-16|
    10. |1970-01-01T08:00:00.019+08:00| -3.932894898639461E-9|-1.2104202549376264E-8|
    11. +-----------------------------+----------------------+----------------------+

    SQL for query:

    1. select ifft(re, im, 'interval'='1m', 'start'='2021-01-01 00:00:00') from root.test.d1

    Output series:

    1. +-----------------------------+-------------------------------------------------------+
    2. | Time|ifft(root.test.d1.re, root.test.d1.im, "interval"="1m",|
    3. | | "start"="2021-01-01 00:00:00")|
    4. +-----------------------------+-------------------------------------------------------+
    5. |2021-01-01T00:00:00.000+08:00| 2.902112992431231|
    6. |2021-01-01T00:01:00.000+08:00| 1.1755704705132448|
    7. |2021-01-01T00:02:00.000+08:00| -2.175570513757101|
    8. |2021-01-01T00:03:00.000+08:00| -1.9021130389094498|
    9. |2021-01-01T00:04:00.000+08:00| 0.9999999925494194|
    10. |2021-01-01T00:05:00.000+08:00| 1.902113046743454|
    11. |2021-01-01T00:06:00.000+08:00| 0.17557053610884188|
    12. |2021-01-01T00:07:00.000+08:00| -1.1755704886020932|
    13. |2021-01-01T00:08:00.000+08:00| -0.9021130371347148|
    14. |2021-01-01T00:09:00.000+08:00| 3.552713678800501E-16|
    15. |2021-01-01T00:10:00.000+08:00| 0.9021130371347154|
    16. |2021-01-01T00:11:00.000+08:00| 1.1755704886020932|
    17. |2021-01-01T00:12:00.000+08:00| -0.17557053610884144|
    18. |2021-01-01T00:13:00.000+08:00| -1.902113046743454|
    19. |2021-01-01T00:14:00.000+08:00| -0.9999999925494196|
    20. |2021-01-01T00:15:00.000+08:00| 1.9021130389094498|
    21. |2021-01-01T00:16:00.000+08:00| 2.1755705137571004|
    22. |2021-01-01T00:17:00.000+08:00| -1.1755704705132448|
    23. |2021-01-01T00:18:00.000+08:00| -2.902112992431231|
    24. |2021-01-01T00:19:00.000+08:00| -3.552713678800501E-16|
    25. +-----------------------------+-------------------------------------------------------+

    This function performs low-pass filtering on the input series and extracts components below the cutoff frequency. The timestamps of input will be ignored and all data points will be regarded as equidistant.

    Name: LOWPASS

    Input: Only support a single input series. The type is INT32 / INT64 / FLOAT / DOUBLE.

    Parameters:

    • wpass: The normalized cutoff frequency which values (0,1). This parameter cannot be lacked.

    Output: Output a single series. The type is DOUBLE. It is the input after filtering. The length and timestamps of output are the same as the input.

    Note: NaN in the input series will be ignored.

    Examples

    Input series:

    1. +-----------------------------+---------------+
    2. | Time|root.test.d1.s1|
    3. +-----------------------------+---------------+
    4. |1970-01-01T08:00:00.000+08:00| 2.902113|
    5. |1970-01-01T08:00:01.000+08:00| 1.1755705|
    6. |1970-01-01T08:00:02.000+08:00| -2.1755705|
    7. |1970-01-01T08:00:03.000+08:00| -1.9021131|
    8. |1970-01-01T08:00:04.000+08:00| 1.0|
    9. |1970-01-01T08:00:05.000+08:00| 1.9021131|
    10. |1970-01-01T08:00:06.000+08:00| 0.1755705|
    11. |1970-01-01T08:00:07.000+08:00| -1.1755705|
    12. |1970-01-01T08:00:08.000+08:00| -0.902113|
    13. |1970-01-01T08:00:09.000+08:00| 0.0|
    14. |1970-01-01T08:00:10.000+08:00| 0.902113|
    15. |1970-01-01T08:00:11.000+08:00| 1.1755705|
    16. |1970-01-01T08:00:12.000+08:00| -0.1755705|
    17. |1970-01-01T08:00:13.000+08:00| -1.9021131|
    18. |1970-01-01T08:00:14.000+08:00| -1.0|
    19. |1970-01-01T08:00:15.000+08:00| 1.9021131|
    20. |1970-01-01T08:00:16.000+08:00| 2.1755705|
    21. |1970-01-01T08:00:17.000+08:00| -1.1755705|
    22. |1970-01-01T08:00:18.000+08:00| -2.902113|
    23. |1970-01-01T08:00:19.000+08:00| 0.0|

    SQL for query:

    1. select lowpass(s1,'wpass'='0.45') from root.test.d1

    Output series: