ProteoWizard
Classes | Functions | Variables
FrequencyEstimatorPhysicalModelTest.cpp File Reference
#include "FrequencyEstimatorPhysicalModel.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Classes

struct  Datum
 

Functions

void test ()
 
int main (int argc, char *argv[])
 

Variables

ostream * os_ = 0
 
Datum data_ []
 
const int dataSize_ = sizeof(data_)/sizeof(Datum)
 

Function Documentation

◆ test()

void test ( )

Definition at line 73 of file FrequencyEstimatorPhysicalModelTest.cpp.

74{
75 if (os_) *os_ << setprecision(14);
76
77 // initialize frequency data
78
80 for (const Datum* p=data_; p!=data_+dataSize_; ++p)
81 fd.data().push_back(FrequencyDatum(p->frequency, p->intensity));
82 fd.observationDuration(.768);
83 fd.analyze();
84
85 // "peak detection"
86
87 Peak detected;
88 detected.attributes[Peak::Attribute_Frequency] = fd.max()->x;
89 if (os_) *os_ << "detected: " << detected << endl;
90
91 // create estimator
92
94 auto_ptr<FrequencyEstimatorPhysicalModel> fe(FrequencyEstimatorPhysicalModel::create(config));
95
96 // get estimate and check answer
97
98 Peak estimate = fe->estimate(fd, detected);
99 if (os_) *os_ << "estimate: " << estimate << endl;
100
101 unit_assert_equal(estimate.attributes[Peak::Attribute_Frequency], 159454.98465, 1e-4);
102}
Class for binary storage of complex frequency data.
double observationDuration() const
const_iterator max() const
returns an iterator to FrequencyDatum with highest magnitude
void analyze()
recache statistics calculations after any direct data changes via non-const data()
const container & data() const
const access to underlying data
static std::auto_ptr< FrequencyEstimatorPhysicalModel > create(const Config &config)
create an instance
SampleDatum< double, std::complex< double > > FrequencyDatum
#define unit_assert_equal(x, y, epsilon)
Definition unit.hpp:99

References pwiz::data::FrequencyData::analyze(), pwiz::data::peakdata::Peak::Attribute_Frequency, pwiz::data::peakdata::Peak::attributes, pwiz::frequency::FrequencyEstimatorPhysicalModel::create(), pwiz::data::FrequencyData::data(), data_, dataSize_, pwiz::data::FrequencyData::max(), pwiz::data::FrequencyData::observationDuration(), os_, and unit_assert_equal.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 105 of file FrequencyEstimatorPhysicalModelTest.cpp.

106{
107 TEST_PROLOG(argc, argv)
108
109 try
110 {
111 if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
112 if (os_) *os_ << "FrequencyEstimatorPhysicalModelTest\n";
113 test();
114 }
115 catch (exception& e)
116 {
117 TEST_FAILED(e.what())
118 }
119 catch (...)
120 {
121 TEST_FAILED("Caught unknown exception.")
122 }
123
125}
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175

References os_, test(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG.

Variable Documentation

◆ os_

ostream* os_ = 0

Definition at line 34 of file FrequencyEstimatorPhysicalModelTest.cpp.

Referenced by main(), and test().

◆ data_

Datum data_[]
Initial value:
=
{
{159442.7083, complex<double>(4877.101315, 44697.12422)},
{159444.0104, complex<double>(4080.603141, 50558.42071)},
{159445.3125, complex<double>(6577.789977, 58423.29765)},
{159446.6146, complex<double>(12831.99571, 62206.40467)},
{159447.9167, complex<double>(12432.57475, 78692.36757)},
{159449.2188, complex<double>(14863.21774, 97002.26961)},
{159450.5208, complex<double>(20799.47308, 118598.6778)},
{159451.8229, complex<double>(22593.31198, 165638.8917)},
{159453.125, complex<double>(47599.33584, 277486.3998)},
{159454.4271, complex<double>(286144.9904, 833086.4972)},
{159455.7292, complex<double>(185071.6796, -646557.3157)},
{159457.0312, complex<double>(-17704.58144, -233633.2989)},
{159458.3333, complex<double>(12582.54006, -142740.2498)},
{159459.6354, complex<double>(-4281.026921, -119490.1607)},
{159460.9375, complex<double>(-2407.375413, -104118.8209)},
{159462.2396, complex<double>(-6020.466709, -71343.6045)},
{159463.5417, complex<double>(-6861.637568, -64726.61834)},
{159464.8438, complex<double>(4448.264865, -50486.19487)},
{159466.1458, complex<double>(-2683.225884, -43254.46692)},
{159467.4479, complex<double>(-1409.582306, -46362.11256)},
{159468.75, complex<double>(-901.9171424, -39197.02914)},
}

Definition at line 44 of file FrequencyEstimatorPhysicalModelTest.cpp.

45{
46 {159442.7083, complex<double>(4877.101315, 44697.12422)},
47 {159444.0104, complex<double>(4080.603141, 50558.42071)},
48 {159445.3125, complex<double>(6577.789977, 58423.29765)},
49 {159446.6146, complex<double>(12831.99571, 62206.40467)},
50 {159447.9167, complex<double>(12432.57475, 78692.36757)},
51 {159449.2188, complex<double>(14863.21774, 97002.26961)},
52 {159450.5208, complex<double>(20799.47308, 118598.6778)},
53 {159451.8229, complex<double>(22593.31198, 165638.8917)},
54 {159453.125, complex<double>(47599.33584, 277486.3998)},
55 {159454.4271, complex<double>(286144.9904, 833086.4972)},
56 {159455.7292, complex<double>(185071.6796, -646557.3157)},
57 {159457.0312, complex<double>(-17704.58144, -233633.2989)},
58 {159458.3333, complex<double>(12582.54006, -142740.2498)},
59 {159459.6354, complex<double>(-4281.026921, -119490.1607)},
60 {159460.9375, complex<double>(-2407.375413, -104118.8209)},
61 {159462.2396, complex<double>(-6020.466709, -71343.6045)},
62 {159463.5417, complex<double>(-6861.637568, -64726.61834)},
63 {159464.8438, complex<double>(4448.264865, -50486.19487)},
64 {159466.1458, complex<double>(-2683.225884, -43254.46692)},
65 {159467.4479, complex<double>(-1409.582306, -46362.11256)},
66 {159468.75, complex<double>(-901.9171424, -39197.02914)},
67};

Referenced by pwiz::frequency::ParametrizedFunction< value_type >::ErrorFunction::dp(), pwiz::frequency::ParametrizedFunction< value_type >::ErrorFunction::dp2(), pwiz::frequency::ParametrizedFunction< value_type >::ErrorFunction::operator()(), and test().

◆ dataSize_

const int dataSize_ = sizeof(data_)/sizeof(Datum)

Definition at line 70 of file FrequencyEstimatorPhysicalModelTest.cpp.

Referenced by test().