casacore
rftimeblockencoder.h
Go to the documentation of this file.
1 #ifndef DYSCO_RFTIME_BLOCK_ENCODER_H
2 #define DYSCO_RFTIME_BLOCK_ENCODER_H
3 
4 #include "stochasticencoder.h"
5 #include "timeblockbuffer.h"
6 #include "uvector.h"
7 
8 #include <complex>
9 #include <random>
10 #include <vector>
11 
12 #include "timeblockencoder.h"
13 
15  public:
16  RFTimeBlockEncoder(size_t nPol, size_t nChannels);
17 
18  virtual ~RFTimeBlockEncoder() override;
19 
20  virtual void EncodeWithDithering(
21  const dyscostman::StochasticEncoder<float> &gausEncoder, FBuffer &buffer,
22  float *metaBuffer, symbol_t *symbolBuffer, size_t antennaCount,
23  std::mt19937 &rnd) final override {
24  encode<true>(gausEncoder, buffer, metaBuffer, symbolBuffer, antennaCount,
25  &rnd);
26  }
27 
28  virtual void EncodeWithoutDithering(
29  const dyscostman::StochasticEncoder<float> &gausEncoder, FBuffer &buffer,
30  float *metaBuffer, symbol_t *symbolBuffer,
31  size_t antennaCount) final override {
32  encode<false>(gausEncoder, buffer, metaBuffer, symbolBuffer, antennaCount,
33  0);
34  }
35 
36  virtual void InitializeDecode(const float *metaBuffer, size_t nRow,
37  size_t nAntennae) final override;
38 
39  virtual void Decode(const dyscostman::StochasticEncoder<float> &gausEncoder,
40  FBuffer &buffer, const symbol_t *symbolBuffer,
41  size_t blockRow, size_t antenna1,
42  size_t antenna2) final override;
43 
44  virtual size_t SymbolCount(size_t nRow, size_t nPol,
45  size_t nChannels) const final override {
46  return nRow * nChannels * nPol * 2 /*complex*/;
47  }
48 
49  virtual size_t SymbolCount(size_t nRow) const final override {
50  return nRow * _nChannels * _nPol * 2 /*complex*/;
51  }
52 
53  virtual size_t SymbolsPerRow() const final override {
54  return _nChannels * _nPol * 2 /*complex*/;
55  }
56 
57  virtual size_t MetaDataCount(size_t nRow, size_t nPol, size_t nChannels,
58  size_t /*nAntennae*/) const final override {
59  return nPol * (nChannels + nRow);
60  }
61 
63  TimeBlockBuffer<std::complex<float>> &buffer,
64  size_t antennaCount);
65 
66  private:
67  void calculateAntennaeRMS(const std::vector<DBufferRow> &data,
68  size_t polIndex, size_t antennaCount);
69 
70  template <bool UseDithering>
72  const FBuffer &buffer, float *metaBuffer, symbol_t *symbolBuffer,
73  size_t antennaCount, std::mt19937 *rnd);
74 
75  void changeChannelFactor(std::vector<DBufferRow> &data, float *metaBuffer,
76  size_t visIndex, double factor);
77  void fitToMaximum(std::vector<DBufferRow> &data, float *metaBuffer,
78  const dyscostman::StochasticEncoder<float> &gausEncoder,
79  size_t antennaCount);
80 
81  size_t _nPol, _nChannels;
82 
84  std::uniform_int_distribution<unsigned> _ditherDist;
85 };
86 
87 #endif
ao::uvector< double > _rowFactors
virtual ~RFTimeBlockEncoder() override
void calculateAntennaeRMS(const std::vector< DBufferRow > &data, size_t polIndex, size_t antennaCount)
virtual void EncodeWithDithering(const dyscostman::StochasticEncoder< float > &gausEncoder, FBuffer &buffer, float *metaBuffer, symbol_t *symbolBuffer, size_t antennaCount, std::mt19937 &rnd) final override
virtual size_t SymbolCount(size_t nRow) const final override
virtual void InitializeDecode(const float *metaBuffer, size_t nRow, size_t nAntennae) final override
virtual size_t SymbolsPerRow() const final override
RFTimeBlockEncoder(size_t nPol, size_t nChannels)
virtual void EncodeWithoutDithering(const dyscostman::StochasticEncoder< float > &gausEncoder, FBuffer &buffer, float *metaBuffer, symbol_t *symbolBuffer, size_t antennaCount) final override
virtual size_t MetaDataCount(size_t nRow, size_t nPol, size_t nChannels, size_t) const final override
ao::uvector< double > _channelFactors
void encode(const dyscostman::StochasticEncoder< float > &gausEncoder, const FBuffer &buffer, float *metaBuffer, symbol_t *symbolBuffer, size_t antennaCount, std::mt19937 *rnd)
void changeChannelFactor(std::vector< DBufferRow > &data, float *metaBuffer, size_t visIndex, double factor)
void Normalize(const dyscostman::StochasticEncoder< float > &gausEncoder, TimeBlockBuffer< std::complex< float >> &buffer, size_t antennaCount)
void fitToMaximum(std::vector< DBufferRow > &data, float *metaBuffer, const dyscostman::StochasticEncoder< float > &gausEncoder, size_t antennaCount)
std::uniform_int_distribution< unsigned > _ditherDist
virtual size_t SymbolCount(size_t nRow, size_t nPol, size_t nChannels) const final override
virtual void Decode(const dyscostman::StochasticEncoder< float > &gausEncoder, FBuffer &buffer, const symbol_t *symbolBuffer, size_t blockRow, size_t antenna1, size_t antenna2) final override
Lossy encoder for stochastic values.
Header file for uvector and its relational and swap functions.