Skip to main content

nominal_api/conjure/objects/scout/compute/api/
fft.rs

1/// Returns the single sided amplitude spectrum of the input series.
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    conjure_object::private::DeriveWith
8)]
9#[serde(crate = "conjure_object::serde")]
10#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
11#[conjure_object::private::staged_builder::staged_builder]
12#[builder(crate = conjure_object::private::staged_builder, update, inline)]
13pub struct Fft {
14    #[builder(custom(type = super::NumericSeries, convert = Box::new))]
15    #[serde(rename = "input")]
16    input: Box<super::NumericSeries>,
17    #[builder(default, into)]
18    #[serde(rename = "window", skip_serializing_if = "Option::is_none", default)]
19    window: Option<super::FftWindow>,
20    #[builder(
21        default,
22        custom(
23            type = impl
24            Into<Option<super::FrequencySummarizationStrategy>>,
25            convert = |v|v.into().map(Box::new)
26        )
27    )]
28    #[serde(
29        rename = "summarizationStrategy",
30        skip_serializing_if = "Option::is_none",
31        default
32    )]
33    summarization_strategy: Option<Box<super::FrequencySummarizationStrategy>>,
34    #[builder(default, into)]
35    #[serde(rename = "nfft", skip_serializing_if = "Option::is_none", default)]
36    nfft: Option<i32>,
37}
38impl Fft {
39    /// Constructs a new instance of the type.
40    #[inline]
41    pub fn new(input: super::NumericSeries) -> Self {
42        Self::builder().input(input).build()
43    }
44    #[inline]
45    pub fn input(&self) -> &super::NumericSeries {
46        &*self.input
47    }
48    /// Window function applied to the input series. Defaults to RECT is not specified.
49    #[inline]
50    pub fn window(&self) -> Option<&super::FftWindow> {
51        self.window.as_ref().map(|o| &*o)
52    }
53    /// Strategy to downsample the output frequency spectrum.
54    #[inline]
55    pub fn summarization_strategy(
56        &self,
57    ) -> Option<&super::FrequencySummarizationStrategy> {
58        self.summarization_strategy.as_ref().map(|o| &**o)
59    }
60    /// Length of the FFT. When nfft < input length, the input is truncated to the first nfft samples before
61    /// windowing and transforming. When nfft > input length, the windowed input is zero-padded up to nfft
62    /// before transforming. When nfft is unset, defaults to the input length, producing the same result as
63    /// setting nfft to the input length. The output contains nfft/2 + 1 single-sided frequency bins with spacing
64    /// fs/nfft. For best performance, prefer a power of 2 (e.g. 512, 1024, 2048).
65    #[inline]
66    pub fn nfft(&self) -> Option<i32> {
67        self.nfft.as_ref().map(|o| *o)
68    }
69}