File: predictresidual.cpp

package info (click to toggle)
aoflagger 3.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,004 kB
  • sloc: cpp: 67,891; python: 497; sh: 242; makefile: 22
file content (39 lines) | stat: -rw-r--r-- 1,362 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "predictresidual.h"

#include "sisco.h"

using casacore::BitFloat;
using casacore::sisco::CompressorState;

namespace algorithms {

void PredictResidual(TimeFrequencyData& data) {
  CompressorState state;
  std::vector<uint32_t> mantissa_data(data.ImageWidth());
  std::vector<int8_t> exponent_data(data.ImageWidth());
  for (size_t image_index = 0; image_index != data.ImageCount();
       ++image_index) {
    Image2D image(*data.GetImage(image_index));

    for (size_t y = 0; y != image.Height(); ++y) {
      std::span row_data(image.ValuePtr(0, y), image.Width());
      std::span mantissa_span(
          reinterpret_cast<std::byte*>(mantissa_data.data()),
          image.Width() * sizeof(uint32_t));
      std::span exponent_span(
          reinterpret_cast<std::byte*>(exponent_data.data()),
          image.Width() * sizeof(int8_t));
      QuadraticCompress2D(state, row_data, mantissa_span, exponent_span);
      for (size_t x = 0; x != image.Width(); ++x) {
        const float residual =
            BitFloat::FromCompressed(mantissa_data[x], exponent_data[x])
                .ToFloat();
        row_data[x] = residual;  // BitFloat::FromCompressed(mantissa_data[x],
                                 // exponent_data[x]).Mantissa();
      }
    }
    data.SetImage(image_index, Image2D::MakePtr(image));
  }
}

}  // namespace algorithms