nidas v1.2.3
NearestResamplerAtRate.h
Go to the documentation of this file.
1// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2// vim: set shiftwidth=4 softtabstop=4 expandtab:
3/*
4 ********************************************************************
5 ** NIDAS: NCAR In-situ Data Acquistion Software
6 **
7 ** 2006, Copyright University Corporation for Atmospheric Research
8 **
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation; either version 2 of the License, or
12 ** (at your option) any later version.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** The LICENSE.txt file accompanying this software contains
20 ** a copy of the GNU General Public License. If it is not found,
21 ** write to the Free Software Foundation, Inc.,
22 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 **
24 ********************************************************************
25*/
26
27#ifndef NIDAS_CORE_NEARESTRESAMPLERATRATE_H
28#define NIDAS_CORE_NEARESTRESAMPLERATRATE_H
29
30#include "Resampler.h"
31#include "SampleTag.h"
32
33#include <vector>
34
35namespace nidas { namespace core {
36
76public:
77
82 NearestResamplerAtRate(const std::vector<const Variable*>& vars,
83 bool nansVariable=true);
84
86
96 void setRate(double val);
97
98 double getRate() const
99 {
100 return _rate;
101 }
102
115 void setMiddleTimeTags(bool val)
116 {
118 }
119
120 bool getMiddleTimeTags() const
121 {
122 return _middleTimeTags;
123 }
124
128 void setFillGaps(bool val)
129 {
130 _fillGaps = val;
131 }
132
133 bool getFillGaps() const
134 {
135 return _fillGaps;
136 }
137
139
141
145 std::list<const SampleTag*> getSampleTags() const
146 {
147 return _source.getSampleTags();
148 }
149
157
161 void addSampleClient(SampleClient* client) throw()
162 {
163 _source.addSampleClient(client);
164 }
165
166 void removeSampleClient(SampleClient* client) throw()
167 {
169 }
170
175 void addSampleClientForTag(SampleClient* client,const SampleTag*) throw()
176 {
177 // I only have one tag, so just call addSampleClient()
178 _source.addSampleClient(client);
179 }
180
182 {
184 }
185
186 int getClientCount() const throw()
187 {
188 return _source.getClientCount();
189 }
190
194 void flush() throw();
195
197 {
198 return _source.getSampleStats();
199 }
200
206 void connect(SampleSource* input);
207
208 void disconnect(SampleSource* input) throw();
209
210 bool receive(const Sample *s) throw();
211
212
213private:
214
218 void addSampleTag(const SampleTag* tag) throw()
219 {
221 }
222
223 void removeSampleTag(const SampleTag* tag) throw ()
224 {
226 }
227
228 void sendSample(dsm_time_t) throw();
229
231
233
237 std::vector<Variable *> _reqVars;
238
242 std::map<Variable*,unsigned int> _outVarIndices;
243
248 std::map<dsm_sample_id_t,std::vector<unsigned int> > _inmap;
249
253 std::map<dsm_sample_id_t,std::vector<unsigned int> > _lenmap;
254
258 std::map<dsm_sample_id_t,std::vector<unsigned int> > _outmap;
259
261
263
264 double _rate;
265
270
275
280
288
302
304
306
308
310
311 float* _prevData;
312
313 float* _nearData;
314
316
317 SampleT<float>* _osamp;
318
320
321 std::map<dsm_sample_id_t,unsigned int> _ttOutOfOrder;
322
327
332};
333
334}} // namespace nidas namespace core
335
336#endif
A simple, nearest-point resampler, for generating merged samples from variables from one or more samp...
Definition NearestResamplerAtRate.h:75
NearestResamplerAtRate(const std::vector< const Variable * > &vars, bool nansVariable=true)
Use the given list of Variables as inputs and use them to generate an output sample tag.
Definition NearestResamplerAtRate.cc:42
SampleTagIterator getSampleTagIterator() const
Implementation of SampleSource::getSampleTagIterator().
Definition NearestResamplerAtRate.h:153
void addSampleClientForTag(SampleClient *client, const SampleTag *)
Add a Client for a given SampleTag.
Definition NearestResamplerAtRate.h:175
NearestResamplerAtRate(const NearestResamplerAtRate &x)=delete
No copy.
int _ndataValues
Definition NearestResamplerAtRate.h:260
dsm_time_t _nextOutputTT
Definition NearestResamplerAtRate.h:305
void removeSampleClient(SampleClient *client)
Remove a SampleClient from this SampleSource.
Definition NearestResamplerAtRate.h:166
void disconnect(SampleSource *input)
Definition NearestResamplerAtRate.cc:236
int * _samplesSinceOutput
Definition NearestResamplerAtRate.h:315
std::map< dsm_sample_id_t, std::vector< unsigned int > > _outmap
For each input sample, index into output sample of each variable.
Definition NearestResamplerAtRate.h:258
bool _middleTimeTags
If true, generate output timetags that are the middle of the requested output periods.
Definition NearestResamplerAtRate.h:301
int _deltatUsec
The output deltaT, 1/rate in microseconds.
Definition NearestResamplerAtRate.h:269
std::vector< Variable * > _reqVars
Requested variables.
Definition NearestResamplerAtRate.h:237
void setRate(double val)
Set the requested output rate, in Hz.
Definition NearestResamplerAtRate.cc:130
void removeSampleTag(const SampleTag *tag)
Definition NearestResamplerAtRate.h:223
void flush()
Implementation of Resampler::flush().
Definition NearestResamplerAtRate.cc:451
double getRate() const
Definition NearestResamplerAtRate.h:98
int _deltatUsecD2
DeltaT over 2.
Definition NearestResamplerAtRate.h:279
void removeSampleClientForTag(SampleClient *client, const SampleTag *)
Remove a SampleClient for a given SampleTag from this SampleSource.
Definition NearestResamplerAtRate.h:181
float * _nearData
Definition NearestResamplerAtRate.h:313
void setFillGaps(bool val)
Should output records of all missing data (nans), be generated, or just discarded.
Definition NearestResamplerAtRate.h:128
int getClientCount() const
How many SampleClients are currently in my list.
Definition NearestResamplerAtRate.h:186
~NearestResamplerAtRate()
Definition NearestResamplerAtRate.cc:117
void setMiddleTimeTags(bool val)
If true, generate output timetags that are the middle of the requested output periods.
Definition NearestResamplerAtRate.h:115
dsm_time_t * _prevTT
Definition NearestResamplerAtRate.h:307
const SampleStats & getSampleStats() const
Definition NearestResamplerAtRate.h:196
bool getFillGaps() const
Definition NearestResamplerAtRate.h:133
void sendSample(dsm_time_t)
Definition NearestResamplerAtRate.cc:347
std::map< dsm_sample_id_t, unsigned int > _ttOutOfOrder
Definition NearestResamplerAtRate.h:321
int _outlen
Definition NearestResamplerAtRate.h:262
SampleT< float > * _osamp
Definition NearestResamplerAtRate.h:317
SampleSource * getRawSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition NearestResamplerAtRate.h:138
bool _exactDeltatUsec
True if simple integer math is used to increment output sample time tags.
Definition NearestResamplerAtRate.h:287
void connect(SampleSource *input)
Connect the resampler to a SampleSource.
Definition NearestResamplerAtRate.cc:150
bool receive(const Sample *s)
Method called to pass a sample to this client.
Definition NearestResamplerAtRate.cc:241
double _rate
Definition NearestResamplerAtRate.h:264
std::map< Variable *, unsigned int > _outVarIndices
Index of each requested output variable in the output sample.
Definition NearestResamplerAtRate.h:242
std::map< dsm_sample_id_t, std::vector< unsigned int > > _lenmap
For each input sample, length of variables to read.
Definition NearestResamplerAtRate.h:253
SampleTag _outSample
Definition NearestResamplerAtRate.h:232
std::list< const SampleTag * > getSampleTags() const
Get the SampleTag of my merged output sample.
Definition NearestResamplerAtRate.h:145
float * _prevData
Definition NearestResamplerAtRate.h:311
SampleSourceSupport _source
Definition NearestResamplerAtRate.h:230
NearestResamplerAtRate & operator=(const NearestResamplerAtRate &)=delete
No assignment.
void addSampleTag(const SampleTag *tag)
Add a SampleTag to this SampleSource.
Definition NearestResamplerAtRate.h:218
int _deltatUsecD10
DeltaT over 10.
Definition NearestResamplerAtRate.h:274
dsm_time_t * _nearTT
Definition NearestResamplerAtRate.h:309
std::map< dsm_sample_id_t, std::vector< unsigned int > > _inmap
For each input sample, first index of variable data values to be read.
Definition NearestResamplerAtRate.h:248
bool _fillGaps
Definition NearestResamplerAtRate.h:319
void addSampleClient(SampleClient *client)
Implementation of SampleSource::addSampleClient().
Definition NearestResamplerAtRate.h:161
bool getMiddleTimeTags() const
Definition NearestResamplerAtRate.h:120
SampleSource * getProcessedSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition NearestResamplerAtRate.h:140
dsm_time_t _outputTT
Definition NearestResamplerAtRate.h:303
Interface for a resampler, simply a SampleClient and a SampleSource.
Definition Resampler.h:39
Pure virtual interface of a client of Samples.
Definition SampleClient.h:38
A source of samples.
Definition SampleSourceSupport.h:47
void removeSampleClient(SampleClient *c)
Remove a SampleClient from this SampleSource This will also remove a SampleClient if it has been adde...
Definition SampleSourceSupport.cc:88
void addSampleClient(SampleClient *c)
Add a SampleClient to this SampleSource.
Definition SampleSourceSupport.cc:80
SampleTagIterator getSampleTagIterator() const
Definition SampleSourceSupport.cc:75
int getClientCount() const
How many SampleClients are currently in my list.
Definition SampleSourceSupport.cc:136
void removeSampleTag(const SampleTag *tag)
Definition SampleSourceSupport.cc:67
const SampleStats & getSampleStats() const
Definition SampleSourceSupport.h:149
void addSampleTag(const SampleTag *tag)
Add a SampleTag to this SampleSource.
Definition SampleSourceSupport.cc:60
std::list< const SampleTag * > getSampleTags() const
What SampleTags am I a SampleSource for?
Definition SampleSourceSupport.cc:54
Pure virtual interface for a source of Samples.
Definition SampleSource.h:48
A source of samples.
Definition SampleStats.h:41
Class for iterating over the SampleTags of a Project, Site, DSMConfig, or a SampleSource.
Definition NidsIterators.h:218
Class describing a group of variables that are sampled and handled together.
Definition SampleTag.h:88
Interface to a data sample.
Definition Sample.h:190
Sample * getSample(sampleType type, unsigned int len)
A convienence method for getting a sample of an enumerated type from a pool.
Definition Sample.cc:70
long long dsm_time_t
Posix time in microseconds, the number of non-leap microseconds since 1970 Jan 1 00:00 UTC.
Definition Sample.h:62
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31