Skip to main content

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

1/// Produces a list of ranges for each point that is greater than its neighbors.
2/// Peaks at edges are discarded, and continuous, multivalue, flat peaks will return all values.
3#[derive(
4    Debug,
5    Clone,
6    conjure_object::serde::Serialize,
7    conjure_object::serde::Deserialize,
8    conjure_object::private::DeriveWith
9)]
10#[serde(crate = "conjure_object::serde")]
11#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[conjure_object::private::staged_builder::staged_builder]
13#[builder(crate = conjure_object::private::staged_builder, update, inline)]
14pub struct PeakRanges {
15    #[builder(custom(type = super::NumericSeries, convert = Box::new))]
16    #[serde(rename = "input")]
17    input: Box<super::NumericSeries>,
18    #[builder(default, into)]
19    #[serde(rename = "returnsPeaks", skip_serializing_if = "Option::is_none", default)]
20    returns_peaks: Option<bool>,
21    #[builder(default, into)]
22    #[serde(rename = "returnType", skip_serializing_if = "Option::is_none", default)]
23    return_type: Option<super::PeakType>,
24    #[builder(
25        default,
26        custom(
27            type = impl
28            Into<Option<super::DoubleConstant>>,
29            convert = |v|v.into().map(Box::new)
30        )
31    )]
32    #[serde(
33        rename = "minimumProminence",
34        skip_serializing_if = "Option::is_none",
35        default
36    )]
37    minimum_prominence: Option<Box<super::DoubleConstant>>,
38}
39impl PeakRanges {
40    /// Constructs a new instance of the type.
41    #[inline]
42    pub fn new(input: super::NumericSeries) -> Self {
43        Self::builder().input(input).build()
44    }
45    #[inline]
46    pub fn input(&self) -> &super::NumericSeries {
47        &*self.input
48    }
49    /// True if returning peaks, else troughs.
50    #[deprecated(note = "No longer used, use returnType instead")]
51    #[inline]
52    pub fn returns_peaks(&self) -> Option<bool> {
53        self.returns_peaks.as_ref().map(|o| *o)
54    }
55    /// Optional for backcompatibility.
56    #[inline]
57    pub fn return_type(&self) -> Option<&super::PeakType> {
58        self.return_type.as_ref().map(|o| &*o)
59    }
60    /// The minimum topographic prominence for an extrema to be returned.
61    /// Prominence is the minimum vertical distance needed to travel from an extrema to one of greater magnitude.
62    #[inline]
63    pub fn minimum_prominence(&self) -> Option<&super::DoubleConstant> {
64        self.minimum_prominence.as_ref().map(|o| &**o)
65    }
66}