Frequency Domain Analysis
Frequency Domain Analysis
Conv
Usage
This function is used to calculate the convolution, i.e. polynomial multiplication.
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: NaN
in the input series will be ignored.
Examples
Input series:
+-----------------------------+---------------+---------------+
| Time|root.test.d2.s1|root.test.d2.s2|
+-----------------------------+---------------+---------------+
|1970-01-01T08:00:00.000+08:00| 1.0| 7.0|
|1970-01-01T08:00:00.001+08:00| 0.0| 2.0|
|1970-01-01T08:00:00.002+08:00| 1.0| null|
+-----------------------------+---------------+---------------+
SQL for query:
select conv(s1,s2) from root.test.d2
Output series:
+-----------------------------+--------------------------------------+
| Time|conv(root.test.d2.s1, root.test.d2.s2)|
+-----------------------------+--------------------------------------+
|1970-01-01T08:00:00.000+08:00| 7.0|
|1970-01-01T08:00:00.001+08:00| 2.0|
|1970-01-01T08:00:00.002+08:00| 7.0|
|1970-01-01T08:00:00.003+08:00| 2.0|
+-----------------------------+--------------------------------------+
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:
+-----------------------------+---------------+---------------+
| Time|root.test.d2.s3|root.test.d2.s2|
+-----------------------------+---------------+---------------+
|1970-01-01T08:00:00.000+08:00| 8.0| 7.0|
|1970-01-01T08:00:00.001+08:00| 2.0| 2.0|
|1970-01-01T08:00:00.002+08:00| 7.0| null|
|1970-01-01T08:00:00.003+08:00| 2.0| null|
+-----------------------------+---------------+---------------+
SQL for query:
select deconv(s3,s2) from root.test.d2
Output series:
+-----------------------------+----------------------------------------+
| Time|deconv(root.test.d2.s3, root.test.d2.s2)|
+-----------------------------+----------------------------------------+
|1970-01-01T08:00:00.000+08:00| 1.0|
|1970-01-01T08:00:00.001+08:00| 0.0|
|1970-01-01T08:00:00.002+08:00| 1.0|
+-----------------------------+----------------------------------------+
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:
select deconv(s3,s2,'result'='remainder') from root.test.d2
Output series:
+-----------------------------+--------------------------------------------------------------+
| Time|deconv(root.test.d2.s3, root.test.d2.s2, "result"="remainder")|
+-----------------------------+--------------------------------------------------------------+
|1970-01-01T08:00:00.000+08:00| 1.0|
|1970-01-01T08:00:00.001+08:00| 0.0|
|1970-01-01T08:00:00.002+08:00| 0.0|
|1970-01-01T08:00:00.003+08:00| 0.0|
+-----------------------------+--------------------------------------------------------------+
DWT
Usage
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.
Parameters:
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 . 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:
+-----------------------------+---------------+
| Time|root.test.d1.s1|
+-----------------------------+---------------+
|1970-01-01T08:00:00.000+08:00| 0.0|
|1970-01-01T08:00:00.100+08:00| 0.2|
|1970-01-01T08:00:00.200+08:00| 1.5|
|1970-01-01T08:00:00.300+08:00| 1.2|
|1970-01-01T08:00:00.400+08:00| 0.6|
|1970-01-01T08:00:00.500+08:00| 1.7|
|1970-01-01T08:00:00.600+08:00| 0.8|
|1970-01-01T08:00:00.700+08:00| 2.0|
|1970-01-01T08:00:00.800+08:00| 2.5|
|1970-01-01T08:00:00.900+08:00| 2.1|
|1970-01-01T08:00:01.000+08:00| 0.0|
|1970-01-01T08:00:01.100+08:00| 2.0|
|1970-01-01T08:00:01.200+08:00| 1.8|
|1970-01-01T08:00:01.300+08:00| 1.2|
|1970-01-01T08:00:01.400+08:00| 1.0|
|1970-01-01T08:00:01.500+08:00| 1.6|
+-----------------------------+---------------+
SQL for query:
select dwt(s1,"method"="haar") from root.test.d1
Output series:
+-----------------------------+-------------------------------------+
| Time|dwt(root.test.d1.s1, "method"="haar")|
+-----------------------------+-------------------------------------+
|1970-01-01T08:00:00.000+08:00| 0.14142135834465192|
|1970-01-01T08:00:00.100+08:00| 1.909188342921157|
|1970-01-01T08:00:00.200+08:00| 1.6263456473052773|
|1970-01-01T08:00:00.300+08:00| 1.9798989957517026|
|1970-01-01T08:00:00.400+08:00| 3.252691126023161|
|1970-01-01T08:00:00.500+08:00| 1.414213562373095|
|1970-01-01T08:00:00.600+08:00| 2.1213203435596424|
|1970-01-01T08:00:00.700+08:00| 1.8384776479437628|
|1970-01-01T08:00:00.800+08:00| -0.14142135834465192|
|1970-01-01T08:00:00.900+08:00| 0.21213200063848547|
|1970-01-01T08:00:01.000+08:00| -0.7778174761639416|
|1970-01-01T08:00:01.100+08:00| -0.8485281289944873|
|1970-01-01T08:00:01.200+08:00| 0.2828427799095765|
|1970-01-01T08:00:01.300+08:00| -1.414213562373095|
|1970-01-01T08:00:01.400+08:00| 0.42426400127697095|
|1970-01-01T08:00:01.500+08:00| -0.42426408557066786|
+-----------------------------+-------------------------------------+
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:
+-----------------------------+---------------+
| Time|root.test.d1.s1|
+-----------------------------+---------------+
|1970-01-01T08:00:00.000+08:00| 2.902113|
|1970-01-01T08:00:01.000+08:00| 1.1755705|
|1970-01-01T08:00:02.000+08:00| -2.1755705|
|1970-01-01T08:00:03.000+08:00| -1.9021131|
|1970-01-01T08:00:04.000+08:00| 1.0|
|1970-01-01T08:00:05.000+08:00| 1.9021131|
|1970-01-01T08:00:06.000+08:00| 0.1755705|
|1970-01-01T08:00:07.000+08:00| -1.1755705|
|1970-01-01T08:00:08.000+08:00| -0.902113|
|1970-01-01T08:00:09.000+08:00| 0.0|
|1970-01-01T08:00:10.000+08:00| 0.902113|
|1970-01-01T08:00:11.000+08:00| 1.1755705|
|1970-01-01T08:00:12.000+08:00| -0.1755705|
|1970-01-01T08:00:13.000+08:00| -1.9021131|
|1970-01-01T08:00:14.000+08:00| -1.0|
|1970-01-01T08:00:15.000+08:00| 1.9021131|
|1970-01-01T08:00:16.000+08:00| 2.1755705|
|1970-01-01T08:00:17.000+08:00| -1.1755705|
|1970-01-01T08:00:18.000+08:00| -2.902113|
|1970-01-01T08:00:19.000+08:00| 0.0|
+-----------------------------+---------------+
SQL for query:
select fft(s1) from root.test.d1
Output series:
+-----------------------------+----------------------+
| Time| fft(root.test.d1.s1)|
+-----------------------------+----------------------+
|1970-01-01T08:00:00.000+08:00| 0.0|
|1970-01-01T08:00:00.001+08:00| 1.2727111142703152E-8|
|1970-01-01T08:00:00.002+08:00| 2.385520799101839E-7|
|1970-01-01T08:00:00.003+08:00| 8.723291723972645E-8|
|1970-01-01T08:00:00.004+08:00| 19.999999960195904|
|1970-01-01T08:00:00.005+08:00| 9.999999850988388|
|1970-01-01T08:00:00.006+08:00| 3.2260694930700566E-7|
|1970-01-01T08:00:00.007+08:00| 8.723291605373329E-8|
|1970-01-01T08:00:00.008+08:00| 1.108657103979944E-7|
|1970-01-01T08:00:00.009+08:00| 1.2727110997246171E-8|
|1970-01-01T08:00:00.010+08:00|1.9852334701272664E-23|
|1970-01-01T08:00:00.011+08:00| 1.2727111194499847E-8|
|1970-01-01T08:00:00.012+08:00| 1.108657103979944E-7|
|1970-01-01T08:00:00.013+08:00| 8.723291785769131E-8|
|1970-01-01T08:00:00.014+08:00| 3.226069493070057E-7|
|1970-01-01T08:00:00.015+08:00| 9.999999850988388|
|1970-01-01T08:00:00.016+08:00| 19.999999960195904|
|1970-01-01T08:00:00.017+08:00| 8.723291747109068E-8|
|1970-01-01T08:00:00.018+08:00| 2.3855207991018386E-7|
|1970-01-01T08:00:00.019+08:00| 1.2727112069910878E-8|
+-----------------------------+----------------------+
Note: The input is with a length of 20. Thus, there are peaks in and of the output.
Uniform FFT with Compression
Input series is the same as above, the SQL for query is shown below:
select fft(s1, 'result'='real', 'compress'='0.99'), fft(s1, 'result'='imag','compress'='0.99') from root.test.d1
Output series:
+-----------------------------+----------------------+----------------------+
| Time| fft(root.test.d1.s1,| fft(root.test.d1.s1,|
| | "result"="real",| "result"="imag",|
| | "compress"="0.99")| "compress"="0.99")|
+-----------------------------+----------------------+----------------------+
|1970-01-01T08:00:00.000+08:00| 0.0| 0.0|
|1970-01-01T08:00:00.001+08:00| -3.932894010461041E-9| 1.2104201863039066E-8|
|1970-01-01T08:00:00.002+08:00|-1.4021739447490164E-7| 1.9299268669082926E-7|
|1970-01-01T08:00:00.003+08:00| -7.057291240286645E-8| 5.127422242345858E-8|
|1970-01-01T08:00:00.004+08:00| 19.021130288047125| -6.180339875198807|
|1970-01-01T08:00:00.005+08:00| 9.999999850988388| 3.501852745067114E-16|
|1970-01-01T08:00:00.019+08:00| -3.932894898639461E-9|-1.2104202549376264E-8|
+-----------------------------+----------------------+----------------------+
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.
HighPass
Usage
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.
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:
+-----------------------------+---------------+
| Time|root.test.d1.s1|
+-----------------------------+---------------+
|1970-01-01T08:00:00.000+08:00| 2.902113|
|1970-01-01T08:00:01.000+08:00| 1.1755705|
|1970-01-01T08:00:02.000+08:00| -2.1755705|
|1970-01-01T08:00:03.000+08:00| -1.9021131|
|1970-01-01T08:00:04.000+08:00| 1.0|
|1970-01-01T08:00:05.000+08:00| 1.9021131|
|1970-01-01T08:00:06.000+08:00| 0.1755705|
|1970-01-01T08:00:07.000+08:00| -1.1755705|
|1970-01-01T08:00:08.000+08:00| -0.902113|
|1970-01-01T08:00:09.000+08:00| 0.0|
|1970-01-01T08:00:10.000+08:00| 0.902113|
|1970-01-01T08:00:11.000+08:00| 1.1755705|
|1970-01-01T08:00:12.000+08:00| -0.1755705|
|1970-01-01T08:00:13.000+08:00| -1.9021131|
|1970-01-01T08:00:14.000+08:00| -1.0|
|1970-01-01T08:00:15.000+08:00| 1.9021131|
|1970-01-01T08:00:16.000+08:00| 2.1755705|
|1970-01-01T08:00:17.000+08:00| -1.1755705|
|1970-01-01T08:00:18.000+08:00| -2.902113|
|1970-01-01T08:00:19.000+08:00| 0.0|
+-----------------------------+---------------+
SQL for query:
select highpass(s1,'wpass'='0.45') from root.test.d1
Output series:
+-----------------------------+-----------------------------------------+
| Time|highpass(root.test.d1.s1, "wpass"="0.45")|
+-----------------------------+-----------------------------------------+
|1970-01-01T08:00:00.000+08:00| 0.9999999534830373|
|1970-01-01T08:00:01.000+08:00| 1.7462829277628608E-8|
|1970-01-01T08:00:02.000+08:00| -0.9999999593178128|
|1970-01-01T08:00:03.000+08:00| -4.1115269056426626E-8|
|1970-01-01T08:00:04.000+08:00| 0.9999999925494194|
|1970-01-01T08:00:05.000+08:00| 3.328126513330016E-8|
|1970-01-01T08:00:06.000+08:00| -1.0000000183304454|
|1970-01-01T08:00:07.000+08:00| 6.260191433311374E-10|
|1970-01-01T08:00:08.000+08:00| 1.0000000018134796|
|1970-01-01T08:00:09.000+08:00| -3.097210911744423E-17|
|1970-01-01T08:00:10.000+08:00| -1.0000000018134794|
|1970-01-01T08:00:11.000+08:00| -6.260191627862097E-10|
|1970-01-01T08:00:12.000+08:00| 1.0000000183304454|
|1970-01-01T08:00:13.000+08:00| -3.328126501424346E-8|
|1970-01-01T08:00:14.000+08:00| -0.9999999925494196|
|1970-01-01T08:00:15.000+08:00| 4.111526915498874E-8|
|1970-01-01T08:00:16.000+08:00| 0.9999999593178128|
|1970-01-01T08:00:17.000+08:00| -1.7462829341296528E-8|
|1970-01-01T08:00:18.000+08:00| -0.9999999534830369|
|1970-01-01T08:00:19.000+08:00| -1.035237222742873E-16|
+-----------------------------+-----------------------------------------+
Note: The input is with a length of 20. Thus, the output is 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:
+-----------------------------+----------------------+----------------------+
| Time| root.test.d1.re| root.test.d1.im|
+-----------------------------+----------------------+----------------------+
|1970-01-01T08:00:00.000+08:00| 0.0| 0.0|
|1970-01-01T08:00:00.001+08:00| -3.932894010461041E-9| 1.2104201863039066E-8|
|1970-01-01T08:00:00.002+08:00|-1.4021739447490164E-7| 1.9299268669082926E-7|
|1970-01-01T08:00:00.003+08:00| -7.057291240286645E-8| 5.127422242345858E-8|
|1970-01-01T08:00:00.004+08:00| 19.021130288047125| -6.180339875198807|
|1970-01-01T08:00:00.005+08:00| 9.999999850988388| 3.501852745067114E-16|
|1970-01-01T08:00:00.019+08:00| -3.932894898639461E-9|-1.2104202549376264E-8|
+-----------------------------+----------------------+----------------------+
SQL for query:
select ifft(re, im, 'interval'='1m', 'start'='2021-01-01 00:00:00') from root.test.d1
Output series:
+-----------------------------+-------------------------------------------------------+
| Time|ifft(root.test.d1.re, root.test.d1.im, "interval"="1m",|
| | "start"="2021-01-01 00:00:00")|
+-----------------------------+-------------------------------------------------------+
|2021-01-01T00:00:00.000+08:00| 2.902112992431231|
|2021-01-01T00:01:00.000+08:00| 1.1755704705132448|
|2021-01-01T00:02:00.000+08:00| -2.175570513757101|
|2021-01-01T00:03:00.000+08:00| -1.9021130389094498|
|2021-01-01T00:04:00.000+08:00| 0.9999999925494194|
|2021-01-01T00:05:00.000+08:00| 1.902113046743454|
|2021-01-01T00:06:00.000+08:00| 0.17557053610884188|
|2021-01-01T00:07:00.000+08:00| -1.1755704886020932|
|2021-01-01T00:08:00.000+08:00| -0.9021130371347148|
|2021-01-01T00:09:00.000+08:00| 3.552713678800501E-16|
|2021-01-01T00:10:00.000+08:00| 0.9021130371347154|
|2021-01-01T00:11:00.000+08:00| 1.1755704886020932|
|2021-01-01T00:12:00.000+08:00| -0.17557053610884144|
|2021-01-01T00:13:00.000+08:00| -1.902113046743454|
|2021-01-01T00:14:00.000+08:00| -0.9999999925494196|
|2021-01-01T00:15:00.000+08:00| 1.9021130389094498|
|2021-01-01T00:16:00.000+08:00| 2.1755705137571004|
|2021-01-01T00:17:00.000+08:00| -1.1755704705132448|
|2021-01-01T00:18:00.000+08:00| -2.902112992431231|
|2021-01-01T00:19:00.000+08:00| -3.552713678800501E-16|
+-----------------------------+-------------------------------------------------------+
LowPass
Usage
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:
+-----------------------------+---------------+
| Time|root.test.d1.s1|
+-----------------------------+---------------+
|1970-01-01T08:00:00.000+08:00| 2.902113|
|1970-01-01T08:00:01.000+08:00| 1.1755705|
|1970-01-01T08:00:02.000+08:00| -2.1755705|
|1970-01-01T08:00:03.000+08:00| -1.9021131|
|1970-01-01T08:00:04.000+08:00| 1.0|
|1970-01-01T08:00:05.000+08:00| 1.9021131|
|1970-01-01T08:00:06.000+08:00| 0.1755705|
|1970-01-01T08:00:07.000+08:00| -1.1755705|
|1970-01-01T08:00:08.000+08:00| -0.902113|
|1970-01-01T08:00:09.000+08:00| 0.0|
|1970-01-01T08:00:10.000+08:00| 0.902113|
|1970-01-01T08:00:11.000+08:00| 1.1755705|
|1970-01-01T08:00:12.000+08:00| -0.1755705|
|1970-01-01T08:00:13.000+08:00| -1.9021131|
|1970-01-01T08:00:14.000+08:00| -1.0|
|1970-01-01T08:00:15.000+08:00| 1.9021131|
|1970-01-01T08:00:16.000+08:00| 2.1755705|
|1970-01-01T08:00:17.000+08:00| -1.1755705|
|1970-01-01T08:00:18.000+08:00| -2.902113|
|1970-01-01T08:00:19.000+08:00| 0.0|
+-----------------------------+---------------+
SQL for query:
select lowpass(s1,'wpass'='0.45') from root.test.d1
Output series:
+-----------------------------+----------------------------------------+
| Time|lowpass(root.test.d1.s1, "wpass"="0.45")|
+-----------------------------+----------------------------------------+
|1970-01-01T08:00:00.000+08:00| 1.9021130073323922|
|1970-01-01T08:00:01.000+08:00| 1.1755704705132448|
|1970-01-01T08:00:02.000+08:00| -1.1755705286582614|
|1970-01-01T08:00:03.000+08:00| -1.9021130389094498|
|1970-01-01T08:00:04.000+08:00| 7.450580419288145E-9|
|1970-01-01T08:00:05.000+08:00| 1.902113046743454|
|1970-01-01T08:00:06.000+08:00| 1.1755705212076808|
|1970-01-01T08:00:07.000+08:00| -1.1755704886020932|
|1970-01-01T08:00:08.000+08:00| -1.9021130222335536|
|1970-01-01T08:00:09.000+08:00| 3.552713678800501E-16|
|1970-01-01T08:00:10.000+08:00| 1.9021130222335536|
|1970-01-01T08:00:11.000+08:00| 1.1755704886020932|
|1970-01-01T08:00:12.000+08:00| -1.1755705212076801|
|1970-01-01T08:00:13.000+08:00| -1.902113046743454|
|1970-01-01T08:00:14.000+08:00| -7.45058112983088E-9|
|1970-01-01T08:00:15.000+08:00| 1.9021130389094498|
|1970-01-01T08:00:16.000+08:00| 1.1755705286582616|
|1970-01-01T08:00:17.000+08:00| -1.1755704705132448|
|1970-01-01T08:00:18.000+08:00| -1.9021130073323924|
|1970-01-01T08:00:19.000+08:00| -2.664535259100376E-16|
+-----------------------------+----------------------------------------+
Note: The input is with a length of 20. Thus, the output is after low-pass filtering.