nidas v1.2.3
NearestResampler.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_NEARESTRESAMPLER_H
28#define NIDAS_CORE_NEARESTRESAMPLER_H
29
30#include "Resampler.h"
31#include "SampleTag.h"
32
33#include <vector>
34
35namespace nidas { namespace core {
36
55public:
56
60 NearestResampler(const std::vector<const Variable*>& vars,bool nansVariable=true);
61
62 NearestResampler(const std::vector<Variable*>& vars,bool nansVariable=true);
63
65
67
69
73 std::list<const SampleTag*> getSampleTags() const
74 {
75 return _source.getSampleTags();
76 }
77
85
89 void addSampleClient(SampleClient* client) throw()
90 {
92 }
93
94 void removeSampleClient(SampleClient* client) throw()
95 {
97 }
98
103 void addSampleClientForTag(SampleClient* client,const SampleTag*) throw()
104 {
105 // I only have one tag, so just call addSampleClient()
106 _source.addSampleClient(client);
107 }
108
110 {
112 }
113
114 int getClientCount() const throw()
115 {
116 return _source.getClientCount();
117 }
118
120 {
121 return _source.getSampleStats();
122 }
123
129 void connect(SampleSource* src);
130
131 void disconnect(SampleSource* src) throw();
132
136 bool receive(const Sample *s) throw();
137
142 void flush() throw();
143
144private:
145
149 void ctorCommon(const std::vector<const Variable*>& vars,bool nansVariable);
150
154 void addSampleTag(const SampleTag* tag) throw ()
155 {
157 }
158
159 void removeSampleTag(const SampleTag* tag) throw ()
160 {
162 }
163
165
167
171 std::vector<Variable *> _reqVars;
172
176 std::map<Variable*,unsigned int> _outVarIndices;
177
182 std::map<dsm_sample_id_t,std::vector<unsigned int> > _inmap;
183
187 std::map<dsm_sample_id_t,std::vector<unsigned int> > _lenmap;
188
192 std::map<dsm_sample_id_t,std::vector<unsigned int> > _outmap;
193
194 unsigned int _ndataValues;
195
196 unsigned int _outlen;
197
198 unsigned int _master;
199
201
203
205
206 float* _prevData;
207
208 float* _nearData;
209
211
212 std::map<dsm_sample_id_t,unsigned int> _ttOutOfOrder;
213
214 bool _debug;
215
220
225};
226
227}} // namespace nidas namespace core
228
229#endif
A simple, nearest-point resampler, for generating merged samples from variables from one or more samp...
Definition NearestResampler.h:54
void removeSampleTag(const SampleTag *tag)
Definition NearestResampler.h:159
std::map< dsm_sample_id_t, unsigned int > _ttOutOfOrder
Definition NearestResampler.h:212
SampleTagIterator getSampleTagIterator() const
Implementation of SampleSource::getSampleTagIterator().
Definition NearestResampler.h:81
void addSampleTag(const SampleTag *tag)
Add a SampleTag to this SampleSource.
Definition NearestResampler.h:154
int _nmaster
Definition NearestResampler.h:200
void removeSampleClientForTag(SampleClient *client, const SampleTag *)
Remove a SampleClient for a given SampleTag from this SampleSource.
Definition NearestResampler.h:109
std::map< dsm_sample_id_t, std::vector< unsigned int > > _lenmap
For each input sample, length of variables to read.
Definition NearestResampler.h:187
void ctorCommon(const std::vector< const Variable * > &vars, bool nansVariable)
Common tasks of constructors.
Definition NearestResampler.cc:80
void addSampleClientForTag(SampleClient *client, const SampleTag *)
Add a Client for a given SampleTag.
Definition NearestResampler.h:103
int getClientCount() const
How many SampleClients are currently in my list.
Definition NearestResampler.h:114
unsigned int _outlen
Definition NearestResampler.h:196
void addSampleClient(SampleClient *client)
Implementation of SampleSource::addSampleClient().
Definition NearestResampler.h:89
~NearestResampler()
Definition NearestResampler.cc:68
dsm_time_t * _nearTT
Definition NearestResampler.h:204
float * _nearData
Definition NearestResampler.h:208
std::map< dsm_sample_id_t, std::vector< unsigned int > > _outmap
For each input sample, index into output sample of each variable.
Definition NearestResampler.h:192
std::vector< Variable * > _reqVars
Requested variables.
Definition NearestResampler.h:171
bool receive(const Sample *s)
Implementation of SampleClient::receive().
Definition NearestResampler.cc:254
std::list< const SampleTag * > getSampleTags() const
Get the SampleTag of my merged output sample.
Definition NearestResampler.h:73
SampleSource * getRawSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition NearestResampler.h:66
unsigned int _ndataValues
Definition NearestResampler.h:194
void flush()
Implementation of Resampler::flush().
Definition NearestResampler.cc:462
dsm_time_t * _prevTT
Definition NearestResampler.h:202
float * _prevData
Definition NearestResampler.h:206
int * _samplesSinceMaster
Definition NearestResampler.h:210
void removeSampleClient(SampleClient *client)
Remove a SampleClient from this SampleSource.
Definition NearestResampler.h:94
bool _debug
Definition NearestResampler.h:214
NearestResampler(const std::vector< const Variable * > &vars, bool nansVariable=true)
Constructor.
Definition NearestResampler.cc:39
NearestResampler(const NearestResampler &x)
No copy.
SampleTag _outSample
Definition NearestResampler.h:166
std::map< Variable *, unsigned int > _outVarIndices
Index of each requested output variable in the output sample.
Definition NearestResampler.h:176
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 NearestResampler.h:182
NearestResampler & operator=(const NearestResampler &)
No assignment.
SampleSourceSupport _source
Definition NearestResampler.h:164
unsigned int _master
Definition NearestResampler.h:198
void disconnect(SampleSource *src)
Definition NearestResampler.cc:249
const SampleStats & getSampleStats() const
Definition NearestResampler.h:119
SampleSource * getProcessedSampleSource()
Several objects in NIDAS can be both a SampleSource of raw Samples and processed Samples.
Definition NearestResampler.h:68
void connect(SampleSource *src)
Connect the resampler to a SampleSource.
Definition NearestResampler.cc:157
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
Class describing a sampled variable.
Definition Variable.h:47
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